GNOME Bugzilla – Bug 557681
YouTube problems with mrl and location
Last modified: 2009-01-30 18:37:46 UTC
Please describe the problem: I don't know if youtube changed their api or what, but for some reason ( re.match (".*[?&]t=([^&]+)", location).groups()[0]) keeps giving me None It also appears some youtube dlers have stopped working too, not all though. I found another python module called youtube-dl that still works however, and adapted some lines from it to make it work again Added socket and urllib2 to imports Removed all references to location and mrl = and replaced with: try: video_webpage = urllib2.urlopen("http://www.youtube.com/watch?v=" + urllib.quote (youtube_id)).read() except (urllib2.URLError, httplib.HTTPException, socket.error), err: self.to_stderr(u'ERROR: unable to download video webpage: %s' % str(err)) return True mobj = re.search(r', "t": "([^"]+)"', video_webpage) if mobj != None: mrl = 'http://www.youtube.com/get_video?video_id=%s&t=%s' % (youtube_id, mobj.group(1)) Steps to reproduce: 1. try to watch youtube video 2. 3. Actual results: Exception in thread Thread-2: Traceback (most recent call last):
+ Trace 208626
self.run()
res = self.callback(*self.args, **self.kwargs)
mrl = "http://www.youtube.com/get_video?video_id=" + urllib.quote (youtube_id) + "&t=" + urllib.quote ( re.match (".*[?&]t=([^&]+)", location).groups()[0]) + self.get_fmt_string()
Expected results: mrl to be set Does this happen every time? yes Other information:
Could you please post your patch as an attachment, and use "diff -up" to generate it?
Created attachment 121268 [details] [review] Mrl patch It's not perfect, it's copied from http://www.arrakis.es/~rggi3/youtube-dl/ . Some videos still do not play with it, but a lot more do than none.
Created attachment 121285 [details] [review] Mrl patch This one works better, the videos that did fail with the first mrl patch don't seem to now with this one. I also put back in the fmt_string that was in the old mrl scheme (I assume that's to get the video format, highres vs low res). I just noticed it needs my other multiple search patch applied, or it can be done by hand still, sorry about that, it's very tiny, I can also make a patch that applies against the unmodified plugin if it's a serious problem.
If you could clean up the patch and make sure it applies against the current upstream version of the plugin, it would be greatly appreciated. This fix needs to go in to the stable versions, otherwise the plugin is a bit pointless. Then we can concentrate on your other patch.
I'd already written a patch this morning, but didn't have time to fully test it or post it on Bugzilla. I've committed it instead of yours, since it doesn't introduce new dependencies on socket or urllib2. 2008-10-24 Philip Withnall <philip@tecnocode.co.uk> * src/plugins/youtube/youtube.py: Update the YouTube URL resolution code to work with Google's latest updates to YouTube. (Closes: #557681)
just a tiny note the version that's in svn no longer uses the location variable except in that if so that could be changed to location=self.resolve_t_param (youtube_id) then have the mrl = "youtube" + id + "&t=" + location + self.get_fmt_string (), having it there and set to what it is just creates an extra connection to youtube now :)
2008-10-24 Philip Withnall <philip@tecnocode.co.uk> * src/plugins/youtube/youtube.py: Remove redundant HTTP request when loading search results.
*** Bug 526238 has been marked as a duplicate of this bug. ***