Mar 032010


Tired of crappy flash performance? Play YouTube videos in MPlayer with one click (self.linux)

You need the following software:

* Firefox
* MPlayer (but other players should work too)
* youtube-dl (Don’t use the version that comes with ubuntu, it’s two years old)
* CommandRun add on

If you want to start the video with a mouse gesture, then you need

* FireGestures

If you want to start it from the context menu, then you need

* Context Options

You can of course use both.

First, create a script named “yt” (or whatever you like) somewhere in your path with the following content:

mplayer "$(youtube-dl -g -f 18 $1)" &

and make it executable (chmod +x yt). You can of course add custom options to mplayer and choose the youtube format you like best (i.e something different than 18).

Next, in Firefox go to Tools – Add-ons – commandrun – Preferences and add your script to the allowed commands. You need to add the full path enclosed in double quotes and square brackets (e.g. [“/usr/local/bin/yt”]).

If you want to start videos with a mouse gesture, go to Tools – Add-ons – FireGestures – Preferences – Mapping – Add Script…, give it a name (e.g. Play with MPlayer) and paste the following code into the Script field:

var srcNode = FireGestures.sourceNode;
var linkURL = FireGestures.getLinkURL(srcNode);
if (!linkURL) throw "Not a link";
var CR = new CommandRunHandler();"/usr/local/bin/yt",[linkURL]);

and change “/usr/local/bin/yt” to the path of your script. Finally assign a gesture to it.

If you want to start the video from the context menu, go to Tools – Add-ons – Context Options – Preferences, click on New, uncheck everything but Hyperlink and paste the following code into the bottom field:

try {
var linkURL = get_link_url();
if (!linkURL) throw "Not a link";
var CR = new CommandRunHandler(); ("/usr/local/bin/yt",[linkURL]);
} catch (err) {
alert ("Error: " + err.description);

Again, remember to insert the right path. Finally give it a name in the upper text box in the middle column.

That’s it! Right click on any youtube link or perform your mouse gesture to watch the video in MPlayer.

 Posted by at 6:27 am