mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-11-21 17:51:51 +00:00
[youtube:tab] Fix extraction with cookies provided (closes #27005)
This commit is contained in:
parent
91dcde8a38
commit
6699b6ce41
1 changed files with 13 additions and 6 deletions
|
@ -2723,7 +2723,7 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||||
'itct': ctp,
|
'itct': ctp,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _entries(self, tab):
|
def _entries(self, tab, identity_token):
|
||||||
continuation = None
|
continuation = None
|
||||||
slr_contents = tab['sectionListRenderer']['contents']
|
slr_contents = tab['sectionListRenderer']['contents']
|
||||||
for slr_content in slr_contents:
|
for slr_content in slr_contents:
|
||||||
|
@ -2768,16 +2768,20 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||||
if not continuation:
|
if not continuation:
|
||||||
continuation = self._extract_continuation(is_renderer)
|
continuation = self._extract_continuation(is_renderer)
|
||||||
|
|
||||||
|
headers = {
|
||||||
|
'x-youtube-client-name': '1',
|
||||||
|
'x-youtube-client-version': '2.20201112.04.01',
|
||||||
|
}
|
||||||
|
if identity_token:
|
||||||
|
headers['x-youtube-identity-token'] = identity_token
|
||||||
|
|
||||||
for page_num in itertools.count(1):
|
for page_num in itertools.count(1):
|
||||||
if not continuation:
|
if not continuation:
|
||||||
break
|
break
|
||||||
browse = self._download_json(
|
browse = self._download_json(
|
||||||
'https://www.youtube.com/browse_ajax', None,
|
'https://www.youtube.com/browse_ajax', None,
|
||||||
'Downloading page %d' % page_num,
|
'Downloading page %d' % page_num,
|
||||||
headers={
|
headers=headers, query=continuation, fatal=False)
|
||||||
'x-youtube-client-name': '1',
|
|
||||||
'x-youtube-client-version': '2.20201030.01.00',
|
|
||||||
}, query=continuation, fatal=False)
|
|
||||||
if not browse:
|
if not browse:
|
||||||
break
|
break
|
||||||
response = try_get(browse, lambda x: x[1]['response'], dict)
|
response = try_get(browse, lambda x: x[1]['response'], dict)
|
||||||
|
@ -2848,8 +2852,11 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor):
|
||||||
title = channel_title or channel_id
|
title = channel_title or channel_id
|
||||||
if tab_title:
|
if tab_title:
|
||||||
title += ' - %s' % tab_title
|
title += ' - %s' % tab_title
|
||||||
|
identity_token = self._search_regex(
|
||||||
|
r'\bID_TOKEN["\']\s*:\s*["\'](.+?)["\']', webpage,
|
||||||
|
'identity token', default=None)
|
||||||
return self.playlist_result(
|
return self.playlist_result(
|
||||||
self._entries(selected_tab['content']),
|
self._entries(selected_tab['content'], identity_token),
|
||||||
playlist_id=channel_external_id or channel_id,
|
playlist_id=channel_external_id or channel_id,
|
||||||
playlist_title=title)
|
playlist_title=title)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue