Skip to content

Commit

Permalink
🐛 Fix #40 SABnzbd API compatibility
Browse files Browse the repository at this point in the history
🪦️ Remove NZBKing (Rip!)
  • Loading branch information
nzblnk committed Dec 11, 2022
1 parent 5ab3155 commit 3a8fbc4
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 34 deletions.
37 changes: 10 additions & 27 deletions src/nzbmonkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def __init__(self, nzb_file, max_missing_files=2, max_missing_segments_percent=2

self.regexes = {
'file_count_subject_1': re.compile(r'.*?[(\[](\d{1,4})/(\d{1,4})[)\]].*?\((\d{1,4})/(\d{1,5})\)', re.I),
'file_count_subject_2': re.compile(r'.*?[\[](\d{1,4})/(\d{1,5})[\]]', re.I),
'file_count_subject_2': re.compile(r'.*?\[(\d{1,4})/(\d{1,5})\]', re.I),
'segment_count_subject': re.compile(r'.*?\((\d{1,4})/(\d{1,5})\)$', re.I)}

self.max_missing_files = int(max_missing_files)
Expand Down Expand Up @@ -763,29 +763,13 @@ def search_nzb(header, password, search_engines, best_nzb, max_missing_files, ma
'downloadUrl': 'http://www.binsearch.info/?action=nzb&{id}=1&server=2',
'skip_segment_debug': False
},
'nzbking':
{
'name': 'NZBKing',
'searchUrl': 'https://www.nzbking.com/search/?q={0}',
'regex': r'href="/nzb:(?P<id>.*?)/".*"',
'downloadUrl': 'https://www.nzbking.com/nzb:{id}/',
'skip_segment_debug': True
},
'nzbindex':
{
'name': 'NZBIndex',
'searchUrl': 'https://nzbindex.com/search/rss?q={0}&hidespam=1&sort=agedesc&complete=1',
'regex': r'<link>https:\/\/nzbindex\.com\/download\/(?P<id>\d{8,})\/?<\/link>',
'downloadUrl': 'https://nzbindex.com/download/{id}.nzb?r[]={id}',
'skip_segment_debug': False
},
'newzleech':
{
'name': 'Newzleech',
'searchUrl': 'https://www.newzleech.com/?m=search&q={0}',
'regex': r'class="subject"><a\s+(?:class="incomplete"\s+)?href="\?p=(?P<id>\d+)',
'downloadUrl': 'https://www.newzleech.com/?m=gen&dl=1&post={id}',
'skip_segment_debug': False
}
}

Expand Down Expand Up @@ -1499,9 +1483,7 @@ def main():
{'binsearch': cfg['Searchengines'].as_int('binsearch'),
'binsearch_alternative':
cfg['Searchengines'].as_int('binsearch_alternative'),
'nzbking': cfg['Searchengines'].as_int('nzbking'),
'nzbindex': cfg['Searchengines'].as_int('nzbindex'),
'newzleech': cfg['Searchengines'].as_int('newzleech')},
'nzbindex': cfg['Searchengines'].as_int('nzbindex')},
cfg['NZBCheck'].as_bool('best_nzb'),
cfg['NZBCheck'].get('max_missing_files', 2),
cfg['NZBCheck'].get('max_missing_segments_percent', 2.5),
Expand Down Expand Up @@ -1542,32 +1524,33 @@ def main():

if ExeTypes.SABNZBD.name == exe_target:
scheme = 'https' if exe_target_cfg.as_bool('ssl') else 'http'
req_url = '{0}://{1}:{2}/{3}/api?mode=queue&output=json' \
req_url = '{0}://{1}:{2}/{3}/api?mode=get_cats&output=json' \
'&apikey={4}'.format(scheme,
exe_target_cfg.get('host', 'localhost'),
exe_target_cfg.get('port', '8080'),
exe_target_cfg.get('basepath', 'sabnzbd'),
exe_target_cfg.get('nzbkey', ''))

try:
res = json.loads(requests.get(req_url, verify=False, timeout=REQUESTS_TIMEOUT * 2).text)
if 'error' in res.keys() and res['error'].lower() == 'api key incorrect':
print(Col.FAIL + ' - Please use the API KEY not the NZB KEY in your config!' + Col.OFF)
res = requests.get(req_url, verify=False, timeout=REQUESTS_TIMEOUT * 2)
if res.status_code == 403:
print_and_wait(Col.FAIL + ' - Please use the API KEY not the NZB KEY in your config!' + Col.OFF, WAITING_TIME_LONG)
raise EnvironmentError

if 'queue' not in res.keys():
res = json.loads(res.text)

if 'categories' not in res.keys():
print(Col.FAIL + ' - Reading categories failed!' + Col.OFF)
raise EnvironmentError

sabcats = res['queue']['categories']
sabcats = res['categories']
for sabcat in sabcats:
if sabcat != '*':
cat_choice.append(sabcat)

except (EnvironmentError, ValueError):
cat_choice = []

# Ask NZBGet for categories

if ExeTypes.NZBGET.name == exe_target:

Expand Down
8 changes: 2 additions & 6 deletions src/nzbmonkeyspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,9 @@ def getSpec():
# 0 = disabled; 1-9 = enabled; 1-9 are also the order in which the search engines are used
# More than 1 server with the same order number is allowed
# Enable Binsearch
binsearch = integer(default = 1)
binsearch = integer(default = 2)
# Enable Binsearch - Alternative Server
binsearch_alternative = integer(default = 1)
binsearch_alternative = integer(default = 2)
# Enable NZBIndex
nzbindex = integer(default = 1)
# Enable NZBKing
nzbking = integer(default = 1)
# Enable Newzleech
newzleech = integer(default = 1)
""".split('\n'))
6 changes: 5 additions & 1 deletion src/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# -*- coding: utf-8 -*-
"""
History
v0.2.8
- Fix #40 SABnzbd API compatibility
- Remove NZBKing (Rip!)
v0.2.7
- Fix #15 (Linux KDE/Plasma konsole option removed, thx @PietroPizzi69)
- Provider fail save (thx @kwaaak)
Expand Down Expand Up @@ -87,5 +91,5 @@
"""

__version__ = '0.2.7'
__version__ = '0.2.8'
__requires__ = ['pyperclip', 'requests', 'configobj', 'colorama', 'cryptography']

0 comments on commit 3a8fbc4

Please sign in to comment.