Last change
on this file since 296 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
|
Line | |
---|
1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # Crude attempt to keep torrent in sync from FreeBSD RSS 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 |
|
---|
11 | TORRENTQUEUE=/data/transmission/upload
|
---|
12 | TORRENTRSS=${1-http://torrents.freebsd.org:8080/rss.xml}
|
---|
13 |
|
---|
14 | # Cleanup bits
|
---|
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
|
---|
19 |
|
---|
20 |
|
---|
21 | # Check for new ones
|
---|
22 | fetch -qo - $TORRENTRSS > $RSSFILE
|
---|
23 | if [ \! -s "$RSSFILE" ]; then
|
---|
24 | echo "Failed to download RSS feed $TORRENTRSS"
|
---|
25 | exit 1
|
---|
26 | fi
|
---|
27 |
|
---|
28 | # Split based on item
|
---|
29 | awk -vTMPDIR=$TMPDIR '/<item>/{n++}{print > sprintf("%s/item.txt.%03i", TMPDIR ,n) }' $RSSFILE
|
---|
30 |
|
---|
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.