[weboob] [PATCH 1/1] Fix Youtube mplayer error "No stream found to handle url"

Vincent Texier vit at free.fr
Thu May 22 21:55:25 CEST 2014


Set the "_play_proxy" boolean attribute to the video object
to pipe the video to mplayer.

Fix Youtube module test.

Signed-off-by: Vincent Texier <vit at free.fr>
---
 modules/dailymotion/pages.py |    8 ++++----
 modules/youtube/backend.py   |    5 +++++
 modules/youtube/test.py      |    2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/modules/dailymotion/pages.py b/modules/dailymotion/pages.py
index 3b92f65..1be381b 100644
--- a/modules/dailymotion/pages.py
+++ b/modules/dailymotion/pages.py
@@ -95,6 +95,10 @@ class VideoPage(BasePage):
 
         video.set_empty_fields(NotAvailable)
 
+        # Dailymotion video url is protected by a redirection with cookie verification
+        # so we need to use the "play_proxy" method using urllib2 proxy streaming to handle this
+        video._play_proxy = True
+
         return video
 
     def set_video_metadata(self, video):
@@ -153,10 +157,6 @@ class VideoPage(BasePage):
 
         video.url = unicode(info[max_quality])
 
-        # dailymotion video url is protected by a redirection with cookie verification
-        # so we need to do a "play_proxy" using urllib2 proxy streaming to handle this
-        video._play_proxy = True
-
 class KidsVideoPage(VideoPage):
 
     CONTROLLER_PAGE = 'http://kids.dailymotion.com/controller/Page_Kids_KidsUserHome?%s'
diff --git a/modules/youtube/backend.py b/modules/youtube/backend.py
index 3b006b6..e1afd56 100644
--- a/modules/youtube/backend.py
+++ b/modules/youtube/backend.py
@@ -115,6 +115,11 @@ class YoutubeBackend(BaseBackend, ICapVideo, ICapCollection):
         self._set_video_url(video)
 
         video.set_empty_fields(NotAvailable)
+
+        # Youtube video url is https, using ssl encryption
+        # so we need to use the "play_proxy" method using urllib2 proxy streaming to handle this
+        video._play_proxy = True
+
         return video
 
     def search_videos(self, pattern, sortby=ICapVideo.SEARCH_RELEVANCE, nsfw=False):
diff --git a/modules/youtube/test.py b/modules/youtube/test.py
index a18a9e9..2b08889 100644
--- a/modules/youtube/test.py
+++ b/modules/youtube/test.py
@@ -30,7 +30,7 @@ class YoutubeTest(BackendTest):
         self.assertTrue(len(l) > 0)
         v = l[0]
         self.backend.fillobj(v, ('url',))
-        self.assertTrue(v.url and v.url.startswith('http://'), 'URL for video "%s" not found: %s' % (v.id, v.url))
+        self.assertTrue(v.url and v.url.startswith('https://'), 'URL for video "%s" not found: %s' % (v.id, v.url))
         assert self.backend.get_video(v.shorturl)
         self.backend.browser.openurl(v.url)
 
-- 
1.7.9.5



More information about the weboob mailing list