Watching Youtube videos in Elinks

January 2, 2010

Elinks is a great browser, but rather limited when it comes to websites that use more than just text. Youtube, or other websites that host flash videos, are fairly useless in Elinks, as you can’t access that what they are all about (and, let’s admit, no one really wants to read the comments on Youtube…)

It is, however, possible to use Elinks in combination with other applications to access and view the flash videos on Youtube and other such sites. I will describe two ways here, one using youtube-dl (wholly following finferlu’s explanations) and the other clive (or cclive if you prefer that). Both methods use mplayer to play the video, though you could adapt both to use any other media player that plays flash videos if you so prefer.

Youtube-dl

First download and install youtube-dl, which is available in the repositories of most distros. If you use Debian Testing, download the package from the sid repostories and install that (dpkg -i youtube-dl_2009.09.13-2_all.deb), as for some reason it has not made its way to the Testing repos.

Once youtube-dl is installed, create the following script:

#!/bin/bash

video_url=`youtube-dl -g $1`
mplayer -vc ffflv -ac mp3 -cache 300 -prefer-ipv4 $video_url > /dev/null 2>&1

Save the script somewhere in one of your executable paths (I have it in /usr/local/bin as utube), and make it executable (chmod +x filename).

Now start elinks, and go to the “Options manager” by pressing o or through the menu (press Escape) in Setup > Options manager. Select the category “Document” and press + to show all the options. At the very end of the the list (just before the next section, ECMAScript) there is an subsection called “URI passing”. Navigate to that section and press a to add an entry, and give it an appropriate name (I called mine youtube). Select the newly created entry and press e to edit it. You should see the following window:

Add the command utube %c (replace utube with whatever you called the above script) into the “Value” field as in the above picture, press Enter, and press v to save the new settings.

Now you need to assign a keybinding to this script, so that you can tell Elinks to launch it when you want to view a Youtube video. Close the Options manager if you haven’t done so already (press c) and open the “Keybindings manager” (press k or go to “Setup > Keybindings manager” in the menu). Open the first section called “Main mapping” with the + key.

You now have two options (or three if you decide to use both). You can assign a keybinding to tell Elinks to view the Youtube video of either the selected link, or of the current page. With the former, you don’t actually have to browse to the page of the Youtube video you want to view, but can just select the link to that page from your Youtube search results list. With the latter you’d have to be on the page that contains the video.

To assign a keybinding to play the video of the selected link, select the “Pass URI of current link to external command” and press a to add a keybinding, and enter the keybinding you want to use in the “Keystroke” field.

To play the video of the current page, select the “Pass URI of current tab to external command” and add your keybinding there. Inverting finferlu’s choice, I use “Alt-p” for the current link, and “Alt-o” for the current page or tab.

Once all the above is done, you’re all set to watch Youtube videos with Elinks and Mplayer. Simply press “Alt-o” to view the video of the current page, or “Alt-p” to view the video that is linked to by the selected link, and Mplayer should stream the video nearly instantly.

Clive

Using youtube-dl to watch Youtube videos has a few disadvantages. First of all, it is limited to Youtube (though you could modify the above with metacafe-dl or nicovideo-dl to watch videos from metacafe.com and the to me entirely unknown nicoveo.jp). Secondly, though mplayer streams the videos very fast (much faster than the flash player in a graphical browser on my old computers!), it is hard to jump ahead with this method, as the mplayer first stutters and then freezes whenever I attempt that.

Using clive instead of youtube-dl handles both of these better. According to the website, clive supports the following websites (most of which I had never heard of): Youtube, Google, Sevenload, Break, Liveleak, Evisor TV, Dailymotion, CCTV (not to be confused with “closed-circuit television”), Redtube, Vimeo, Spiegel.de, Golem, ehrensenf.de, Clipfish, Funyhub, adn Myubo. Secondly, fast forwarding with clive works really well (as long as it has streamed that far ahead), and results in smoother playback. Clive does have some disadvantages. It will download the video file to your harddisk, and it takes a little longer before Mplayer starts playing the video.

The method to use clive instead is largely similar to that of youtube-dl. Open the Options manager in Elinks, go to the “URI passing” subsection of the “Document” section and create a new entry: press a and name the new entry “clive”. Select the new entry, press e to edit it, and add the following command in the “Value” field:

clive -q --save-dir=/tmp --stream-exec=\"mplayer -really-quiet %i\" --stream=10 %c

If you would prefer to let clive stream more before mplayer starts to play, increase the value after the “–stream” option (in percentage). If you want to view the best quality of the video available add “–format=best” to the above command (before “%c”!). For more options, see man clive.

If you have used both the clive and youtube-dl methods (or if you have created some other URI passing options), you will be presented with a list of commands that appears at the position of your cursor when you press Alt-o or Alt-p. Select the one you prefer, and press enter. If you only have one “URI passing” command, that one will automatically load when you press your keybinding.

