Page 1 of 2

SCRIPT: Send iOS push notification when torrent is complete

Posted: Wed Jun 04, 2014 5:02 pm
by krautboy
Hello everyone,

i hope this is the appropriate forum/category to post this, if not please move/edit. I just wanted to share
a quick and simple script i did for use with Transmission and Boxcar. What it does is send a push notification
to your iOS device whenever a torrent has finished downloading.

All you need for this is the free Boxcar iOS app, create a account inside the app. Edit the token inside
the script. Set Transmission to call the script after a torrent is done. Thats it.

Code: Select all

#!/bin/sh

#
# Send push notification to iOS device when a torrent is complete.
#
# Requires: Boxcar account, Transmission torrent client and curl.
#
# Get the API token from the boxcar iOS app.
# Change text output below if you wish.
# Set Transmission to start script when torrent is complete.
# Make sure you keep this script as Plain-text, save changes.
# Open Terminal, go to folder of this script and do “chmod +x TransmissionBoxcar.sh”
#
#
#
# http://www.boxcar.io
# http://www.transmissionbt.com
#

#
# Available environment variables from Transmission (as of v2.83) are:
#
# TR_APP_VERSION
# TR_TIME_LOCALTIME
# TR_TORRENT_DIR
# TR_TORRENT_HASH
# TR_TORRENT_ID
# TR_TORRENT_NAME
#

# You need to change this! Get your token from the boxcar iOS app.
token=“XXXXXXXXXXXXXXXX”

# message title for the notification
title="'$TR_TORRENT_NAME' complete"

# the full message text when opened in the boxcar app (can use HTML)
message="<b>$TR_TORRENT_NAME</b> <br><br>is finished downloading. <br><br><br>$TR_TIME_LOCALTIME<br>"

# For a list of possible sounds, check the boxcar website
sound="'bird-1'"

# what shows up as source of the notification
source="Transmission"

# what url curl does connect to, do not change
url="https://new.boxcar.io/api/notifications"


# this now actually connects to boxcar and sends the notification, do not change
curl -k -d "user_credentials=$token" -d "notification[title]=$title" -d "notification[long_message]=$message" -d "notification[sound]=$sound" -d "notification[source_name]=$source" $url

#
#
# EOF
Any comments are welcome. Hope this is useful to some of you.

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Wed Jan 07, 2015 8:58 pm
by Mitchdzj
Hello Krautboy,
Thank you for this script. I would like to give it a shot but Im a total noob and need really precise directions. My first question is if Im suppose to copy and paste the code or download the file? I don't see a download option however I could be missing it. This leads me to my next question which is what I should name the file if Im to copy and paste it into a new txt file. Is it TransmissionBoxcar.sh?
Thx again!

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Sat Jan 31, 2015 6:15 pm
by Mikey_
I modified krautboy's script to work with pushover instead of boxcar.

Code: Select all

#!/bin/sh

#
# Send push notification to pushover device when a torrent is complete.
#
# Requires: Pushover account, Transmission torrent client and curl.
#
# Get the API token from the pushover website.
# Change text output below if you wish.
# Set Transmission to start script when torrent is complete.
# Make sure you keep this script as Plain-text, save changes.
# Open Terminal, go to folder of this script and do “chmod +x TransmissionPushover.sh”
#
#
#
# https://pushover.net/
# http://www.transmissionbt.com
#

#
# Available environment variables from Transmission (as of v2.83) are:
#
# TR_APP_VERSION
# TR_TIME_LOCALTIME
# TR_TORRENT_DIR
# TR_TORRENT_HASH
# TR_TORRENT_ID
# TR_TORRENT_NAME
#

# Insert your own tokens
TOKEN_USER="USER_TOKEN";
TOKEN_APP="APP_TOKEN";

# Message for the notification.
MESSAGE="$TR_TORRENT_NAME finished downloading.

$TR_TIME_LOCALTIME";

PRIORITY=0;
SOUND="tugboat";
TITLE="Download complete";

