1 from .common
import InfoExtractor
11 class NineCNineMediaIE(InfoExtractor
):
13 _GEO_COUNTRIES
= ['CA']
14 _VALID_URL
= r
'9c9media:(?P<destination_code>[^:]+):(?P<id>\d+)'
15 _API_BASE_TEMPLATE
= 'http://capi.9c9media.com/destinations/%s/platforms/desktop/contents/%s/'
17 def _real_extract(self
, url
):
18 destination_code
, content_id
= self
._match
_valid
_url
(url
).groups()
19 api_base_url
= self
._API
_BASE
_TEMPLATE
% (destination_code
, content_id
)
20 content
= self
._download
_json
(api_base_url
, content_id
, query
={
21 '$include': '[Media.Name,Season,ContentPackages.Duration,ContentPackages.Id]',
23 title
= content
['Name']
24 content_package
= content
['ContentPackages'][0]
25 package_id
= content_package
['Id']
26 content_package_url
= api_base_url
+ f
'contentpackages/{package_id}/'
27 content_package
= self
._download
_json
(
28 content_package_url
, content_id
, query
={
29 '$include': '[HasClosedCaptions]',
32 if (not self
.get_param('allow_unplayable_formats')
33 and try_get(content_package
, lambda x
: x
['Constraints']['Security']['Type'])):
34 self
.report_drm(content_id
)
36 manifest_base_url
= content_package_url
+ 'manifest.'
38 formats
.extend(self
._extract
_m
3u8_formats
(
39 manifest_base_url
+ 'm3u8', content_id
, 'mp4',
40 'm3u8_native', m3u8_id
='hls', fatal
=False))
41 formats
.extend(self
._extract
_f
4m
_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))
49 for image
in (content
.get('Images') or []):
50 image_url
= image
.get('Url')
55 'width': int_or_none(image
.get('Width')),
56 'height': int_or_none(image
.get('Height')),
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')
65 container
.append(e_name
)
67 season
= content
.get('Season') or {}
72 'description': content
.get('Desc') or content
.get('ShortDesc'),
73 'timestamp': parse_iso8601(content
.get('BroadcastDateTime')),
74 'episode_number': int_or_none(content
.get('Episode')),
75 'season': season
.get('Name'),
76 'season_number': int_or_none(season
.get('Number')),
77 'season_id': str_or_none(season
.get('Id')),
78 'series': try_get(content
, lambda x
: x
['Media']['Name']),
80 'categories': categories
,
81 'duration': float_or_none(content_package
.get('Duration')),
83 'thumbnails': thumbnails
,
86 if content_package
.get('HasClosedCaptions'):
89 'url': manifest_base_url
+ 'vtt',
92 'url': manifest_base_url
+ 'srt',
100 class CPTwentyFourIE(InfoExtractor
):
102 _GEO_COUNTRIES
= ['CA']
103 _VALID_URL
= r
'https?://(?:www\.)?cp24\.com/news/(?P<id>[^?#]+)'
106 'url': 'https://www.cp24.com/news/video-shows-atm-being-ripped-out-of-business-by-pickup-truck-driver-in-mississauga-1.5676877',
110 'title': 'WATCH: Truck rips ATM from Mississauga business',
111 'description': 'md5:cf7498480885f080a754389a2b2f7073',
112 'timestamp': 1637618377,
113 'season': 'Season 0',
115 'season_id': '57974',
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 video_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}:{video_id}', NineCNineMediaIE
, video_id
)