The script is written for the TorrentBytes tracker but you should be able to modify the code to work on other sites too. Anyway here it is
#!/usr/bin/python
#######################################
# RSS Downloader for torrenbytes
# Programmed by Severed Spirit
#######################################
import os
import sys
from commands import getoutput
###Get Arguments
option = ""
if len(sys.argv) > 1:
if sys.argv[1] == "-c":
option = "check"
else:
option = "default"
###User Required Variables
cookie_file = "/home/alan/rss_downloaders/.lynx_cookies"
search_filter = "Saturday.Night.Live.*720p|" + \
"Aqua.Teen.Hunger.Force.|" + \
"30.Rock.*720p|" + \
"The.Office.*720p|" + \
"South.Park.*720p|" + \
"The.Big.Bang.Theory.*720p|" + \
"Rab_C_Nesbitt.*720p|" + \
"Family.Guy"
watch_folder = "/torrent/watch/"
prev_down_loc = "/home/alan/rss_downloaders/torrentbytes_downloaded"
tb_passkey = "###################"
tb_username = "###################"
###Initialise Variables
listoftorrents = ""
previously_downloaded = getoutput('cat ' + prev_down_loc)
rss_feed = getoutput('curl "http://www.torrentbytes.net/rss.php?passkey=' + tb_passkey + \
'&username=' + tb_username + '&direct" | grep guid').replace("&","&").split("")
for torrent in rss_feed[1:]:
torrent = torrent.split("")[0].split("\r")
#fix issue with curl data
if len(torrent) > 1:
torrent = torrent[0] + torrent[1].split("\n")[len(torrent) -1]
else:
torrent = torrent[0]
if option == "check":
print torrent
episodes = search_filter.split("|")
for episode in episodes:
items = episode.split("*")
found = "true"
for filter in items:
if filter not in torrent:
found = "false"
# Display torrent if all items are matched
if found == "true":
listoftorrents = listoftorrents + "|" + torrent
for link in listoftorrents[1:].split("|"):
if len(link) > 0:
torrent_name = link.split("&name=")[1]
if option == "default":
if torrent_name not in previously_downloaded:
os.system('wget -q --referer=http://www.torrentbytes.net/login.php --cookies=on --load-cookies="' + cookie_file + '" ' + \
'--keep-session-cookies --save-cookies="' + cookie_file + '" "' + link + '" -O ' + watch_folder + torrent_name)
os.system('echo "' + torrent_name + '" >> "' + prev_down_loc + '"')
print "Downloaded: " + torrent_name
else:
print "Already Downloaded: " + torrent_name
else:
print "No Torrents Found in Query"
All you have to do is modify the "###User Required Variables" section along with the cookie file and you should be set. I'd love to here what sites you've gotten this to work on plus if you can see where my code might have tried to join the failbus then please leave comments :)
0 comments:
Post a Comment