1
0
Fork 0
mirror of https://github.com/evilhero/mylar synced 2024-12-25 01:01:47 +00:00

IMP: (beta) NZBGet functionality added (#213)(#144)

This commit is contained in:
evilhero 2013-02-19 22:03:51 -05:00
parent 105a4dc46f
commit 04bf0af912
4 changed files with 158 additions and 59 deletions

View file

@ -147,7 +147,10 @@
<tr>
<td>
<fieldset>
<legend>SABnzbd</legend>
<div class="row checkbox">
<input id="use_sabnzbd" type="checkbox" onclick="initConfigCheckbox($(this))"; name="use_sabnzbd" value="1" ${config['use_sabnzbd']} /><label>SABnbzd</label>
</div>
<div class="config">
<div class="row">
<label>SABnzbd Host:</label>
<input type="text" name="sab_host" value="${config['sab_host']}" size="30">
@ -160,6 +163,7 @@
<div class="row">
<label>SABnzbd API:</label>
<input type="text" name="sab_apikey" value="${config['sab_api']}" size="36">
</div>
<div class="row">
<label>SABnzbd Password:</label>
@ -190,7 +194,49 @@
</select>
</div>
</div>
<div class="row checkbox">
<input id="use_nzbget" type="checkbox" onclick="initConfigCheckbox($(this))"; name="use_nzbget" value="1" ${config['use_nzbget']} /><label>NZBGet</label>
</div>
<div class="config">
<div class="row">
<label>NZBGet Host:</label>
<input type="text" name="nzbget_host" value="${config['nzbget_host']}" size="30">
<small>usually http://localhost</small>
</div>
<div class="row">
<label>NZBGet Port:</label>
<input type="text" name="mzbget_port" value="${config['nzbget_port']}" size="36">
</div>
<div class="row">
<label>NZBGet Username:</label>
<input type="text" name="nzbget_username" value="${config['nzbget_user']}" size="20">
</div>
<div class="row">
<label>NZBGet Password:</label>
<input type="password" name="nzbget_password" value="${config['nzbget_pass']}" size="20">
</div>
<div class="row">
<label>NZBGet Category:</label>
<input type="text" name="nzbget_category" value="${config['nzbget_cat']}" size="20">
</div>
<div class="row">
<label>NZBGet Priority</label>
<select name="nzbget_priority">
%for prio in ['Default', 'Low', 'Normal', 'High', 'Paused']:
<%
if config['nzbget_priority'] == prio:
outputselect = 'selected'
else:
outputselect = ''
%>
<option value=${prio} ${outputselect}>${prio}</option>
%endfor
</select>
</div>
</div>
</div>
</fieldset>
</td>
@ -669,6 +715,8 @@
});
initActions();
initConfigCheckbox("#launch_browser");
initConfigCheckbox("#use_sabnzbd");
initConfigCheckbox("#use_nzbget");
initConfigCheckbox("#useblackhole");
initConfigCheckbox("#usenewznab");
initConfigCheckbox("#usenzbsu");

View file

