]>
Commit | Line | Data |
---|---|---|
05a0068a RA |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
29f7c58a | 3 | float_or_none, |
fe45b0e0 | 4 | int_or_none, |
29f7c58a | 5 | parse_iso8601, |
f4f9f6d0 | 6 | str_or_none, |
29f7c58a | 7 | try_get, |
05a0068a RA |
8 | ) |
9 | ||
10 | ||
c9e12a61 | 11 | class NineCNineMediaIE(InfoExtractor): |
fe45b0e0 | 12 | IE_NAME = '9c9media' |
c9e12a61 | 13 | _GEO_COUNTRIES = ['CA'] |
fe45b0e0 | 14 | _VALID_URL = r'9c9media:(?P<destination_code>[^:]+):(?P<id>\d+)' |
c9e12a61 | 15 | _API_BASE_TEMPLATE = 'http://capi.9c9media.com/destinations/%s/platforms/desktop/contents/%s/' |
fe45b0e0 RA |
16 | |
17 | def _real_extract(self, url): | |
5ad28e7f | 18 | destination_code, content_id = self._match_valid_url(url).groups() |
fe45b0e0 RA |
19 | api_base_url = self._API_BASE_TEMPLATE % (destination_code, content_id) |
20 | content = self._download_json(api_base_url, content_id, query={ | |
3721515b | 21 | '$include': '[Media.Name,Season,ContentPackages.Duration,ContentPackages.Id]', |
fe45b0e0 RA |
22 | }) |
23 | title = content['Name'] | |
fe45b0e0 RA |
24 | content_package = content['ContentPackages'][0] |
25 | package_id = content_package['Id'] | |
26 | content_package_url = api_base_url + 'contentpackages/%s/' % package_id | |
c9e12a61 RA |
27 | content_package = self._download_json( |
28 | content_package_url, content_id, query={ | |
29 | '$include': '[HasClosedCaptions]', | |
30 | }) | |
fe45b0e0 | 31 | |
a06916d9 | 32 | if (not self.get_param('allow_unplayable_formats') |
06869367 | 33 | and try_get(content_package, lambda x: x['Constraints']['Security']['Type'])): |
88acdbc2 | 34 | self.report_drm(content_id) |
fe45b0e0 | 35 | |
c9e12a61 RA |
36 | manifest_base_url = content_package_url + 'manifest.' |
37 | formats = [] | |
38 | formats.extend(self._extract_m3u8_formats( | |
39 | manifest_base_url + 'm3u8', content_id, 'mp4', | |
40 | 'm3u8_native', m3u8_id='hls', fatal=False)) | |
41 | formats.extend(self._extract_f4m_formats( | |
42 | manifest_base_url + 'f4m', content_id, | |
43 | f4m_id='hds', fatal=False)) | |
44 | formats.extend(self._extract_mpd_formats( | |
45 | manifest_base_url + 'mpd', content_id, | |
46 | mpd_id='dash', fatal=False)) | |
fe45b0e0 RA |
47 | |
48 | thumbnails = [] | |
29f7c58a | 49 | for image in (content.get('Images') or []): |
fe45b0e0 RA |
50 | image_url = image.get('Url') |
51 | if not image_url: | |
52 | continue | |
53 | thumbnails.append({ | |
54 | 'url': image_url, | |
55 | 'width': int_or_none(image.get('Width')), | |
56 | 'height': int_or_none(image.get('Height')), | |
57 | }) | |
58 | ||
59 | tags, categories = [], [] | |
60 | for source_name, container in (('Tags', tags), ('Genres', categories)): | |
61 | for e in content.get(source_name, []): | |
62 | e_name = e.get('Name') | |
63 | if not e_name: | |
64 | continue | |
65 | container.append(e_name) | |
66 | ||
29f7c58a | 67 | season = content.get('Season') or {} |
c9e12a61 RA |
68 | |
69 | info = { | |
70 | 'id': content_id, | |
71 | 'title': title, | |
72 | 'description': content.get('Desc') or content.get('ShortDesc'), | |
fe45b0e0 RA |
73 | 'timestamp': parse_iso8601(content.get('BroadcastDateTime')), |
74 | 'episode_number': int_or_none(content.get('Episode')), | |
75 | 'season': season.get('Name'), | |
29f7c58a | 76 | 'season_number': int_or_none(season.get('Number')), |
f4f9f6d0 | 77 | 'season_id': str_or_none(season.get('Id')), |
29f7c58a | 78 | 'series': try_get(content, lambda x: x['Media']['Name']), |
fe45b0e0 RA |
79 | 'tags': tags, |
80 | 'categories': categories, | |
c9e12a61 RA |
81 | 'duration': float_or_none(content_package.get('Duration')), |
82 | 'formats': formats, | |
29f7c58a | 83 | 'thumbnails': thumbnails, |
fe45b0e0 RA |
84 | } |
85 | ||
c9e12a61 RA |
86 | if content_package.get('HasClosedCaptions'): |
87 | info['subtitles'] = { | |
88 | 'en': [{ | |
89 | 'url': manifest_base_url + 'vtt', | |
90 | 'ext': 'vtt', | |
91 | }, { | |
92 | 'url': manifest_base_url + 'srt', | |
93 | 'ext': 'srt', | |
94 | }] | |
fe45b0e0 | 95 | } |
fe45b0e0 | 96 | |
c9e12a61 | 97 | return info |
3938a921 AG |
98 | |
99 | ||
100 | class CPTwentyFourIE(InfoExtractor): | |
101 | IE_NAME = 'cp24' | |
102 | _GEO_COUNTRIES = ['CA'] | |
103 | _VALID_URL = r'https?://(?:www\.)?cp24\.com/news/(?P<id>[^?#]+)' | |
104 | ||
105 | _TESTS = [{ | |
106 | 'url': 'https://www.cp24.com/news/video-shows-atm-being-ripped-out-of-business-by-pickup-truck-driver-in-mississauga-1.5676877', | |
107 | 'info_dict': { | |
108 | 'id': '2328005', | |
109 | 'ext': 'mp4', | |
110 | 'title': 'WATCH: Truck rips ATM from Mississauga business', | |
111 | 'description': 'md5:cf7498480885f080a754389a2b2f7073', | |
112 | 'timestamp': 1637618377, | |
3938a921 AG |
113 | 'season': 'Season 0', |
114 | 'season_number': 0, | |
f4f9f6d0 | 115 | 'season_id': '57974', |
3938a921 AG |
116 | 'series': 'CTV News Toronto', |
117 | 'duration': 26.86, | |
118 | 'thumbnail': 'http://images2.9c9media.com/image_asset/2014_11_5_2eb609a0-475b-0132-fbd6-34b52f6f1279_jpg_2000x1125.jpg', | |
119 | 'upload_date': '20211122', | |
120 | }, | |
121 | 'params': {'skip_download': True, 'format': 'bv'} | |
122 | }] | |
123 | ||
124 | def _real_extract(self, url): | |
125 | display_id = self._match_id(url) | |
126 | webpage = self._download_webpage(url, display_id) | |
127 | id, destination = self._search_regex( | |
128 | r'getAuthStates\("(?P<id>[^"]+)",\s?"(?P<destination>[^"]+)"\);', | |
129 | webpage, 'video id and destination', group=('id', 'destination')) | |
130 | return self.url_result(f'9c9media:{destination}:{id}', ie=NineCNineMediaIE.ie_key(), video_id=id) |