1 from .common
import InfoExtractor
10 class NineCNineMediaIE(InfoExtractor
):
12 _GEO_COUNTRIES
= ['CA']
13 _VALID_URL
= r
'9c9media:(?P<destination_code>[^:]+):(?P<id>\d+)'
14 _API_BASE_TEMPLATE
= 'http://capi.9c9media.com/destinations/%s/platforms/desktop/contents/%s/'
16 def _real_extract(self
, url
):
17 destination_code
, content_id
= self
._match
_valid
_url
(url
).groups()
18 api_base_url
= self
._API
_BASE
_TEMPLATE
% (destination_code
, content_id
)
19 content
= self
._download
_json
(api_base_url
, content_id
, query
={
20 '$include': '[Media.Name,Season,ContentPackages.Duration,ContentPackages.Id]',
22 title
= content
['Name']
23 content_package
= content
['ContentPackages'][0]
24 package_id
= content_package
['Id']
25 content_package_url
= api_base_url
+ 'contentpackages/%s/' % package_id
26 content_package
= self
._download
_json
(
27 content_package_url
, content_id
, query
={
28 '$include': '[HasClosedCaptions]',
31 if (not self
.get_param('allow_unplayable_formats')
32 and try_get(content_package
, lambda x
: x
['Constraints']['Security']['Type'])):
33 self
.report_drm(content_id
)
35 manifest_base_url
= content_package_url
+ 'manifest.'
37 formats
.extend(self
._extract
_m
3u8_formats
(
38 manifest_base_url
+ 'm3u8', content_id
, 'mp4',
39 'm3u8_native', m3u8_id
='hls', fatal
=False))
40 formats
.extend(self
._extract
_f
4m
_formats
(
41 manifest_base_url
+ 'f4m', content_id
,
42 f4m_id
='hds', fatal
=False))
43 formats
.extend(self
._extract
_mpd
_formats
(
44 manifest_base_url
+ 'mpd', content_id
,
45 mpd_id
='dash', fatal
=False))
48 for image
in (content
.get('Images') or []):
49 image_url
= image
.get('Url')
54 'width': int_or_none(image
.get('Width')),
55 'height': int_or_none(image
.get('Height')),
58 tags
, categories
= [], []
59 for source_name
, container
in (('Tags', tags
), ('Genres', categories
)):
60 for e
in content
.get(source_name
, []):
61 e_name
= e
.get('Name')
64 container
.append(e_name
)
66 season
= content
.get('Season') or {}
71 'description': content
.get('Desc') or content
.get('ShortDesc'),
72 'timestamp': parse_iso8601(content
.get('BroadcastDateTime')),
73 'episode_number': int_or_none(content
.get('Episode')),
74 'season': season
.get('Name'),
75 'season_number': int_or_none(season
.get('Number')),
76 'season_id': season
.get('Id'),
77 'series': try_get(content
, lambda x
: x
['Media']['Name']),
79 'categories': categories
,
80 'duration': float_or_none(content_package
.get('Duration')),
82 'thumbnails': thumbnails
,
85 if content_package
.get('HasClosedCaptions'):
88 'url': manifest_base_url
+ 'vtt',
91 'url': manifest_base_url
+ 'srt',
99 class CPTwentyFourIE(InfoExtractor
):
101 _GEO_COUNTRIES
= ['CA']
102 _VALID_URL
= r
'https?://(?:www\.)?cp24\.com/news/(?P<id>[^?#]+)'
105 'url': 'https://www.cp24.com/news/video-shows-atm-being-ripped-out-of-business-by-pickup-truck-driver-in-mississauga-1.5676877',
109 'title': 'WATCH: Truck rips ATM from Mississauga business',
110 'description': 'md5:cf7498480885f080a754389a2b2f7073',
111 'timestamp': 1637618377,
112 'episode_number': None,
113 'season': 'Season 0',
116 'series': 'CTV News Toronto',
118 'thumbnail': 'http://images2.9c9media.com/image_asset/2014_11_5_2eb609a0-475b-0132-fbd6-34b52f6f1279_jpg_2000x1125.jpg',
119 'upload_date': '20211122',
121 'params': {'skip_download': True, 'format': 'bv'}
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)