]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/commonmistakes.py
debian/copyright: Update my copyright years.
[youtubedl] / youtube_dl / extractor / commonmistakes.py
1 from __future__ import unicode_literals
2
3 import sys
4
5 from .common import InfoExtractor
6 from ..utils import ExtractorError
7
8
9 class CommonMistakesIE(InfoExtractor):
10 IE_DESC = False # Do not list
11 _VALID_URL = r'''(?x)
12 (?:url|URL)$
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 = (
25 'You\'ve asked youtube-dl to download the URL "%s". '
26 'That doesn\'t make any sense. '
27 'Simply remove the parameter in your command or configuration.'
28 ) % url
29 if not self._downloader.params.get('verbose'):
30 msg += ' Add -v to the command line to see what arguments and configuration youtube-dl got.'
31 raise ExtractorError(msg, expected=True)
32
33
34 class UnicodeBOMIE(InfoExtractor):
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/rg3/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)