|
|
|
@ -35,7 +35,11 @@ tpb = "https://thepiratebay.se"
|
|
|
|
|
|
|
|
|
|
# Torrent server IP; can be any machine running transmission-daemon
|
|
|
|
|
# with a firewall inbound allowed to TCP/9091 (transmissionrpc)
|
|
|
|
|
rpcserver = 'localhost'
|
|
|
|
|
rpcserver = ''
|
|
|
|
|
|
|
|
|
|
if not rpcserver:
|
|
|
|
|
print "[!] Transmission server not set! Update the 'rpcserver' variable in the script"
|
|
|
|
|
exit(10)
|
|
|
|
|
|
|
|
|
|
# Squelch HTTPS insecure warnings
|
|
|
|
|
requests.packages.urllib3.disable_warnings()
|
|
|
|
@ -49,7 +53,7 @@ parser.add_argument('--search', '-s', dest='arg_search_string', help='The string
|
|
|
|
|
|
|
|
|
|
parser.add_argument('--top', '-t', dest='arg_take_top', action='store_true', help='Automatically grab the torrent with most seeds', required=False)
|
|
|
|
|
|
|
|
|
|
parser.add_argument('--file', '-l', dest='arg_magnet_link', help='Direct link to magnet link or torrent file', required=False)
|
|
|
|
|
parser.add_argument('--magnet', '-m', dest='arg_magnet_link', help='Direct link to magnet link or torrent file', required=False)
|
|
|
|
|
|
|
|
|
|
parser.add_argument('--url', '-u', dest='arg_torrent_page', help='URL of the torrent file', required=False)
|
|
|
|
|
|
|
|
|
@ -97,7 +101,6 @@ def Get_Search_URL():
|
|
|
|
|
tpb_search_string = raw_input("[+] What would you like to search?\n>>> ")
|
|
|
|
|
|
|
|
|
|
tpb_search_url = "{}/search/{}/0/7/0".format(tpb, tpb_search_string) #/0/7/0 tells TPB to sort descending by seeds
|
|
|
|
|
|
|
|
|
|
tpb_torrent_page_source = requests.get(tpb_search_url, verify=False).text #Use requests lib to fetch page source for bs4 parsing
|
|
|
|
|
|
|
|
|
|
Get_Torrent_Links(tpb_torrent_page_source) #Run Get_Torrent_Links function, passing page source for BS4 parsing
|
|
|
|
@ -118,7 +121,6 @@ def Get_Torrent_Links(source):
|
|
|
|
|
if link.get('href').startswith('/torrent'): #Only get links with /torrent as they're valid torrent pages
|
|
|
|
|
tpb_torrent_links.append(link.get('href')) #Set the results to tpb_torrent_links array
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#If -t is supplied, bypass this section of code and go on to download the top torrent
|
|
|
|
|
if args.arg_take_top and tpb_torrent_links:
|
|
|
|
|
Download_Torrent_From_URL("{}/{}".format(tpb, tpb_torrent_links[0]))
|
|
|
|
@ -127,7 +129,6 @@ def Get_Torrent_Links(source):
|
|
|
|
|
for number,link in enumerate(tpb_torrent_links): #Enumerate the array so the numbers start at 0
|
|
|
|
|
tpb_search_results.update({number:link}) #Append results to tpb_search_results dictionary
|
|
|
|
|
print "({}) {}".format(number, path.basename(link))
|
|
|
|
|
|
|
|
|
|
if tpb_search_results: #If dict is not empty, continue with script
|
|
|
|
|
print "\n(98) Search again"
|
|
|
|
|
print "(99) Exit"
|
|
|
|
@ -178,24 +179,18 @@ def Download_Torrent_From_URL(tpb_torrent_url):
|
|
|
|
|
"""
|
|
|
|
|
Grabs the first magnet link and adds it to the queue via RPC to rpcserver
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
tpb_magnet_links = []
|
|
|
|
|
|
|
|
|
|
tpb_torrent_page = requests.get(tpb_torrent_url, verify=False)
|
|
|
|
|
tpb_torrent_page_soup = bs4.BeautifulSoup(tpb_torrent_page.content, "html.parser")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for link in tpb_torrent_page_soup.find_all('a'):
|
|
|
|
|
if str(link.get('href')).startswith('magnet:?xt'):
|
|
|
|
|
tpb_magnet_links.append(link.get('href'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tpb_magnet_link = tpb_magnet_links[0]
|
|
|
|
|
|
|
|
|
|
print "\n[+] Adding magnet link for torrent:\n\n{}".format(tpb_torrent_url)
|
|
|
|
|
|
|
|
|
|
transmissionrpc.Client(rpcserver).add_torrent(tpb_magnet_link)
|
|
|
|
|
|
|
|
|
|
print "\n[.] Done!\n"
|
|
|
|
|
|
|
|
|
|
exit(0)
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|