diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html
index bf99dafd..aad752a5 100644
--- a/data/interfaces/default/config.html
+++ b/data/interfaces/default/config.html
@@ -336,9 +336,14 @@
Convert
+
+
+
+ Embed
+
- Note: opening magnet URL's is not suitable for headless/console/terminal servers.
+ Note: Opening magnet URLs is not suitable for headless/console/terminal servers. Embed only works for rTorrent.
diff --git a/data/interfaces/default/css/style.css b/data/interfaces/default/css/style.css
index a6723818..ef8047c7 100644
--- a/data/interfaces/default/css/style.css
+++ b/data/interfaces/default/css/style.css
@@ -334,7 +334,7 @@ form .row label {
font-size: 12px;
line-height: normal;
padding-top: 7px;
- width: 175px;
+ width: 170px;
}
form .row label.inline {
margin-right: 5px;
@@ -368,7 +368,7 @@ form .row small {
display: block;
font-size: 9px;
line-height: 12px;
- margin-left: 175px;
+ margin-left: 170px;
margin-top: 3px;
}
form .left label {
diff --git a/data/interfaces/default/css/style.less b/data/interfaces/default/css/style.less
index b03057c2..3e0f9659 100644
--- a/data/interfaces/default/css/style.less
+++ b/data/interfaces/default/css/style.less
@@ -190,7 +190,7 @@ form {
font-size: 12px;
line-height: normal;
padding-top: 7px;
- width: 175px;
+ width: 170px;
&.inline {
margin-right: 5px;
@@ -216,7 +216,7 @@ form {
display: block;
font-size: 9px;
line-height: 12px;
- margin-left: 175px;
+ margin-left: 170px;
margin-top: 3px;
}
}
diff --git a/headphones/config.py b/headphones/config.py
index e2a122e2..7db9509b 100644
--- a/headphones/config.py
+++ b/headphones/config.py
@@ -160,7 +160,7 @@ _CONFIG_DEFINITIONS = {
'OMGWTFNZBS': (int, 'omgwtfnzbs', 0),
'OMGWTFNZBS_APIKEY': (str, 'omgwtfnzbs', ''),
'OMGWTFNZBS_UID': (str, 'omgwtfnzbs', ''),
- 'OPEN_MAGNET_LINKS': (int, 'General', 0), # 0: Ignore, 1: Open, 2: Convert
+ 'OPEN_MAGNET_LINKS': (int, 'General', 0), # 0: Ignore, 1: Open, 2: Convert, 3: Embed (rtorrent)
'MAGNET_LINKS': (int, 'General', 0),
'OSX_NOTIFY_APP': (str, 'OSX_Notify', '/Applications/Headphones'),
'OSX_NOTIFY_ENABLED': (int, 'OSX_Notify', 0),
diff --git a/headphones/searcher.py b/headphones/searcher.py
index 7dbcf5ba..6f9ea87a 100644
--- a/headphones/searcher.py
+++ b/headphones/searcher.py
@@ -165,7 +165,7 @@ def get_seed_ratio(provider):
elif provider == 'Mininova':
seed_ratio = headphones.CONFIG.MININOVA_RATIO
elif provider == 'Strike':
- seed_ratio = headphones.CONFIG.STRIKE_RATIO
+ seed_ratio = headphones.CONFIG.STRIKE_RATIO
else:
seed_ratio = None
@@ -711,7 +711,7 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None, choose_spe
def send_to_downloader(data, bestqual, album):
- logger.info(u'Found best result from %s: %s - %s', bestqual[3], bestqual[2], bestqual[0], helpers.bytes_to_mb(bestqual[1]))
+ logger.info(u'Found best result from %s: [%s] - %s - %s', bestqual[3], bestqual[2], bestqual[0], helpers.bytes_to_mb(bestqual[1]))
# Get rid of any dodgy chars here so we can prevent sab from renaming our downloads
kind = bestqual[4]
seed_ratio = None
@@ -810,8 +810,11 @@ def send_to_downloader(data, bestqual, album):
logger.warning("Unable to convert magnet with hash " \
"'%s' into a torrent file.", torrent_hash)
return
+ elif headphones.CONFIG.MAGNET_LINKS == 3:
+ torrent_to_file(download_path, data)
+ return
else:
- logger.error("Cannot save magnet link in blackhole. " \
+ logger.error("Ignoring magnet links for blackhole. " \
"Please switch your torrent downloader to " \
"Transmission or uTorrent, or allow Headphones " \
"to open or convert magnet links")
@@ -1198,20 +1201,41 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None, choose
seeders = item['seeds']
url = item['torrentLink']
size = int(item['size'])
+ hash = item['hash']
+ # The "tr" querystring used in magnetUri is a hack since it assumes the tracker is always the same for KAT.
+ # It currently works for all torrents tested but it should be changed to load the HTML, and parse out the real magnet URI.
+ magnetUri = r"magnet:?xt=urn:btih:" + hash + r"&tr=udp%3A%2F%2Fopen.demonii.com%3A1337"
if format == "2":
torrent = request.request_content(url, headers=headers)
if not torrent or (int(torrent.find(".mp3")) > 0 and int(torrent.find(".flac")) < 1):
rightformat = False
- if rightformat and size < maxsize and minimumseeders < int(seeders):
- match = True
- logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
- else:
- match = False
- logger.info('%s is larger than the maxsize, the wrong format or has too little seeders for this category, skipping. (Size: %i bytes, Seeders: %d, Format: %s)', title, size, int(seeders), rightformat)
+ #if rightformat and size < maxsize and minimumseeders < int(seeders):
+ # match = True
+ # logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
+ #else:
+ # match = False
+ # logger.info('%s is larger than the maxsize, the wrong format or has too little seeders for this category, skipping. (Size: %i bytes, Seeders: %d, Format: %s)', title, size, int(seeders), rightformat)
- resultlist.append((title, size, url, provider, 'torrent', match))
+ match = False
+ if rightformat:
+ if size < maxsize:
+ if minimumseeders < int(seeders):
+ match = True
+ logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
+ else:
+ logger.info('%s has too little seeders for this category, skipping. (Size: %i bytes, Seeders: %d, Format: %s)', title, size, int(seeders), rightformat)
+ else:
+ logger.info('%s is larger than the maxsize for this category, skipping. (Size: %i bytes, Seeders: %d, Format: %s)', title, size, int(seeders), rightformat)
+ else:
+ logger.info('%s is the wrong format for this category, skipping. (Size: %i bytes, Seeders: %d, Format: %s)', title, size, int(seeders), rightformat)
+
+
+ # The URL returned from KAT is NOT a torrent URL. It is a jump page.
+ # More work needs to be done here to get this to work right for real torrent files. Refer to CouchPotatos HTML parsing method.
+ #resultlist.append((title, size, url, provider, 'torrent', match))
+ resultlist.append((title, size, magnetUri, provider, 'magnet', match))
except Exception as e:
logger.exception("Unhandled exception in the KAT parser")
@@ -1669,7 +1693,6 @@ def preprocess(resultlist):
headers = {}
if result[3] == 'Kick Ass Torrents':
- #headers['Referer'] = 'http://kat.ph/'
headers['User-Agent'] = USER_AGENT
elif result[3] == 'What.cd':
headers['User-Agent'] = 'Headphones'
@@ -1677,6 +1700,10 @@ def preprocess(resultlist):
headers['User-Agent'] = 'Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2243.2 Safari/537.36'
return request.request_content(url=result[2], headers=headers), result
+ if result[4] == 'magnet':
+ magnet_link = result[2]
+ return "d10:magnet-uri%d:%se" % (len(magnet_link), magnet_link), result
+
else:
headers = {'User-Agent': USER_AGENT}
diff --git a/headphones/webserve.py b/headphones/webserve.py
index 121e8667..4966ec5b 100644
--- a/headphones/webserve.py
+++ b/headphones/webserve.py
@@ -1153,6 +1153,7 @@ class WebInterface(object):
"magnet_links_0": radio(headphones.CONFIG.MAGNET_LINKS, 0),
"magnet_links_1": radio(headphones.CONFIG.MAGNET_LINKS, 1),
"magnet_links_2": radio(headphones.CONFIG.MAGNET_LINKS, 2),
+ "magnet_links_3": radio(headphones.CONFIG.MAGNET_LINKS, 3),
"log_dir": headphones.CONFIG.LOG_DIR,
"cache_dir": headphones.CONFIG.CACHE_DIR,
"interface_list": interface_list,