diff options
author | Sergey M․ <[email protected]> | 2021-03-03 11:42:59 +0700 |
---|---|---|
committer | Sergey M․ <[email protected]> | 2021-03-03 11:42:59 +0700 |
commit | 061c03013311eff75ac381cb4060204ce91b2510 (patch) | |
tree | 2b31ea2dbb9c7da3cb663d87f1badc69625f9e0e /youtube_dl | |
parent | 8f56907afa693290a6b2e05fb7ffc2f15dca33e2 (diff) | |
download | youtube-dl-061c03013311eff75ac381cb4060204ce91b2510.tar.gz youtube-dl-061c03013311eff75ac381cb4060204ce91b2510.zip |
[youtube:tab] Switch continuation to browse API (closes #28289, closes #28327)
Until further investigation.
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/extractor/youtube.py | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py index 2496d27f1..eb5a58807 100644 --- a/youtube_dl/extractor/youtube.py +++ b/youtube_dl/extractor/youtube.py @@ -2478,24 +2478,37 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor): headers = { 'x-youtube-client-name': '1', 'x-youtube-client-version': '2.20201112.04.01', + 'content-type': 'application/json', } if identity_token: headers['x-youtube-identity-token'] = identity_token + data = { + 'context': { + 'client': { + 'clientName': 'WEB', + 'clientVersion': '2.20201021.03.00', + } + }, + } + for page_num in itertools.count(1): if not continuation: break + data['continuation'] = continuation['continuation'] + data['clickTracking'] = { + 'clickTrackingParams': continuation['itct'] + } count = 0 retries = 3 while count <= retries: try: # Downloading page may result in intermittent 5xx HTTP error # that is usually worked around with a retry - browse = self._download_json( - 'https://www.youtube.com/browse_ajax', None, - 'Downloading page %d%s' - % (page_num, ' (retry #%d)' % count if count else ''), - headers=headers, query=continuation) + response = self._download_json( + 'https://www.youtube.com/youtubei/v1/browse?key=AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8', + None, 'Downloading page %d%s' % (page_num, ' (retry #%d)' % count if count else ''), + headers=headers, data=json.dumps(data).encode('utf8')) break except ExtractorError as e: if isinstance(e.cause, compat_HTTPError) and e.cause.code in (500, 503): @@ -2503,9 +2516,6 @@ class YoutubeTabIE(YoutubeBaseInfoExtractor): if count <= retries: continue raise - if not browse: - break - response = try_get(browse, lambda x: x[1]['response'], dict) if not response: break |