Skip to content

Commit

Permalink
[youtube] Fix playlist and feed extraction (closes #25675)
Browse files Browse the repository at this point in the history
  • Loading branch information
dstftw committed Jun 15, 2020
1 parent 48bd042 commit d84b21b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions youtube_dl/extractor/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class YoutubeBaseInfoExtractor(InfoExtractor):

_PLAYLIST_ID_RE = r'(?:PL|LL|EC|UU|FL|RD|UL|TL|PU|OLAK5uy_)[0-9A-Za-z-_]{10,}'

_YOUTUBE_CLIENT_HEADERS = {
'x-youtube-client-name': '1',
'x-youtube-client-version': '1.20200609.04.02',
}

def _set_language(self):
self._set_cookie(
'.youtube.com', 'PREF', 'f1=50000000&hl=en',
Expand Down Expand Up @@ -301,7 +306,8 @@ def _entries(self, page, playlist_id):
'https://youtube.com/%s' % mobj.group('more'), playlist_id,
'Downloading page #%s%s'
% (page_num, ' (retry #%d)' % count if count else ''),
transform_source=uppercase_escape)
transform_source=uppercase_escape,
headers=self._YOUTUBE_CLIENT_HEADERS)
break
except ExtractorError as e:
if isinstance(e.cause, compat_HTTPError) and e.cause.code in (500, 503):
Expand Down Expand Up @@ -3250,7 +3256,8 @@ def _entries(self, page):
more = self._download_json(
'https://youtube.com/%s' % mobj.group('more'), self._PLAYLIST_TITLE,
'Downloading page #%s' % page_num,
transform_source=uppercase_escape)
transform_source=uppercase_escape,
headers=self._YOUTUBE_CLIENT_HEADERS)
content_html = more['content_html']
more_widget_html = more['load_more_widget_html']

Expand Down

0 comments on commit d84b21b

Please sign in to comment.