After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 557681 - YouTube problems with mrl and location
YouTube problems with mrl and location
Status: RESOLVED FIXED
Product: totem
Classification: Core
Component: YouTube plugin
2.24.x
Other All
: Normal major
: ---
Assigned To: General Totem maintainer(s)
General Totem maintainer(s)
: 526238 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-10-24 00:23 UTC by Matthew Adams
Modified: 2009-01-30 18:37 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
Mrl patch (1.65 KB, patch)
2008-10-24 12:50 UTC, Matthew Adams
none Details | Review
Mrl patch (2.03 KB, patch)
2008-10-24 15:35 UTC, Matthew Adams
none Details | Review

Description Matthew Adams 2008-10-24 00:23:45 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):
  • File "/usr/lib/python2.5/threading.py", line 486 in __bootstrap_inner
    self.run()
  • File "/usr/lib/totem/plugins/youtube/youtube.py", line 58 in run
    res = self.callback(*self.args, **self.kwargs)
  • File "/usr/lib/totem/plugins/youtube/youtube.py", line 334 in process_next_thumbnail
    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()
AttributeError: 'NoneType' object has no attribute 'groups'

Expected results:
mrl to be set

Does this happen every time?
yes

Other information:
Comment 1 Bastien Nocera 2008-10-24 00:33:25 UTC
Could you please post your patch as an attachment, and use "diff -up" to generate it?
Comment 2 Matthew Adams 2008-10-24 12:50:13 UTC
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.
Comment 3 Matthew Adams 2008-10-24 15:35:39 UTC
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.
Comment 4 Bastien Nocera 2008-10-24 15:40:30 UTC
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.
Comment 5 Philip Withnall 2008-10-24 15:57:58 UTC
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)
Comment 6 Matthew Adams 2008-10-24 16:07:35 UTC
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 :)
Comment 7 Philip Withnall 2008-10-24 18:03:58 UTC
2008-10-24  Philip Withnall  <philip@tecnocode.co.uk>

	* src/plugins/youtube/youtube.py: Remove redundant HTTP request
	when loading search results.
Comment 8 Philip Withnall 2009-01-30 18:37:46 UTC
*** Bug 526238 has been marked as a duplicate of this bug. ***