FIX:(#390) If year not present within brackets in nzb filename would discard - now attempts to put within brackets (rupaschomaker), IMP: Redid Newznab section to allow for better integration and future improvements (rankings, priority, max results,etc)

This commit is contained in:
evilhero 2013-05-19 00:07:18 -04:00
parent a64de49d41
commit d0c6eb1d52
4 changed files with 40 additions and 57 deletions

View File

@ -369,22 +369,8 @@
<input id="usenewznab" type="checkbox" name="newznab" onclick="initConfigCheckbox($(this));" value="1" ${config['use_newznab']} /><label>Use Newznab</label>
</div>
<div id="newznab_providers">
<div class="config" id="newznab1">
<div class="row">
<label>Newznab Host</label>
<input type="text" name="newznab_host" value="${config['newznab_host']}" size="30">
<small>e.g. http://nzb.su</small>
</div>
<div class="row">
<label>Newznab API</label>
<input type="text" name="newznab_apikey" value="${config['newznab_api']}" size="36">
</div>
<div class="row checkbox">
<input id="newznab_enabled" type="checkbox" name="newznab_enabled" onclick="initConfigCheckbox($(this));" value="1" ${config['newznab_enabled']} /><label>Enabled</label>
</div>
</div>
<%
newznab_number = 2
newznab_number = 1
%>
%for newznab in config['extra_newznabs']:
<%

View File

@ -174,6 +174,7 @@ NEWZNAB_HOST = None
NEWZNAB_APIKEY = None
NEWZNAB_ENABLED = False
EXTRA_NEWZNABS = []
NEWZNAB_EXTRA = None
RAW = False
RAW_PROVIDER = None
@ -211,6 +212,7 @@ CVURL = None
WEEKFOLDER = 0
LOCMOVE = 0
NEWCOM_DIR = None
OLDCONFIG_VERSION = None
def CheckSection(sec):
""" Check if INI section exists, if not create it """
@ -262,13 +264,13 @@ def initialize():
with INIT_LOCK:
global __INITIALIZED__, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, COMICSORT, DATA_DIR, CONFIG_FILE, CFG, CONFIG_VERSION, LOG_DIR, CACHE_DIR, LOGVERBOSE, \
global __INITIALIZED__, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, COMICSORT, DATA_DIR, CONFIG_FILE, CFG, CONFIG_VERSION, LOG_DIR, CACHE_DIR, LOGVERBOSE, OLDCONFIG_VERSION, \
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, DESTINATION_DIR, \
DOWNLOAD_DIR, USENET_RETENTION, SEARCH_INTERVAL, NZB_STARTUP_SEARCH, INTERFACE, AUTOWANT_ALL, AUTOWANT_UPCOMING, ZERO_LEVEL, ZERO_LEVEL_N, COMIC_COVER_LOCAL, HIGHCOUNT, \
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,\
NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS, NEWZNAB_EXTRA, \
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, PUSHOVER_ENABLED, PUSHOVER_PRIORITY, PUSHOVER_APIKEY, PUSHOVER_USERKEY, PUSHOVER_ONSNATCH, LOCMOVE, NEWCOM_DIR, \
PREFERRED_QUALITY, MOVE_FILES, RENAME_FILES, LOWERCASE_FILENAMES, USE_MINSIZE, MINSIZE, USE_MAXSIZE, MAXSIZE, CORRECT_METADATA, FOLDER_FORMAT, FILE_FORMAT, REPLACE_CHAR, REPLACE_SPACES, ADD_TO_CSV, CVINFO, LOG_LEVEL, POST_PROCESSING, SEARCH_DELAY, GRABBAG_DIR, READ2FILENAME, CVURL, CVAPIFIX, \
@ -295,7 +297,7 @@ def initialize():
if HTTP_PORT < 21 or HTTP_PORT > 65535:
HTTP_PORT = 8090
# CONFIG_VERSION = check_setting_str(CFG, 'General', 'config_version', '')
CONFIG_VERSION = check_setting_str(CFG, 'General', 'config_version', '')
HTTP_HOST = check_setting_str(CFG, 'General', 'http_host', '0.0.0.0')
HTTP_USERNAME = check_setting_str(CFG, 'General', 'http_username', '')
HTTP_PASSWORD = check_setting_str(CFG, 'General', 'http_password', '')
@ -442,15 +444,23 @@ def initialize():
EXPERIMENTAL = bool(check_setting_int(CFG, 'Experimental', 'experimental', 0))
NEWZNAB = bool(check_setting_int(CFG, 'Newznab', 'newznab', 0))
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))
if CONFIG_VERSION:
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))
# 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)]))
#to counteract the loss of the 1st newznab entry because of a switch, let's rewrite to the tuple
if NEWZNAB_HOST and CONFIG_VERSION:
EXTRA_NEWZNABS.append((NEWZNAB_HOST, NEWZNAB_APIKEY, int(NEWZNAB_ENABLED)))
# Need to rewrite config here and bump up config version
CONFIG_VERSION = '3'
config_write()
# update folder formats in the config & bump up config version
if CONFIG_VERSION == '0':
from mylar.helpers import replace_all
@ -761,9 +771,7 @@ def config_write():
new_config['Newznab'] = {}
new_config['Newznab']['newznab'] = int(NEWZNAB)
new_config['Newznab']['newznab_host'] = NEWZNAB_HOST
new_config['Newznab']['newznab_apikey'] = NEWZNAB_APIKEY
new_config['Newznab']['newznab_enabled'] = int(NEWZNAB_ENABLED)
# Need to unpack the extra newznabs for saving in config.ini
flattened_newznabs = []
for newznab in EXTRA_NEWZNABS:

