diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html
index ef0f534c..503b4d47 100644
--- a/data/interfaces/default/config.html
+++ b/data/interfaces/default/config.html
@@ -265,6 +265,19 @@ m<%inherit file="base.html"/>
+
+
+
+
@@ -785,6 +798,7 @@ m<%inherit file="base.html"/>
initConfigCheckbox("#usenewzbin");
initConfigCheckbox("#usenzbsorg");
initConfigCheckbox("#usewaffles");
+ initConfigCheckbox("#usewhatcd");
initConfigCheckbox("#useblackhole");
initConfigCheckbox("#useapi");
}
diff --git a/headphones/__init__.py b/headphones/__init__.py
index a6ab5255..c14253b4 100644
--- a/headphones/__init__.py
+++ b/headphones/__init__.py
@@ -146,6 +146,9 @@ MININOVA = None
WAFFLES = None
WAFFLES_UID = None
WAFFLES_PASSKEY = None
+WHATCD = None
+WHATCD_UID = None
+WHATCD_PASSKEY = None
DOWNLOAD_TORRENT_DIR = None
INTERFACE = None
@@ -238,7 +241,7 @@ def initialize():
CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, MUSIC_DIR, DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, \
ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, \
ADD_ALBUM_ART, 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, DOWNLOAD_TORRENT_DIR, \
+ TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, ISOHUNT, KAT, MININOVA, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, WHATCD, WHATCD_UID, WHATCD_PASSKEY, DOWNLOAD_TORRENT_DIR, \
LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \
NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, \
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
@@ -258,6 +261,7 @@ def initialize():
CheckSection('NZBsorg')
CheckSection('Newzbin')
CheckSection('Waffles')
+ CheckSection('What.cd')
CheckSection('Prowl')
CheckSection('XBMC')
CheckSection('NMA')
@@ -327,6 +331,10 @@ def initialize():
WAFFLES_UID = check_setting_str(CFG, 'Waffles', 'waffles_uid', '')
WAFFLES_PASSKEY = check_setting_str(CFG, 'Waffles', 'waffles_passkey', '')
+ WHATCD = bool(check_setting_int(CFG, 'What.cd', 'whatcd', 0))
+ WHATCD_UID = check_setting_str(CFG, 'What.cd', 'whatcd_uid', '')
+ WHATCD_PASSKEY = check_setting_str(CFG, 'What.cd', 'whatcd_passkey', '')
+
SAB_HOST = check_setting_str(CFG, 'SABnzbd', 'sab_host', '')
SAB_USERNAME = check_setting_str(CFG, 'SABnzbd', 'sab_username', '')
SAB_PASSWORD = check_setting_str(CFG, 'SABnzbd', 'sab_password', '')
@@ -593,6 +601,11 @@ def config_write():
new_config['Waffles']['waffles_uid'] = WAFFLES_UID
new_config['Waffles']['waffles_passkey'] = WAFFLES_PASSKEY
+ new_config['What.cd'] = {}
+ new_config['What.cd']['whatcd'] = int(WHATCD)
+ new_config['What.cd']['whatcd_uid'] = WHATCD_UID
+ new_config['What.cd']['whatcd_passkey'] = WHATCD_PASSKEY
+
new_config['General']['search_interval'] = SEARCH_INTERVAL
new_config['General']['libraryscan_interval'] = LIBRARYSCAN_INTERVAL
new_config['General']['download_scan_interval'] = DOWNLOAD_SCAN_INTERVAL
diff --git a/headphones/searcher.py b/headphones/searcher.py
index 95e14a5e..7c9877fe 100644
--- a/headphones/searcher.py
+++ b/headphones/searcher.py
@@ -97,7 +97,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) and foundNZB == "none":
+ if (headphones.KAT or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES or headphones.WHATCD) and foundNZB == "none":
if result['Status'] == "Wanted Lossless":
searchTorrent(result['AlbumID'], new, losslessOnly=True)
else:
@@ -109,7 +109,7 @@ def searchforalbum(albumid=None, new=False, lossless=False):
if (headphones.NZBMATRIX or headphones.NEWZNAB or headphones.NZBSORG or headphones.NEWZBIN) and (headphones.SAB_HOST or headphones.BLACKHOLE):
foundNZB = searchNZB(albumid, new, lossless)
- if (headphones.KAT or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES) and foundNZB == "none":
+ if (headphones.KAT or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES or headphones.WHATCD) and foundNZB == "none":
searchTorrent(albumid, new, lossless)
def searchNZB(albumid=None, new=False, losslessOnly=False):
@@ -768,6 +768,70 @@ def searchTorrent(albumid=None, new=False, losslessOnly=False):
except Exception, e:
logger.error(u"An error occurred while trying to parse the response from Waffles.fm: %s" % e)
+ if headphones.WHATCD:
+ provider = "What.cd"
+ providerurl = url_fix("https://www.what.cd/browse.php")
+
+ bitrate = None
+ if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
+ format = "FLAC"
+ bitrate = "(Lossless)"
+ maxsize = 10000000000
+ elif headphones.PREFERRED_QUALITY:
+ format = "FLAC OR MP3"
+ maxsize = 10000000000
+ else:
+ format = "MP3"
+ maxsize = 300000000
+
+ query_items = ['artist:"%s"' % artistterm,
+ 'album:"%s"' % albumterm,
+ 'format:(%s)' % format,
+ 'size:[0 TO %d]' % maxsize,
+ '-seeders:0'] # cut out dead torrents
+ if bitrate:
+ query_items.append('bitrate:"%s"' % bitrate)
+
+ params = {
+ "uid": headphones.WHATCD_UID,
+ "passkey": headphones.WHATCD_PASSKEY,
+ "rss": "1",
+ "c0": "1",
+ "s": "seeders", # sort by
+ "d": "desc" # direction
+ }
+
+ searchURL = "%s?%s&q=%s" % (providerurl, urllib.urlencode(params), urllib.quote(" ".join(query_items)))
+
+ try:
+ data = urllib2.urlopen(searchURL, timeout=20).read()
+ except urllib2.URLError, e:
+ logger.warn('Error fetching data from %s: %s' % (provider, e))
+ data = False
+
+ if data:
+
+ d = feedparser.parse(data)
+ if not len(d.entries):
+ logger.info(u"No results found from %s for %s" % (provider, term))
+ pass
+
+ else:
+ for item in d.entries:
+ try:
+ title_match = re.search(r"(.+)\[(.+)\]$", item.title)
+ title = title_match.group(1).strip()
+ details = title_match.group(2).split("-")
+
+ desc_match = re.search(r"Size: (\d+)<", item.description)
+ size = desc_match.group(1)
+
+ url = item.link
+
+ resultlist.append((title, size, url, provider))
+ logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size)))
+ except Exception, e:
+ logger.error(u"An error occurred while trying to parse the response from What.cd: %s" % e)
if headphones.ISOHUNT:
diff --git a/headphones/webserve.py b/headphones/webserve.py
index fc0332e7..9a492024 100644
--- a/headphones/webserve.py
+++ b/headphones/webserve.py
@@ -399,6 +399,9 @@ class WebInterface(object):
"use_waffles" : checked(headphones.WAFFLES),
"waffles_uid" : headphones.WAFFLES_UID,
"waffles_passkey": headphones.WAFFLES_PASSKEY,
+ "use_whatcd" : checked(headphones.WHATCD),
+ "whatcd_uid" : headphones.WHATCD_UID,
+ "whatcd_passkey": headphones.WHATCD_PASSKEY,
"pref_qual_0" : radio(headphones.PREFERRED_QUALITY, 0),
"pref_qual_1" : radio(headphones.PREFERRED_QUALITY, 1),
"pref_qual_3" : radio(headphones.PREFERRED_QUALITY, 3),
@@ -460,7 +463,7 @@ class WebInterface(object):
sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, download_dir=None, blackhole=0, blackhole_dir=None,
usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, newznab=0, newznab_host=None, newznab_apikey=None,
nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None, newzbin_password=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,
+ 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_uid=None, whatcd_passkey=None,
rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, autowant_upcoming=False, autowant_all=False, interface=None, log_dir=None,
music_encoder=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0,
prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=0, xbmc_enabled=0, xbmc_host=None, xbmc_username=None, xbmc_password=None, xbmc_update=0, xbmc_notify=0,
@@ -506,6 +509,9 @@ class WebInterface(object):
headphones.WAFFLES = waffles
headphones.WAFFLES_UID = waffles_uid
headphones.WAFFLES_PASSKEY = waffles_passkey
+ headphones.WHATCD = whatcd
+ headphones.WHATCD_UID = whatcd_uid
+ headphones.WHATCD_PASSKEY = whatcd_passkey
headphones.PREFERRED_QUALITY = int(preferred_quality)
headphones.PREFERRED_BITRATE = preferred_bitrate
headphones.DETECT_BITRATE = detect_bitrate