TIMESTAMP=$(date +%s);

curl -s --form-string "token=$TOKEN_APP" --form-string "user=$TOKEN_USER" --form-string "timestamp=$TIMESTAMP" --form-string "priority=$PRIORITY" --form-string "sound=$SOUND" --form-string "title=$TITLE" --form-string "message=$MESSAGE" https://api.pushover.net/1/messages.json

#
#
# EOF
How to use it
Download the script into /root/ by typing:

Code: Select all

 wget -P /root/ https://dl.dropboxusercontent.com/u/10098610/Transmission/TransmissionPushover.sh
Get the app token and user token from the pushover site, and replace APP_TOKEN and USER_TOKEN with those.

To open TransmissionPushover.sh for editing, type:

Code: Select all

nano /root/TransmissionPushover.sh
After saving the script, we need to give the script permission to run by typing:

Code: Select all

chmod 0755 /root/TransmissionPushover.sh
In /etc/transmission-daemon/settings.json edit

Code: Select all

"script-torrent-done-enabled": true, 
"script-torrent-done-filename": "/root/TransmissionPushover.sh",

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Wed Feb 04, 2015 3:47 pm
by twalsh77
Mikey_ wrote:I modified krautboy's script to work with pushover instead of boxcar.

Code: Select all

#!/bin/sh

#
# Send push notification to pushover device when a torrent is complete.
#
# Requires: Pushover account, Transmission torrent client and curl.
#
# Get the API token from the pushover website.
# Change text output below if you wish.
# Set Transmission to start script when torrent is complete.
# Make sure you keep this script as Plain-text, save changes.
# Open Terminal, go to folder of this script and do “chmod +x TransmissionPushover.sh”
#
#
#
# https://pushover.net/
# http://www.transmissionbt.com
#

#
# Available environment variables from Transmission (as of v2.83) are:
#
# TR_APP_VERSION
# TR_TIME_LOCALTIME
# TR_TORRENT_DIR
# TR_TORRENT_HASH
# TR_TORRENT_ID
# TR_TORRENT_NAME
#

# Insert your own tokens
TOKEN_USER="USER_TOKEN";
TOKEN_APP="APP_TOKEN";

# Message for the notification.
MESSAGE="$TR_TORRENT_NAME finished downloading.

$TR_TIME_LOCALTIME";

PRIORITY=0;
SOUND="tugboat";
TITLE="Download complete";

TIMESTAMP=$(date +%s);

curl -s --form-string "token=$TOKEN_APP" --form-string "user=$TOKEN_USER" --form-string "timestamp=$TIMESTAMP" --form-string "priority=$PRIORITY" --form-string "sound=$SOUND" --form-string "title=$TITLE" --form-string "message=$MESSAGE" https://api.pushover.net/1/messages.json

#
#
# EOF

How to use it
[list][*]Create a file, ex in /root/TransmissionPushover.sh
[*]Paste above text into TransmissionPushover.sh
[*]Get the app token and user token from the pushover site, and replace APP_TOKEN and USER_TOKEN with those.
[*]Open Terminal, go to folder of this script and do “chmod +x TransmissionPushover.sh”
[*]In /etc/transmission-daemon/settings.json edit[/list]
[code]"script-torrent-done-enabled": true, 
"script-torrent-done-filename": "/root/TransmissionBoxcar.sh", 
Can someone give me a how to do this in layman terms.

