mirror of
https://github.com/evilhero/mylar
synced 2024-12-21 23:32:23 +00:00
implement torznab test
This commit is contained in:
parent
e604c3d216
commit
9627a344ba
4 changed files with 80 additions and 11 deletions
|
@ -897,6 +897,10 @@
|
|||
else:
|
||||
torznab_enabled = ""
|
||||
|
||||
if torznab[2] == '1' or torznab[2] == 1:
|
||||
torznab_verify = "checked"
|
||||
else:
|
||||
torznab_verify = ""
|
||||
%>
|
||||
|
||||
<div class="config" id="torznab${torznab_number}">
|
||||
|
@ -908,13 +912,17 @@
|
|||
<label>Torznab Host</label>
|
||||
<input type="text" name="torznab_host${torznab_number}" id="torznab_host${torznab_number}" value="${torznab[1]}" size="30">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Verify SSL</label>
|
||||
<input type="checkbox" name="torznab_verify${torznab_number}" id="torznab_verify${torznab_number}" value="${torznab[2]}">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Torznab API</label>
|
||||
<input type="text" name="torznab_apikey${torznab_number}" id="torznab_apikey${torznab_number}" value="${torznab[2]}" size="36">
|
||||
<input type="text" name="torznab_apikey${torznab_number}" id="torznab_apikey${torznab_number}" value="${torznab[3]}" size="36">
|
||||
</div>
|
||||
<div class="row">
|
||||
<label>Torznab Category</label>
|
||||
<input type="text" name="torznab_category${torznab_number}" id="torznab_category${torznab_number}" value="${torznab[3]}" size="12">
|
||||
<input type="text" name="torznab_category${torznab_number}" id="torznab_category${torznab_number}" value="${torznab[4]}" size="12">
|
||||
</div>
|
||||
<div class="row checkbox">
|
||||
<input id="torznab_enabled${torznab_number}" type="checkbox" name="torznab_enabled${torznab_number}" value="1" ${torznab_enabled} /><label>Enabled</label>
|
||||
|
@ -2183,7 +2191,7 @@
|
|||
|
||||
$("#add_torznab").click(function() {
|
||||
var intId = $("#torznab_providers > div").size() + deletedTorznabs + 1;
|
||||
var torformfields = $("<div class=\"config\" id=\"torznab" + intId + "\"><div class=\"row\"><label>Torznab Name</label><input type=\"text\" id=\"torznab_name" + intId + "\" name=\"torznab_name" + intId + "\" size=\"36\"></div><div class=\"row\"><label>Torznab Host</label><input type=\"text\" id=\"torznab_host" + intId + "\" name=\"torznab_host" + intId + "\" + value=\"http://\" + size=\"30\"></div><div class=\"row\"><label>Torznab API</label><input type=\"text\" id=\"torznab_apikey" + intId + "\" name=\"torznab_apikey" + intId + "\" size=\"36\"></div><div class=\"row\"><label>Torznab Category</label><input type=\"text\" id=\"torznab_category" + intId + "\" name=\"torznab_category" + intId + "\" size=\"36\"></div><div class=\"row checkbox\"><input type=\"checkbox\" name=\"torznab_enabled" + intId + "\" value=\"1\" checked /><label>Enabled</label></div>");
|
||||
var torformfields = $("<div class=\"config\" id=\"torznab" + intId + "\"><div class=\"row\"><label>Torznab Name</label><input type=\"text\" id=\"torznab_name" + intId + "\" name=\"torznab_name" + intId + "\" size=\"36\"></div><div class=\"row\"><label>Torznab Host</label><input type=\"text\" id=\"torznab_host" + intId + "\" name=\"torznab_host" + intId + "\" + value=\"http://\" + size=\"30\"></div><div class=\"row checkbox\"><input id=\"torznab_verify" + intId + "\" type=\"checkbox\" name=\"torznab_verify" + intId + "\" value=\"1\"/><label>Verify SSL</label></div><div class=\"row\"><label>Torznab API</label><input type=\"text\" id=\"torznab_apikey" + intId + "\" name=\"torznab_apikey" + intId + "\" size=\"36\"></div><div class=\"row\"><label>Torznab Category</label><input type=\"text\" id=\"torznab_category" + intId + "\" name=\"torznab_category" + intId + "\" size=\"36\"></div><div class=\"row checkbox\"><input type=\"checkbox\" name=\"torznab_enabled" + intId + "\" value=\"1\" checked /><label>Enabled</label></div>");
|
||||
var tortestButton = $("<div class=\"row\"><img name=\"torznabstatus" + intId + "\" id=\"torznabstatus" + intId + "\" src=\"interfaces/default/images/success.png\" style=\"float:right;visibility:hidden;\" height=\"20\" width=\"20\" /><input type=\"button\" class=\"torznabtest\" value=\"Test\" id=\"torznab_test" + intId + "\" name=\"torznab_test" + intId + "\" style=\"float:right;margin-right:10px;\" /></div>");
|
||||
var torremoveButton = $("<div class=\"row\"><input type=\"button\" class=\"remove\" value=\"Remove\" /></div>");
|
||||
torremoveButton.click(function() {
|
||||
|
@ -2326,10 +2334,11 @@
|
|||
|
||||
$(".torznabtest").click(function () {
|
||||
var torznab = this.attributes["name"].value.replace('torznab_test', '');
|
||||
var imagechk = document.getElementById("tornabstatus"+torznab);
|
||||
var imagechk = document.getElementById("torznabstatus"+torznab);
|
||||
var name = document.getElementById("torznab_name"+torznab).value;
|
||||
var host = document.getElementById("torznab_host"+torznab).value;
|
||||
var apikey = document.getElementById("torznab_api"+torznab).value;
|
||||
var ssl = document.getElementById("torznab_verify"+torznab).checked;
|
||||
var apikey = document.getElementById("torznab_apikey"+torznab).value;
|
||||
$.get("testtorznab",
|
||||
{ name: name, host: host, ssl: ssl, apikey: apikey },
|
||||
function(data){
|
||||
|
|
|
@ -556,7 +556,7 @@ class Config(object):
|
|||
if self.CONFIG_VERSION < 8:
|
||||
print('Checking for existing torznab configuration...')
|
||||
if not any([self.TORZNAB_NAME is None, self.TORZNAB_HOST is None, self.TORZNAB_APIKEY is None, self.TORZNAB_CATEGORY is None]):
|
||||
torznabs =[(self.TORZNAB_NAME, self.TORZNAB_HOST, self.TORZNAB_APIKEY, self.TORZNAB_CATEGORY, str(int(self.ENABLE_TORZNAB)))]
|
||||
torznabs =[(self.TORZNAB_NAME, self.TORZNAB_HOST, self.TORZNAB_VERIFY, self.TORZNAB_APIKEY, self.TORZNAB_CATEGORY, str(int(self.ENABLE_TORZNAB)))]
|
||||
setattr(self, 'EXTRA_TORZNABS', torznabs)
|
||||
config.set('Torznab', 'EXTRA_TORZNABS', str(torznabs))
|
||||
print('Successfully converted existing torznab for multiple configuration allowance. Removing old references.')
|
||||
|
@ -564,9 +564,9 @@ class Config(object):
|
|||
print('No existing torznab configuration found. Just removing config references at this point..')
|
||||
config.remove_option('Torznab', 'torznab_name')
|
||||
config.remove_option('Torznab', 'torznab_host')
|
||||
config.remove_option('Torznab', 'torznab_verify')
|
||||
config.remove_option('Torznab', 'torznab_apikey')
|
||||
config.remove_option('Torznab', 'torznab_category')
|
||||
config.remove_option('Torznab', 'torznab_verify')
|
||||
print('Successfully removed outdated config entries.')
|
||||
if self.newconfig < 9:
|
||||
#rejig rtorrent settings due to change.
|
||||
|
@ -1112,7 +1112,7 @@ class Config(object):
|
|||
return extra_newznabs
|
||||
|
||||
def get_extra_torznabs(self):
|
||||
extra_torznabs = zip(*[iter(self.EXTRA_TORZNABS.split(', '))]*5)
|
||||
extra_torznabs = zip(*[iter(self.EXTRA_TORZNABS.split(', '))]*6)
|
||||
return extra_torznabs
|
||||
|
||||
def provider_sequence(self):
|
||||
|
@ -1155,7 +1155,7 @@ class Config(object):
|
|||
|
||||
if self.ENABLE_TORZNAB:
|
||||
for ets in self.EXTRA_TORZNABS:
|
||||
if str(ets[4]) == '1': # if torznabs are enabled
|
||||
if str(ets[5]) == '1': # if torznabs are enabled
|
||||
if ets[0] == "":
|
||||
et_name = ets[1]
|
||||
else:
|
||||
|
|
|
@ -3657,6 +3657,42 @@ def newznab_test(name, host, ssl, apikey):
|
|||
logger.info('[ERROR:%s] - %s' % (code, description))
|
||||
return False
|
||||
|
||||
def torznab_test(name, host, ssl, apikey):
|
||||
from xml.dom.minidom import parseString, Element
|
||||
params = {'t': 'search',
|
||||
'apikey': apikey,
|
||||
'o': 'xml'}
|
||||
|
||||
if host[-1:] == '/':
|
||||
host = host[:-1]
|
||||
headers = {'User-Agent': str(mylar.USER_AGENT)}
|
||||
logger.info('host: %s' % host)
|
||||
try:
|
||||
r = requests.get(host, params=params, headers=headers, verify=bool(ssl))
|
||||
except Exception as e:
|
||||
logger.warn('Unable to connect: %s' % e)
|
||||
return
|
||||
else:
|
||||
try:
|
||||
data = parseString(r.content)
|
||||
except Exception as e:
|
||||
logger.warn('[WARNING] Error attempting to test: %s' % e)
|
||||
|
||||
try:
|
||||
error_code = data.getElementsByTagName('error')[0].attributes['code'].value
|
||||
except Exception as e:
|
||||
logger.info('Connected - Status code returned: %s' % r.status_code)
|
||||
if r.status_code == 200:
|
||||
return True
|
||||
else:
|
||||
logger.warn('Received response - Status code returned: %s' % r.status_code)
|
||||
return False
|
||||
|
||||
code = error_code
|
||||
description = data.getElementsByTagName('error')[0].attributes['description'].value
|
||||
logger.info('[ERROR:%s] - %s' % (code, description))
|
||||
return False
|
||||
|
||||
def get_free_space(folder):
|
||||
min_threshold = 100000000 #threshold for minimum amount of freespace available (#100mb)
|
||||
if platform.system() == "Windows":
|
||||
|
|
|
@ -5017,7 +5017,7 @@ class WebInterface(object):
|
|||
"dognzb_verify": helpers.checked(mylar.CONFIG.DOGNZB_VERIFY),
|
||||
"experimental": helpers.checked(mylar.CONFIG.EXPERIMENTAL),
|
||||
"enable_torznab": helpers.checked(mylar.CONFIG.ENABLE_TORZNAB),
|
||||
"extra_torznabs": sorted(mylar.CONFIG.EXTRA_TORZNABS, key=itemgetter(4), reverse=True),
|
||||
"extra_torznabs": sorted(mylar.CONFIG.EXTRA_TORZNABS, key=itemgetter(5), reverse=True),
|
||||
"newznab": helpers.checked(mylar.CONFIG.NEWZNAB),
|
||||
"extra_newznabs": sorted(mylar.CONFIG.EXTRA_NEWZNABS, key=itemgetter(5), reverse=True),
|
||||
"enable_ddl": helpers.checked(mylar.CONFIG.ENABLE_DDL),
|
||||
|
@ -5323,10 +5323,12 @@ class WebInterface(object):
|
|||
if not checkdirectory:
|
||||
logger.warn('Error trying to validate/create directory. Aborting this process at this time.')
|
||||
updatedir = False
|
||||
|
||||
else:
|
||||
logger.info('[Create directories False] Not creating physical directory, but updating series location in dB to: %s' % com_location)
|
||||
if updatedir is True:
|
||||
newValues['ComicLocation'] = com_location
|
||||
|
||||
myDB.upsert("comics", newValues, controlValueDict)
|
||||
logger.fdebug('Updated Series options!')
|
||||
raise cherrypy.HTTPRedirect("comicDetails?ComicID=%s" % ComicID)
|
||||
|
@ -5447,6 +5449,10 @@ class WebInterface(object):
|
|||
if torznab_name == "":
|
||||
continue
|
||||
torznab_host = helpers.clean_url(kwargs['torznab_host' + torznab_number])
|
||||
try:
|
||||
torznab_verify = kwargs['torznab_verify' + torznab_number]
|
||||
except:
|
||||
torznab_verify = 0
|
||||
torznab_api = kwargs['torznab_apikey' + torznab_number]
|
||||
torznab_category = kwargs['torznab_category' + torznab_number]
|
||||
try:
|
||||
|
@ -5456,7 +5462,7 @@ class WebInterface(object):
|
|||
|
||||
del kwargs[kwarg]
|
||||
|
||||
mylar.CONFIG.EXTRA_TORZNABS.append((torznab_name, torznab_host, torznab_api, torznab_category, torznab_enabled))
|
||||
mylar.CONFIG.EXTRA_TORZNABS.append((torznab_name, torznab_host, torznab_verify, torznab_api, torznab_category, torznab_enabled))
|
||||
|
||||
mylar.CONFIG.process_kwargs(kwargs)
|
||||
|
||||
|
@ -6027,6 +6033,24 @@ class WebInterface(object):
|
|||
return 'Error - failed running test for %s' % name
|
||||
testnewznab.exposed = True
|
||||
|
||||
def testtorznab(self, name, host, ssl, apikey):
|
||||
logger.fdebug('ssl/verify: %s' % ssl)
|
||||
if 'ssl' == '0' or ssl == '1':
|
||||
ssl = bool(int(ssl))
|
||||
else:
|
||||
if ssl == 'false':
|
||||
ssl = False
|
||||
else:
|
||||
ssl = True
|
||||
result = helpers.torznab_test(name, host, ssl, apikey)
|
||||
if result is True:
|
||||
logger.info('Successfully tested %s [%s] - valid api response received' % (name, host))
|
||||
return 'Successfully tested %s!' % name
|
||||
else:
|
||||
print result
|
||||
logger.warn('Testing failed to %s [HOST:%s][SSL:%s]' % (name, host, bool(ssl)))
|
||||
return 'Error - failed running test for %s' % name
|
||||
testtorznab.exposed = True
|
||||
|
||||
def orderThis(self, **kwargs):
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue