commonmistakes.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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|hypervideo)$'
  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. 'You\'ve asked hypervideo to download the URL "%s". '
  16. 'That doesn\'t make any sense. '
  17. 'Simply remove the parameter in your command or configuration.'
  18. ) % url
  19. if not self.get_param('verbose'):
  20. msg += ' Add -v to the command line to see what arguments and configuration hypervideo 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. 'Removing the BOM and looking for "%s" ...' % real_url)
  34. return self.url_result(real_url)