View File

@ -68,45 +68,25 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, IssueDate, IssueI
newznabs = 0
if mylar.NEWZNAB == 1:
logger.fdebug("mylar.newznab:" + str(mylar.NEWZNAB))
if mylar.NEWZNAB_ENABLED:
newznab_hosts = [(mylar.NEWZNAB_HOST, mylar.NEWZNAB_APIKEY, mylar.NEWZNAB_ENABLED)]
logger.fdebug("newznab_hosts:" + str(mylar.NEWZNAB_HOST))
logger.fdebug("newznab_enabled:" + str(mylar.NEWZNAB_ENABLED))
newznabs = 1
else:
newznab_hosts = []
logger.fdebug("initial newznab provider not enabled...checking for additional newznabs.")
newznab_hosts = []
#logger.fdebug("mylar.EXTRA_NEWZNABS:" + str(mylar.EXTRA_NEWZNABS))
if mylar.NEWZNAB == 1:
for newznab_host in mylar.EXTRA_NEWZNABS:
if newznab_host[2] == '1' or newznab_host[2] == 1:
# nzbprovider.append('newznab')
# nzbp+=1
newznab_hosts.append(newznab_host)
newznabs = newznabs + 1
nzbprovider.append('newznab')
newznabs+=1
logger.fdebug("newznab host:" + str(newznab_host[0]) + " - enabled: " + str(newznab_host[2]))
# print("newznab_nzbp-1:" + str(nzbprovider(nzbp-1)))
# print("newznab_nzbp:" + str(nzbprovider(nzbp)))
if mylar.NEWZNAB_ENABLED and 'newznab' not in nzbprovider:
nzbprovider.append('newznab')
nzbp+=1
#categories = "7030"
#for newznab_host in newznab_hosts:
# mylar.NEWZNAB_APIKEY = newznab_host[1]
# mylar.NEWZNAB_HOST = newznab_host[0]
# --------
providercount = int(nzbp + newznabs)
logger.fdebug("there are : " + str(providercount) + " search providers you have selected.")
logger.fdebug("Usenet Retention : " + str(mylar.USENET_RETENTION) + " days")
nzbpr = nzbp-1
nzbpr = providercount - 1
if nzbpr < 0:
nzbpr == 0
findit = 'no'
#fix for issue dates between Nov-Dec/Jan
@ -117,12 +97,10 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, IssueDate, IssueI
IssDateFix = "no"
while (nzbpr >= 0 ):
if nzbprovider[nzbpr] == 'newznab':
#this is for newznab
nzbprov = 'newznab'
for newznab_host in newznab_hosts:
#logger.fdebug("using newznab_host: " + str(newznab_host[0]))
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID, UseFuzzy, newznab_host, ComicVersion)
if findit == 'yes':
logger.fdebug("findit = found!")
@ -407,6 +385,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
if nzbprov == 'newznab' and 'localhost' in str(host_newznab_fix):
pass
else:
logger.fdebug("pausing for " + str(pause_the_search) + " seconds before continuing to avoid hammering")
time.sleep(pause_the_search)
try:
@ -446,6 +425,12 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
nzbname = cleantitle
# if there are no () in the string, try to add them if it looks like a year (19xx or 20xx)
if len(re.findall('[^()]+', cleantitle)):
logger.fdebug("detected invalid nzb filename - attempting to detect year to continue")
cleantitle = re.sub('(.*)\s+(19\d{2}|20\d{2})(.*)', '\\1 (\\2) \\3', cleantitle)
#adjust for covers only by removing them entirely...
logger.fdebug("Cleantitle: " + str(cleantitle))

View File

@ -1704,9 +1704,9 @@ class WebInterface(object):
mylar.RAW_GROUPS = raw_groups
mylar.EXPERIMENTAL = experimental
mylar.NEWZNAB = newznab
mylar.NEWZNAB_HOST = newznab_host
mylar.NEWZNAB_APIKEY = newznab_apikey
mylar.NEWZNAB_ENABLED = newznab_enabled
#mylar.NEWZNAB_HOST = newznab_host
#mylar.NEWZNAB_APIKEY = newznab_apikey
#mylar.NEWZNAB_ENABLED = newznab_enabled
mylar.PREFERRED_QUALITY = int(preferred_quality)
mylar.MOVE_FILES = move_files
mylar.RENAME_FILES = rename_files
@ -1755,6 +1755,10 @@ class WebInterface(object):
# Handle the variable config options. Note - keys with False values aren't getting passed
mylar.EXTRA_NEWZNABS = []
#changing this for simplicty - adding all newznabs into extra_newznabs
if newznab_host is not None:
#this
mylar.EXTRA_NEWZNABS.append((newznab_host, newznab_apikey, int(newznab_enabled)))
for kwarg in kwargs:
if kwarg.startswith('newznab_host'):