source: transmission/torrent-sync.sh@ 376

Last change on this file since 376 was 296, checked in by Rick van der Zwet, 14 years ago

Also compatible with latest version of transmissiionbt which added .added files if added to queue.

  • Property svn:executable set to *
File size: 1.1 KB
RevLine 
[295]1#!/bin/sh
2#
3# Crude attempt to keep torrent in sync from FreeBSD URL feed
4# eq autofeed them into transmission
5#
6# Lesson learned: Shell is NOT useable for XML parsing
7#
8# Licence: BSDLike
9# Rick van der Zwet <info@rickvanderzwet.nl>
10
11TORRENTQUEUE=/data/transmission/upload
12TORRENTURL=${1-http://torrents.freebsd.org:8080}
13
14# Cleanup bits
15TMPDIR=`mktemp -d /tmp/$(basename $0).XXXXX`
16URLFILE=$TMPDIR/output.html
17trap "rm -Rf $TMPDIR; exit 1" 1 2 3 15
18trap "rm -Rf $TMPDIR; exit 0" 0
19
20
21# Check for new ones
22fetch -qo - $TORRENTURL > $URLFILE
23if [ \! -s "$URLFILE" ]; then
24 echo "Failed to download URL feed $TORRENTURL"
25 exit 1
26fi
27
28TORRENTS=`awk -F'"' '/.torrent"/ {print $8}' $URLFILE`
29
30# Download the new ones please, if not yet existing
31for TORRENT in $TORRENTS; do
32 TARGET=$TORRENTQUEUE/`basename $TORRENT`
33 URI=$TORRENTURL$TORRENT
[296]34 if [ -r $TARGET.added ]; then
35 echo "# Torrent $TARGET already exist"
36 elif [ -r $TARGET ]; then
37 echo "# Torrent $TARGET already exist, but not yet added"
38 else
[295]39 echo "# Adding torrent $TARGET ($URI)"
40 fetch -qo $TARGET $URI
41 fi
42done
Note: See TracBrowser for help on using the repository browser.