@ -135,6 +135,7 @@ CVINFO = False
LOG_LEVEL = None
POST_PROCESSING = True
USE_SABNZBD = True
SAB_HOST = None
SAB_USERNAME = None
SAB_PASSWORD = None
@ -143,6 +144,14 @@ SAB_CATEGORY = None
SAB_PRIORITY = None
SAB_DIRECTORY = None
USE_NZBGET = False
NZBGET_HOST = None
NZBGET_PORT = None
NZBGET_USERNAME = None
NZBGET_PASSWORD = None
NZBGET_PRIORITY = None
NZBGET_CATEGORY = None
NZBSU = False
NZBSU_APIKEY = None
@ -235,8 +244,8 @@ def initialize():
HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, LAUNCH_BROWSER, GIT_PATH, \
CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, USER_AGENT, MUSIC_DIR, DESTINATION_DIR, \
DOWNLOAD_DIR, USENET_RETENTION, SEARCH_INTERVAL, NZB_STARTUP_SEARCH, INTERFACE, AUTOWANT_ALL, AUTOWANT_UPCOMING, ZERO_LEVEL, ZERO_LEVEL_N, COMIC_COVER_LOCAL, \
LIBRARYSCAN, LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_PRIORITY, SAB_DIRECTORY, BLACKHOLE, BLACKHOLE_DIR, ADD_COMICS, COMIC_DIR, IMP_MOVE, IMP_RENAME, IMP_METADATA, \
NZBSU, NZBSU_APIKEY, DOGNZB, DOGNZB_APIKEY, NZBX,\
LIBRARYSCAN, LIBRARYSCAN_INTERVAL, DOWNLOAD_SCAN_INTERVAL, USE_SABNZBD, SAB_HOST, SAB_USERNAME, SAB_PASSWORD, SAB_APIKEY, SAB_CATEGORY, SAB_PRIORITY, SAB_DIRECTORY, BLACKHOLE, BLACKHOLE_DIR, ADD_COMICS, COMIC_DIR, IMP_MOVE, IMP_RENAME, IMP_METADATA, \
USE_NZBGET, NZBGET_HOST, NZBGET_PORT, NZBGET_USERNAME, NZBGET_PASSWORD, NZBGET_CATEGORY, NZBGET_PRIORITY, NZBSU, NZBSU_APIKEY, DOGNZB, DOGNZB_APIKEY, NZBX,\
NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS,\
RAW, RAW_PROVIDER, RAW_USERNAME, RAW_PASSWORD, RAW_GROUPS, EXPERIMENTAL, \
PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, NMA_ENABLED, NMA_APIKEY, NMA_PRIORITY, NMA_ONSNATCH, \
@ -249,6 +258,7 @@ def initialize():
# Make sure all the config sections exist
CheckSection('General')
CheckSection('SABnzbd')
CheckSection('NZBGet')
CheckSection('NZBsu')
CheckSection('DOGnzb')
CheckSection('Raw')
@ -334,6 +344,7 @@ def initialize():
PRE_SCRIPTS = check_setting_str(CFG, 'General', 'pre_scripts', '')
POST_PROCESSING = bool(check_setting_int(CFG, 'General', 'post_processing', 1))
USE_SABNZBD = bool(check_setting_int(CFG, 'SABnzbd', 'use_sabnzbd', 0))
SAB_HOST = check_setting_str(CFG, 'SABnzbd', 'sab_host', '')
SAB_USERNAME = check_setting_str(CFG, 'SABnzbd', 'sab_username', '')
SAB_PASSWORD = check_setting_str(CFG, 'SABnzbd', 'sab_password', '')
@ -348,6 +359,15 @@ def initialize():
elif SAB_PRIORITY == "3": SAB_PRIORITY = "High"
elif SAB_PRIORITY == "4": SAB_PRIORITY = "Paused"
else: SAB_PRIORITY = "Default"
USE_NZBGET = bool(check_setting_int(CFG, 'NZBGet', 'use_nzbget', 0))
NZBGET_HOST = check_setting_str(CFG, 'NZBGet', 'nzbget_host', '')
NZBGET_PORT = check_setting_str(CFG, 'NZBGet', 'nzbget_port', '')
NZBGET_USERNAME = check_setting_str(CFG, 'NZBGet', 'nzbget_username', '')
NZBGET_PASSWORD = check_setting_str(CFG, 'NZBGet', 'nzbget_password', '')
NZBGET_CATEGORY = check_setting_str(CFG, 'NZBGet', 'nzbget_category', '')
NZBGET_PRIORITY = check_setting_str(CFG, 'NZBGet', 'nzbget_priority', '')
NZBSU = bool(check_setting_int(CFG, 'NZBsu', 'nzbsu', 0))
NZBSU_APIKEY = check_setting_str(CFG, 'NZBsu', 'nzbsu_apikey', '')
@ -601,7 +621,9 @@ def config_write():
new_config['General']['pre_scripts'] = PRE_SCRIPTS
new_config['General']['post_processing'] = POST_PROCESSING
new_config['SABnzbd'] = {}
new_config['SABnzbd']['use_sabnzbd'] = int(USE_SABNZBD)
new_config['SABnzbd']['sab_host'] = SAB_HOST
new_config['SABnzbd']['sab_username'] = SAB_USERNAME
new_config['SABnzbd']['sab_password'] = SAB_PASSWORD
@ -610,6 +632,16 @@ def config_write():
new_config['SABnzbd']['sab_priority'] = SAB_PRIORITY
new_config['SABnzbd']['sab_directory'] = SAB_DIRECTORY
new_config['NZBGet'] = {}
new_config['NZBGet']['use_nzbget'] = int(USE_NZBGET)
new_config['NZBGet']['nzbget_host'] = NZBGET_HOST
new_config['NZBGet']['nzbget_port'] = NZBGET_PORT
new_config['NZBGet']['nzbget_username'] = NZBGET_USERNAME
new_config['NZBGet']['nzbget_password'] = NZBGET_PASSWORD
new_config['NZBGet']['nzbget_category'] = NZBGET_CATEGORY
new_config['NZBGet']['nzbget_priority'] = NZBGET_PRIORITY
new_config['NZBsu'] = {}
new_config['NZBsu']['nzbsu'] = int(NZBSU)
new_config['NZBsu']['nzbsu_apikey'] = NZBSU_APIKEY

