You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.5 KiB

  1. from __future__ import unicode_literals
  2. import sys
  3. from .common import InfoExtractor
  4. from ..utils import ExtractorError
  5. class CommonMistakesIE(InfoExtractor):
  6. IE_DESC = False # Do not list
  7. _VALID_URL = r'''(?x)
  8. (?:url|URL)$
  9. '''
  10. _TESTS = [{
  11. 'url': 'url',
  12. 'only_matching': True,
  13. }, {
  14. 'url': 'URL',
  15. 'only_matching': True,
  16. }]
  17. def _real_extract(self, url):
  18. msg = (
  19. 'You\'ve asked youtube-dl to download the URL "%s". '
  20. 'That doesn\'t make any sense. '
  21. 'Simply remove the parameter in your command or configuration.'
  22. ) % url
  23. if not self._downloader.params.get('verbose'):
  24. msg += ' Add -v to the command line to see what arguments and configuration youtube-dl got.'
  25. raise ExtractorError(msg, expected=True)
  26. class UnicodeBOMIE(InfoExtractor):
  27. IE_DESC = False
  28. _VALID_URL = r'(?P<bom>\ufeff)(?P<id>.*)$'
  29. # Disable test for python 3.2 since BOM is broken in re in this version
  30. # (see https://github.com/ytdl-org/youtube-dl/issues/9751)
  31. _TESTS = [] if (3, 0) < sys.version_info <= (3, 3) else [{
  32. 'url': '\ufeffhttp://www.youtube.com/watch?v=BaW_jenozKc',
  33. 'only_matching': True,
  34. }]
  35. def _real_extract(self, url):
  36. real_url = self._match_id(url)
  37. self.report_warning(
  38. 'Your URL starts with a Byte Order Mark (BOM). '
  39. 'Removing the BOM and looking for "%s" ...' % real_url)
  40. return self.url_result(real_url)