commonmistakes.py 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. from .common import InfoExtractor
  2. from ..utils import ExtractorError
  3. class CommonMistakesIE(InfoExtractor):
  4. IE_DESC = False # Do not list
  5. _VALID_URL = r'(?:url|URL|yt-dlp)$'
  6. _TESTS = [{
  7. 'url': 'url',
  8. 'only_matching': True,
  9. }, {
  10. 'url': 'URL',
  11. 'only_matching': True,
  12. }]
  13. def _real_extract(self, url):
  14. msg = (
  15. f'You\'ve asked yt-dlp to download the URL "{url}". '
  16. 'That doesn\'t make any sense. '
  17. 'Simply remove the parameter in your command or configuration.'
  18. )
  19. if not self.get_param('verbose'):
  20. msg += ' Add -v to the command line to see what arguments and configuration yt-dlp has'
  21. raise ExtractorError(msg, expected=True)
  22. class UnicodeBOMIE(InfoExtractor):
  23. IE_DESC = False
  24. _VALID_URL = r'(?P<bom>\ufeff)(?P<id>.*)$'
  25. _TESTS = [{
  26. 'url': '\ufeffhttp://www.youtube.com/watch?v=BaW_jenozKc',
  27. 'only_matching': True,
  28. }]
  29. def _real_extract(self, url):
  30. real_url = self._match_id(url)
  31. self.report_warning(
  32. 'Your URL starts with a Byte Order Mark (BOM). '
  33. f'Removing the BOM and looking for "{real_url}" ...')
  34. return self.url_result(real_url)
  35. class BlobIE(InfoExtractor):
  36. IE_DESC = False
  37. _VALID_URL = r'blob:'
  38. _TESTS = [{
  39. 'url': 'blob:https://www.youtube.com/4eb3d090-a761-46e6-8083-c32016a36e3b',
  40. 'only_matching': True,
  41. }]
  42. def _real_extract(self, url):
  43. raise ExtractorError(
  44. 'You\'ve asked yt-dlp to download a blob URL. '
  45. 'A blob URL exists only locally in your browser. '
  46. 'It is not possible for yt-dlp to access it.', expected=True)