Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
nzblnk committed Dec 24, 2018
2 parents 0475e8a + 3d6daaf commit 45335fb
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 14 deletions.
46 changes: 33 additions & 13 deletions src/nzbmonkey.py
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,22 @@ def search_nzb(header, password, search_engines, best_nzb, max_missing_files, ma
'regex': r'label for="box(?P<id>\d{8,})".*?class="highlight"',
'downloadUrl': 'http://nzbindex.com/download/{id}/',
'skip_segment_debug': False
},
'nzbindex_beta':
{
'name': 'NZBIndex Beta',
'searchUrl': 'http://beta.nzbindex.com/search/rss?q={0}&hidespam=1&sort=agedesc&complete=1',
'regex': r'<link>http:\/\/beta\.nzbindex\.com\/download\/(?P<id>\d{8,})<\/link>',
'downloadUrl': 'http://beta.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 @@ -1273,7 +1289,6 @@ def push_nzb_synologydls(host, port, ssl, username, password, basepath, tag, nzb
req_url = '{0}://{1}:{2}/{3}/auth.cgi?api=SYNO.API.Auth&version=2&method=login&account={4}&passwd={5}' \
'&session=DownloadStation&format=cookie'.format(scheme, host, port, basepath, username, password)

sid = ''
try:
sid = json.loads(requests.get(req_url, verify=False, timeout=REQUESTS_TIMEOUT).text)['data']['sid']
except requests.exceptions.RequestException as e:
Expand All @@ -1282,22 +1297,25 @@ def push_nzb_synologydls(host, port, ssl, username, password, basepath, tag, nzb
print(' Requests-Exception: {}'.format(e))
return 1

req_url = '{0}://{1}:{2}/{3}/DownloadStation/task.cgi'.format(scheme, host, port, basepath)
req_url = '{0}://{1}:{2}/{3}/entry.cgi'.format(scheme, host, port, basepath)

nzbname = '{}.nzb'.format(normalize('NFKD', tag).encode('ascii', 'ignore').decode("utf-8", "ignore"))
nzb_data = {'file': (nzbname, io.BytesIO(nzb_content.encode('utf8')))}

post_data = {
'api': 'SYNO.DownloadStation.Task',
'method': 'create',
'version': '1',
'_sid': sid,
'unzip_password': nzb_pass
}
# API reverse engineered, for some stupid reason the order of parameters matters - thx Synology!
file_data = [
('api', (None, 'SYNO.DownloadStation2.Task', None)),
('method', (None, 'create', None)),
('version', (None, '2', None)),
('extract_password', (None, '"' + nzb_pass + '"', None)),
('destination', (None, '""', None)),
('create_list', (None, 'false', None)),
('type', (None, '"file"', None)),
('file', (None, '["torrent"]', None)),
('torrent', (nzbname, io.BytesIO(nzb_content.encode('utf8')), 'application/x-nzb; charset="UTF-8"'))
]

try:
res = requests.post(req_url, data=post_data, files=nzb_data, verify=False, timeout=REQUESTS_TIMEOUT)

res = requests.post(req_url, files=file_data, verify=False, timeout=REQUESTS_TIMEOUT, cookies={'id': sid})
if res.status_code == 200 and res.text.find('success":true') > 0:
print(Col.OK + 'OK' + Col.OFF)
else:
Expand Down Expand Up @@ -1480,7 +1498,9 @@ def main():
'binsearch_alternative':
cfg['Searchengines'].as_int('binsearch_alternative'),
'nzbking': cfg['Searchengines'].as_int('nzbking'),
'nzbindex': cfg['Searchengines'].as_int('nzbindex')},
'nzbindex': cfg['Searchengines'].as_int('nzbindex'),
'nzbindex_beta': cfg['Searchengines'].as_int('nzbindex_beta'),
'newzleech': cfg['Searchengines'].as_int('newzleech')},
cfg['NZBCheck'].as_bool('best_nzb'),
cfg['NZBCheck'].get('max_missing_files', 2),
cfg['NZBCheck'].get('max_missing_segments_percent', 2.5),
Expand Down
4 changes: 4 additions & 0 deletions src/nzbmonkeyspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def getSpec():
binsearch_alternative = integer(default = 1)
# Enable NZBIndex
nzbindex = integer(default = 1)
# Enable NZBIndex Beta
nzbindex_beta = integer(default = 1)
# Enable NZBKing
nzbking = integer(default = 1)
# Enable Newzleech
newzleech = integer(default = 1)
""".split('\n'))
9 changes: 8 additions & 1 deletion src/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
"""
History
v0.2.3
- NzbindexBeta indexer added
v0.2.2
- Newzleech indexer added
- Synology Downloadstation API fixed
v0.2.1
- Fixed category settings
Expand Down Expand Up @@ -65,5 +72,5 @@
"""

__version__ = '0.2.1'
__version__ = '0.2.3'
__requires__ = ['pyperclip', 'requests', 'configobj', 'colorama', 'cryptography']

0 comments on commit 45335fb

Please sign in to comment.