Last change
on this file since 299 was 285, checked in by Rick van der Zwet, 14 years ago |
New idea, based on XML and persistent upload stores.
|
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Id
|
File size:
1.1 KB
|
Rev | Line | |
---|
[201] | 1 | #!/bin/sh
|
---|
| 2 | #
|
---|
| 3 | # Crude attempt to keep torrent in sync from FreeBSD RSS feed
|
---|
[285] | 4 | # eq autofeed them into transmission
|
---|
| 5 | #
|
---|
| 6 | # Lesson learned: Shell is NOT useable for XML parsing
|
---|
[201] | 7 | #
|
---|
[285] | 8 | # Licence: BSDLike
|
---|
[201] | 9 | # Rick van der Zwet <info@rickvanderzwet.nl>
|
---|
| 10 |
|
---|
| 11 | TORRENTQUEUE=/data/transmission/upload
|
---|
[285] | 12 | TORRENTRSS=${1-http://torrents.freebsd.org:8080/rss.xml}
|
---|
[201] | 13 |
|
---|
| 14 | # Cleanup bits
|
---|
[285] | 15 | TMPDIR=`mktemp -d /tmp/$(basename $0).XXXXX`
|
---|
| 16 | RSSFILE=$TMPDIR/output.rss
|
---|
| 17 | trap "rm -Rf $TMPDIR; exit 1" 1 2 3 15
|
---|
| 18 | trap "rm -Rf $TMPDIR; exit 0" 0
|
---|
[201] | 19 |
|
---|
| 20 |
|
---|
| 21 | # Check for new ones
|
---|
[285] | 22 | fetch -qo - $TORRENTRSS > $RSSFILE
|
---|
| 23 | if [ \! -s "$RSSFILE" ]; then
|
---|
| 24 | echo "Failed to download RSS feed $TORRENTRSS"
|
---|
[201] | 25 | exit 1
|
---|
| 26 | fi
|
---|
| 27 |
|
---|
[285] | 28 | # Split based on item
|
---|
| 29 | awk -vTMPDIR=$TMPDIR '/<item>/{n++}{print > sprintf("%s/item.txt.%03i", TMPDIR ,n) }' $RSSFILE
|
---|
[201] | 30 |
|
---|
[285] | 31 | # Download the new ones please, if not yet existing
|
---|
| 32 | for ITEM in $TMPDIR/item.txt.???; do
|
---|
| 33 | URI=`awk -F\" '/^<enclosure url=/{print $2}' $ITEM`
|
---|
| 34 | [ -z "$URI" ] && continue
|
---|
| 35 | TITLE=`awk '/^<title>/{print $0}' $ITEM`
|
---|
| 36 | TARGET=$TORRENTQUEUE/`basename $URI`
|
---|
| 37 | if [ \! -r $TARGET ]; then
|
---|
| 38 | echo "# Adding torrent $TARGET ($TITLE)"
|
---|
| 39 | fetch -qo $TARGET $URI
|
---|
| 40 | fi
|
---|
| 41 | done
|
---|
Note:
See
TracBrowser
for help on using the repository browser.