From 22d99a801ab2291beed7b9b9e8244fc9ceab39f0 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Wed, 30 Apr 2014 01:35:52 +0200 Subject: [PATCH] [syfy] Add suppor for generic URLs (Fixes #2827) --- youtube_dl/extractor/syfy.py | 28 ++++++++++++++++++++++++---- youtube_dl/extractor/theplatform.py | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/youtube_dl/extractor/syfy.py b/youtube_dl/extractor/syfy.py index 8809a57fe3..f76b6e2b22 100644 --- a/youtube_dl/extractor/syfy.py +++ b/youtube_dl/extractor/syfy.py @@ -6,9 +6,9 @@ class SyfyIE(InfoExtractor): - _VALID_URL = r'https?://www\.syfy\.com/videos/.+?vid:(?P\d+)' + _VALID_URL = r'https?://www\.syfy\.com/(?:videos/.+?vid:(?P[0-9]+)|(?!videos)(?P[^/]+)(?:$|[?#]))' - _TEST = { + _TESTS = [{ 'url': 'http://www.syfy.com/videos/Robot%20Combat%20League/Behind%20the%20Scenes/vid:2631458', 'md5': 'e07de1d52c7278adbb9b9b1c93a66849', 'info_dict': { @@ -18,10 +18,30 @@ class SyfyIE(InfoExtractor): 'description': 'Listen to what insights George Lucas give his daughter Amanda.', }, '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'], + 'skip': 'Blocked outside the US', + }] def _real_extract(self, url): mobj = re.match(self._VALID_URL, url) - video_id = mobj.group('id') + video_name = mobj.group('video_name') + if video_name: + generic_webpage = self._download_webpage(url, video_name) + video_id = self._search_regex( + r'', + 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)) diff --git a/youtube_dl/extractor/theplatform.py b/youtube_dl/extractor/theplatform.py index 91f2453ebf..f15780ef54 100644 --- a/youtube_dl/extractor/theplatform.py +++ b/youtube_dl/extractor/theplatform.py @@ -52,7 +52,7 @@ def _get_info(self, video_id, smil_url): head = meta.find(_x('smil:head')) body = meta.find(_x('smil:body')) - f4m_node = body.find(_x('smil:seq/smil:video')) + f4m_node = body.find(_x('smil:seq//smil:video')) if f4m_node is not None: f4m_url = f4m_node.attrib['src'] if 'manifest.f4m?' not in f4m_url: