Totem YouTube plugin

Update (2011-08-27): A lot has happened to the Totem YouTube plugin since this blog post. It's been ported to C, extended to do HD videos, trimmed down to no longer do HD, and then moved to Grilo, where it now lives. It can be used in Totem from the Grilo plugin, which provides a unified UI for accessing video websites like YouTube from Totem. For more information on the history of the plugin, see my blog posts about Totem.

YouTube has come to Totem…

…in the form of a plugin I've written which allows you to browse YouTube from the comfort of everyone's favourite movie player. It allows searching for videos, and when you play a video, it displays its related videos.

The feature I'm most proud of though, is the fact that it automatically paginates when you scroll down the search results, loading more results as you go down. With a hint from Patrys in the comments in my blog post on it (and thanks to the other guys who left comments :)), it works by loading results immediately if you scroll 80% or more of the way down the treeview with the mouse or keyboard, or if you let go of the scrollbar handle more than 80% of the way down when moving it with the mouse. Query pages are loaded in a separate thread, and then the results are brought in with an idle function. This isn't quite as lag-free as I'd've wanted, but I can't see much more I can do to improve things.

Anyway, try things out by downloading and compiling SVN Totem, then enabling the "YouTube browser" plugin. You'll need the GData Python library (that's what the YouTube API uses, PyGTK 2.12 and Python 2.5. Before anyone asks, there's no way to sanely support video uploading yet, as Google unfortunately haven't yet exposed a public upload API. :(

Oh, and the cake is a lie.

7 thoughts on “Totem YouTube plugin

  1. Étienne Bersac

    Hi,

    Congratulation ! I'm wondering if this can lead to bloat totem and make it behave like miro.

    Regards

  2. Chris Lord

    After a LOT of hassle, I finally built svn totem and the relevant plugins (python-gdata is broken with python 2.5 in ubuntu gutsy - easily fixable, and the API is slightly different to what you've used - again, easily fixable)

    Your plugin is very neat :) I find that it gives *much* better results if you order by relevance though, rather than view count, and also that you probably want to separate search terms with a '+' rather than submitting a search term with spaces - so I changed the relevant line to this:

    self.get_results ("/feeds/videos?vq=" + str(urllib.quote(search_terms)).replace("%20", '+') + "&orderby=relevance&max-results=" + str (self.max_results), _("Search Results:"))

    Note, I'm not a python coder at all, so there are probably much nicer ways of doing that, etc. Cool stuff, anyway, well done :) Now I just need to build ffdemux_swf...

    p.s. Your captcha is far too hard...

  3. Martin

    Cool!

    A small UI suggestion though. I think you should put the search entry above the search results. It would increase the flow (something HCI people talk about ;) of the dialog.

  4. Julien Moutte

    Are you passing the .flv directly to Totem or the Youtube player ? I implemented a FLV demuxer in gstreamer-plugins-bad CVS HEAD and it supports streaming from Youtube with seeking using HTTP/1.1

    I think that would be very cute to make the plug-in provide FLV URIs to Totem and use this demuxer to seek and stream FLVs from Youtube.

    Nice work !

  5. Jan Arne Petersen

    I created an URL with the following code to play the FLV-file directly:

    conn = httplib.HTTPConnection (\"www.youtube.com\")
    conn.request (\"GET\", \"/v/\" + urllib.quote (youtube_id))
    response = conn.getresponse ()
    if response.status == 303:
    location = response.getheader(\'location\')
    url = \"http://www.youtube.com/get_video?video_id=\" + urllib.quote (youtube_id) + \"&t=\" + urllib.quote (location[location.rfind(\'&t=\')+3:])

    self.totem.action_set_mrl_and_play (url)

Comments are closed.