Thnaks,

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Sat Feb 07, 2015 5:22 pm
by Mikey_
The instructions in my earlier post should hold all the answers. Code tags was a bit off, so instructions was inside the code itself. If it isn't clear enough, please let me know what part you are stuck at, so I can try and improve that step.

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Mon Feb 09, 2015 6:49 pm
by twalsh77
Mikey_ wrote:The instructions in my earlier post should hold all the answers. Code tags was a bit off, so instructions was inside the code itself. If it isn't clear enough, please let me know what part you are stuck at, so I can try and improve that step.
If you could walk me through the whole way that would be awesome, bit of a noob with stuff like this but would love to use this script.

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Mon Feb 09, 2015 8:44 pm
by Mikey_
twalsh77 wrote:
Mikey_ wrote:The instructions in my earlier post should hold all the answers. Code tags was a bit off, so instructions was inside the code itself. If it isn't clear enough, please let me know what part you are stuck at, so I can try and improve that step.
If you could walk me through the whole way that would be awesome, bit of a noob with stuff like this but would love to use this script.
But I already did? What part of it is unclear?

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Mon Feb 09, 2015 8:50 pm
by twalsh77
Mikey_ wrote:
twalsh77 wrote:
Mikey_ wrote:The instructions in my earlier post should hold all the answers. Code tags was a bit off, so instructions was inside the code itself. If it isn't clear enough, please let me know what part you are stuck at, so I can try and improve that step.
If you could walk me through the whole way that would be awesome, bit of a noob with stuff like this but would love to use this script.
But I already did? What part of it is unclear?
Ok so the first step is to create a file called TransmissionPushover.sh right? Do I do this in textedit?

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Thu Feb 12, 2015 5:24 pm
by Mikey_
Updated my earlier post with instructions that should pretty much be copy&paste to get it to work.

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Sun Feb 22, 2015 8:47 pm
by interconnect
Hi, I've been unable to get this script to work with Boxcar. I've saved the file TransmissionBoxcar.sh and have added my Boxcar token as directed. I have saved the file in Documents/Scripts/TransmissionBoxcar.sh. I have set Transmission to call the script and have also made the script executable by doing: “chmod +x TransmissionBoxcar.sh”. When I download a torrent, I never receive a notification. Am I missing something?

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Sun Feb 22, 2015 8:49 pm
by Mikey_
interconnect wrote:Hi, I've been unable to get this script to work with Boxcar. I've saved the file TransmissionBoxcar.sh and have added my Boxcar token as directed. I have saved the file in Documents/Scripts/TransmissionBoxcar.sh. I have set Transmission to call the script and have also made the script executable by doing: “chmod +x TransmissionBoxcar.sh”. When I download a torrent, I never receive a notification. Am I missing something?
Try chmod 0755 on the file instead, could be because the user transmission is running under can't get to it. (also check it can get into the folders)

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Sun Feb 22, 2015 9:19 pm
by interconnect
Tried changing to 0755 no luck. When I run in Terminal I get {"Response":"Not Authorized"}. Should mention I am using Mac OS X. I don't know if it's a good idea to change the permission of the users folders. Is their somewhere else I can put the file?

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Sun Feb 22, 2015 9:21 pm
by Mikey_
interconnect wrote:Tried changing to 0755 no luck. When I run in Terminal I get {"Response":"Not Authorized"}. Should mention I am using Mac OS X. I don't know if it's a good idea to change the permission of the users folders. Is their somewhere else I can put the file?
That looks like the reply from their API saying you are not authorized, have you changed the token in the script?

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Sun Feb 22, 2015 9:22 pm
by interconnect
Mikey_ wrote:
interconnect wrote:Tried changing to 0755 no luck. When I run in Terminal I get {"Response":"Not Authorized"}. Should mention I am using Mac OS X. I don't know if it's a good idea to change the permission of the users folders. Is their somewhere else I can put the file?
That looks like the reply from their API saying you are not authorized, have you changed the token in the script?
Yes, I did. Entered by hand. Let me quadruple check it!

Re: SCRIPT: Send iOS push notification when torrent is compl

Posted: Sun Feb 22, 2015 9:27 pm
by interconnect
Mikey_ wrote:
interconnect wrote:Tried changing to 0755 no luck. When I run in Terminal I get {"Response":"Not Authorized"}. Should mention I am using Mac OS X. I don't know if it's a good idea to change the permission of the users folders. Is their somewhere else I can put the file?
That looks like the reply from their API saying you are not authorized, have you changed the token in the script?
No luck. I even copied it just to be safe.