From edf581de25e3b72d4989a19e0b82522bd52da34c Mon Sep 17 00:00:00 2001 From: Lance Allen Date: Sat, 30 May 2015 13:11:13 -0700 Subject: [PATCH] asd --- pirate.py | 11 ++++++++--- removeFinishedTorrents.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 removeFinishedTorrents.py diff --git a/pirate.py b/pirate.py index 54571e2..c3da9f4 100755 --- a/pirate.py +++ b/pirate.py @@ -30,8 +30,13 @@ import transmissionrpc results = {} links = [] choice = "" + +# Current/working PirateBay URL tpb = "https://thepiratebay.se" +# IP of the machine running transmission. Probably localhost +transmissionServer = '' + # Squelch HTTPS insecure warnings requests.packages.urllib3.disable_warnings() @@ -42,11 +47,11 @@ requests.packages.urllib3.disable_warnings() def checkTransmission(): """ - Checks to see if transmission-daemon is running on localhost + Checks to see if transmission-daemon is running on transmissionServer and and initiates the function to ask user for input """ try: - transmissionrpc.Client('localhost', port=9091) + transmissionrpc.Client(transmissionServer, port=9091) getSearchURL() except KeyboardInterrupt: print "\n\nLater bro." @@ -146,7 +151,7 @@ def downloadTorrent(torrent): print "\n[+] Adding magnet link for torrent:\n\n{}".format(torrent) - transmissionrpc.Client('localhost').add_torrent(magnetLink) + transmissionrpc.Client(transmissionServer).add_torrent(magnetLink) print "\n[.] Done!\n" diff --git a/removeFinishedTorrents.py b/removeFinishedTorrents.py new file mode 100644 index 0000000..a72f6f4 --- /dev/null +++ b/removeFinishedTorrents.py @@ -0,0 +1,38 @@ +#!/usr/bin/env python + +""" +This Python script combs through transmission downloads +and removes torrents at 100% fully downloaded. Great for keeping my +ISP off my back. Also sends a Pushbullet notification to my devices + +Learn more about PushBullet here: +pushbullet.com +""" + +__author__ = 'lance - github.com/lalanza808' + + +import transmissionrpc +import pushbullet +import requests +from time import sleep + +# Get rid of the SSL warnings +requests.packages.urllib3.disable_warnings() + +# Grab Pushbullet API +with open('/home/lance/pb_api.txt', 'rb') as file: + api = file.read().strip() + +################################################## +# Connect to services + +t = transmissionrpc.Client('localhost', port=9091) +pb = pushbullet.Pushbullet(api) + +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)