]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/hotstar.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
12 class HotStarIE(InfoExtractor
):
13 _VALID_URL
= r
'https?://(?:www\.)?hotstar\.com/.*?[/-](?P<id>\d{10})'
15 'url': 'http://www.hotstar.com/on-air-with-aib--english-1000076273',
19 'title': 'On Air With AIB - English',
20 'description': 'md5:c957d8868e9bc793ccb813691cc4c434',
21 'timestamp': 1447227000,
22 'upload_date': '20151111',
27 'skip_download': True,
31 _GET_CONTENT_TEMPLATE
= 'http://account.hotstar.com/AVS/besc?action=GetAggregatedContentDetails&channel=PCTV&contentId=%s'
32 _GET_CDN_TEMPLATE
= 'http://getcdn.hotstar.com/AVS/besc?action=GetCDN&asJson=Y&channel=%s&id=%s&type=%s'
34 def _download_json(self
, url_or_request
, video_id
, note
='Downloading JSON metadata', fatal
=True):
35 json_data
= super(HotStarIE
, self
)._download
_json
(url_or_request
, video_id
, note
, fatal
=fatal
)
36 if json_data
['resultCode'] != 'OK':
38 raise ExtractorError(json_data
['errorDescription'])
40 return json_data
['resultObj']
42 def _real_extract(self
, url
):
43 video_id
= self
._match
_id
(url
)
44 video_data
= self
._download
_json
(
45 self
._GET
_CONTENT
_TEMPLATE
% video_id
,
46 video_id
)['contentInfo'][0]
49 # PCTV for extracting f4m manifest
51 format_data
= self
._download
_json
(
52 self
._GET
_CDN
_TEMPLATE
% (f
, video_id
, 'VOD'),
53 video_id
, 'Downloading %s JSON metadata' % f
, fatal
=False)
55 format_url
= format_data
['src']
56 ext
= determine_ext(format_url
)
58 m3u8_formats
= self
._extract
_m
3u8_formats
(format_url
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False)
60 formats
.extend(m3u8_formats
)
62 # produce broken files
67 'width': int_or_none(format_data
.get('width')),
68 'height': int_or_none(format_data
.get('height')),
70 self
._sort
_formats
(formats
)
74 'title': video_data
['episodeTitle'],
75 'description': video_data
.get('description'),
76 'duration': int_or_none(video_data
.get('duration')),
77 'timestamp': int_or_none(video_data
.get('broadcastDate')),