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.

46 lines
1.8 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class SyfyIE(InfoExtractor):
  5. _VALID_URL = r'https?://www\.syfy\.com/(?:videos/.+?vid:(?P<id>[0-9]+)|(?!videos)(?P<video_name>[^/]+)(?:$|[?#]))'
  6. _TESTS = [{
  7. 'url': 'http://www.syfy.com/videos/Robot%20Combat%20League/Behind%20the%20Scenes/vid:2631458',
  8. 'info_dict': {
  9. 'id': 'NmqMrGnXvmO1',
  10. 'ext': 'flv',
  11. 'title': 'George Lucas has Advice for his Daughter',
  12. 'description': 'Listen to what insights George Lucas give his daughter Amanda.',
  13. },
  14. 'add_ie': ['ThePlatform'],
  15. }, {
  16. 'url': 'http://www.syfy.com/wilwheaton',
  17. 'md5': '94dfa54ee3ccb63295b276da08c415f6',
  18. 'info_dict': {
  19. 'id': '4yoffOOXC767',
  20. 'ext': 'flv',
  21. 'title': 'The Wil Wheaton Project - Premiering May 27th at 10/9c.',
  22. 'description': 'The Wil Wheaton Project premieres May 27th at 10/9c. Don\'t miss it.',
  23. },
  24. 'add_ie': ['ThePlatform'],
  25. 'skip': 'Blocked outside the US',
  26. }]
  27. def _real_extract(self, url):
  28. mobj = re.match(self._VALID_URL, url)
  29. video_name = mobj.group('video_name')
  30. if video_name:
  31. generic_webpage = self._download_webpage(url, video_name)
  32. video_id = self._search_regex(
  33. r'<iframe.*?class="video_iframe_page"\s+src="/_utils/video/thP_video_controller.php.*?_vid([0-9]+)">',
  34. generic_webpage, 'video ID')
  35. url = 'http://www.syfy.com/videos/%s/%s/vid:%s' % (
  36. video_name, video_name, video_id)
  37. else:
  38. video_id = mobj.group('id')
  39. webpage = self._download_webpage(url, video_id)
  40. return self.url_result(self._og_search_video_url(webpage))