View file

@ -338,7 +338,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
findurl = "http://www.nzb.su/api?t=search&q=" + str(comsearch[findloop]) + "&apikey=" + str(apikey) + "&o=xml&cat=7030"
elif nzbprov == 'newznab':
#let's make sure the host has a '/' at the end, if not add it.
if host_newznab[-1] != "/": host_newznab = str(host_newznab) + "/"
if host_newznab[:-1] != "/": host_newznab = str(host_newznab) + "/"
findurl = str(host_newznab) + "api?t=search&q=" + str(comsearch[findloop]) + "&apikey=" + str(apikey) + "&o=xml&cat=7030"
logger.fdebug("search-url: " + str(findurl))
elif nzbprov == 'nzbx':
@ -698,24 +698,25 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
logger.fdebug("new linkapi (this should =nzbname) :" + str(linkapi))
# #test nzb.get
# if mylar.NZBGET:
# from xmlrpclib import ServerProxy
# if mylar.NZBGET_HOST[:4] = 'http':
# tmpapi = "http://"
# nzbget_host = mylar.NZBGET_HOST[7]
# elif mylar.NZBGET_HOST[:5] = 'https':
# tmpapi = "https://"
# nzbget_host = mylar.NZBGET_HOST[8]
# tmpapi = tmpapi + str(mylar.NZBGET_USERNAME) + ":" + str(mylar.NZBGET_PASSWORD)
# tmpapi = tmpapi + "@" + nzbget_host + ":" + str(mylar.NZBGET_PORT) + "/xmlrpc"
# server = ServerProxy(tmpapi)
# send_to_nzbget = server.appendurl(nzbname, mylar.NZBGET_CATEGORY, mylar.NZBGET_PRIORITY, True, str(linkapi))
# if send_to_nzbget is True:
# logger.info("Successfully sent nzb to NZBGet!")
# else:
# logger.info("Unable to send nzb to NZBGet - check your configs.")
if mylar.USE_NZBGET:
from xmlrpclib import ServerProxy
if mylar.NZBGET_HOST[:4] == 'http':
tmpapi = "http://"
nzbget_host = mylar.NZBGET_HOST[7]
elif mylar.NZBGET_HOST[:5] == 'https':
tmpapi = "https://"
nzbget_host = mylar.NZBGET_HOST[8]
tmpapi = tmpapi + str(mylar.NZBGET_USERNAME) + ":" + str(mylar.NZBGET_PASSWORD)
tmpapi = tmpapi + "@" + nzbget_host + ":" + str(mylar.NZBGET_PORT) + "/xmlrpc"
server = ServerProxy(tmpapi)
send_to_nzbget = server.appendurl(nzbname, mylar.NZBGET_CATEGORY, mylar.NZBGET_PRIORITY, True, str(linkapi))
if send_to_nzbget is True:
logger.info("Successfully sent nzb to NZBGet!")
else:
logger.info("Unable to send nzb to NZBGet - check your configs.")
# #end nzb.get test
elif mylar.USE_SABNZBD:
# let's build the send-to-SAB string now:
tmpapi = str(mylar.SAB_HOST)
logger.fdebug("send-to-SAB host string: " + str(tmpapi))

