Last updated: 2007-06-11

Table of contents

What is Torrent Pouncer

Torrent Pouncer is an automatic torrent downloader for periodic releases of tv shows, series and similar. Contrary to popular RSS-based torrent downloaders, it searches various torrent search engines like Mininova and Pirate Bay. For user convenience, it keeps databases of downloaded torrents and associates them with shows and season and episode numbers. Torrent Pouncer is easily extensible with new search engine support and features a very powerful configuration language.

Requirements and download

The following requirements must be met in order to successfully install and use Torrent Pouncer:

scrAPI is distributed under MIT license, while Torrent Pouncer is covered by GPL license. There are several ways to install these packages, some of them are:

Getting started

Torrent Pouncer is always invoked with a configuration file as an argument. If it's not found in current directory, Pouncer will try hard to find it in ~/.pouncer directory. So, for example, when invoked like this:

pounce galactica
It will look for configuration file under following paths: ./galactica, ~/.pouncer/galactica, ~/.pouncer/galactica.conf, ~/.pouncer/galactica.cfg, ~/.pouncer/galactica.rb.

Torrent Pouncer also maintains a separate database for each configuration file. It contains information on torrents found on remote search engine web pages, as well as tracks which episodes we have already seen. The command line utility allows to download new torrents (which is the default action), mark the given episode as not seen ("unwatch", useful when we got a corrupted torrent), and the combination of the two - "rewatch". See the built-in documentation for details how to use it (pounce --help).

An example, imaginary configuration file may look like this:

------------------------- galactica.conf -----------------------------
# search Pirate Bay for 'galactica'
search PirateBay, 'galactica'

# add score 1 (default) to our favourite release group "orenji"
prefer {|t| t.name =~ /orenji/i}

# don't you hate those pesky rar releases? worry no more
prefer(-2) do |t|
    wget(t.torrent) {|file| system "grep -q '\.rar' #{file}"}
end

# assign a score of 0-1 based on number of seeds, 1 to the best seeded one
prefer_dynamic do |t, torrents|
    max = torrents.map {|x| x.seeds}.max.to_f
    t.seeds / max
end

# big fat releases
filter {|t, torrents| t.size > 320 and t.size < 380}

# get season 3 episode 9 and upwards and everything from season 4
# (we have seen the rest before switching to torrent pouncer)
filter {|t| t.season == 3 and t.episode >= 9 or t.season >= 4}

# copy torrent to current directory
action_copy '.'
----------------------- galactica.conf end ---------------------------

Configuration file

A Torrent Pouncer configuration file consists of at least one search and action statement, and usually a few filter and prefer statements. The basic mode of operation for Pouncer is more or less this:

  1. Find all new torrents resulting from a search statement(s).
  2. Apply filters (i.e. reject torrents that don't match).
  3. Award bonus points to torrents according to preferences.
  4. Download torrents for episodes that haven't yet been seen, and perform actions (e.g. copying) on them. Highest scoring torrents are preferred, but if downloading or an action fails the next torrents in queue will be tried.

Below is the description of valid configuration file statements:

Utility functions

Pouncer also provides some useful functions that can be used in configuration scripts:

Extending Torrent Pouncer

Torrent Pouncer is rather easily extended to support new search engines. The code itself can either be forced into the main program file or stored in ~/.pouncer (it is automatically added to Ruby's search path) and required from within each config file. Same goes for custom actions (like built-in action_copy).

In order to write to new search backend we will need to understand how Pouncer interacts with Searchers. Pouncer expects a Searcher class (derived from SearcherBase to respond to 2 methods:

Then, the results object is asked about a .torrents array, which is expected to contain torrent objects. torrent is usually derived from SearcherBase too, to allow customized serialization. torrent must have the following attributes defined: Following attributes are not mandatory, but it is helpful to provide them as well (some will be guessed automatically, like season/episode):

When developing new backends it is helpful to learn how built-in ones work first. Also, the scrAPI cheat sheet might prove to be useful. If you write a new search backend you will be very welcome to send it to the maintainer of Torrent Pouncer.

Acknowledgments

The following people have contributed to Torrent Pouncer:

Please let me know if I left out anyone or anything.

Contact information

You can contact the author using this email address: Michal Janeczek <janeczek@gmail.com>.