From 63f05de10bac9250f58b2f15539f109ec75b3af7 Mon Sep 17 00:00:00 2001 From: Johny Mo Swag Date: Mon, 29 Jul 2013 12:11:57 -0700 Subject: [PATCH 1/3] detect vevo embed --- youtube_dl/extractor/worldstarhiphop.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/youtube_dl/extractor/worldstarhiphop.py b/youtube_dl/extractor/worldstarhiphop.py index 5b9779c05..8715848ee 100644 --- a/youtube_dl/extractor/worldstarhiphop.py +++ b/youtube_dl/extractor/worldstarhiphop.py @@ -21,6 +21,14 @@ def _real_extract(self, url): webpage_src = self._download_webpage(url, video_id) + video_url = self._search_regex('videoId=(.*?)&?', + webpage_src, u'video URL', fatal=False) + + if video_url: + self.to_screen(u'Vevo video detected:') + vevo_id = 'vevo:%s' video_url + self.url_result(vevo_id) + video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)', webpage_src, u'video URL') From 579e2691feca6173c5a84c1fb4fe7a213386c223 Mon Sep 17 00:00:00 2001 From: Johny Mo Swag Date: Mon, 29 Jul 2013 12:24:26 -0700 Subject: [PATCH 2/3] detect vevo embed fix --- youtube_dl/extractor/worldstarhiphop.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/worldstarhiphop.py b/youtube_dl/extractor/worldstarhiphop.py index 8715848ee..a93928f3c 100644 --- a/youtube_dl/extractor/worldstarhiphop.py +++ b/youtube_dl/extractor/worldstarhiphop.py @@ -21,17 +21,23 @@ def _real_extract(self, url): webpage_src = self._download_webpage(url, video_id) - video_url = self._search_regex('videoId=(.*?)&?', + video_url = self._search_regex(r'videoId=(.*?)&?', webpage_src, u'video URL', fatal=False) - + if video_url: self.to_screen(u'Vevo video detected:') - vevo_id = 'vevo:%s' video_url - self.url_result(vevo_id) + return self.url_result('vevo:%s' % video_url, ie='Vevo') video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)', webpage_src, u'video URL') + if video_url == None: + video_url = self._search_regex(r'videoId=(.*?)&?', + webpage_src, u'video URL') + self.to_screen(u'Vevo video detected:') + vevo_id = 'vevo:%s' % video_url + return self.url_result(vevo_id, ie='Vevo') + if 'youtube' in video_url: self.to_screen(u'Youtube video detected:') return self.url_result(video_url, ie='Youtube') From d75654c15ea67424abf0fe69fdfb50e2a2d50101 Mon Sep 17 00:00:00 2001 From: Johny Mo Swag Date: Mon, 29 Jul 2013 14:39:14 -0700 Subject: [PATCH 3/3] using re.search --- youtube_dl/extractor/worldstarhiphop.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/worldstarhiphop.py b/youtube_dl/extractor/worldstarhiphop.py index a93928f3c..8a52c7a99 100644 --- a/youtube_dl/extractor/worldstarhiphop.py +++ b/youtube_dl/extractor/worldstarhiphop.py @@ -21,17 +21,17 @@ def _real_extract(self, url): webpage_src = self._download_webpage(url, video_id) - video_url = self._search_regex(r'videoId=(.*?)&?', - webpage_src, u'video URL', fatal=False) + video_url = re.search(r'videoId=(.*?)&?', + webpage_src) if video_url: self.to_screen(u'Vevo video detected:') - return self.url_result('vevo:%s' % video_url, ie='Vevo') + return self.url_result('vevo:%s' % video_url.group(1), ie='Vevo') video_url = self._search_regex(r'so\.addVariable\("file","(.*?)"\)', webpage_src, u'video URL') - if video_url == None: + if video_url is None: video_url = self._search_regex(r'videoId=(.*?)&?', webpage_src, u'video URL') self.to_screen(u'Vevo video detected:')