]>
Raphaƫl G. Git Repositories - youtubedl/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,
30 'url': 'http://www.hotstar.com/sports/cricket/rajitha-sizzles-on-debut-with-329/2001477583',
31 'only_matching': True,
33 'url': 'http://www.hotstar.com/1000000515',
34 'only_matching': True,
37 def _download_json(self
, url_or_request
, video_id
, note
='Downloading JSON metadata', fatal
=True, query
=None):
38 json_data
= super(HotStarIE
, self
)._download
_json
(
39 url_or_request
, video_id
, note
, fatal
=fatal
, query
=query
)
40 if json_data
['resultCode'] != 'OK':
42 raise ExtractorError(json_data
['errorDescription'])
44 return json_data
['resultObj']
46 def _real_extract(self
, url
):
47 video_id
= self
._match
_id
(url
)
48 video_data
= self
._download
_json
(
49 'http://account.hotstar.com/AVS/besc', video_id
, query
={
50 'action': 'GetAggregatedContentDetails',
52 'contentId': video_id
,
54 title
= video_data
['episodeTitle']
56 if video_data
.get('encrypted') == 'Y':
57 raise ExtractorError('This video is DRM protected.', expected
=True)
61 format_data
= self
._download
_json
(
62 'http://getcdn.hotstar.com/AVS/besc',
63 video_id
, 'Downloading %s JSON metadata' % f
,
72 format_url
= format_data
.get('src')
75 ext
= determine_ext(format_url
)
77 formats
.extend(self
._extract
_m
3u8_formats
(
78 format_url
, video_id
, 'mp4',
79 m3u8_id
='hls', fatal
=False))
81 # produce broken files
86 'width': int_or_none(format_data
.get('width')),
87 'height': int_or_none(format_data
.get('height')),
89 self
._sort
_formats
(formats
)
94 'description': video_data
.get('description'),
95 'duration': int_or_none(video_data
.get('duration')),
96 'timestamp': int_or_none(video_data
.get('broadcastDate')),
99 'episode_number': int_or_none(video_data
.get('episodeNumber')),
100 'series': video_data
.get('contentTitle'),