Skip to content

Instantly share code, notes, and snippets.

@vor0nwe
Last active July 23, 2022 19:43
Show Gist options
  • Save vor0nwe/e33ace72c850f93bc979 to your computer and use it in GitHub Desktop.
Save vor0nwe/e33ace72c850f93bc979 to your computer and use it in GitHub Desktop.
Send a PushBullet notification when Transmission has finished a download.
#!/bin/bash
curl -u YOUR_ACCESS_TOKEN: \
-X POST https://api.pushbullet.com/v2/pushes \
--header 'Content-Type: application/json' \
--data-binary "{\"type\":\"note\",\"title\":\"Downloaded\",\"body\":\"$TR_TORRENT_NAME: $TR_TIME_LOCALTIME\"}"
#
# Get YOUR_ACCESS_TOKEN from your account page at https://www.pushbullet.com/account
#
# Find transmission's settings.json, and update the following two lines
#
# "script-torrent-done-enabled": true,
# "script-torrent-done-filename": "/path/to/where/you/saved/this/gist/transmission-torrent-done.sh",
#
@ssandras
Copy link

Thank you for this, it works great, however cannot get the torrent name and localtime. In the alert just shows up as below
$TR_TORRENT_NAME
$TR_TIME_LOCALTIME

Thanks,
Sandra

@ravi72munde
Copy link

ravi72munde commented Feb 28, 2015

Hey Sandra,
I had the same problem. Maybe the json was not parsing the file name correctly. I tried storing filename temporarily in another variable. I observed that the filename with spaces was problem somehow. So I replaced spaces with "_" in the filename before "curl -u" statement. I did it like this: TR_TORRENT_NAME="${TR_TORRENT_NAME// /_}". Same thing with the $TR_TORRENT_NAME. Passing it was success and I got the correct notification.

@andycarver101
Copy link

Hi, not working for me.

I have script in ~Documents and have used GUI to set preferences.

I really want this to work.
Please help.

@andycarver101
Copy link

Ran sh in term. Error on Key. All working is Requires password. Key not enough. Added sandras fix also. Cheers to all.

@andycarver101
Copy link

Ok so scratch that. I'm encountering Sandra's issue with and without the super user article. What am I doing wrong? It must be a " or something simple.

@vor0nwe
Copy link
Author

vor0nwe commented Jan 16, 2020

Sorry about that, @ssandras and @andycarver101; I never got a notification about these comments.
Shell $VARIABLE expansion doesn’t work when you use single quotes. I’ve updated the gist to use double quotes instead (which means escaping all the JSON double quotes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment