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.

43 lines
1.2 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from .fivemin import FiveMinIE
  5. from ..utils import (
  6. url_basename,
  7. )
  8. class EngadgetIE(InfoExtractor):
  9. _VALID_URL = r'''(?x)https?://www.engadget.com/
  10. (?:video/5min/(?P<id>\d+)|
  11. [\d/]+/.*?)
  12. '''
  13. _TEST = {
  14. 'url': 'http://www.engadget.com/video/5min/518153925/',
  15. 'md5': 'c6820d4828a5064447a4d9fc73f312c9',
  16. 'info_dict': {
  17. 'id': '518153925',
  18. 'ext': 'mp4',
  19. 'title': 'Samsung Galaxy Tab Pro 8.4 Review',
  20. },
  21. 'add_ie': ['FiveMin'],
  22. }
  23. def _real_extract(self, url):
  24. mobj = re.match(self._VALID_URL, url)
  25. video_id = mobj.group('id')
  26. if video_id is not None:
  27. return FiveMinIE._build_result(video_id)
  28. else:
  29. title = url_basename(url)
  30. webpage = self._download_webpage(url, title)
  31. ids = re.findall(r'<iframe[^>]+?playList=(\d+)', webpage)
  32. return {
  33. '_type': 'playlist',
  34. 'title': title,
  35. 'entries': [FiveMinIE._build_result(id) for id in ids]
  36. }