From 91bfdcd4bd83f3cde6fb001dedc4aed79b0c6b1a Mon Sep 17 00:00:00 2001 From: Ade Date: Sun, 3 Aug 2014 12:04:46 +1200 Subject: [PATCH] Removed Isohunt, nzbsrus + mb fixups --- data/interfaces/default/config.html | 32 ++------ headphones/__init__.py | 21 +---- headphones/mb.py | 61 +++++++------- headphones/searcher.py | 121 +--------------------------- headphones/webserve.py | 12 +-- 5 files changed, 47 insertions(+), 200 deletions(-) diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 5ee7a95b..78dfaef2 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -362,22 +362,6 @@ -
- NZBsRus -
- -
-
-
- - -
-
- - -
-
-
omgwtfnzbs
@@ -390,7 +374,7 @@
- +
@@ -407,10 +391,7 @@ -
- -
-
+
@@ -480,12 +461,14 @@
Preferred Bitrate: kbps
- Reject if less than % or more than % of the target size (leave blank for no limit)

-
+ + Reject if less than % or more than % of the target size (leave blank for no limit)
+
+
-
+
@@ -1751,7 +1734,6 @@ initActions(); initConfigCheckbox("#use_headphones_indexer"); initConfigCheckbox("#usenewznab"); - initConfigCheckbox("#usenzbsrus"); initConfigCheckbox("#usenzbsorg"); initConfigCheckbox("#useomgwtfnzbs"); initConfigCheckbox("#usepiratebay"); diff --git a/headphones/__init__.py b/headphones/__init__.py index 5f77209d..4d361eaf 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -169,10 +169,6 @@ NZBSORG = False NZBSORG_UID = None NZBSORG_HASH = None -NZBSRUS = False -NZBSRUS_UID = None -NZBSRUS_APIKEY = None - OMGWTFNZBS = False OMGWTFNZBS_UID = None OMGWTFNZBS_APIKEY = None @@ -191,7 +187,6 @@ ALBUM_COMPLETION_PCT = None # This is used in importer.py to determine how co TORRENTBLACKHOLE_DIR = None NUMBEROFSEEDERS = 10 -ISOHUNT = None KAT = None MININOVA = None PIRATEBAY = None @@ -349,12 +344,12 @@ def initialize(): LOSSLESS_DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, \ RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, FILE_UNDERSCORES, CLEANUP_FILES, INCLUDE_EXTRAS, EXTRAS, AUTOWANT_UPCOMING, AUTOWANT_ALL, KEEP_TORRENT_FILES, PREFER_TORRENTS, OPEN_MAGNET_LINKS, \ ADD_ALBUM_ART, ALBUM_ART_FORMAT, EMBED_ALBUM_ART, EMBED_LYRICS, REPLACE_EXISTING_FOLDERS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \ - TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, ISOHUNT, KAT, PIRATEBAY, PIRATEBAY_PROXY_URL, MININOVA, WAFFLES, WAFFLES_UID, WAFFLES_PASSKEY, \ + TORRENTBLACKHOLE_DIR, NUMBEROFSEEDERS, KAT, PIRATEBAY, PIRATEBAY_PROXY_URL, 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, UPDATE_DB_INTERVAL, MB_IGNORE_AGE, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, \ NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_HOST, HEADPHONES_INDEXER, NZBMATRIX, TRANSMISSION_HOST, TRANSMISSION_USERNAME, TRANSMISSION_PASSWORD, \ UTORRENT_HOST, UTORRENT_USERNAME, UTORRENT_PASSWORD, UTORRENT_LABEL, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS, \ - NZBSORG, NZBSORG_UID, NZBSORG_HASH, NZBSRUS, NZBSRUS_UID, NZBSRUS_APIKEY, OMGWTFNZBS, OMGWTFNZBS_UID, OMGWTFNZBS_APIKEY, \ + NZBSORG, NZBSORG_UID, NZBSORG_HASH, OMGWTFNZBS, OMGWTFNZBS_UID, OMGWTFNZBS_APIKEY, \ NZB_DOWNLOADER, TORRENT_DOWNLOADER, PREFERRED_WORDS, REQUIRED_WORDS, IGNORED_WORDS, LASTFM_USERNAME, \ INTERFACE, FOLDER_PERMISSIONS, FILE_PERMISSIONS, ENCODERFOLDER, ENCODER_PATH, ENCODER, XLDPROFILE, BITRATE, SAMPLINGFREQUENCY, \ MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRCBR, ENCODERLOSSLESS, ENCODER_MULTICORE, ENCODER_MULTICORE_COUNT, DELETE_LOSSLESS_FILES, \ @@ -380,7 +375,6 @@ def initialize(): CheckSection('Headphones') CheckSection('Newznab') CheckSection('NZBsorg') - CheckSection('NZBsRus') CheckSection('omgwtfnzbs') CheckSection('Waffles') CheckSection('Rutracker') @@ -481,7 +475,6 @@ def initialize(): TORRENTBLACKHOLE_DIR = check_setting_str(CFG, 'General', 'torrentblackhole_dir', '') 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)) PIRATEBAY_PROXY_URL = check_setting_str(CFG, 'General', 'piratebay_proxy_url', '') @@ -535,10 +528,6 @@ def initialize(): NZBSORG_UID = check_setting_str(CFG, 'NZBsorg', 'nzbsorg_uid', '') NZBSORG_HASH = check_setting_str(CFG, 'NZBsorg', 'nzbsorg_hash', '') - NZBSRUS = bool(check_setting_int(CFG, 'NZBsRus', 'nzbsrus', 0)) - NZBSRUS_UID = check_setting_str(CFG, 'NZBsRus', 'nzbsrus_uid', '') - NZBSRUS_APIKEY = check_setting_str(CFG, 'NZBsRus', 'nzbsrus_apikey', '') - OMGWTFNZBS = bool(check_setting_int(CFG, 'omgwtfnzbs', 'omgwtfnzbs', 0)) OMGWTFNZBS_UID = check_setting_str(CFG, 'omgwtfnzbs', 'omgwtfnzbs_uid', '') OMGWTFNZBS_APIKEY = check_setting_str(CFG, 'omgwtfnzbs', 'omgwtfnzbs_apikey', '') @@ -901,7 +890,6 @@ def config_write(): new_config['General']['numberofseeders'] = NUMBEROFSEEDERS new_config['General']['torrentblackhole_dir'] = TORRENTBLACKHOLE_DIR - new_config['General']['isohunt'] = int(ISOHUNT) new_config['General']['kat'] = int(KAT) new_config['General']['mininova'] = int(MININOVA) new_config['General']['piratebay'] = int(PIRATEBAY) @@ -975,11 +963,6 @@ def config_write(): new_config['NZBsorg']['nzbsorg_uid'] = NZBSORG_UID new_config['NZBsorg']['nzbsorg_hash'] = NZBSORG_HASH - new_config['NZBsRus'] = {} - new_config['NZBsRus']['nzbsrus'] = int(NZBSRUS) - new_config['NZBsRus']['nzbsrus_uid'] = NZBSRUS_UID - new_config['NZBsRus']['nzbsrus_apikey'] = NZBSRUS_APIKEY - new_config['omgwtfnzbs'] = {} new_config['omgwtfnzbs']['omgwtfnzbs'] = int(OMGWTFNZBS) new_config['omgwtfnzbs']['omgwtfnzbs_uid'] = OMGWTFNZBS_UID diff --git a/headphones/mb.py b/headphones/mb.py index 80467e5f..850dddb9 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -77,12 +77,14 @@ def findArtist(name, limit=1): artistlist = [] artistResults = None - chars = set('!?*') + chars = set('!?*-') if any((c in chars) for c in name): name = '"'+name+'"' - + + criteria = {'artist': name.lower()} + try: - artistResults = musicbrainzngs.search_artists(query='artist:'+name,limit=limit)['artist-list'] + artistResults = musicbrainzngs.search_artists(limit=limit, **criteria)['artist-list'] except WebServiceError, e: logger.warn('Attempt to query MusicBrainz for %s failed (%s)' % (name, str(e))) time.sleep(5) @@ -124,15 +126,17 @@ def findRelease(name, limit=1, artist=None): with mb_lock: releaselist = [] releaseResults = None - - chars = set('!?') - if any((c in chars) for c in name): - name = '"'+name+'"' # additional artist search if not artist and ':' in name: name, artist = name.rsplit(":",1) + chars = set('!?*-') + if any((c in chars) for c in name): + name = '"'+name+'"' + if artist and any((c in chars) for c in artist): + artist = '"'+artist+'"' + try: releaseResults = musicbrainzngs.search_releases(query=name,limit=limit,artist=artist)['release-list'] except WebServiceError, e: #need to update exceptions @@ -152,22 +156,23 @@ def findRelease(name, limit=1, artist=None): format_dict = OrderedDict() formats = '' tracks = '' - for medium in result['medium-list']: - if 'format' in medium: - format = medium['format'] - if format not in format_dict: - format_dict[format] = 0 - format_dict[format] += 1 - if 'track-count' in medium: - if tracks: - tracks += ' + ' - tracks += str(medium['track-count']) - for format, count in format_dict.items(): - if formats: - formats += ' + ' - if count > 1: - formats += str(count) + 'x' - formats += format + if 'medium-list' in result: + for medium in result['medium-list']: + if 'format' in medium: + format = medium['format'] + if format not in format_dict: + format_dict[format] = 0 + format_dict[format] += 1 + if 'track-count' in medium: + if tracks: + tracks += ' + ' + tracks += str(medium['track-count']) + for format, count in format_dict.items(): + if formats: + formats += ' + ' + if count > 1: + formats += str(count) + 'x' + formats += format releaselist.append({ 'uniquename': unicode(result['artist-credit'][0]['artist']['name']), @@ -603,13 +608,15 @@ def findArtistbyAlbum(name): def findAlbumID(artist=None, album=None): results = None - + try: if album and artist: - term = '"'+album+'" AND artist:"'+artist+'"' + criteria = {'release': album.lower()} + criteria['artist'] = artist.lower() else: - term = album - results = musicbrainzngs.search_release_groups(term,1).get('release-group-list') + criteria = {'release': album.lower()} + + results = musicbrainzngs.search_release_groups(limit=1, **criteria).get('release-group-list') except WebServiceError, e: logger.warn('Attempt to query MusicBrainz for %s - %s failed (%s)' % (artist, album, str(e))) time.sleep(5) diff --git a/headphones/searcher.py b/headphones/searcher.py index 9308d3bb..ee00b075 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -89,9 +89,9 @@ def searchforalbum(albumid=None, new=False, losslessOnly=False, choose_specific_ def do_sorted_search(album, new, losslessOnly, choose_specific_download=False): - NZB_PROVIDERS = (headphones.HEADPHONES_INDEXER or headphones.NEWZNAB or headphones.NZBSORG or headphones.NZBSRUS or headphones.OMGWTFNZBS) + NZB_PROVIDERS = (headphones.HEADPHONES_INDEXER or headphones.NEWZNAB or headphones.NZBSORG or headphones.OMGWTFNZBS) NZB_DOWNLOADERS = (headphones.SAB_HOST or headphones.BLACKHOLE_DIR or headphones.NZBGET_HOST) - TORRENT_PROVIDERS = (headphones.KAT or headphones.PIRATEBAY or headphones.ISOHUNT or headphones.MININOVA or headphones.WAFFLES or headphones.RUTRACKER or headphones.WHATCD) + TORRENT_PROVIDERS = (headphones.KAT or headphones.PIRATEBAY or headphones.MININOVA or headphones.WAFFLES or headphones.RUTRACKER or headphones.WHATCD) results = [] myDB = db.DBConnection() @@ -492,58 +492,6 @@ def searchNZB(album, new=False, losslessOnly=False, albumlength=None): except Exception as e: logger.exception("Unhandled exception while parsing feed") - if headphones.NZBSRUS: - provider = "nzbsrus" - categories = "54" - - if headphones.PREFERRED_QUALITY == 3 or losslessOnly: - sub = "16" - elif headphones.PREFERRED_QUALITY ==1 or allow_lossless: - sub = "" - else: - sub = "15" - - if album['Type'] == 'Other': - sub = "" - logger.info("Album type is audiobook/spokenword. Searching all music categories") - - # Request results - logger.info('Parsing results from NZBsRus') - - headers = { 'User-Agent': USER_AGENT } - params = { - "uid": headphones.NZBSRUS_UID, - "key": headphones.NZBSRUS_APIKEY, - "cat": categories, - "sub": sub, - "age": headphones.USENET_RETENTION, - "searchtext": term - } - - data = request.request_json( - url='https://www.nzbsrus.com/api.php', - params=params, headers=headers, - validator=lambda x: type(x) == dict - ) - - # Parse response - if data: - if data.get('matches', 0) == 0: - logger.info(u"No results found from NZBsRus for %s", term) - pass - else: - for item in data['results']: - try: - url = "http://www.nzbsrus.com/nzbdownload_rss.php/" + item['id'] + "/" + headphones.NZBSRUS_UID + "/" + item['key'] - title = item['name'] - size = int(item['size']) - - resultlist.append((title, size, url, provider, 'nzb')) - logger.info('Found %s. Size: %s', title, helpers.bytes_to_mb(size)) - - except Exception as e: - logger.exception("Unhandled exception") - if headphones.OMGWTFNZBS: provider = "omgwtfnzbs" @@ -1270,71 +1218,6 @@ def searchTorrent(album, new=False, losslessOnly=False, albumlength=None): except Exception as 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) - if headphones.PREFERRED_QUALITY == 3 or losslessOnly: - categories = "7" #music - format = "2" #flac - maxsize = 10000000000 - elif headphones.PREFERRED_QUALITY == 1 or allow_lossless: - categories = "7" #music - format = "10" #mp3+flac - maxsize = 10000000000 - else: - categories = "7" #music - format = "8" #mp3 - maxsize = 300000000 - - # Requesting content - logger.info('Parsing results from ISOHunt') - - headers = { 'User-Agent': USER_AGENT } - params = { - "iht": "2", - "sort": "seeds" - } - - data = request.request_feed( - url=providerurl, - params=params, headers=headers, - auth=(headphones.HPUSER, headphones.HPPASS), - timeout=20 - ) - - # Process feed - if data: - if not len(data.entries): - logger.info(u"No results found from %s for %s", provider, term) - else: - for item in data.entries: - try: - rightformat = True - title = re.sub(r"(?<= \[)(.+)(?=\])","",item.title) - title = title.replace("[]","") - sxstart = item.description.find("Seeds: ") + 7 - seeds = "" - while item.description[sxstart:sxstart + 1] != " ": - seeds = seeds + item.description[sxstart:sxstart + 1] - sxstart = sxstart + 1 - url = item.links[1]['url'] - size = int(item.links[1]['length']) - if format == "2": - torrent = request.request_content(url) - - if not torrent or (int(torrent.find(".mp3")) > 0 and int(torrent.find(".flac")) < 1): - rightformat = False - for findterm in term.split(" "): - if not findterm in title: - rightformat = False - if rightformat == True and size < maxsize and minimumseeders < seeds: - resultlist.append((title, size, url, provider, 'torrent')) - logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size))) - else: - logger.info('%s is larger than the maxsize, the wrong format or has too little seeders for this category, skipping. (Size: %i bytes, Seeders: %i, Format: %s)' % (title, size, int(seeds), rightformat)) - except Exception: - logger.exception("Unhandled exception in isoHunt parser") - if headphones.MININOVA: provider = "Mininova" providerurl = url_fix("http://www.mininova.org/rss/" + term + "/5") diff --git a/headphones/webserve.py b/headphones/webserve.py index d8c74942..9dd20b50 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -997,9 +997,6 @@ class WebInterface(object): "use_nzbsorg" : checked(headphones.NZBSORG), "nzbsorg_uid" : headphones.NZBSORG_UID, "nzbsorg_hash" : headphones.NZBSORG_HASH, - "use_nzbsrus" : checked(headphones.NZBSRUS), - "nzbsrus_uid" : headphones.NZBSRUS_UID, - "nzbsrus_apikey" : headphones.NZBSRUS_APIKEY, "use_omgwtfnzbs" : checked(headphones.OMGWTFNZBS), "omgwtfnzbs_uid" : headphones.OMGWTFNZBS_UID, "omgwtfnzbs_apikey" : headphones.OMGWTFNZBS_APIKEY, @@ -1009,7 +1006,6 @@ class WebInterface(object): "torrentblackhole_dir" : headphones.TORRENTBLACKHOLE_DIR, "download_torrent_dir" : headphones.DOWNLOAD_TORRENT_DIR, "numberofseeders" : headphones.NUMBEROFSEEDERS, - "use_isohunt" : checked(headphones.ISOHUNT), "use_kat" : checked(headphones.KAT), "use_piratebay" : checked(headphones.PIRATEBAY), "piratebay_proxy_url" : headphones.PIRATEBAY_PROXY_URL, @@ -1159,9 +1155,9 @@ class WebInterface(object): download_scan_interval=None, update_db_interval=None, mb_ignore_age=None, nzb_search_interval=None, libraryscan_interval=None, sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, nzbget_host=None, nzbget_username=None, nzbget_password=None, nzbget_category=None, transmission_host=None, transmission_username=None, transmission_password=None, utorrent_host=None, utorrent_username=None, utorrent_password=None, utorrent_label=None,nzb_downloader=0, torrent_downloader=0, download_dir=None, blackhole_dir=None, usenet_retention=None, - use_headphones_indexer=0, 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, omgwtfnzbs=0, omgwtfnzbs_uid=None, omgwtfnzbs_apikey=None, + use_headphones_indexer=0, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0, nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, omgwtfnzbs=0, omgwtfnzbs_uid=None, omgwtfnzbs_apikey=None, 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=None, use_piratebay=0, piratebay_proxy_url=None, 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=None, use_piratebay=0, piratebay_proxy_url=None, use_kat=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, replace_existing_folders=False, destination_dir=None, lossless_destination_dir=None, folder_format=None, file_format=None, file_underscores=0, include_extras=0, single=0, ep=0, compilation=0, soundtrack=0, live=0, remix=0, spokenword=0, audiobook=0, other=0, autowant_upcoming=False, autowant_all=False, keep_torrent_files=False, prefer_torrents=0, open_magnet_links=0, interface=None, log_dir=None, cache_dir=None, music_encoder=0, encoder=None, xldprofile=None, @@ -1218,9 +1214,6 @@ class WebInterface(object): headphones.NZBSORG = nzbsorg headphones.NZBSORG_UID = nzbsorg_uid headphones.NZBSORG_HASH = nzbsorg_hash - headphones.NZBSRUS = nzbsrus - headphones.NZBSRUS_UID = nzbsrus_uid - headphones.NZBSRUS_APIKEY = nzbsrus_apikey headphones.OMGWTFNZBS = omgwtfnzbs headphones.OMGWTFNZBS_UID = omgwtfnzbs_uid headphones.OMGWTFNZBS_APIKEY = omgwtfnzbs_apikey @@ -1230,7 +1223,6 @@ class WebInterface(object): headphones.TORRENTBLACKHOLE_DIR = torrentblackhole_dir headphones.NUMBEROFSEEDERS = numberofseeders headphones.DOWNLOAD_TORRENT_DIR = download_torrent_dir - headphones.ISOHUNT = use_isohunt headphones.KAT = use_kat headphones.PIRATEBAY = use_piratebay headphones.PIRATEBAY_PROXY_URL = piratebay_proxy_url