]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/hotstar.py
d28af36ec1704a8d4c508c2036962c8584ea38aa
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
15 class HotStarBaseIE(InfoExtractor
):
16 _GEO_COUNTRIES
= ['IN']
18 def _download_json(self
, *args
, **kwargs
):
19 response
= super(HotStarBaseIE
, self
)._download
_json
(*args
, **kwargs
)
20 if response
['resultCode'] != 'OK':
21 if kwargs
.get('fatal'):
23 response
['errorDescription'], expected
=True)
25 return response
['resultObj']
27 def _download_content_info(self
, content_id
):
28 return self
._download
_json
(
29 'https://account.hotstar.com/AVS/besc', content_id
, query
={
30 'action': 'GetAggregatedContentDetails',
31 'appVersion': '5.0.40',
33 'contentId': content_id
,
37 class HotStarIE(HotStarBaseIE
):
38 _VALID_URL
= r
'https?://(?:www\.)?hotstar\.com/(?:.+?[/-])?(?P<id>\d{10})'
40 'url': 'http://www.hotstar.com/on-air-with-aib--english-1000076273',
44 'title': 'On Air With AIB',
45 'description': 'md5:c957d8868e9bc793ccb813691cc4c434',
46 'timestamp': 1447227000,
47 'upload_date': '20151111',
52 'skip_download': True,
55 'url': 'http://www.hotstar.com/sports/cricket/rajitha-sizzles-on-debut-with-329/2001477583',
56 'only_matching': True,
58 'url': 'http://www.hotstar.com/1000000515',
59 'only_matching': True,
62 def _real_extract(self
, url
):
63 video_id
= self
._match
_id
(url
)
65 video_data
= self
._download
_content
_info
(video_id
)
67 title
= video_data
['episodeTitle']
69 if video_data
.get('encrypted') == 'Y':
70 raise ExtractorError('This video is DRM protected.', expected
=True)
74 format_data
= self
._download
_json
(
75 'http://getcdn.hotstar.com/AVS/besc',
76 video_id
, 'Downloading %s JSON metadata' % f
,
85 format_url
= format_data
.get('src')
88 ext
= determine_ext(format_url
)
90 formats
.extend(self
._extract
_m
3u8_formats
(
91 format_url
, video_id
, 'mp4',
92 m3u8_id
='hls', fatal
=False))
94 # produce broken files
99 'width': int_or_none(format_data
.get('width')),
100 'height': int_or_none(format_data
.get('height')),
102 self
._sort
_formats
(formats
)
107 'description': video_data
.get('description'),
108 'duration': int_or_none(video_data
.get('duration')),
109 'timestamp': int_or_none(video_data
.get('broadcastDate')),
112 'episode_number': int_or_none(video_data
.get('episodeNumber')),
113 'series': video_data
.get('contentTitle'),
117 class HotStarPlaylistIE(HotStarBaseIE
):
118 IE_NAME
= 'hotstar:playlist'
119 _VALID_URL
= r
'(?P<url>https?://(?:www\.)?hotstar\.com/tv/[^/]+/(?P<content_id>\d+))/(?P<type>[^/]+)/(?P<id>\d+)'
121 'url': 'http://www.hotstar.com/tv/pratidaan/14982/episodes/14812/9993',
125 'playlist_mincount': 75,
127 'url': 'http://www.hotstar.com/tv/pratidaan/14982/popular-clips/9998/9998',
128 'only_matching': True,
131 'episodes': 'EPISODE',
132 'popular-clips': 'CLIPS',
135 def _real_extract(self
, url
):
136 mobj
= re
.match(self
._VALID
_URL
, url
)
137 base_url
= mobj
.group('url')
138 content_id
= mobj
.group('content_id')
139 playlist_type
= mobj
.group('type')
141 content_info
= self
._download
_content
_info
(content_id
)
142 playlist_id
= compat_str(content_info
['categoryId'])
144 collection
= self
._download
_json
(
145 'https://search.hotstar.com/AVS/besc', playlist_id
, query
={
146 'action': 'SearchContents',
147 'appVersion': '5.0.40',
149 'moreFilters': 'series:%s;' % playlist_id
,
151 'searchOrder': 'last_broadcast_date desc,year desc,title asc',
152 'type': self
._ITEM
_TYPES
.get(playlist_type
, 'EPISODE'),
157 '%s/_/%s' % (base_url
, video
['contentId']),
158 ie
=HotStarIE
.ie_key(), video_id
=video
['contentId'])
159 for video
in collection
['response']['docs']
160 if video
.get('contentId')]
162 return self
.playlist_result(entries
, playlist_id
)