You are not logged in.

#1 2011-07-28 12:59:13

SidK
Member
Registered: 2011-03-03
Posts: 116

torss - downloads selected torrents from RSS feeds

I often have a problem with various private torrent trackers that by the time I add to torrent to my client it has already been active for a long time and I struggle to maintain a good ratio. As such I wanted something which could scrape the tracker's RSS feed, find torrents that match various patterns and download the torrent files to a folder for my torrent client to pick up.

So I wrote torss. It's quite simple, but it does what I need it to do. The user defines some rules, decides which "getter" to use (each RSS feed has its own getter) and runs torss with those settings (likely from cron).

Help:

$ torss -h
Usage: /usr/bin/torss -g getter [OPTIONS]...
torss is parser of RSS feeds which downloads files referenced in the RSS if the
title of the entry matches given rules.
    -g, --getter        getter script to use
    -r, --rules        rules file to use
    -d, --destination    destination path to save torrents to
    -i, --history        history file to use
    -h, --help        help

The rules file must contain an array named rules containing at least one entry.
These entries should be regular expressions (for grep -Ei) for torrent titles
to be downloaded. See /etc/torss/rules.sample

The getter script will be looked for in ~/.config/torss/getters/, then
/etc/torss/getters/ and finally as a file referenced from the CWD. This means
you can pass either simply the filename or the absolute/relative path.

The destination path will usually be a folder where your torrent client
automatically picks up torrent files.

The history file is used to ensure the same torrent isn't downloaded multiple
times, as such it should, for normal use, be left as the default value.

Example Use:
~/.config/torss/rules:

rules[0]="foobar S01E[0-9]{2}(.+)?720(.+)?x264"

Those rules match what's in a demo getter script that's included in torss.

$ torss -g demo
Downloading 'Foobar S01E02 720p x264-Pirate' to /home/sid
Downloading 'Foobar S01E01 720p x264-Pirate' to /home/sid

There is also a history file to avoid downloading the same torrents a second time.

I've created the following PKGBUILD, but not yet put it in the AUR as I'd like some feedback first.
PKGBUILD:

# Maintainer: Sid Karunaratne <sakaru at gmail dot com>

pkgname=torss
pkgver=0.2.3
pkgrel=1
pkgdesc="scrapes RSS feeds to find torrents that match user defined rules, then downloads them"
license=('LGPL2')
arch=('any')
depends=('xmlstarlet')
source=(${pkgname}-${pkgver}.tar.gz::https://github.com/sakaru/${pkgname}/tarball/${pkgver})
md5sums=('992f825a649b83e592c31c43eb256c53')
backup=('etc/torss/getters/hd-torrents.org' 'etc/torss/getters/thebox.bz' 'etc/torss/getters/thepiratebay.org')
install=install

build() {
    # We need to rename githubs folder as its name isn't easy to predict
    cd $srcdir
    folder=$(tar -tf ${pkgname}-${pkgver}.tar.gz | head -n1)
    mv $folder ${pkgname}-${pkgver}
}

package() {
    install -Dm755 ${srcdir}/${pkgname}-${pkgver}/torss $pkgdir/usr/bin/torss
    install -Dm644 ${srcdir}/${pkgname}-${pkgver}/rules.sample $pkgdir/etc/torss/rules.sample
    install -Dm644 ${srcdir}/${pkgname}-${pkgver}/getters/demo $pkgdir/etc/torss/getters/demo
    install -Dm644 ${srcdir}/${pkgname}-${pkgver}/getters/thepiratebay.org $pkgdir/etc/torss/getters/thepiratebay.org
    install -Dm644 ${srcdir}/${pkgname}-${pkgver}/getters/hd-torrents.org $pkgdir/etc/torss/getters/hd-torrents.org
    install -Dm644 ${srcdir}/${pkgname}-${pkgver}/getters/thebox.bz $pkgdir/etc/torss/getters/thebox.bz
}

install:

post_install() {
  cat <<EOF
==> Various getter scripts have been installed to /etc/torss/getters.
==> If you intend to use the getters for private trackers you will need
==> to edit the appropriate scripts to use your credentials. Copy them to
==> ~/.config/torss/getters if you wish them to be private.
EOF
}

Since it's on github I know I could use git to clone the repo for the latest code, but I prefer using tags to state releases. This way things like aurcheck/yaourt/packer/etc know there has been an update.

Some private trackers (the ones I made for myself) are already included, though you'll need to edit them, setting the cookiejar values to those of your own cookies.

I would greatly appreciate feedback, this is the first non-trivial bash script I've written.

Offline

Board footer

Powered by FluxBB