And so you can watch your favourite Youtube (or Google Video, or Vimeo, or …) clips without having to rely on Flash, or even X. Now K.Mandla can finally watch his favourite slug races on the framebuffer! :twisted:

About these ads

25 Responses to “Watching Youtube videos in Elinks”

  1. Thuban said

    Very nice trick! thanks a lot!

  2. Thuban said

    Oh, you also can write options in a .cliverc file.
    It’s really lighter than gnash. I would like to add such things on midori :)

  3. Leon said

    That’s Awesome, and nothing else.

  4. [...] Zum Beispiel hielt ich es bis vor kurzem für unmöglich youtube Videos auf speedy anzuschauen. Ein genialer Blogeintrag, elinks und mplayer haben das aber dann doch möglich gemacht. Da selbst auf  leistungsfähigeren [...]

  5. [...] Grundidee ist einfach. Ausführlich vorgestellt wurde sie Anfang des Jahres in Englisch von Urukrama. Gesucht ist ein Programm, welches schnell Suchergebnisse von Youtube zurückliefert, die URL des [...]

  6. aqa said

    try youtube-viewer is for search a video in youtube and download and play with mplayer

  7. robert said

    Hey, this looks promising … !
    so I chose ‘cclive’ way and went for looking for the latest tarballs I needed. These I didn’t have installed :
    cclive-0.7.9
    libiconv-1.14
    libquvi-0.4.0
    libquvi-scripts-0.4.3
    I went a way of compiling ( MY FIRST ATTEMPT EVER ).
    Many problems occurred straight during configuring, mostly like:
    “configure: error: Package requirements (libquvi >= 0.4.0) were not met:

    No package ‘libquvi’ found

    Consider adjusting the PKG_CONFIG_PATH environment variable if you installed software in a non-standard prefix.

    Alternatively, you may set the environment variables libquvi_CFLAGS
    and libquvi_LIBS to avoid the need to call pkg-config.
    See the pkg-config man page for more details.”

    This was situation when I didn’t know what to do next !!!
    For previous similar ones I found answers on the web.

    BUT there is installed ‘libquvi-0.4.0′ !!! … maybe there is missing a development file which I found in Synaptic ‘libquvi-dev’ but not sure about this. There are 2 more packages:
    libquvi-doc
    libquvi0
    … do I need to install them? If I compiled before newer version of libquvi-0.4.0?

    Where to go next? anyone can light up my way?

    thanx, robert

  8. robert said

    Hey,
    Ok,managed to install all I’ve needed, but …!!
    WHY when play videos is ‘command’s output’ shown in elinks, then when scrolling webpage it looks that output stays behind the text.
    ???
    do you have the same case ??
    … and
    for playing videos I am using VLC player and ‘quvi’ with command:
    quvi –exec=\”vlc %u\” %c
    … VLC plays only .flv files not VP80 !!!

  9. srikanth ganta said

    Reblogged this on Srikanth's Blog.

  10. Ross said

    With havin so much written content do you ever run into any issues of plagorism or copyright infringement?

    My site has a lot of completely unique content I’ve either created myself or outsourced but it seems a lot of it is popping it up all over the internet without my agreement. Do you know any methods to help prevent content from being stolen? I’d genuinely appreciate it.

  11. -error said

    [...] more see this blog at urukrama.wordpress.com of this blog at [...]

  12. [...] for more see this blog at rjeanblog.blogspot.co.nz of this blog at urukrama.wordpress.com [...]

  13. [...] the latest blog here at urukrama.wordpress.com or here from [...]

  14. [...] learn more about this at caereinion.epowys.net or at urukrama.wordpress.com [...]

  15. [...] learn more about this at buddy.boxtwobox.com or at urukrama.wordpress.com [...]

  16. Braden said

    “Bad string

    options may only contain alphanumeric characters in addition to ‘-’ and ‘_’ ”

    when I try to enter “clive -q –save-dir=/tmp –stream-exec=\”mplayer -really-quiet %i\” –stream=10 %c” into the value field

    What gives?

  17. Because the admin of this web site is working, no hesitation very quickly it will be
    famous, due to its quality contents.

  18. This is my first time pay a quick visit at here and i am in fact happy to read everthing at alone place.

  19. Thank you for any other informative site. Where else may
    just I am getting that type of information written in such
    an ideal manner? I have a project that I’m simply now operating on, and I’ve been on the glance out for such information.

  20. My brother suggested I might like this website. He used to be totally
    right. This submit actually made my day. You can not imagine just how a
    lot time I had spent for this info! Thanks!

  21. Quinn said

    I really like your blog.. very nice colors & theme.
    Did you create this website yourself or did you hire
    someone to do it for you? Plz respond as I’m looking to design my own blog
    and would like to find out where u got this from.
    thank you

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 79 other followers