+
+
+class HotStarPlaylistIE(HotStarBaseIE):
+ IE_NAME = 'hotstar:playlist'
+ _VALID_URL = r'(?P<url>https?://(?:www\.)?hotstar\.com/tv/[^/]+/(?P<content_id>\d+))/(?P<type>[^/]+)/(?P<id>\d+)'
+ _TESTS = [{
+ 'url': 'http://www.hotstar.com/tv/pratidaan/14982/episodes/14812/9993',
+ 'info_dict': {
+ 'id': '14812',
+ },
+ 'playlist_mincount': 75,
+ }, {
+ 'url': 'http://www.hotstar.com/tv/pratidaan/14982/popular-clips/9998/9998',
+ 'only_matching': True,
+ }]
+ _ITEM_TYPES = {
+ 'episodes': 'EPISODE',
+ 'popular-clips': 'CLIPS',
+ }
+
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ base_url = mobj.group('url')
+ content_id = mobj.group('content_id')
+ playlist_type = mobj.group('type')
+
+ content_info = self._download_content_info(content_id)
+ playlist_id = compat_str(content_info['categoryId'])
+
+ collection = self._download_json(
+ 'https://search.hotstar.com/AVS/besc', playlist_id, query={
+ 'action': 'SearchContents',
+ 'appVersion': '5.0.40',
+ 'channel': 'PCTV',
+ 'moreFilters': 'series:%s;' % playlist_id,
+ 'query': '*',
+ 'searchOrder': 'last_broadcast_date desc,year desc,title asc',
+ 'type': self._ITEM_TYPES.get(playlist_type, 'EPISODE'),
+ })
+
+ entries = [
+ self.url_result(
+ '%s/_/%s' % (base_url, video['contentId']),
+ ie=HotStarIE.ie_key(), video_id=video['contentId'])
+ for video in collection['response']['docs']
+ if video.get('contentId')]
+
+ return self.playlist_result(entries, playlist_id)