mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-15 16:19:28 +01:00
Added Pirate Bay support
This commit is contained in:
@@ -336,6 +336,9 @@
|
||||
<td>
|
||||
<fieldset>
|
||||
<legend>Torrents</legend>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="use_piratebay" value="1" ${config['use_piratebay']} /><label>Pirate Bay</label>
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="use_isohunt" value="1" ${config['use_isohunt']} /><label>Isohunt</label>
|
||||
</div>
|
||||
@@ -343,7 +346,8 @@
|
||||
<input type="checkbox" name="use_mininova" value="1" ${config['use_mininova']} /><label>Mininova</label>
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input type="checkbox" name="use_kat" value="1" ${config['use_kat']} /><label>Kick Ass Torrents</label></div>
|
||||
<input type="checkbox" name="use_kat" value="1" ${config['use_kat']} /><label>Kick Ass Torrents</label>
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input id="usewaffles" type="checkbox" name="waffles" onclick="initConfigCheckbox($(this));" value="1" ${config['use_waffles']} /><label>Waffles.fm</label>
|
||||
</div>
|
||||
|
||||
@@ -178,6 +178,7 @@ NUMBEROFSEEDERS = 10
|
||||
ISOHUNT = None
|
||||
KAT = None
|
||||
MININOVA = None
|
||||
PIRATEBAY = None
|
||||
WAFFLES = None
|
||||
WAFFLES_UID = None
|
||||
WAFFLES_PASSKEY = None
|
||||
@@ -291,7 +292,7 @@ def initialize():
|
||||
LOSSLESS_DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, \
|
||||
RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, KEEP_TORRENT_FILES, \
|
||||
ADD_ALBUM_ART, ALBUM_ART_FORMAT, EMBED_ALBUM_ART, EMBED_LYRICS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \
|
||||
TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, ISOHUNT, KAT, MININOVA, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, \
|
||||
TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, ISOHUNT, KAT, PIRATEBAY, MININOVA, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, \
|
||||
RUTRACKER, RUTRACKER_USER, RUTRACKER_PASSWORD, WHATCD, WHATCD_USERNAME, WHATCD_PASSWORD, DOWNLOAD_TORRENT_DIR, \
|
||||
LIBRARYSCAN, LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \
|
||||
NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, TRANSMISSION_HOST, TRANSMISSION_USERNAME, TRANSMISSION_PASSWORD, \
|
||||
@@ -399,6 +400,7 @@ def initialize():
|
||||
NUMBEROFSEEDERS = check_setting_str(CFG, 'General', 'numberofseeders', '10')
|
||||
ISOHUNT = bool(check_setting_int(CFG, 'General', 'isohunt', 0))
|
||||
KAT = bool(check_setting_int(CFG, 'General', 'kat', 0))
|
||||
PIRATEBAY = bool(check_setting_int(CFG, 'General', 'piratebay', 0))
|
||||
MININOVA = bool(check_setting_int(CFG, 'General', 'mininova', 0))
|
||||
DOWNLOAD_TORRENT_DIR = check_setting_str(CFG, 'General', 'download_torrent_dir', '')
|
||||
|
||||
@@ -739,6 +741,7 @@ def config_write():
|
||||
new_config['General']['isohunt'] = int(ISOHUNT)
|
||||
new_config['General']['kat'] = int(KAT)
|
||||
new_config['General']['mininova'] = int(MININOVA)
|
||||
new_config['General']['piratebay'] = int(PIRATEBAY)
|
||||
new_config['General']['download_torrent_dir'] = DOWNLOAD_TORRENT_DIR
|
||||
|
||||
new_config['Waffles'] = {}
|
||||
|
||||
@@ -142,6 +142,23 @@ def mb_to_bytes(mb_str):
|
||||
result = re.search('^(\d+(?:\.\d+)?)\s?(?:mb)?', mb_str, flags=re.I)
|
||||
if result:
|
||||
return int(float(result.group(1))*1048576)
|
||||
|
||||
def piratesize(size):
|
||||
split = size.split(" ")
|
||||
factor = float(split[0])
|
||||
unit = split[1]
|
||||
if unit == 'MiB':
|
||||
size = factor * 1048576
|
||||
elif unit == 'GiB':
|
||||
size = factor * 1073741824
|
||||
elif unit == 'KiB':
|
||||
size = factor * 1024
|
||||
elif unit == "B":
|
||||
size = factor
|
||||
else:
|
||||
size = 0
|
||||
|
||||
return size
|
||||
|
||||
def replace_all(text, dic):
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
import urllib, urllib2, urlparse, httplib
|
||||
import lib.feedparser as feedparser
|
||||
from bs4 import BeautifulSoup
|
||||
from lib.pygazelle import api as gazelleapi
|
||||
from lib.pygazelle import encoding as gazelleencoding
|
||||
from lib.pygazelle import format as gazelleformat
|
||||
@@ -117,7 +118,7 @@ def searchforalbum(albumid=None, new=False, lossless=False):
|
||||
else:
|
||||
foundNZB = searchNZB(result['AlbumID'], new)
|
||||
|
||||
if (headphones.KAT or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES or headphones.RUTRACKER or headphones.WHATCD) and foundNZB == "none":
|
||||
if (headphones.KAT or headphones.PIRATEBAY or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES or headphones.RUTRACKER or headphones.WHATCD) and foundNZB == "none":
|
||||
|
||||
if result['Status'] == "Wanted Lossless":
|
||||
searchTorrent(result['AlbumID'], new, losslessOnly=True)
|
||||
@@ -127,10 +128,10 @@ def searchforalbum(albumid=None, new=False, lossless=False):
|
||||
else:
|
||||
|
||||
foundNZB = "none"
|
||||
if (headphones.NZBMATRIX or headphones.NEWZNAB or headphones.NZBSORG or headphones.NEWZBIN or headphones.NZBX or headphones.NZBSRUS) and (headphones.SAB_HOST or headphones.BLACKHOLE_DIR or headphones.NZBGET_HOST):
|
||||
if (headphones.NEWZNAB or headphones.NZBSORG or headphones.NZBX or headphones.NZBSRUS) and (headphones.SAB_HOST or headphones.BLACKHOLE_DIR or headphones.NZBGET_HOST):
|
||||
foundNZB = searchNZB(albumid, new, lossless)
|
||||
|
||||
if (headphones.KAT or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES or headphones.RUTRACKER or headphones.WHATCD) and foundNZB == "none":
|
||||
if (headphones.KAT or headphones.PIRATEBAY or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES or headphones.RUTRACKER or headphones.WHATCD) and foundNZB == "none":
|
||||
searchTorrent(albumid, new, lossless)
|
||||
|
||||
def searchNZB(albumid=None, new=False, losslessOnly=False):
|
||||
@@ -1045,6 +1046,58 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False):
|
||||
gazelle.generate_torrent_link(torrent.id),
|
||||
provider))
|
||||
|
||||
# Pirate Bay
|
||||
if headphones.PIRATEBAY and headphones.TORRENT_DOWNLOADER != 0:
|
||||
provider = "The Pirate Bay"
|
||||
providerurl = url_fix("http://thepiratebay.sx/search/" + term + "/0/99/")
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
category = '104' #flac
|
||||
maxsize = 10000000000
|
||||
elif headphones.PREFERRED_QUALITY:
|
||||
category = '100' #audio cat
|
||||
maxsize = 10000000000
|
||||
else:
|
||||
category = '101' #mp3
|
||||
maxsize = 300000000
|
||||
|
||||
searchURL = providerurl + category
|
||||
|
||||
try:
|
||||
data = urllib2.urlopen(searchURL, timeout=20).read()
|
||||
except urllib2.URLError, e:
|
||||
logger.warn('Error fetching data from The Pirate Bay: %s' % e)
|
||||
data = False
|
||||
|
||||
if data:
|
||||
|
||||
logger.info(u'Parsing results from <a href="%s">The Pirate Bay</a>' % searchURL)
|
||||
|
||||
soup = BeautifulSoup(data)
|
||||
table = soup.find('table')
|
||||
rows = table.findAll('tr')
|
||||
|
||||
if len(rows) == '1':
|
||||
logger.info(u"No results found from %s for %s" % (provider, term))
|
||||
pass
|
||||
|
||||
else:
|
||||
for item in rows[1:]:
|
||||
try:
|
||||
rightformat = True
|
||||
title = ''.join(item.find("a", {"class" : "detLink"}))
|
||||
seeds = int(''.join(item.find("td", {"align" : "right"})))
|
||||
url = item.findAll("a")[3]['href']
|
||||
formatted_size = re.search('Size (.*),', unicode(item)).group(1).replace(u'\xa0', ' ')
|
||||
size = helpers.piratesize(formatted_size)
|
||||
if size < maxsize and minimumseeders < seeds:
|
||||
resultlist.append((title, size, url, provider))
|
||||
logger.info('Found %s. Size: %s' % (title, formatted_size))
|
||||
else:
|
||||
logger.info('%s is larger than the maxsize or has too little seeders for this category, skipping. (Size: %i bytes, Seeders: %i)' % (title, size, int(seeds)))
|
||||
|
||||
except Exception, e:
|
||||
logger.error(u"An unknown error occurred in the Pirate Bay parser: %s" % e)
|
||||
|
||||
if headphones.ISOHUNT:
|
||||
provider = "isoHunt"
|
||||
providerurl = url_fix("http://isohunt.com/js/rss/" + term)
|
||||
@@ -1295,6 +1348,8 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False):
|
||||
|
||||
(data, bestqual) = preprocesstorrent(torrentlist, pre_sorted_results)
|
||||
|
||||
logger.info(u"Made it out")
|
||||
|
||||
if data and bestqual:
|
||||
logger.info(u'Found best result from %s: <a href="%s">%s</a> - %s' % (bestqual[3], bestqual[2], bestqual[0], helpers.bytes_to_mb(bestqual[1])))
|
||||
torrent_folder_name = '%s - %s [%s]' % (helpers.latinToAscii(albums[0]).encode('UTF-8').replace('/', '_'), helpers.latinToAscii(albums[1]).encode('UTF-8').replace('/', '_'), year)
|
||||
@@ -1345,10 +1400,9 @@ def preprocesstorrent(resultlist, pre_sorted_list=False):
|
||||
selresult = result
|
||||
elif int(selresult[1]) < int(result[1]): # if size is lower than new result replace previous selected result (bigger size = better quality?)
|
||||
selresult = result
|
||||
|
||||
# get outta here if rutracker
|
||||
|
||||
if selresult[3] == 'rutracker.org':
|
||||
|
||||
# get outta here if rutracker or piratebay
|
||||
if selresult[3] == 'rutracker.org' or selresult[3] == 'The Pirate Bay':
|
||||
return True, selresult
|
||||
|
||||
if pre_sorted_list:
|
||||
|
||||
@@ -615,6 +615,7 @@ class WebInterface(object):
|
||||
"numberofseeders" : headphones.NUMBEROFSEEDERS,
|
||||
"use_isohunt" : checked(headphones.ISOHUNT),
|
||||
"use_kat" : checked(headphones.KAT),
|
||||
"use_piratebay" : checked(headphones.PIRATEBAY),
|
||||
"use_mininova" : checked(headphones.MININOVA),
|
||||
"use_waffles" : checked(headphones.WAFFLES),
|
||||
"waffles_uid" : headphones.WAFFLES_UID,
|
||||
@@ -718,7 +719,7 @@ class WebInterface(object):
|
||||
utorrent_host=None, utorrent_username=None, utorrent_password=None, nzb_downloader=0, torrent_downloader=0, download_dir=None, blackhole=0, blackhole_dir=None,
|
||||
usenet_retention=None, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0, nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, nzbsrus=0, nzbsrus_uid=None,
|
||||
nzbsrus_apikey=None, nzbx=0, preferred_words=None, required_words=None, ignored_words=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0, torrentblackhole_dir=None, download_torrent_dir=None,
|
||||
numberofseeders=10, use_isohunt=0, use_kat=0, use_mininova=0, waffles=0, waffles_uid=None, waffles_passkey=None, whatcd=0, whatcd_username=None, whatcd_password=None,
|
||||
numberofseeders=10, use_isohunt=0, use_kat=0, use_piratebay=0, use_mininova=0, waffles=0, waffles_uid=None, waffles_passkey=None, whatcd=0, whatcd_username=None, whatcd_password=None,
|
||||
rutracker=0, rutracker_user=None, rutracker_password=None, rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, album_art_format=None, embed_album_art=0, embed_lyrics=0,
|
||||
destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, include_extras=0, single=0, ep=0, compilation=0, soundtrack=0, live=0,
|
||||
remix=0, spokenword=0, audiobook=0, autowant_upcoming=False, autowant_all=False, keep_torrent_files=False, interface=None, log_dir=None, cache_dir=None, music_encoder=0, encoder=None, xldprofile=None,
|
||||
@@ -778,6 +779,7 @@ class WebInterface(object):
|
||||
headphones.DOWNLOAD_TORRENT_DIR = download_torrent_dir
|
||||
headphones.ISOHUNT = use_isohunt
|
||||
headphones.KAT = use_kat
|
||||
headphones.PIRATEBAY = use_piratebay
|
||||
headphones.MININOVA = use_mininova
|
||||
headphones.WAFFLES = waffles
|
||||
headphones.WAFFLES_UID = waffles_uid
|
||||
|
||||
Reference in New Issue
Block a user