diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html index 58baf946..29978480 100644 --- a/data/interfaces/default/config.html +++ b/data/interfaces/default/config.html @@ -184,23 +184,7 @@ - - + +
-
- NZBMatrix -
- -
-
-
- - -
-
- - -
-
-
- + NZBs
Newznab
@@ -254,9 +238,7 @@
-
+
NZBs.org
@@ -270,21 +252,24 @@
- Newsbin + NZBsRus
- +
- - + +
- - + +
+
Torrents
@@ -1038,9 +1023,8 @@ $( "#tabs" ).tabs(); }); initActions(); - initConfigCheckbox("#usenzbmatrix"); initConfigCheckbox("#usenewznab"); - initConfigCheckbox("#usenewzbin"); + initConfigCheckbox("#usenzbsrus"); initConfigCheckbox("#usenzbsorg"); initConfigCheckbox("#usewaffles"); initConfigCheckbox("#userutracker"); diff --git a/headphones/__init__.py b/headphones/__init__.py index 9286835f..efbfe7e5 100644 --- a/headphones/__init__.py +++ b/headphones/__init__.py @@ -140,6 +140,10 @@ NEWZBIN = False NEWZBIN_UID = None NEWZBIN_PASSWORD = None +NZBSRUS = False +NZBSRUS_UID = None +NZBSRUS_APIKEY = None + LASTFM_USERNAME = None LOSSY_MEDIA_FORMATS = ["mp3", "aac", "ogg", "ape", "m4a"] @@ -268,7 +272,7 @@ def initialize(): 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, \ NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS,\ - NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \ + NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, NZBSRUS, NZBSRUS_UID, NZBSRUS_APIKEY, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \ ENCODERFOLDER, ENCODER_PATH, ENCODER, XLDPROFILE, BITRATE, SAMPLINGFREQUENCY, MUSIC_ENCODER, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, \ ENCODERVBRCBR, ENCODERLOSSLESS, DELETE_LOSSLESS_FILES, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, \ PUSHOVER_ENABLED, PUSHOVER_PRIORITY, PUSHOVER_KEYS, PUSHOVER_ONSNATCH, MIRRORLIST, \ @@ -285,6 +289,7 @@ def initialize(): CheckSection('NZBMatrix') CheckSection('Newznab') CheckSection('NZBsorg') + CheckSection('NZBsRus') CheckSection('Newzbin') CheckSection('Waffles') CheckSection('Rutracker') @@ -400,6 +405,10 @@ def initialize(): NEWZBIN = bool(check_setting_int(CFG, 'Newzbin', 'newzbin', 0)) NEWZBIN_UID = check_setting_str(CFG, 'Newzbin', 'newzbin_uid', '') NEWZBIN_PASSWORD = check_setting_str(CFG, 'Newzbin', 'newzbin_password', '') + + 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', '') LASTFM_USERNAME = check_setting_str(CFG, 'General', 'lastfm_username', '') @@ -725,6 +734,11 @@ def config_write(): new_config['Newzbin']['newzbin_uid'] = NEWZBIN_UID new_config['Newzbin']['newzbin_password'] = NEWZBIN_PASSWORD + 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['Prowl'] = {} new_config['Prowl']['prowl_enabled'] = int(PROWL_ENABLED) new_config['Prowl']['prowl_keys'] = PROWL_KEYS diff --git a/headphones/searcher.py b/headphones/searcher.py index 99ef1d63..0b46f55b 100644 --- a/headphones/searcher.py +++ b/headphones/searcher.py @@ -173,65 +173,65 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): resultlist = [] - if headphones.NZBMATRIX: - provider = "nzbmatrix" - if headphones.PREFERRED_QUALITY == 3 or losslessOnly: - categories = "23" - elif headphones.PREFERRED_QUALITY: - categories = "23,22" - else: - categories = "22" - - # Search Audiobooks/Singles/etc - if albums['Type'] == "Other": - categories = "49" - logger.info("Album type is audiobook/spokenword. Using audiobook category") - if albums['Type'] == "Single": - categories = "47" - logger.info("Album type is 'Single'. Using singles category") - - # For some reason NZBMatrix is erroring out/timing out when the term starts with a "The" right now - # so we'll strip it out for the time being. This may get fixed on their end, it may not, but - # hopefully this will fix it for now. If you notice anything else it gets stuck on, please post it - # on Github so it can be added - if term.lower().startswith("the "): - term = term[4:] - - - params = { "page": "download", - "username": headphones.NZBMATRIX_USERNAME, - "apikey": headphones.NZBMATRIX_APIKEY, - "subcat": categories, - "maxage": headphones.USENET_RETENTION, - "english": 1, - "ssl": 1, - "scenename": 1, - "term": term - } - - searchURL = "https://rss.nzbmatrix.com/rss.php?" + urllib.urlencode(params) - logger.info(u'Parsing results from NZBMatrix' % searchURL) - try: - data = urllib2.urlopen(searchURL, timeout=20).read() - except urllib2.URLError, e: - logger.warn('Error fetching data from NZBMatrix: %s' % e) - data = False - - if data: - - d = feedparser.parse(data) - - for item in d.entries: - try: - url = item.link - title = item.title - size = int(item.links[1]['length']) - - resultlist.append((title, size, url, provider)) - logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size))) - - except AttributeError, e: - logger.info(u"No results found from NZBMatrix for %s" % term) +# if headphones.NZBMATRIX: +# provider = "nzbmatrix" +# if headphones.PREFERRED_QUALITY == 3 or losslessOnly: +# categories = "23" +# elif headphones.PREFERRED_QUALITY: +# categories = "23,22" +# else: +# categories = "22" +# +# # Search Audiobooks/Singles/etc +# if albums['Type'] == "Other": +# categories = "49" +# logger.info("Album type is audiobook/spokenword. Using audiobook category") +# if albums['Type'] == "Single": +# categories = "47" +# logger.info("Album type is 'Single'. Using singles category") +# +# # For some reason NZBMatrix is erroring out/timing out when the term starts with a "The" right now +# # so we'll strip it out for the time being. This may get fixed on their end, it may not, but +# # hopefully this will fix it for now. If you notice anything else it gets stuck on, please post it +# # on Github so it can be added +# if term.lower().startswith("the "): +# term = term[4:] +# +# +# params = { "page": "download", +# "username": headphones.NZBMATRIX_USERNAME, +# "apikey": headphones.NZBMATRIX_APIKEY, +# "subcat": categories, +# "maxage": headphones.USENET_RETENTION, +# "english": 1, +# "ssl": 1, +# "scenename": 1, +# "term": term +# } +# +# searchURL = "https://rss.nzbmatrix.com/rss.php?" + urllib.urlencode(params) +# logger.info(u'Parsing results from NZBMatrix' % searchURL) +# try: +# data = urllib2.urlopen(searchURL, timeout=20).read() +# except urllib2.URLError, e: +# logger.warn('Error fetching data from NZBMatrix: %s' % e) +# data = False +# +# if data: +# +# d = feedparser.parse(data) +# +# for item in d.entries: +# try: +# url = item.link +# title = item.title +# size = int(item.links[1]['length']) +# +# resultlist.append((title, size, url, provider)) +# logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size))) +# +# except AttributeError, e: +# logger.info(u"No results found from NZBMatrix for %s" % term) if headphones.NEWZNAB: @@ -359,89 +359,149 @@ def searchNZB(albumid=None, new=False, losslessOnly=False): except Exception, e: logger.error(u"An unknown error occurred trying to parse the feed: %s" % e) - - if headphones.NEWZBIN: - provider = "newzbin" - providerurl = "https://www.newzbin2.es/" + + if headphones.NZBSRUS: + + provider = "nzbsrus" + categories = "54" + if headphones.PREFERRED_QUALITY == 3 or losslessOnly: - categories = "7" #music - format = "2" #flac + sub = "16" elif headphones.PREFERRED_QUALITY: - categories = "7" #music - format = "10" #mp3+flac + sub = "" else: - categories = "7" #music - format = "8" #mp3 - + sub = "15" + if albums['Type'] == 'Other': - categories = "13" - format = "16" - logger.info("Album type is audiobook/spokenword. Using audiobook category") - - params = { - "fpn": "p", - 'u_nfo_posts_only': 0, - 'u_url_posts_only': 0, - 'u_comment_posts_only': 0, - 'u_show_passworded': 0, - "searchaction": "Search", - #"dl": 1, - "category": categories, - "retention": headphones.USENET_RETENTION, - "ps_rb_audio_format": format, - "feed": "rss", - "u_post_results_amt": 50, #this can default to a high number per user - "hauth": 1, - "q": term - } - searchURL = providerurl + "search/?%s" % urllib.urlencode(params) - try: - data = getNewzbinURL(searchURL) - except exceptions.NewzbinAPIThrottled: - #try again if we were throttled - data = getNewzbinURL(searchURL) - if data: - logger.info(u'Parsing results from %s' % (searchURL, providerurl)) - - try: - d = minidom.parseString(data) - node = d.documentElement - items = d.getElementsByTagName("item") - except ExpatError: - logger.info('Unable to get the NEWZBIN feed. Check that your settings are correct - post a bug if they are') - items = [] - - if len(items): - - for item in items: - - sizenode = item.getElementsByTagName("report:size")[0].childNodes - titlenode = item.getElementsByTagName("title")[0].childNodes - linknode = item.getElementsByTagName("link")[0].childNodes - - for node in sizenode: - size = int(node.data) - for node in titlenode: - title = node.data - for node in linknode: - url = node.data - - #exract the reportid from the link nodes - id_regex = re.escape(providerurl) + 'browse/post/(\d+)/' - id_match = re.match(id_regex, url) - if not id_match: - logger.info("Didn't find a valid Newzbin reportid in linknode") - else: - url = id_match.group(1) #we have to make a post request later, need the id - if url: - resultlist.append((title, size, url, provider)) - logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size))) - else: - logger.info('No url link found in nzb. Skipping.') - - else: - logger.info('No results found from NEWZBIN for %s' % term) + sub = "" + logger.info("Album type is audiobook/spokenword. Searching all music categories") + params = { "uid": headphones.NZBSRUS_UID, + "key": headphones.NZBSRUS_APIKEY, + "cat": categories, + "sub": sub, + "age": headphones.USENET_RETENTION, + "searchtext": term + } + + searchURL = 'https://www.nzbsrus.com/api.php?' + urllib.urlencode(params) + + # Add a user-agent + request = urllib2.Request(searchURL) + request.add_header('User-Agent', 'headphones/0.0 +https://github.com/rembo10/headphones') + opener = urllib2.build_opener() + + logger.info(u'Parsing results from NZBsRus' % searchURL) + + try: + data = opener.open(request).read() + except Exception, e: + logger.warn('Error fetching data from NZBsRus: %s' % e) + data = False + + if data: + + d = feedparser.parse(data) + + if not len(d.entries): + logger.info(u"No results found from NZBsRus for %s" % term) + pass + + else: + for item in d.entries: + try: + url = item.link + title = item.title + size = int(item.links[1]['length']) + + 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 unknown error occurred trying to parse the feed: %s" % e) + +# if headphones.NEWZBIN: +# provider = "newzbin" +# providerurl = "https://www.newzbin2.es/" +# if headphones.PREFERRED_QUALITY == 3 or losslessOnly: +# categories = "7" #music +# format = "2" #flac +# elif headphones.PREFERRED_QUALITY: +# categories = "7" #music +# format = "10" #mp3+flac +# else: +# categories = "7" #music +# format = "8" #mp3 +# +# if albums['Type'] == 'Other': +# categories = "13" +# format = "16" +# logger.info("Album type is audiobook/spokenword. Using audiobook category") +# +# params = { +# "fpn": "p", +# 'u_nfo_posts_only': 0, +# 'u_url_posts_only': 0, +# 'u_comment_posts_only': 0, +# 'u_show_passworded': 0, +# "searchaction": "Search", +# #"dl": 1, +# "category": categories, +# "retention": headphones.USENET_RETENTION, +# "ps_rb_audio_format": format, +# "feed": "rss", +# "u_post_results_amt": 50, #this can default to a high number per user +# "hauth": 1, +# "q": term +# } +# searchURL = providerurl + "search/?%s" % urllib.urlencode(params) +# try: +# data = getNewzbinURL(searchURL) +# except exceptions.NewzbinAPIThrottled: +# #try again if we were throttled +# data = getNewzbinURL(searchURL) +# if data: +# logger.info(u'Parsing results from %s' % (searchURL, providerurl)) +# +# try: +# d = minidom.parseString(data) +# node = d.documentElement +# items = d.getElementsByTagName("item") +# except ExpatError: +# logger.info('Unable to get the NEWZBIN feed. Check that your settings are correct - post a bug if they are') +# items = [] +# +# if len(items): +# +# for item in items: +# +# sizenode = item.getElementsByTagName("report:size")[0].childNodes +# titlenode = item.getElementsByTagName("title")[0].childNodes +# linknode = item.getElementsByTagName("link")[0].childNodes +# +# for node in sizenode: +# size = int(node.data) +# for node in titlenode: +# title = node.data +# for node in linknode: +# url = node.data +# +# #exract the reportid from the link nodes +# id_regex = re.escape(providerurl) + 'browse/post/(\d+)/' +# id_match = re.match(id_regex, url) +# if not id_match: +# logger.info("Didn't find a valid Newzbin reportid in linknode") +# else: +# url = id_match.group(1) #we have to make a post request later, need the id +# if url: +# resultlist.append((title, size, url, provider)) +# logger.info('Found %s. Size: %s' % (title, helpers.bytes_to_mb(size))) +# else: +# logger.info('No url link found in nzb. Skipping.') +# +# else: +# logger.info('No results found from NEWZBIN for %s' % term) +# #attempt to verify that this isn't a substring result #when looking for "Foo - Foo" we don't want "Foobar" #this should be less of an issue when it isn't a self-titled album so we'll only check vs artist diff --git a/headphones/webserve.py b/headphones/webserve.py index f7b52f01..926e379a 100644 --- a/headphones/webserve.py +++ b/headphones/webserve.py @@ -568,9 +568,9 @@ class WebInterface(object): "use_blackhole" : checked(headphones.BLACKHOLE), "blackhole_dir" : headphones.BLACKHOLE_DIR, "usenet_retention" : headphones.USENET_RETENTION, - "use_nzbmatrix" : checked(headphones.NZBMATRIX), - "nzbmatrix_user" : headphones.NZBMATRIX_USERNAME, - "nzbmatrix_api" : headphones.NZBMATRIX_APIKEY, +# "use_nzbmatrix" : checked(headphones.NZBMATRIX), +# "nzbmatrix_user" : headphones.NZBMATRIX_USERNAME, +# "nzbmatrix_api" : headphones.NZBMATRIX_APIKEY, "use_newznab" : checked(headphones.NEWZNAB), "newznab_host" : headphones.NEWZNAB_HOST, "newznab_api" : headphones.NEWZNAB_APIKEY, @@ -579,9 +579,12 @@ class WebInterface(object): "use_nzbsorg" : checked(headphones.NZBSORG), "nzbsorg_uid" : headphones.NZBSORG_UID, "nzbsorg_hash" : headphones.NZBSORG_HASH, - "use_newzbin" : checked(headphones.NEWZBIN), - "newzbin_uid" : headphones.NEWZBIN_UID, - "newzbin_pass" : headphones.NEWZBIN_PASSWORD, +# "use_newzbin" : checked(headphones.NEWZBIN), +# "newzbin_uid" : headphones.NEWZBIN_UID, +# "newzbin_pass" : headphones.NEWZBIN_PASSWORD, + "use_nzbsrus" : checked(headphones.NZBSRUS), + "nzbsrus_uid" : headphones.NZBSRUS_UID, + "nzbsrus_apikey" : headphones.NZBSRUS_APIKEY, "torrentblackhole_dir" : headphones.TORRENTBLACKHOLE_DIR, "download_torrent_dir" : headphones.DOWNLOAD_TORRENT_DIR, "numberofseeders" : headphones.NUMBEROFSEEDERS, @@ -683,9 +686,9 @@ class WebInterface(object): def configUpdate(self, http_host='0.0.0.0', http_username=None, http_port=8181, http_password=None, launch_browser=0, api_enabled=0, api_key=None, download_scan_interval=None, nzb_search_interval=None, libraryscan_interval=None, 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, newznab_enabled=0, 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, + sab_category=None, 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, 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, rutracker=0, rutracker_user=None, rutracker_password=None, rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, 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, @@ -715,9 +718,9 @@ class WebInterface(object): headphones.BLACKHOLE = blackhole headphones.BLACKHOLE_DIR = blackhole_dir headphones.USENET_RETENTION = usenet_retention - headphones.NZBMATRIX = nzbmatrix - headphones.NZBMATRIX_USERNAME = nzbmatrix_username - headphones.NZBMATRIX_APIKEY = nzbmatrix_apikey +# headphones.NZBMATRIX = nzbmatrix +# headphones.NZBMATRIX_USERNAME = nzbmatrix_username +# headphones.NZBMATRIX_APIKEY = nzbmatrix_apikey headphones.NEWZNAB = newznab headphones.NEWZNAB_HOST = newznab_host headphones.NEWZNAB_APIKEY = newznab_apikey @@ -725,9 +728,12 @@ class WebInterface(object): headphones.NZBSORG = nzbsorg headphones.NZBSORG_UID = nzbsorg_uid headphones.NZBSORG_HASH = nzbsorg_hash - headphones.NEWZBIN = newzbin - headphones.NEWZBIN_UID = newzbin_uid - headphones.NEWZBIN_PASSWORD = newzbin_password +# headphones.NEWZBIN = newzbin +# headphones.NEWZBIN_UID = newzbin_uid +# headphones.NEWZBIN_PASSWORD = newzbin_password + headphones.NZBSRUS = nzbsrus + headphones.NZBSRUS_UID = nzbsrus_uid + headphones.NZBSRUS_APIKEY = nzbsrus_apikey headphones.TORRENTBLACKHOLE_DIR = torrentblackhole_dir headphones.NUMBEROFSEEDERS = numberofseeders headphones.DOWNLOAD_TORRENT_DIR = download_torrent_dir