View file

@ -934,6 +934,7 @@ class WebInterface(object):
"nzb_search_interval" : mylar.SEARCH_INTERVAL,
"nzb_startup_search" : helpers.checked(mylar.NZB_STARTUP_SEARCH),
"libraryscan_interval" : mylar.LIBRARYSCAN_INTERVAL,
"use_sabnzbd" : helpers.checked(mylar.USE_SABNZBD),
"sab_host" : mylar.SAB_HOST,
"sab_user" : mylar.SAB_USERNAME,
"sab_api" : mylar.SAB_APIKEY,
@ -941,6 +942,14 @@ class WebInterface(object):
"sab_cat" : mylar.SAB_CATEGORY,
"sab_priority" : mylar.SAB_PRIORITY,
"sab_directory" : mylar.SAB_DIRECTORY,
"use_nzbget" : helpers.checked(mylar.USE_NZBGET),
"nzbget_host" : mylar.NZBGET_HOST,
"nzbget_port" : mylar.NZBGET_PORT,
"nzbget_user" : mylar.NZBGET_USERNAME,
"nzbget_pass" : mylar.NZBGET_PASSWORD,
"nzbget_cat" : mylar.NZBGET_CATEGORY,
"nzbget_priority" : mylar.NZBGET_PRIORITY,
"use_blackhole" : helpers.checked(mylar.BLACKHOLE),
"blackhole_dir" : mylar.BLACKHOLE_DIR,
"usenet_retention" : mylar.USENET_RETENTION,
@ -1090,7 +1099,8 @@ class WebInterface(object):
comic_config.exposed = True
def configUpdate(self, http_host='0.0.0.0', http_username=None, http_port=8090, http_password=None, launch_browser=0, logverbose=0, download_scan_interval=None, nzb_search_interval=None, nzb_startup_search=0, libraryscan_interval=None,
sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, sab_priority=None, sab_directory=None, log_dir=None, log_level=0, blackhole=0, blackhole_dir=None,
use_sabnzbd=0, sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, sab_priority=None, sab_directory=None, log_dir=None, log_level=0, blackhole=0, blackhole_dir=None,
use_nzbget=0, nzbget_host=None, nzbget_port=None, nzbget_username=None, nzbget_password=None, nzbget_category=None, nzbget_priority=None,
usenet_retention=None, nzbsu=0, nzbsu_apikey=None, dognzb=0, dognzb_apikey=None, nzbx=0, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0,
raw=0, raw_provider=None, raw_username=None, raw_password=None, raw_groups=None, experimental=0,
prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=None, nma_enabled=0, nma_apikey=None, nma_priority=0, nma_onsnatch=0,
@ -1106,6 +1116,7 @@ class WebInterface(object):
mylar.SEARCH_INTERVAL = nzb_search_interval
mylar.NZB_STARTUP_SEARCH = nzb_startup_search
mylar.LIBRARYSCAN_INTERVAL = libraryscan_interval
mylar.USE_SABNZBD = use_sabnzbd
mylar.SAB_HOST = sab_host
mylar.SAB_USERNAME = sab_username
mylar.SAB_PASSWORD = sab_password
@ -1113,6 +1124,13 @@ class WebInterface(object):
mylar.SAB_CATEGORY = sab_category
mylar.SAB_PRIORITY = sab_priority
mylar.SAB_DIRECTORY = sab_directory
mylar.USE_NZBGET = use_nzbget
mylar.NZBGET_HOST = nzbget_host
mylar.NZBGET_USERNAME = nzbget_username
mylar.NZBGET_PASSWORD = nzbget_password
mylar.NZBGET_PORT = nzbget_port
mylar.NZBGET_CATEGORY = nzbget_category
mylar.NZBGET_PRIORITY = nzbget_priority
mylar.BLACKHOLE = blackhole
mylar.BLACKHOLE_DIR = blackhole_dir
mylar.USENET_RETENTION = usenet_retention