mirror of
https://github.com/rembo10/headphones.git
synced 2026-03-31 01:59:26 +01:00
Some fixes to get mult_newznabs working: unpack & repack settings when saving to/pulling from config, modified searcher.py to work with tuples, fixed config.html to create new intIds no matter what, place new newznabs before add button, instead of after last div
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
m<%inherit file="base.html"/>
|
||||
<%!
|
||||
import headphones
|
||||
from operator import itemgetter
|
||||
%>
|
||||
|
||||
<%def name="headerIncludes()">
|
||||
@@ -218,9 +217,9 @@ m<%inherit file="base.html"/>
|
||||
<%
|
||||
newznab_number = 2
|
||||
%>
|
||||
%for newznab in sorted(config['extra_newznabs'], key=itemgetter(0)):
|
||||
%for newznab in config['extra_newznabs']:
|
||||
<%
|
||||
if newznab[2]:
|
||||
if newznab[2] == '1' or newznab[2] == 1:
|
||||
newznab_enabled = "checked"
|
||||
else:
|
||||
newznab_enabled = ""
|
||||
@@ -814,21 +813,25 @@ m<%inherit file="base.html"/>
|
||||
$("#mirror").change(handleNewSelection);
|
||||
handleNewSelection.apply($("#mirror"));
|
||||
|
||||
var deletedNewznabs = 0;
|
||||
|
||||
$(".remove").click(function() {
|
||||
$(this).parent().parent().remove();
|
||||
deletedNewznabs = deletedNewznabs + 1;
|
||||
});
|
||||
|
||||
$("#add_newznab").click(function() {
|
||||
var intIdPrev = $("#newznab_providers > div").size();
|
||||
var intId = intIdPrev + 1;
|
||||
var intId = $("#newznab_providers > div").size() + deletedNewznabs + 1;
|
||||
var formfields = $("<div class=\"config\" id=\"newznab" + intId + "\"><div class=\"row\"><label>Newznab Host</label><input type=\"text\" name=\"newznab_host" + intId + "\" size=\"30\"></div><div class=\"row\"><label>Newznab API</label><input type=\"text\" name=\"newznab_api" + intId + "\" size=\"36\"></div><div class=\"row checkbox\"><input type=\"checkbox\" name=\"newznab_enabled" + intId + "\" value=\"1\" checked /><label>Enabled</label></div>");
|
||||
var removeButton = $("<div class=\"row\"><input type=\"button\" class=\"remove\" value=\"Remove\" /></div>");
|
||||
removeButton.click(function() {
|
||||
$(this).parent().remove();
|
||||
deletedNewznabs = deletedNewznabs + 1;
|
||||
|
||||
});
|
||||
formfields.append(removeButton);
|
||||
formfields.append("</div>");
|
||||
$("#newznab" + intIdPrev).after(formfields);
|
||||
$("#add_newznab").before(formfields);
|
||||
});
|
||||
|
||||
$(function() {
|
||||
|
||||
@@ -20,6 +20,7 @@ import os, sys, subprocess
|
||||
import threading
|
||||
import webbrowser
|
||||
import sqlite3
|
||||
import itertools
|
||||
|
||||
from lib.apscheduler.scheduler import Scheduler
|
||||
from lib.configobj import ConfigObj
|
||||
@@ -229,7 +230,6 @@ def check_setting_str(config, cfg_name, item_name, def_val, log=True):
|
||||
else:
|
||||
logger.debug(item_name + " -> ******")
|
||||
return my_val
|
||||
|
||||
|
||||
def initialize():
|
||||
|
||||
@@ -343,7 +343,10 @@ def initialize():
|
||||
NEWZNAB_HOST = check_setting_str(CFG, 'Newznab', 'newznab_host', '')
|
||||
NEWZNAB_APIKEY = check_setting_str(CFG, 'Newznab', 'newznab_apikey', '')
|
||||
NEWZNAB_ENABLED = bool(check_setting_int(CFG, 'Newznab', 'newznab_enabled', 1))
|
||||
EXTRA_NEWZNABS = check_setting_str(CFG, 'Newznab', 'extra_newznabs', [], log=False)
|
||||
|
||||
# Need to pack the extra newznabs back into a list of tuples
|
||||
flattened_newznabs = check_setting_str(CFG, 'Newznab', 'extra_newznabs', [], log=False)
|
||||
EXTRA_NEWZNABS = list(itertools.izip(*[itertools.islice(flattened_newznabs, i, None, 3) for i in range(3)]))
|
||||
|
||||
NZBSORG = bool(check_setting_int(CFG, 'NZBsorg', 'nzbsorg', 0))
|
||||
NZBSORG_UID = check_setting_str(CFG, 'NZBsorg', 'nzbsorg_uid', '')
|
||||
@@ -618,7 +621,13 @@ def config_write():
|
||||
new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
|
||||
new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY
|
||||
new_config['Newznab']['newznab_enabled'] = int(NEWZNAB_ENABLED)
|
||||
new_config['Newznab']['extra_newznabs'] = EXTRA_NEWZNABS
|
||||
# Need to unpack the extra newznabs for saving in config.ini
|
||||
flattened_newznabs = []
|
||||
for newznab in EXTRA_NEWZNABS:
|
||||
for item in newznab:
|
||||
flattened_newznabs.append(item)
|
||||
|
||||
new_config['Newznab']['extra_newznabs'] = flattened_newznabs
|
||||
|
||||
new_config['NZBsorg'] = {}
|
||||
new_config['NZBsorg']['nzbsorg'] = int(NZBSORG)
|
||||
|
||||
@@ -217,14 +217,11 @@ def searchNZB(albumid=None, new=False, losslessOnly=False):
|
||||
|
||||
if headphones.NEWZNAB:
|
||||
|
||||
newznab_hosts = [[headphones.NEWZNAB_HOST, headphones.NEWZNAB_APIKEY, headphones.NEWZNAB_ENABLED]]
|
||||
|
||||
# This is just to make sure we don't have any empty string for EXTRA_NEWZNABS
|
||||
if not headphones.EXTRA_NEWZNABS:
|
||||
headphones.EXTRA_NEWZNABS = []
|
||||
newznab_hosts = [(headphones.NEWZNAB_HOST, headphones.NEWZNAB_APIKEY, headphones.NEWZNAB_ENABLED)]
|
||||
|
||||
for newznab_host in headphones.EXTRA_NEWZNABS:
|
||||
newznab_hosts.append(newznab_host)
|
||||
if newznab_host[2] == '1' or newznab_host[2] == 1:
|
||||
newznab_hosts.append(newznab_host)
|
||||
|
||||
provider = "newznab"
|
||||
if headphones.PREFERRED_QUALITY == 3 or losslessOnly:
|
||||
@@ -239,9 +236,6 @@ def searchNZB(albumid=None, new=False, losslessOnly=False):
|
||||
logger.info("Album type is audiobook/spokenword. Using audiobook category")
|
||||
|
||||
for newznab_host in newznab_hosts:
|
||||
|
||||
if newznab_host[2] == 0 or newznab_host[2] == '0':
|
||||
continue
|
||||
|
||||
params = { "t": "search",
|
||||
"apikey": newznab_host[1],
|
||||
|
||||
@@ -572,7 +572,7 @@ class WebInterface(object):
|
||||
except KeyError:
|
||||
newznab_enabled = 0
|
||||
|
||||
headphones.EXTRA_NEWZNABS.append([newznab_host, newznab_api, newznab_enabled])
|
||||
headphones.EXTRA_NEWZNABS.append((newznab_host, newznab_api, newznab_enabled))
|
||||
|
||||
headphones.config_write()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user