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.

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