summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorGravatar Alan Fitton <ajf@eth0.org.uk>2011-11-22 14:55:34 +0000
committerGravatar Alan Fitton <ajf@eth0.org.uk>2011-11-22 14:55:34 +0000
commitceed760d73e4ec82c8bd6f9a99a93ce184968b23 (patch)
treee3d398a2d27f1b41f57d41ee54925e6512d7062b /extra
parent57cb76cd8486a7cd4ca7de039dd874c6fe32ce94 (diff)
issue 66 - make paths under the default download dir appear as relative. add a example action script for downloading to local.
Diffstat (limited to 'extra')
-rw-r--r--extra/tpull.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/extra/tpull.sh b/extra/tpull.sh
new file mode 100644
index 0000000..eaa2909
--- /dev/null
+++ b/extra/tpull.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+
+# This is a really simple script intended to be run as an action
+# from transmission-remote-gtk. It uses rsync to fetch
+# a torrent/torrents to a local directory (or put it somewhere
+# remote and run it using ssh to there).
+
+# It also shows how we can call transmission-remote with
+# connection details to find information about a torrent or
+# manipulate it.
+
+# Example
+# gnome-terminal -e "tpull.sh %{hostname} %{port} %{username}:%{password} %{id}[,] /srv/incoming/"
+
+if [ -z "$5" ]; then
+ echo "usage: <host> <port> <user:pass> <id> <dest>"
+ exit 1
+fi
+
+HOST=$1
+TPORT=$2
+TAUTH=$3
+IDS=$4
+DEST=$5
+
+echo $IDS | sed "s/,/\n/g" | while read id; do
+ DETAILS=$(transmission-remote $HOST:$TPORT -n $TAUTH -t $id -i)
+
+ if [ $? -ne 0 ]; then
+ read
+ exit 1
+ fi
+
+ LOCATION=$(echo "$DETAILS" | egrep '^\s+Location:' | cut -c 13-)
+ NAME=$(echo "$DETAILS" | egrep '^\s+Name:' | cut -c 9-)
+
+ if [ -z "$LOCATION" -o -z "$NAME" ]; then
+ continue
+ fi
+
+ FULLPATH="$LOCATION/$NAME"
+
+ echo "Syncing $FULLPATH ..."
+ rsync -avPs "$HOST:$FULLPATH" "$DEST"
+done