From da481836a1c29574c443b0ed00a73bd44bf708de Mon Sep 17 00:00:00 2001 From: lalanza808 Date: Mon, 7 Sep 2015 22:53:50 -0700 Subject: [PATCH] removing unused script, adding new one --- getpbtorrents.py | 3 --- pirate-remote.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 3 deletions(-) delete mode 100644 getpbtorrents.py create mode 100644 pirate-remote.py diff --git a/getpbtorrents.py b/getpbtorrents.py deleted file mode 100644 index c0b8dab..0000000 --- a/getpbtorrents.py +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env python - - diff --git a/pirate-remote.py b/pirate-remote.py new file mode 100644 index 0000000..ee455fd --- /dev/null +++ b/pirate-remote.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python + +""" +This Python script auto-adds new torrents from Pushbullet notes if string starts with magnet:? +and combs through transmission downloads and removes torrents when 100% fully downloaded. Great for keeping my +ISP off my back. Sends Pushbullet notes on torrent add/remove + +Run this as a cron job on the same server as transmission + +Learn more about PushBullet here: +pushbullet.com +""" + +__author__ = 'lance - github.com/lalanza808' + + +import transmissionrpc +import pushbullet +import requests +from time import sleep +from os import path,system + +# Put your API key into a text file +pbapi = 'xxxxxxxxxx' + +# Get rid of the SSL warnings +requests.packages.urllib3.disable_warnings() + +################################################## +# Connect to transmission + +t = transmissionrpc.Client('localhost', port=9091) +pb = pushbullet.Pushbullet(api) + +# Remove completed torrents +for torrent in t.get_torrents(): + if torrent.percentDone == 1: + print "[+] Removing torrent:\t{}".format(torrent.name) + pb.push_note("Torrent Complete", torrent.name) + sleep(3) + t.remove_torrent(torrent.id) + +# Add new torrents +pushes = pb.get_pushes() +for push in pushes[1]: + if push['body'].startswith('magnet:?'): + system('/opt/pirate/pirate.py --link {}'.format(str(push['body']))) + pb.delete_push(push['iden']) +