2016-06-30 11:14:59 -06:00
|
|
|
import re
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
2016-06-30 12:52:32 -06:00
|
|
|
from ..utils import orderedSet
|
2016-06-30 11:14:59 -06:00
|
|
|
|
|
|
|
|
|
|
|
class CTVNewsIE(InfoExtractor):
|
2024-11-17 12:35:10 -07:00
|
|
|
_VALID_URL = r'https?://(?:.+?\.)?ctvnews\.ca/(?:video\?(?:clip|playlist|bin)Id=|.*?)(?P<id>[0-9.]+)(?:$|[#?&])'
|
2016-06-30 11:14:59 -06:00
|
|
|
_TESTS = [{
|
|
|
|
'url': 'http://www.ctvnews.ca/video?clipId=901995',
|
2024-11-17 12:35:10 -07:00
|
|
|
'md5': 'b608f466c7fa24b9666c6439d766ab7e',
|
2016-06-30 11:14:59 -06:00
|
|
|
'info_dict': {
|
|
|
|
'id': '901995',
|
2018-05-27 05:10:12 -06:00
|
|
|
'ext': 'flv',
|
2016-06-30 11:14:59 -06:00
|
|
|
'title': 'Extended: \'That person cannot be me\' Johnson says',
|
|
|
|
'description': 'md5:958dd3b4f5bbbf0ed4d045c790d89285',
|
|
|
|
'timestamp': 1467286284,
|
|
|
|
'upload_date': '20160630',
|
2024-11-17 12:35:10 -07:00
|
|
|
'categories': [],
|
|
|
|
'tags': [],
|
|
|
|
'season_id': 57981,
|
|
|
|
'duration': 764.631,
|
|
|
|
'series': 'CTV News National story',
|
|
|
|
'thumbnail': r're:^https?://.*\.jpg$',
|
|
|
|
'season': 'Season 0',
|
|
|
|
'season_number': 0,
|
2024-06-11 17:09:58 -06:00
|
|
|
},
|
2016-06-30 11:14:59 -06:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.ctvnews.ca/video?playlistId=1.2966224',
|
|
|
|
'info_dict':
|
|
|
|
{
|
|
|
|
'id': '1.2966224',
|
|
|
|
},
|
|
|
|
'playlist_mincount': 19,
|
|
|
|
}, {
|
2016-06-30 12:52:32 -06:00
|
|
|
'url': 'http://www.ctvnews.ca/video?binId=1.2876780',
|
2016-06-30 11:14:59 -06:00
|
|
|
'info_dict':
|
|
|
|
{
|
2016-06-30 12:52:32 -06:00
|
|
|
'id': '1.2876780',
|
2016-06-30 11:14:59 -06:00
|
|
|
},
|
2016-06-30 12:52:32 -06:00
|
|
|
'playlist_mincount': 100,
|
2024-11-17 12:35:10 -07:00
|
|
|
}, {
|
|
|
|
'url': 'https://www.ctvnews.ca/it-s-been-23-years-since-toronto-called-in-the-army-after-a-major-snowstorm-1.5736957',
|
|
|
|
'info_dict':
|
|
|
|
{
|
|
|
|
'id': '1.5736957',
|
|
|
|
},
|
|
|
|
'playlist_mincount': 6,
|
2016-06-30 11:14:59 -06:00
|
|
|
}, {
|
|
|
|
'url': 'http://www.ctvnews.ca/1.810401',
|
|
|
|
'only_matching': True,
|
|
|
|
}, {
|
|
|
|
'url': 'http://www.ctvnews.ca/canadiens-send-p-k-subban-to-nashville-in-blockbuster-trade-1.2967231',
|
|
|
|
'only_matching': True,
|
2016-12-10 09:36:32 -07:00
|
|
|
}, {
|
|
|
|
'url': 'http://vancouverisland.ctvnews.ca/video?clipId=761241',
|
|
|
|
'only_matching': True,
|
2016-06-30 11:14:59 -06:00
|
|
|
}]
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
page_id = self._match_id(url)
|
|
|
|
|
|
|
|
def ninecninemedia_url_result(clip_id):
|
|
|
|
return {
|
|
|
|
'_type': 'url_transparent',
|
|
|
|
'id': clip_id,
|
2024-06-11 17:09:58 -06:00
|
|
|
'url': f'9c9media:ctvnews_web:{clip_id}',
|
2016-06-30 11:14:59 -06:00
|
|
|
'ie_key': 'NineCNineMedia',
|
|
|
|
}
|
|
|
|
|
|
|
|
if page_id.isdigit():
|
|
|
|
return ninecninemedia_url_result(page_id)
|
|
|
|
else:
|
2024-06-11 17:09:58 -06:00
|
|
|
webpage = self._download_webpage(f'http://www.ctvnews.ca/{page_id}', page_id, query={
|
2016-06-30 11:14:59 -06:00
|
|
|
'ot': 'example.AjaxPageLayout.ot',
|
2016-06-30 12:52:32 -06:00
|
|
|
'maxItemsPerPage': 1000000,
|
2016-06-30 11:14:59 -06:00
|
|
|
})
|
2016-06-30 12:52:32 -06:00
|
|
|
entries = [ninecninemedia_url_result(clip_id) for clip_id in orderedSet(
|
2016-06-30 11:14:59 -06:00
|
|
|
re.findall(r'clip\.id\s*=\s*(\d+);', webpage))]
|
2022-01-19 06:48:57 -07:00
|
|
|
if not entries:
|
|
|
|
webpage = self._download_webpage(url, page_id)
|
|
|
|
if 'getAuthStates("' in webpage:
|
|
|
|
entries = [ninecninemedia_url_result(clip_id) for clip_id in
|
|
|
|
self._search_regex(r'getAuthStates\("([\d+,]+)"', webpage, 'clip ids').split(',')]
|
2016-06-30 11:14:59 -06:00
|
|
|
return self.playlist_result(entries, page_id)
|