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