conduit r1362 - in trunk: . conduit/modules/GoogleModule
- From: thomasvm svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1362 - in trunk: . conduit/modules/GoogleModule
- Date: Sun, 9 Mar 2008 15:17:31 +0000 (GMT)
Author: thomasvm
Date: Sun Mar 9 15:17:31 2008
New Revision: 1362
URL: http://svn.gnome.org/viewvc/conduit?rev=1362&view=rev
Log:
2008-03-09 Thomas Van Machelen <thomas vanmachelen gmail com>:
* conduit/modules/GoogleModule/GoogleModule.py: revert to using the
old method for getting youtube videos; but use the correct href.
Fixes #518704
Modified:
trunk/ChangeLog
trunk/conduit/modules/GoogleModule/GoogleModule.py
Modified: trunk/conduit/modules/GoogleModule/GoogleModule.py
==============================================================================
--- trunk/conduit/modules/GoogleModule/GoogleModule.py (original)
+++ trunk/conduit/modules/GoogleModule/GoogleModule.py Sun Mar 9 15:17:31 2008
@@ -18,6 +18,8 @@
from gettext import gettext as _
+import re
+
#Distributors, if you ship python gdata >= 1.0.10 then remove this line
#and the appropriate directories
Utils.dataprovider_add_dir_to_path(__file__)
@@ -682,6 +684,7 @@
USERS_FEED = "http://gdata.youtube.com/feeds/users"
STD_FEEDS = "http://gdata.youtube.com/feeds/standardfeeds"
+ VIDEO_NAME_RE = re.compile(r', "t": "([^"]+)"')
def __init__(self, *args):
DataProvider.DataSource.__init__(self)
@@ -827,25 +830,24 @@
# Generic extract step
def _get_flv_video_url (self, url):
- """
- Previous code from here [1] was no longer working,
- therefore we try the trick from here [2]
- [1] http://svn.pythonfr.org/public/pythonfr/video/youtube_client.py
- [2] http://www.abdulqabiz.com/blog/archives/general/update_getting_youtu.php
-
- #FIXME:
- Method 2 doesnt work for old youtube videos, method 1 doesnt work
- for new youtube videos. e.g.
- http://www.youtube.com/watch?v=BWE1tH93G9U
- """
+ import urllib2
flv_url = ''
+ doc = urllib2.urlopen(url)
+ data = doc.read()
- # extract video id
- url_splited = url.split("watch?v=")
- video_id = url_splited[1]
+ # extract video name
+ match = YouTubeSource.VIDEO_NAME_RE.search(data)
+ if match is not None:
+ video_name = match.group(1)
+
+ # extract video id
+ url_splited = url.split("watch?v=")
+ video_id = url_splited[1]
- flv_url = "http://cache.googlevideo.com/get_video?video_id=%s&origin=youtube"
- flv_url = flv_url % video_id
+ flv_url = "http://www.youtube.com/get_video?video_id=%s&t=%s"
+ flv_url = flv_url % (video_id, video_name)
+
+ log.debug ("FLV URL %s" % flv_url)
return flv_url
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]