diff options
Diffstat (limited to 'yt_dlp/extractor/youtube/_mistakes.py')
-rw-r--r-- | yt_dlp/extractor/youtube/_mistakes.py | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/yt_dlp/extractor/youtube/_mistakes.py b/yt_dlp/extractor/youtube/_mistakes.py new file mode 100644 index 000000000..c5eb5161c --- /dev/null +++ b/yt_dlp/extractor/youtube/_mistakes.py @@ -0,0 +1,69 @@ + +from ._base import YoutubeBaseInfoExtractor +from ...utils import ExtractorError + + +class YoutubeTruncatedURLIE(YoutubeBaseInfoExtractor): + IE_NAME = 'youtube:truncated_url' + IE_DESC = False # Do not list + _VALID_URL = r'''(?x) + (?:https?://)? + (?:\w+\.)?[yY][oO][uU][tT][uU][bB][eE](?:-nocookie)?\.com/ + (?:watch\?(?: + feature=[a-z_]+| + annotation_id=annotation_[^&]+| + x-yt-cl=[0-9]+| + hl=[^&]*| + t=[0-9]+ + )? + | + attribution_link\?a=[^&]+ + ) + $ + ''' + + _TESTS = [{ + 'url': 'https://www.youtube.com/watch?annotation_id=annotation_3951667041', + 'only_matching': True, + }, { + 'url': 'https://www.youtube.com/watch?', + 'only_matching': True, + }, { + 'url': 'https://www.youtube.com/watch?x-yt-cl=84503534', + 'only_matching': True, + }, { + 'url': 'https://www.youtube.com/watch?feature=foo', + 'only_matching': True, + }, { + 'url': 'https://www.youtube.com/watch?hl=en-GB', + 'only_matching': True, + }, { + 'url': 'https://www.youtube.com/watch?t=2372', + 'only_matching': True, + }] + + def _real_extract(self, url): + raise ExtractorError( + 'Did you forget to quote the URL? Remember that & is a meta ' + 'character in most shells, so you want to put the URL in quotes, ' + 'like yt-dlp ' + '"https://www.youtube.com/watch?feature=foo&v=BaW_jenozKc" ' + ' or simply yt-dlp BaW_jenozKc .', + expected=True) + + +class YoutubeTruncatedIDIE(YoutubeBaseInfoExtractor): + IE_NAME = 'youtube:truncated_id' + IE_DESC = False # Do not list + _VALID_URL = r'https?://(?:www\.)?youtube\.com/watch\?v=(?P<id>[0-9A-Za-z_-]{1,10})$' + + _TESTS = [{ + 'url': 'https://www.youtube.com/watch?v=N_708QY7Ob', + 'only_matching': True, + }] + + def _real_extract(self, url): + video_id = self._match_id(url) + raise ExtractorError( + f'Incomplete YouTube ID {video_id}. URL {url} looks truncated.', + expected=True) |