[syfy] fix the extraction logic and make the test pass

This commit is contained in:
remitamine 2015-07-21 12:12:52 +01:00
parent 83d10c9ec8
commit ce4dd93a5e

View File

@ -1,46 +1,31 @@
from __future__ import unicode_literals from __future__ import unicode_literals
import re
from .common import InfoExtractor from .common import InfoExtractor
class SyfyIE(InfoExtractor): class SyfyIE(InfoExtractor):
_VALID_URL = r'https?://www\.syfy\.com/(?:videos/.+?vid:(?P<id>[0-9]+)|(?!videos)(?P<video_name>[^/]+)(?:$|[?#]))' _VALID_URL = r'https?://www\.syfy\.com/[^/]+/videos/(?:\d+-)?(?P<id>[A-Za-z0-9-]+)'
_TESTS = [{ _TESTS = [{
'url': 'http://www.syfy.com/videos/Robot%20Combat%20League/Behind%20the%20Scenes/vid:2631458', 'url': 'http://www.syfy.com/sharknado3/videos/sharknado-3-trailer',
'info_dict': { 'info_dict': {
'id': 'NmqMrGnXvmO1', 'id': 'Sueh0V5Eh6L6',
'ext': 'flv', 'ext': 'm3u8',
'title': 'George Lucas has Advice for his Daughter', 'title': 'Sharknado 3: Trailer',
'description': 'Listen to what insights George Lucas give his daughter Amanda.', 'description': 'This time, the entire east coast isn\'t safe. Sharknado 3 premieres July 22 at 9/8c on Syfy.',
},
'add_ie': ['ThePlatform'],
}, {
'url': 'http://www.syfy.com/wilwheaton',
'md5': '94dfa54ee3ccb63295b276da08c415f6',
'info_dict': {
'id': '4yoffOOXC767',
'ext': 'flv',
'title': 'The Wil Wheaton Project - Premiering May 27th at 10/9c.',
'description': 'The Wil Wheaton Project premieres May 27th at 10/9c. Don\'t miss it.',
}, },
'add_ie': ['ThePlatform'], 'add_ie': ['ThePlatform'],
'skip': 'Blocked outside the US', 'skip': 'Blocked outside the US',
'params': {
# rtmp download
'skip_download': True,
}
}] }]
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) display_id = self._match_id(url)
video_name = mobj.group('video_name') webpage = self._download_webpage(url, display_id)
if video_name: releaseURL = self._parse_json(self._html_search_regex(
generic_webpage = self._download_webpage(url, video_name) r'"syfy_mpx"\s*:\s*({[^}]+?})',
video_id = self._search_regex( webpage, 'syfy_mpx'), display_id)['releaseURL']
r'<iframe.*?class="video_iframe_page"\s+src="/_utils/video/thP_video_controller.php.*?_vid([0-9]+)">', return self.url_result(releaseURL)
generic_webpage, 'video ID')
url = 'http://www.syfy.com/videos/%s/%s/vid:%s' % (
video_name, video_name, video_id)
else:
video_id = mobj.group('id')
webpage = self._download_webpage(url, video_id)
return self.url_result(self._og_search_video_url(webpage))