btrss.pl: Automatic RSS enabled torrent script
btrss.pl: Automatic RSS enabled torrent script
btrss.pl is a small script I wrote with the specific purpose of automatically downloading television shows such as The Daily Show With Jon Stewart and The Colbert Report and Little Britain and such. I watch these shows all the time, and manually downloading them each time they air is a nuisance. I tried to set up Azureus to automatically do this, and it is certainly possible, but I wanted something light-weight that worked well without requiring X. I understand that Azureus can be set up for use in the console this way, but trying to set it up proved too complicated for my liking, it was just easier to write something myself.
So essentially the script, when set up properly, will download torrents from RSS feeds and then email you when the download has completed.
How it works
The script is written in Perl and is quite simple. Upon invocation, it will load the configuration file (
.btrss.conf by default), download each RSS feed using
wget, parse the contents using
XML::Simple, and attempt to download the torrent using
btdownloadheadless. Subsequently, each torrent name is written to a log file (
.btrss.log by default) so it is only ever downloaded once. When the download has finished, the torrent is automatically stopped.
Usage
The first thing you will want to do is load
btrss.pl in an editor and adapt the "User configurable variables" to match your machine. You can change such things as the default log and configuration file names and locations, the subjects of notification emails and the addresses these emails are sent to, and the base URL of your web server in case you want to access the downloads remotely.
The script is invoked normally using a command such as:
$ perl btrss.pl
An optional command line argument
-a can be specified, which updates the log file with any new shows, but doesn't download them. This is useful if you haven't run
btrss.pl for a long time and don't want to start a large amount of torrent downloads. Simply edit the log file, deleting the lines containing the shows you want to download, and re-run
btrss.pl without the
-a argument.
The script can be automated by including it in your user-specific
crontab. I set mine up to run every 15 minutes, so I can be sure I'll get the show pretty soon after it has been posted on a torrent site. Currently, my torrent site of choice is
http://mininova.org as it supports searching in RSS feeds, something this script relies upon.
My
crontab, accessed using
crontab -e, is as follows:
# m h dom mon dow command
*/15 * * * * cd /home/donn/download && btrss.pl >> cron-btrss.log 2>&1
This changes to my download directory, invokes
btrss.pl, which exists in my PATH and has the executable flag set, and pipes all output to a log file, every 15 minutes.
Configuration file
The configuration file consists of a list of searchable RSS feeds. It would also work with a list of categorised RSS feeds, or type of feed where you can specify a filtered list of shows.
Here is an example containing two lines:
http://www.mininova.org/searchrss.php?search=daily+show+-big+-brother+-bb+-global+-colbert+-mercer
http://www.mininova.org/searchrss.php?search=colbert+report+-daily+-show
These are specific to
http://mininova.org, but something similar ought to work for other torrent sites. Search terms follow the
?search= parameter and are URL encoded (e.g. a space is represented as a
+). To filter words out you do not want to match, preceed the term with a
-. For example, the first line will match "daily show" only if it doesn't contain "big brother", "bb", "global", or "colbert report". I found this to be a sufficient filter to only show Daily Show torrents, except it will download more than one show per day if multiple copies from different torrents are found.
Requirements
As noted above, the requirements are:
- Perl
- The
XML::Simple Perl module (the libxml-simple-perl debian package)
bittorrent or bittornado
wget
- The
mail command (optional, for email notification)
mencoder (optional, for re-encoding the show to a smaller resolution for faster download)
Download
Download the script and sample configuration file here.
btrss-0.1.tar.gz
Bugs, feedback, etc.
This may not fit everyone's needs, but I found it very useful so I thought I'd share it. It is quite likely that the script will require some tuning. So if you find yourself standardising something, let me know and I'll incorporate it. If you notice any other problems feel free to contact me.
Howie @ 2007.10.17.19:33: I've written two similar scripts, one in Perl and one in Python, that are working well for me and a few friends. Check out LWP to get rid of the wget requirement; with LWP you can load cookies and the like and have a bit more control over filenames and where to write things out to. Additionally there's XML::RSS which is a nice wrapper around XML::Simple (or XML::Parser, I forget offhand).
post a comment (HTML stripped):