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.


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:


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.


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! 😈