mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-20 02:25:31 +01:00
Added support for Newznab & NZBs.org
This commit is contained in:
24
config.py
24
config.py
@@ -23,6 +23,14 @@ NZBMatrix = config['NZBMatrix']
|
||||
nzbmatrix = NZBMatrix['nzbmatrix']
|
||||
nzbmatrix_username = NZBMatrix['nzbmatrix_username']
|
||||
nzbmatrix_apikey = NZBMatrix['nzbmatrix_apikey']
|
||||
Newznab = config['Newznab']
|
||||
newznab = Newznab['newznab']
|
||||
newznab_host = Newznab['newznab_host']
|
||||
newznab_apikey = Newznab['newznab_apikey']
|
||||
NZBsorg = config['NZBsorg']
|
||||
nzbsorg = NZBsorg['nzbsorg']
|
||||
nzbsorg_uid = NZBsorg['nzbsorg_uid']
|
||||
nzbsorg_hash = NZBsorg['nzbsorg_hash']
|
||||
SABnzbd = config['SABnzbd']
|
||||
sab_username = SABnzbd['sab_username']
|
||||
sab_password = SABnzbd['sab_password']
|
||||
@@ -74,7 +82,20 @@ form = '''<div class="table"><div class="config">
|
||||
<td><p>NZBMatrix Username:</p>
|
||||
<input type="text" name="nzbmatrix_username" value="%s" size="30" maxlength="40"/><br /></td>
|
||||
<td><p>NZBMatrix API:</p>
|
||||
<input type="text" name="nzbmatrix_apikey" value="%s" size="46" maxlength="40"/></td></tr></table>
|
||||
<input type="text" name="nzbmatrix_apikey" value="%s" size="46" maxlength="40"/></td></tr>
|
||||
<tr><td><br /><br /><p>Enable Newznab:</p>
|
||||
<input type="checkbox" name="newznab" value="1" %s/>Enabled<br /></td>
|
||||
<td><br /><br /><p>Newznab Host:</p>
|
||||
<input type="text" name="newznab_host" value="%s" size="30" maxlength="40"/><br />
|
||||
<p class="smalltext"> i.e. http://nzb.su</p></td>
|
||||
<td><br /><br /><p>Newznab API:</p>
|
||||
<input type="text" name="newznab_apikey" value="%s" size="46" maxlength="40"/></td></tr>
|
||||
<tr><td><br /><br /><p>Enable NZBs.org:</p>
|
||||
<input type="checkbox" name="nzbsorg" value="1" %s/>Enabled<br /></td>
|
||||
<td><br /><br /><p>NZBs.org UID:</p>
|
||||
<input type="text" name="nzbsorg_uid" value="%s" size="30" maxlength="40"/><br /></td>
|
||||
<td><br /><br /><p>NZBs.org Hash:</p>
|
||||
<input type="text" name="nzbsorg_hash" value="%s" size="46" maxlength="40"/></td></tr></table>
|
||||
<h1><u>Quality & Post Processing</u></h1>
|
||||
<table class="configtable"><tr><td><p>Album Quality:</p>
|
||||
<input type="checkbox" name="include_lossless" value="1" %s/>Include lossless
|
||||
@@ -93,5 +114,6 @@ form = '''<div class="table"><div class="config">
|
||||
(For now, all changes require a restart to take effect)</p></form></div></div>''' % (http_host, http_username,
|
||||
http_port, http_password, var_to_chk(launch_browser), sab_host, sab_username, sab_apikey, sab_password,
|
||||
sab_category, music_download_dir, usenet_retention, var_to_chk(nzbmatrix), nzbmatrix_username, nzbmatrix_apikey,
|
||||
var_to_chk(newznab), newznab_host, newznab_apikey, var_to_chk(nzbsorg), nzbsorg_uid, nzbsorg_hash,
|
||||
var_to_chk(include_lossless), var_to_chk(flac_to_mp3), var_to_chk(move_to_itunes), path_to_itunes, var_to_chk(rename_mp3s),
|
||||
var_to_chk(cleanup), var_to_chk(add_album_art))
|
||||
@@ -28,5 +28,13 @@ def configCreate(path):
|
||||
config['NZBMatrix']['nzbmatrix'] = 0
|
||||
config['NZBMatrix']['nzbmatrix_username'] = ''
|
||||
config['NZBMatrix']['nzbmatrix_apikey'] = ''
|
||||
config['Newznab'] = {}
|
||||
config['Newznab']['newznab'] = 0
|
||||
config['Newznab']['newznab_host'] = ''
|
||||
config['Newznab']['newznab_apikey'] = ''
|
||||
config['NZBsorg'] = {}
|
||||
config['NZBsorg']['nzbsorg'] = 0
|
||||
config['NZBsorg']['nzbsorg_uid'] = ''
|
||||
config['NZBsorg']['nzbsorg_hash'] = ''
|
||||
|
||||
config.write()
|
||||
139
searcher.py
139
searcher.py
@@ -12,10 +12,19 @@ config = ConfigObj(config_file)
|
||||
General = config['General']
|
||||
NZBMatrix = config['NZBMatrix']
|
||||
SABnzbd = config['SABnzbd']
|
||||
Newznab = config['Newznab']
|
||||
NZBsorg = config['NZBsorg']
|
||||
usenet_retention = General['usenet_retention']
|
||||
include_lossless = General['include_lossless']
|
||||
nzbmatrix = NZBMatrix['nzbmatrix']
|
||||
nzbmatrix_username = NZBMatrix['nzbmatrix_username']
|
||||
nzbmatrix_apikey = NZBMatrix['nzbmatrix_apikey']
|
||||
usenet_retention = General['usenet_retention']
|
||||
newznab = Newznab['newznab']
|
||||
newznab_host = Newznab['newznab_host']
|
||||
newznab_apikey = Newznab['newznab_apikey']
|
||||
nzbsorg = NZBsorg['nzbsorg']
|
||||
nzbsorg_uid = NZBsorg['nzbsorg_uid']
|
||||
nzbsorg_hash = NZBsorg['nzbsorg_hash']
|
||||
sab_host = SABnzbd['sab_host']
|
||||
sab_username = SABnzbd['sab_username']
|
||||
sab_password = SABnzbd['sab_password']
|
||||
@@ -23,12 +32,6 @@ sab_apikey = SABnzbd['sab_apikey']
|
||||
sab_category = SABnzbd['sab_category']
|
||||
|
||||
|
||||
if General['include_lossless'] == '1':
|
||||
categories = "23, 22"
|
||||
maxsize = 2000000000
|
||||
else:
|
||||
categories = "22"
|
||||
maxsize = 250000000
|
||||
|
||||
def searchNZB(albumid=None):
|
||||
|
||||
@@ -49,36 +52,108 @@ def searchNZB(albumid=None):
|
||||
clname = string.replace(albums[0], ' & ', ' ')
|
||||
clalbum = string.replace(albums[1], ' & ', ' ')
|
||||
term = re.sub('[\.\-]', ' ', '%s %s %s' % (clname, clalbum, year)).encode('utf-8')
|
||||
|
||||
params = { "page": "download",
|
||||
"username": nzbmatrix_username,
|
||||
"apikey": nzbmatrix_apikey,
|
||||
"subcat": categories,
|
||||
"age": usenet_retention,
|
||||
"english": 1,
|
||||
"ssl": 1,
|
||||
"scenename": 1,
|
||||
"term": term
|
||||
}
|
||||
|
||||
searchURL = "http://rss.nzbmatrix.com/rss.php?" + urllib.urlencode(params)
|
||||
|
||||
d = feedparser.parse(searchURL)
|
||||
|
||||
|
||||
resultlist = []
|
||||
|
||||
for item in d.entries:
|
||||
try:
|
||||
url = item.link
|
||||
title = item.title
|
||||
size = int(item.links[1]['length'])
|
||||
if size < maxsize:
|
||||
resultlist.append((title, size, url))
|
||||
if nzbmatrix == '1':
|
||||
|
||||
if include_lossless == '1':
|
||||
categories = "23,22"
|
||||
maxsize = 2000000000
|
||||
else:
|
||||
categories = "22"
|
||||
maxsize = 250000000
|
||||
|
||||
except:
|
||||
print '''No results found'''
|
||||
|
||||
params = { "page": "download",
|
||||
"username": nzbmatrix_username,
|
||||
"apikey": nzbmatrix_apikey,
|
||||
"subcat": categories,
|
||||
"age": usenet_retention,
|
||||
"english": 1,
|
||||
"ssl": 1,
|
||||
"scenename": 1,
|
||||
"term": term
|
||||
}
|
||||
|
||||
searchURL = "http://rss.nzbmatrix.com/rss.php?" + urllib.urlencode(params)
|
||||
|
||||
d = feedparser.parse(searchURL)
|
||||
|
||||
for item in d.entries:
|
||||
try:
|
||||
url = item.link
|
||||
title = item.title
|
||||
size = int(item.links[1]['length'])
|
||||
if size < maxsize:
|
||||
resultlist.append((title, size, url))
|
||||
|
||||
except:
|
||||
print '''No results found'''
|
||||
|
||||
if newznab == '1':
|
||||
|
||||
if include_lossless == '1':
|
||||
categories = "3040,3010"
|
||||
maxsize = 2000000000
|
||||
else:
|
||||
categories = "3010"
|
||||
maxsize = 250000000
|
||||
|
||||
params = { "t": "search",
|
||||
"apikey": newznab_apikey,
|
||||
"cat": categories,
|
||||
"maxage": usenet_retention,
|
||||
"q": term
|
||||
}
|
||||
|
||||
searchURL = newznab_host + '/api?' + urllib.urlencode(params)
|
||||
|
||||
d = feedparser.parse(searchURL)
|
||||
|
||||
for item in d.entries:
|
||||
try:
|
||||
url = item.link
|
||||
title = item.title
|
||||
size = int(item.links[1]['length'])
|
||||
if size < maxsize:
|
||||
resultlist.append((title, size, url))
|
||||
|
||||
except:
|
||||
print '''No results found'''
|
||||
|
||||
if nzbsorg == '1':
|
||||
|
||||
if include_lossless == '1':
|
||||
categories = "3040,3010"
|
||||
maxsize = 2000000000
|
||||
else:
|
||||
categories = "3010"
|
||||
maxsize = 250000000
|
||||
|
||||
params = { "action": "search",
|
||||
"dl": 1,
|
||||
"i": nzbsorg_uid,
|
||||
"h": nzbsorg_hash,
|
||||
"age": usenet_retention,
|
||||
"q": term
|
||||
}
|
||||
|
||||
searchURL = 'https://secure.nzbs.org/rss.php?' + urllib.urlencode(params)
|
||||
|
||||
d = feedparser.parse(searchURL)
|
||||
|
||||
for item in d.entries:
|
||||
try:
|
||||
url = item.link
|
||||
title = item.title
|
||||
size = int(item.links[1]['length'])
|
||||
if size < maxsize:
|
||||
resultlist.append((title, size, url))
|
||||
|
||||
except:
|
||||
print '''No results found'''
|
||||
|
||||
if len(resultlist):
|
||||
bestqual = sorted(resultlist, key=lambda title: title[1], reverse=True)[0]
|
||||
|
||||
|
||||
12
webServer.py
12
webServer.py
@@ -342,13 +342,15 @@ class Headphones:
|
||||
|
||||
def configUpdate(self, http_host='127.0.0.1', http_username=None, http_port=8181, http_password=None, launch_browser=0,
|
||||
sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, music_download_dir=None,
|
||||
usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, include_lossless=0,
|
||||
flac_to_mp3=0, move_to_itunes=0, path_to_itunes=None, rename_mp3s=0, cleanup=0, add_album_art=0):
|
||||
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, include_lossless=0,flac_to_mp3=0, move_to_itunes=0, path_to_itunes=None, rename_mp3s=0, cleanup=0, add_album_art=0):
|
||||
|
||||
configs = configobj.ConfigObj(config_file)
|
||||
SABnzbd = configs['SABnzbd']
|
||||
General = configs['General']
|
||||
NZBMatrix = configs['NZBMatrix']
|
||||
Newznab = configs['Newznab']
|
||||
NZBsorg = configs['NZBsorg']
|
||||
General['http_host'] = http_host
|
||||
General['http_port'] = http_port
|
||||
General['http_username'] = http_username
|
||||
@@ -364,6 +366,12 @@ class Headphones:
|
||||
NZBMatrix['nzbmatrix'] = nzbmatrix
|
||||
NZBMatrix['nzbmatrix_username'] = nzbmatrix_username
|
||||
NZBMatrix['nzbmatrix_apikey'] = nzbmatrix_apikey
|
||||
Newznab['newznab'] = newznab
|
||||
Newznab['newznab_host'] = newznab_host
|
||||
Newznab['newznab_apikey'] = newznab_apikey
|
||||
NZBsorg['nzbsorg'] = nzbsorg
|
||||
NZBsorg['nzbsorg_uid'] = nzbsorg_uid
|
||||
NZBsorg['nzbsorg_hash'] = nzbsorg_hash
|
||||
General['include_lossless'] = include_lossless
|
||||
General['flac_to_mp3'] = flac_to_mp3
|
||||
General['move_to_itunes'] = move_to_itunes
|
||||
|
||||
Reference in New Issue
Block a user