My blog has moved!

You should be automatically redirected in 6 seconds. If not, visit
http://taylor.braun-jones.com/blog/
and update your bookmarks.

Easy remote torrent queuing with trasmission, zenity, and a dab of glue

Here is just a dab of glue that takes two very cool projects, Transmission and Zenity, and makes something very usable. Open a text editor as the root user (gksu gedit) and copy and paste this script:

#!/usr/bin/env bash

targethost=$(zenity --list --title "Assign host to download torrent" \
--radiolist --column " " --column "Host Name" \
TRUE localhost \
FALSE YOURSERVER) || exit

# Special case for localhost so it will still work if transmission is
# not already running
if [ "${targethost}" == "localhost" ]; then
transmission "$1" &
else
# TODO: Start transmision on the remote host if it is not already
# running
transmission-remote ${targethost} -a "$1"
fi

Just replace YOURSERVER with the name of the computer running transmission. Save the script to /usr/local/bin/add-remote-torrent (or whatever you want to name it) and give it execute permssions (sudo chmod +x /usr/local/bin/add-remote-torrent) For help setting up the transmission daemon the Transmission wiki has some well written guides, particulary the one on running Transmission on a headless machine.

Also, note that this script requires Transmission 1.50 or later, which supports adding torrents by URL. Ubuntu 9.04 and newer have this by default. Users of older releases need to add the official Transmission repository. From System -> Administration -> Software Sources, add the following APT line:

deb http://ppa.launchpad.net/transmissionbt/ubuntu intrepid main

Then add the authentication key so that the software repository is recognized as a "Trusted Software Provider"

sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com \
0xa37da909ae70535824d82620976b5901365c5ca1

Regardless of what version of Ubuntu you are running, you will need to explicitly install the Command Line Interface version of Transmission (transmission-cli) :

sudo apt-get install transmission-cli

Finally, go to your web browsers setting/preferences page and associate BitTorrent files (MIME type "application/x-bittorrent") with /usr/local/bin/add-remote-torrent. In Firefox this setting is located at Edit->Preferences->Applications. Now when ever you click a torrent link you will have the option of downloading the torrent on your own computer or on another computer.

Kink the video, not your neck

If you're anything like me when shooting short video clips with your camera, you regularly find that you've captured a great little clip with one exception – the video is turn on its side. Here is a little script to get you out of that dilemma, since I've found that it's not as easy as it should be with most video editors for Linux.

#!/usr/bin/env perl
#
# Naulilus (or command line) script to rotate one or more videos, renaming
# each one from, e.g., 'dir/input.avi' to 'dir/output (rotated).avi'
#
# Author: Taylor Braun-Jones
#
use File::Basename;

my ($input, $output);
my ($filebase, $dir, $suffix);

if ($ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS}) {
@videos = split "\n", $ENV{NAUTILUS_SCRIPT_SELECTED_FILE_PATHS};
# open DBG, ">/tmp/rotate_video_debug" and select DBG;
} else {
@videos = @ARGV;
}

foreach $input ( @videos ) {
chomp $input;
($filebase, $dir, $suffix) = fileparse("$input", '\..*$') or die "Failed
to parse filename: $input";
$output = "$dir$filebase (rotated)$suffix";
print "Rotating: '$input' -> '$output'\n";
system "mencoder -vf rotate=1 -o \"$output\" -oac copy -ovc lavc \"$inpu
t\"";
}
close DBG if DBG;

Just drop this script into $HOME/.gnome2/nautilus-scripts/ and give it execute permsions
chmod +x SCRIPTNAME
Also, make sure you have mencoder installed. On Debian-based systems (like Ubuntu) it's as simple as:
sudo apt-get install mencoder