]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/commonmistakes.py
[youtube] Force `hl=en` for comments (#594)
[yt-dlp.git] / yt_dlp / extractor / commonmistakes.py
CommitLineData
9f435c5f
PH
1from __future__ import unicode_literals
2
2cc7fcd3
S
3import sys
4
9f435c5f
PH
5from .common import InfoExtractor
6from ..utils import ExtractorError
7
8
9class CommonMistakesIE(InfoExtractor):
10 IE_DESC = False # Do not list
11 _VALID_URL = r'''(?x)
e01bfc19 12 (?:url|URL)$
9f435c5f
PH
13 '''
14
15 _TESTS = [{
16 'url': 'url',
17 'only_matching': True,
18 }, {
19 'url': 'URL',
20 'only_matching': True,
21 }]
22
23 def _real_extract(self, url):
24 msg = (
7a5c1cfe 25 'You\'ve asked yt-dlp to download the URL "%s". '
9f435c5f
PH
26 'That doesn\'t make any sense. '
27 'Simply remove the parameter in your command or configuration.'
28 ) % url
a06916d9 29 if not self.get_param('verbose'):
0760b0a7 30 msg += ' Add -v to the command line to see what arguments and configuration yt-dlp has'
9f435c5f 31 raise ExtractorError(msg, expected=True)
c73fae1e
PH
32
33
34class UnicodeBOMIE(InfoExtractor):
cd37ef44
S
35 IE_DESC = False
36 _VALID_URL = r'(?P<bom>\ufeff)(?P<id>.*)$'
37
38 # Disable test for python 3.2 since BOM is broken in re in this version
39 # (see https://github.com/ytdl-org/youtube-dl/issues/9751)
40 _TESTS = [] if (3, 0) < sys.version_info <= (3, 3) else [{
41 'url': '\ufeffhttp://www.youtube.com/watch?v=BaW_jenozKc',
42 'only_matching': True,
43 }]
44
45 def _real_extract(self, url):
46 real_url = self._match_id(url)
47 self.report_warning(
48 'Your URL starts with a Byte Order Mark (BOM). '
49 'Removing the BOM and looking for "%s" ...' % real_url)
50 return self.url_result(real_url)