]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/discoveryplusindia.py
51801402c3dd49f7042ae0adc6b5f1ba3dfac712
2 from __future__
import unicode_literals
6 from ..compat
import compat_str
7 from ..utils
import try_get
8 from .common
import InfoExtractor
9 from .dplay
import DPlayIE
12 class DiscoveryPlusIndiaIE(DPlayIE
):
13 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.in/videos?' + DPlayIE
._PATH
_REGEX
15 'url': 'https://www.discoveryplus.in/videos/how-do-they-do-it/fugu-and-more?seasonId=8&type=EPISODE',
19 'display_id': 'how-do-they-do-it/fugu-and-more',
20 'title': 'Fugu and More',
21 'description': 'The Japanese catch, prepare and eat the deadliest fish on the planet.',
23 'timestamp': 1582309800,
24 'upload_date': '20200221',
25 'series': 'How Do They Do It?',
28 'creator': 'Discovery Channel',
31 'format': 'bestvideo',
32 'skip_download': True,
34 'skip': 'Cookies (not necessarily logged in) are needed'
37 def _update_disco_api_headers(self
, headers
, disco_base
, display_id
, realm
):
38 headers
['x-disco-params'] = 'realm=%s' % realm
39 headers
['x-disco-client'] = 'WEB:UNKNOWN:dplus-india:17.0.0'
41 def _download_video_playback_info(self
, disco_base
, video_id
, headers
):
42 return self
._download
_json
(
43 disco_base
+ 'playback/v3/videoPlaybackInfo',
44 video_id
, headers
=headers
, data
=json
.dumps({
49 }).encode('utf-8'))['data']['attributes']['streaming']
51 def _real_extract(self
, url
):
52 display_id
= self
._match
_id
(url
)
53 return self
._get
_disco
_api
_info
(
54 url
, display_id
, 'ap2-prod-direct.discoveryplus.in', 'dplusindia', 'in')
57 class DiscoveryPlusIndiaShowIE(InfoExtractor
):
58 _VALID_URL
= r
'https?://(?:www\.)?discoveryplus\.in/show/(?P<show_name>[^/]+)/?(?:[?#]|$)'
60 'url': 'https://www.discoveryplus.in/show/how-do-they-do-it',
61 'playlist_mincount': 140,
63 'id': 'how-do-they-do-it',
67 def _entries(self
, show_name
):
69 'x-disco-client': 'WEB:UNKNOWN:dplus-india:prod',
70 'x-disco-params': 'realm=dplusindia',
71 'referer': 'https://www.discoveryplus.in/',
73 show_url
= 'https://ap2-prod-direct.discoveryplus.in/cms/routes/show/{}?include=default'.format(show_name
)
74 show_json
= self
._download
_json
(show_url
,
76 headers
=headers
)['included'][4]['attributes']['component']
77 show_id
= show_json
['mandatoryParams'].split('=')[-1]
78 season_url
= 'https://ap2-prod-direct.discoveryplus.in/content/videos?sort=episodeNumber&filter[seasonNumber]={}&filter[show.id]={}&page[size]=100&page[number]={}'
79 for season
in show_json
['filters'][0]['options']:
80 season_id
= season
['id']
81 total_pages
, page_num
= 1, 0
82 while page_num
< total_pages
:
83 season_json
= self
._download
_json
(season_url
.format(season_id
, show_id
, compat_str(page_num
+ 1)),
84 video_id
=show_id
, headers
=headers
,
85 note
='Downloading JSON metadata%s' % (' page %d' % page_num
if page_num
else ''))
87 total_pages
= try_get(season_json
, lambda x
: x
['meta']['totalPages'], int) or 1
88 episodes_json
= season_json
['data']
89 for episode
in episodes_json
:
90 video_id
= episode
['attributes']['path']
91 yield self
.url_result(
92 'https://discoveryplus.in/videos/%s' % video_id
,
93 ie
=DiscoveryPlusIndiaIE
.ie_key(), video_id
=video_id
)
96 def _real_extract(self
, url
):
97 show_name
= self
._match
_valid
_url
(url
).group('show_name')
98 return self
.playlist_result(self
._entries
(show_name
), playlist_id
=show_name
)