]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/ninecninemedia.py
2 from __future__
import unicode_literals
5 from .common
import InfoExtractor
15 class NineCNineMediaIE(InfoExtractor
):
17 _GEO_COUNTRIES
= ['CA']
18 _VALID_URL
= r
'9c9media:(?P<destination_code>[^:]+):(?P<id>\d+)'
19 _API_BASE_TEMPLATE
= 'http://capi.9c9media.com/destinations/%s/platforms/desktop/contents/%s/'
21 def _real_extract(self
, url
):
22 destination_code
, content_id
= self
._match
_valid
_url
(url
).groups()
23 api_base_url
= self
._API
_BASE
_TEMPLATE
% (destination_code
, content_id
)
24 content
= self
._download
_json
(api_base_url
, content_id
, query
={
25 '$include': '[Media.Name,Season,ContentPackages.Duration,ContentPackages.Id]',
27 title
= content
['Name']
28 content_package
= content
['ContentPackages'][0]
29 package_id
= content_package
['Id']
30 content_package_url
= api_base_url
+ 'contentpackages/%s/' % package_id
31 content_package
= self
._download
_json
(
32 content_package_url
, content_id
, query
={
33 '$include': '[HasClosedCaptions]',
36 if (not self
.get_param('allow_unplayable_formats')
37 and try_get(content_package
, lambda x
: x
['Constraints']['Security']['Type'])):
38 raise ExtractorError('This video is DRM protected.', expected
=True)
40 manifest_base_url
= content_package_url
+ 'manifest.'
42 formats
.extend(self
._extract
_m
3u8_formats
(
43 manifest_base_url
+ 'm3u8', content_id
, 'mp4',
44 'm3u8_native', m3u8_id
='hls', fatal
=False))
45 formats
.extend(self
._extract
_f
4m
_formats
(
46 manifest_base_url
+ 'f4m', content_id
,
47 f4m_id
='hds', fatal
=False))
48 formats
.extend(self
._extract
_mpd
_formats
(
49 manifest_base_url
+ 'mpd', content_id
,
50 mpd_id
='dash', fatal
=False))
51 self
._sort
_formats
(formats
)
54 for image
in (content
.get('Images') or []):
55 image_url
= image
.get('Url')
60 'width': int_or_none(image
.get('Width')),
61 'height': int_or_none(image
.get('Height')),
64 tags
, categories
= [], []
65 for source_name
, container
in (('Tags', tags
), ('Genres', categories
)):
66 for e
in content
.get(source_name
, []):
67 e_name
= e
.get('Name')
70 container
.append(e_name
)
72 season
= content
.get('Season') or {}
77 'description': content
.get('Desc') or content
.get('ShortDesc'),
78 'timestamp': parse_iso8601(content
.get('BroadcastDateTime')),
79 'episode_number': int_or_none(content
.get('Episode')),
80 'season': season
.get('Name'),
81 'season_number': int_or_none(season
.get('Number')),
82 'season_id': season
.get('Id'),
83 'series': try_get(content
, lambda x
: x
['Media']['Name']),
85 'categories': categories
,
86 'duration': float_or_none(content_package
.get('Duration')),
88 'thumbnails': thumbnails
,
91 if content_package
.get('HasClosedCaptions'):
94 'url': manifest_base_url
+ 'vtt',
97 'url': manifest_base_url
+ 'srt',