iphone push on new rss torrents bash script

Discussion of Transmission that doesn't fit in the other categories
Post Reply
crimsdings
Posts: 3
Joined: Fri Dec 18, 2009 10:11 am

iphone push on new rss torrents bash script

Post by crimsdings »

consider this a quick and rather dirty solution .. but a working one .. but its more a proof of concept ;-) (read: YES I KNOW ITS NOT CODED VERY WELL, i did this in a few minutes just to get it work, i might however clean the mess up .. but feel free to do it yourself and post it here, i expect linux users to know what they do, i might even look into https://trac.transmissionbt.com/wiki/Scripts later ...)

what you get: pushes u iphone notifications when a new torrent is added (manual, rss .. whatever)

what you need: an iphone (surprise), a http://notifo.com/ account, you have to create a service there and subscribe yourself as a user to this service .. read the faq over there, linux, notifio on your iphone (free)

create a bash script (whatever.sh) and include this code, make it executable

Code: Select all

#this command gets a list (names only) of your current downloads
transmission-remote IP_OF_YOUR_TRANSMISSION_SERVER:PORT -n USERNAME:PASSWORD -l | sed 's/^[ \t]*//' | sed 's/   */\//g' | sed 's/^[ \t]*//;s/[ \t]*$//' |  tr [:blank:] '.' |  awk -F/ '{print }' | head -n -1 | tail -n +2 | cut -d'/' -f 9 > torrentlist_new.txt

#this command checks if there where changes
diff -i -b -B -q torrentlist_new.txt torrentlist_old.txt > /dev/null
#if there where changes
if [ ! $? -eq 0 ]; then
        for i in $(diff -b -w torrentlist_new.txt torrentlist_old.txt | grep '<' | cut -d' ' -f 2); do
                curl -k -u YOURNOTIFIOSERVICENAME:YOURNOTIFIOSERVICEAPIKEY -d "to=YOURNOTIFIOUSERNAME&msg=%22$i%22&title=new+torrent&uri=http%3A%2F%2FYOURTRANSMISSIONIP:PORT%2F" https://api.notifo.com/v1/send_notification;
                mv torrentlist_new.txt torrentlist_old.txt
        done
else
#if there where no changes
mv /torrentlist_new.txt torrentlist_old.txt
fi
execute this command once in the folder where your script is, to get the current list

Code: Select all

transmission-remote IP_OF_YOUR_TRANSMISSION_SERVER:PORT -n USERNAME:PASSWORD -l | sed 's/^[ \t]*//' | sed 's/   */\//g' | sed 's/^[ \t]*//;s/[ \t]*$//' |  tr [:blank:] '.' |  awk -F/ '{print }' | head -n -1 | tail -n +2 | cut -d'/' -f 9 > torrentlist_old.txt
add a cron job (every minute)

Code: Select all

* * * * * sh /where/ever/your/put/it/script.sh  #torrents
hf
Post Reply