1
0
Fork 0
mirror of https://github.com/blackjack4494/yt-dlc.git synced 2024-12-23 08:17:00 +00:00

[youtube:playlist] Fix nonexistent/private playlist detection and skip private tests

This commit is contained in:
Sergey M․ 2017-01-23 02:49:56 +07:00
parent 8bc0800d7c
commit 4201ba13e6
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -1856,6 +1856,7 @@ class YoutubePlaylistIE(YoutubePlaylistBaseInfoExtractor):
'title': 'YDL_Empty_List', 'title': 'YDL_Empty_List',
}, },
'playlist_count': 0, 'playlist_count': 0,
'skip': 'This playlist is private',
}, { }, {
'note': 'Playlist with deleted videos (#651). As a bonus, the video #51 is also twice in this list.', 'note': 'Playlist with deleted videos (#651). As a bonus, the video #51 is also twice in this list.',
'url': 'https://www.youtube.com/playlist?list=PLwP_SiAcdui0KVebT0mU9Apz359a4ubsC', 'url': 'https://www.youtube.com/playlist?list=PLwP_SiAcdui0KVebT0mU9Apz359a4ubsC',
@ -1887,6 +1888,7 @@ class YoutubePlaylistIE(YoutubePlaylistBaseInfoExtractor):
'id': 'PLtPgu7CB4gbY9oDN3drwC3cMbJggS7dKl', 'id': 'PLtPgu7CB4gbY9oDN3drwC3cMbJggS7dKl',
}, },
'playlist_count': 2, 'playlist_count': 2,
'skip': 'This playlist is private',
}, { }, {
'note': 'embedded', 'note': 'embedded',
'url': 'https://www.youtube.com/embed/videoseries?list=PL6IaIsEjSbf96XFRuNccS_RuEXwNdsoEu', 'url': 'https://www.youtube.com/embed/videoseries?list=PL6IaIsEjSbf96XFRuNccS_RuEXwNdsoEu',
@ -2002,11 +2004,14 @@ class YoutubePlaylistIE(YoutubePlaylistBaseInfoExtractor):
for match in re.findall(r'<div class="yt-alert-message"[^>]*>([^<]+)</div>', page): for match in re.findall(r'<div class="yt-alert-message"[^>]*>([^<]+)</div>', page):
match = match.strip() match = match.strip()
# Check if the playlist exists or is private # Check if the playlist exists or is private
if re.match(r'[^<]*(The|This) playlist (does not exist|is private)[^<]*', match): mobj = re.match(r'[^<]*(?:The|This) playlist (?P<reason>does not exist|is private)[^<]*', match)
raise ExtractorError( if mobj:
'The playlist doesn\'t exist or is private, use --username or ' reason = mobj.group('reason')
'--netrc to access it.', message = 'This playlist %s' % reason
expected=True) if 'private' in reason:
message += ', use --username or --netrc to access it'
message += '.'
raise ExtractorError(message, expected=True)
elif re.match(r'[^<]*Invalid parameters[^<]*', match): elif re.match(r'[^<]*Invalid parameters[^<]*', match):
raise ExtractorError( raise ExtractorError(
'Invalid parameters. Maybe URL is incorrect.', 'Invalid parameters. Maybe URL is incorrect.',