mirror of https://github.com/evilhero/mylar
remove auth for /cache, added getArt
Set correct headers, add imageurls to do, added getArt.
This commit is contained in:
parent
dea9ee73a2
commit
052e6ecb0b
|
@ -1,6 +1,12 @@
|
||||||
mylar.db
|
mylar.db
|
||||||
config.ini
|
config.ini
|
||||||
*.pyc
|
*.py[co]
|
||||||
.idea
|
.idea
|
||||||
logs
|
logs
|
||||||
.AppleDouble
|
.AppleDouble
|
||||||
|
cache/
|
||||||
|
custom_exceptions.csv
|
||||||
|
Thumbs.db
|
||||||
|
*.torrent
|
||||||
|
ehtumbs.db
|
||||||
|
Thumbs.db
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# This file is part of Mylar.
|
# This file is part of Mylar.
|
||||||
#
|
#
|
||||||
# Mylar is free software: you can redistribute it and/or modify
|
# Mylar is free software: you can redistribute it and/or modify
|
||||||
|
@ -370,12 +373,12 @@ def check_setting_str(config, cfg_name, item_name, def_val, log=True):
|
||||||
else:
|
else:
|
||||||
logger.debug(item_name + " -> ******")
|
logger.debug(item_name + " -> ******")
|
||||||
return my_val
|
return my_val
|
||||||
|
|
||||||
|
|
||||||
def initialize():
|
def initialize():
|
||||||
|
|
||||||
with INIT_LOCK:
|
with INIT_LOCK:
|
||||||
|
|
||||||
global __INITIALIZED__, DBCHOICE, DBUSER, DBPASS, DBNAME, COMICVINE_API, DEFAULT_CVAPI, CVAPI_COUNT, CVAPI_TIME, CVAPI_MAX, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, COMICSORT, DATA_DIR, CONFIG_FILE, CFG, CONFIG_VERSION, LOG_DIR, CACHE_DIR, MAX_LOGSIZE, LOGVERBOSE, OLDCONFIG_VERSION, OS_DETECT, OS_LANG, OS_ENCODING, \
|
global __INITIALIZED__, DBCHOICE, DBUSER, DBPASS, DBNAME, COMICVINE_API, DEFAULT_CVAPI, CVAPI_COUNT, CVAPI_TIME, CVAPI_MAX, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, COMICSORT, DATA_DIR, CONFIG_FILE, CFG, CONFIG_VERSION, LOG_DIR, CACHE_DIR, MAX_LOGSIZE, LOGVERBOSE, OLDCONFIG_VERSION, OS_DETECT, OS_LANG, OS_ENCODING, \
|
||||||
queue, HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, HTTPS_FORCE_ON, API_ENABLED, API_KEY, LAUNCH_BROWSER, GIT_PATH, SAFESTART, AUTO_UPDATE, \
|
queue, HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, ENABLE_HTTPS, HTTPS_CERT, HTTPS_KEY, HTTPS_FORCE_ON, API_ENABLED, API_KEY, LAUNCH_BROWSER, GIT_PATH, SAFESTART, AUTO_UPDATE, \
|
||||||
CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, USER_AGENT, DESTINATION_DIR, MULTIPLE_DEST_DIRS, CREATE_FOLDERS, \
|
CURRENT_VERSION, LATEST_VERSION, CHECK_GITHUB, CHECK_GITHUB_ON_STARTUP, CHECK_GITHUB_INTERVAL, USER_AGENT, DESTINATION_DIR, MULTIPLE_DEST_DIRS, CREATE_FOLDERS, \
|
||||||
|
@ -392,7 +395,7 @@ def initialize():
|
||||||
PUSHBULLET_ENABLED, PUSHBULLET_APIKEY, PUSHBULLET_DEVICEID, PUSHBULLET_ONSNATCH, LOCMOVE, NEWCOM_DIR, FFTONEWCOM_DIR, \
|
PUSHBULLET_ENABLED, PUSHBULLET_APIKEY, PUSHBULLET_DEVICEID, PUSHBULLET_ONSNATCH, LOCMOVE, NEWCOM_DIR, FFTONEWCOM_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, POST_PROCESSING_SCRIPT, SEARCH_DELAY, GRABBAG_DIR, READ2FILENAME, STORYARCDIR, COPY2ARCDIR, CVURL, CVAPIFIX, CHECK_FOLDER, ENABLE_CHECK_FOLDER, \
|
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, POST_PROCESSING_SCRIPT, SEARCH_DELAY, GRABBAG_DIR, READ2FILENAME, STORYARCDIR, COPY2ARCDIR, CVURL, CVAPIFIX, CHECK_FOLDER, ENABLE_CHECK_FOLDER, \
|
||||||
COMIC_LOCATION, QUAL_ALTVERS, QUAL_SCANNER, QUAL_TYPE, QUAL_QUALITY, ENABLE_EXTRA_SCRIPTS, EXTRA_SCRIPTS, ENABLE_PRE_SCRIPTS, PRE_SCRIPTS, PULLNEW, ALT_PULL, COUNT_ISSUES, COUNT_HAVES, COUNT_COMICS, SYNO_FIX, CHMOD_FILE, CHMOD_DIR, ANNUALS_ON, CV_ONLY, CV_ONETIMER, WEEKFOLDER, UMASK
|
COMIC_LOCATION, QUAL_ALTVERS, QUAL_SCANNER, QUAL_TYPE, QUAL_QUALITY, ENABLE_EXTRA_SCRIPTS, EXTRA_SCRIPTS, ENABLE_PRE_SCRIPTS, PRE_SCRIPTS, PULLNEW, ALT_PULL, COUNT_ISSUES, COUNT_HAVES, COUNT_COMICS, SYNO_FIX, CHMOD_FILE, CHMOD_DIR, ANNUALS_ON, CV_ONLY, CV_ONETIMER, WEEKFOLDER, UMASK
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -403,7 +406,7 @@ def initialize():
|
||||||
CheckSection('NZBsu')
|
CheckSection('NZBsu')
|
||||||
CheckSection('DOGnzb')
|
CheckSection('DOGnzb')
|
||||||
CheckSection('Raw')
|
CheckSection('Raw')
|
||||||
CheckSection('Experimental')
|
CheckSection('Experimental')
|
||||||
CheckSection('Newznab')
|
CheckSection('Newznab')
|
||||||
CheckSection('Torrents')
|
CheckSection('Torrents')
|
||||||
# Set global variables based on config file or use defaults
|
# Set global variables based on config file or use defaults
|
||||||
|
@ -411,7 +414,7 @@ def initialize():
|
||||||
HTTP_PORT = check_setting_int(CFG, 'General', 'http_port', 8090)
|
HTTP_PORT = check_setting_int(CFG, 'General', 'http_port', 8090)
|
||||||
except:
|
except:
|
||||||
HTTP_PORT = 8090
|
HTTP_PORT = 8090
|
||||||
|
|
||||||
if HTTP_PORT < 21 or HTTP_PORT > 65535:
|
if HTTP_PORT < 21 or HTTP_PORT > 65535:
|
||||||
HTTP_PORT = 8090
|
HTTP_PORT = 8090
|
||||||
|
|
||||||
|
@ -419,7 +422,7 @@ def initialize():
|
||||||
HTTPS_CERT = os.path.join(DATA_DIR, 'server.crt')
|
HTTPS_CERT = os.path.join(DATA_DIR, 'server.crt')
|
||||||
if HTTPS_KEY == '':
|
if HTTPS_KEY == '':
|
||||||
HTTPS_KEY = os.path.join(DATA_DIR, 'server.key')
|
HTTPS_KEY = os.path.join(DATA_DIR, 'server.key')
|
||||||
|
|
||||||
CONFIG_VERSION = check_setting_str(CFG, 'General', 'config_version', '')
|
CONFIG_VERSION = check_setting_str(CFG, 'General', 'config_version', '')
|
||||||
DBCHOICE = check_setting_str(CFG, 'General', 'dbchoice', 'sqlite3')
|
DBCHOICE = check_setting_str(CFG, 'General', 'dbchoice', 'sqlite3')
|
||||||
DBUSER = check_setting_str(CFG, 'General', 'dbuser', '')
|
DBUSER = check_setting_str(CFG, 'General', 'dbuser', '')
|
||||||
|
@ -438,10 +441,10 @@ def initialize():
|
||||||
HTTP_ROOT = check_setting_str(CFG, 'General', 'http_root', '/')
|
HTTP_ROOT = check_setting_str(CFG, 'General', 'http_root', '/')
|
||||||
ENABLE_HTTPS = bool(check_setting_int(CFG, 'General', 'enable_https', 0))
|
ENABLE_HTTPS = bool(check_setting_int(CFG, 'General', 'enable_https', 0))
|
||||||
HTTPS_CERT = check_setting_str(CFG, 'General', 'https_cert', '')
|
HTTPS_CERT = check_setting_str(CFG, 'General', 'https_cert', '')
|
||||||
HTTPS_KEY = check_setting_str(CFG, 'General', 'https_key', '')
|
HTTPS_KEY = check_setting_str(CFG, 'General', 'https_key', '')
|
||||||
HTTPS_FORCE_ON = bool(check_setting_int(CFG, 'General', 'https_force_on', 0))
|
HTTPS_FORCE_ON = bool(check_setting_int(CFG, 'General', 'https_force_on', 0))
|
||||||
API_ENABLED = bool(check_setting_int(CFG, 'General', 'api_enabled', 0))
|
API_ENABLED = bool(check_setting_int(CFG, 'General', 'api_enabled', 0))
|
||||||
API_KEY = check_setting_str(CFG, 'General', 'api_key', '')
|
API_KEY = check_setting_str(CFG, 'General', 'api_key', '')
|
||||||
LAUNCH_BROWSER = bool(check_setting_int(CFG, 'General', 'launch_browser', 1))
|
LAUNCH_BROWSER = bool(check_setting_int(CFG, 'General', 'launch_browser', 1))
|
||||||
AUTO_UPDATE = bool(check_setting_int(CFG, 'General', 'auto_update', 0))
|
AUTO_UPDATE = bool(check_setting_int(CFG, 'General', 'auto_update', 0))
|
||||||
LOGVERBOSE = bool(check_setting_int(CFG, 'General', 'logverbose', 0))
|
LOGVERBOSE = bool(check_setting_int(CFG, 'General', 'logverbose', 0))
|
||||||
|
@ -451,16 +454,16 @@ def initialize():
|
||||||
VERBOSE = 1
|
VERBOSE = 1
|
||||||
MAX_LOGSIZE = check_setting_int(CFG, 'General', 'max_logsize', 1000000)
|
MAX_LOGSIZE = check_setting_int(CFG, 'General', 'max_logsize', 1000000)
|
||||||
if not MAX_LOGSIZE:
|
if not MAX_LOGSIZE:
|
||||||
MAX_LOGSIZE = 1000000
|
MAX_LOGSIZE = 1000000
|
||||||
GIT_PATH = check_setting_str(CFG, 'General', 'git_path', '')
|
GIT_PATH = check_setting_str(CFG, 'General', 'git_path', '')
|
||||||
LOG_DIR = check_setting_str(CFG, 'General', 'log_dir', '')
|
LOG_DIR = check_setting_str(CFG, 'General', 'log_dir', '')
|
||||||
if not CACHE_DIR:
|
if not CACHE_DIR:
|
||||||
CACHE_DIR = check_setting_str(CFG, 'General', 'cache_dir', '')
|
CACHE_DIR = check_setting_str(CFG, 'General', 'cache_dir', '')
|
||||||
|
|
||||||
CHECK_GITHUB = bool(check_setting_int(CFG, 'General', 'check_github', 1))
|
CHECK_GITHUB = bool(check_setting_int(CFG, 'General', 'check_github', 1))
|
||||||
CHECK_GITHUB_ON_STARTUP = bool(check_setting_int(CFG, 'General', 'check_github_on_startup', 1))
|
CHECK_GITHUB_ON_STARTUP = bool(check_setting_int(CFG, 'General', 'check_github_on_startup', 1))
|
||||||
CHECK_GITHUB_INTERVAL = check_setting_int(CFG, 'General', 'check_github_interval', 360)
|
CHECK_GITHUB_INTERVAL = check_setting_int(CFG, 'General', 'check_github_interval', 360)
|
||||||
|
|
||||||
DESTINATION_DIR = check_setting_str(CFG, 'General', 'destination_dir', '')
|
DESTINATION_DIR = check_setting_str(CFG, 'General', 'destination_dir', '')
|
||||||
MULTIPLE_DEST_DIRS = check_setting_str(CFG, 'General', 'multiple_dest_dirs', '')
|
MULTIPLE_DEST_DIRS = check_setting_str(CFG, 'General', 'multiple_dest_dirs', '')
|
||||||
CREATE_FOLDERS = bool(check_setting_int(CFG, 'General', 'create_folders', 1))
|
CREATE_FOLDERS = bool(check_setting_int(CFG, 'General', 'create_folders', 1))
|
||||||
|
@ -606,7 +609,7 @@ def initialize():
|
||||||
ENABLE_CBT = bool(check_setting_int(CFG, 'Torrents', 'enable_cbt', 0))
|
ENABLE_CBT = bool(check_setting_int(CFG, 'Torrents', 'enable_cbt', 0))
|
||||||
CBT_PASSKEY = check_setting_str(CFG, 'Torrents', 'cbt_passkey', '')
|
CBT_PASSKEY = check_setting_str(CFG, 'Torrents', 'cbt_passkey', '')
|
||||||
SNATCHEDTORRENT_NOTIFY = bool(check_setting_int(CFG, 'Torrents', 'snatchedtorrent_notify', 0))
|
SNATCHEDTORRENT_NOTIFY = bool(check_setting_int(CFG, 'Torrents', 'snatchedtorrent_notify', 0))
|
||||||
|
|
||||||
#this needs to have it's own category - for now General will do.
|
#this needs to have it's own category - for now General will do.
|
||||||
NZB_DOWNLOADER = check_setting_int(CFG, 'General', 'nzb_downloader', 0)
|
NZB_DOWNLOADER = check_setting_int(CFG, 'General', 'nzb_downloader', 0)
|
||||||
#legacy support of older config - reload into old values for consistency.
|
#legacy support of older config - reload into old values for consistency.
|
||||||
|
@ -680,7 +683,7 @@ def initialize():
|
||||||
|
|
||||||
EXPERIMENTAL = bool(check_setting_int(CFG, 'Experimental', 'experimental', 0))
|
EXPERIMENTAL = bool(check_setting_int(CFG, 'Experimental', 'experimental', 0))
|
||||||
ALTEXPERIMENTAL = bool(check_setting_int(CFG, 'Experimental', 'altexperimental', 1))
|
ALTEXPERIMENTAL = bool(check_setting_int(CFG, 'Experimental', 'altexperimental', 1))
|
||||||
if EXPERIMENTAL:
|
if EXPERIMENTAL:
|
||||||
PR.append('Experimental')
|
PR.append('Experimental')
|
||||||
PR_NUM +=1
|
PR_NUM +=1
|
||||||
|
|
||||||
|
@ -712,7 +715,7 @@ def initialize():
|
||||||
elif CONFIG_VERSION == '5':
|
elif CONFIG_VERSION == '5':
|
||||||
EN_NUM = 5 #addition of Newznab UID
|
EN_NUM = 5 #addition of Newznab UID
|
||||||
else:
|
else:
|
||||||
EN_NUM = 3
|
EN_NUM = 3
|
||||||
|
|
||||||
EXTRA_NEWZNABS = list(itertools.izip(*[itertools.islice(flattened_newznabs, i, None, EN_NUM) for i in range(EN_NUM)]))
|
EXTRA_NEWZNABS = list(itertools.izip(*[itertools.islice(flattened_newznabs, i, None, EN_NUM) for i in range(EN_NUM)]))
|
||||||
|
|
||||||
|
@ -730,14 +733,14 @@ def initialize():
|
||||||
#update the configV and write the config.
|
#update the configV and write the config.
|
||||||
CONFIG_VERSION = '5'
|
CONFIG_VERSION = '5'
|
||||||
config_write()
|
config_write()
|
||||||
|
|
||||||
#to counteract the loss of the 1st newznab entry because of a switch, let's rewrite to the tuple
|
#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:
|
if NEWZNAB_HOST and CONFIG_VERSION:
|
||||||
EXTRA_NEWZNABS.append((NEWZNAB_NAME, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_UID, int(NEWZNAB_ENABLED)))
|
EXTRA_NEWZNABS.append((NEWZNAB_NAME, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_UID, int(NEWZNAB_ENABLED)))
|
||||||
#PR_NUM +=1
|
#PR_NUM +=1
|
||||||
# Need to rewrite config here and bump up config version
|
# Need to rewrite config here and bump up config version
|
||||||
CONFIG_VERSION = '5'
|
CONFIG_VERSION = '5'
|
||||||
config_write()
|
config_write()
|
||||||
|
|
||||||
#print 'PR_NUM:' + str(PR_NUM)
|
#print 'PR_NUM:' + str(PR_NUM)
|
||||||
if NEWZNAB:
|
if NEWZNAB:
|
||||||
|
@ -754,7 +757,7 @@ def initialize():
|
||||||
flattened_provider_order = check_setting_str(CFG, 'General', 'provider_order', [], log=False)
|
flattened_provider_order = check_setting_str(CFG, 'General', 'provider_order', [], log=False)
|
||||||
PROVIDER_ORDER = list(itertools.izip(*[itertools.islice(flattened_provider_order, i, None, 2) for i in range(2)]))
|
PROVIDER_ORDER = list(itertools.izip(*[itertools.islice(flattened_provider_order, i, None, 2) for i in range(2)]))
|
||||||
|
|
||||||
if len(flattened_provider_order) == 0:
|
if len(flattened_provider_order) == 0:
|
||||||
#priority provider sequence in order#, ProviderName
|
#priority provider sequence in order#, ProviderName
|
||||||
#print('creating provider sequence order now...')
|
#print('creating provider sequence order now...')
|
||||||
TMPPR_NUM = 0
|
TMPPR_NUM = 0
|
||||||
|
@ -791,7 +794,7 @@ def initialize():
|
||||||
#print 'provider already exists at : ' + str(new_order_seqnum) + ' -- ' + str(PR[TMPPR_NUM])
|
#print 'provider already exists at : ' + str(new_order_seqnum) + ' -- ' + str(PR[TMPPR_NUM])
|
||||||
TMPPR_NUM +=1
|
TMPPR_NUM +=1
|
||||||
|
|
||||||
|
|
||||||
#this isn't ready for primetime just yet...
|
#this isn't ready for primetime just yet...
|
||||||
#print 'Provider Order is:' + str(PROV_ORDER)
|
#print 'Provider Order is:' + str(PROV_ORDER)
|
||||||
|
|
||||||
|
@ -814,9 +817,9 @@ def initialize():
|
||||||
folder_values = { 'series' : 'Series', 'publisher':'Publisher', 'year' : 'Year', 'first' : 'First', 'lowerfirst' : 'first' }
|
folder_values = { 'series' : 'Series', 'publisher':'Publisher', 'year' : 'Year', 'first' : 'First', 'lowerfirst' : 'first' }
|
||||||
FILE_FORMAT = replace_all(FILE_FORMAT, file_values)
|
FILE_FORMAT = replace_all(FILE_FORMAT, file_values)
|
||||||
FOLDER_FORMAT = replace_all(FOLDER_FORMAT, folder_values)
|
FOLDER_FORMAT = replace_all(FOLDER_FORMAT, folder_values)
|
||||||
|
|
||||||
CONFIG_VERSION = '1'
|
CONFIG_VERSION = '1'
|
||||||
|
|
||||||
if CONFIG_VERSION == '1':
|
if CONFIG_VERSION == '1':
|
||||||
|
|
||||||
from mylar.helpers import replace_all
|
from mylar.helpers import replace_all
|
||||||
|
@ -837,10 +840,10 @@ def initialize():
|
||||||
'publisher': '$publisher',
|
'publisher': '$publisher',
|
||||||
'year': '$year',
|
'year': '$year',
|
||||||
'first': '$first'
|
'first': '$first'
|
||||||
}
|
}
|
||||||
FILE_FORMAT = replace_all(FILE_FORMAT, file_values)
|
FILE_FORMAT = replace_all(FILE_FORMAT, file_values)
|
||||||
FOLDER_FORMAT = replace_all(FOLDER_FORMAT, folder_values)
|
FOLDER_FORMAT = replace_all(FOLDER_FORMAT, folder_values)
|
||||||
|
|
||||||
CONFIG_VERSION = '2'
|
CONFIG_VERSION = '2'
|
||||||
|
|
||||||
if 'http://' not in SAB_HOST[:7] and 'https://' not in SAB_HOST[:8]:
|
if 'http://' not in SAB_HOST[:7] and 'https://' not in SAB_HOST[:8]:
|
||||||
|
@ -1024,7 +1027,7 @@ def initialize():
|
||||||
# Store the original umask
|
# Store the original umask
|
||||||
UMASK = os.umask(0)
|
UMASK = os.umask(0)
|
||||||
os.umask(UMASK)
|
os.umask(UMASK)
|
||||||
|
|
||||||
__INITIALIZED__ = True
|
__INITIALIZED__ = True
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -1033,10 +1036,10 @@ def daemonize():
|
||||||
if threading.activeCount() != 1:
|
if threading.activeCount() != 1:
|
||||||
logger.warn('There are %r active threads. Daemonizing may cause \
|
logger.warn('There are %r active threads. Daemonizing may cause \
|
||||||
strange behavior.' % threading.enumerate())
|
strange behavior.' % threading.enumerate())
|
||||||
|
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
|
|
||||||
# Do first fork
|
# Do first fork
|
||||||
try:
|
try:
|
||||||
pid = os.fork()
|
pid = os.fork()
|
||||||
|
@ -1048,7 +1051,7 @@ def daemonize():
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
except OSError, e:
|
except OSError, e:
|
||||||
sys.exit("1st fork failed: %s [%d]" % (e.strerror, e.errno))
|
sys.exit("1st fork failed: %s [%d]" % (e.strerror, e.errno))
|
||||||
|
|
||||||
os.setsid()
|
os.setsid()
|
||||||
|
|
||||||
# Make sure I can read my own files and shut out others
|
# Make sure I can read my own files and shut out others
|
||||||
|
@ -1070,7 +1073,7 @@ def daemonize():
|
||||||
si = open('/dev/null', "r")
|
si = open('/dev/null', "r")
|
||||||
so = open('/dev/null', "a+")
|
so = open('/dev/null', "a+")
|
||||||
se = open('/dev/null', "a+")
|
se = open('/dev/null', "a+")
|
||||||
|
|
||||||
os.dup2(si.fileno(), sys.stdin.fileno())
|
os.dup2(si.fileno(), sys.stdin.fileno())
|
||||||
os.dup2(so.fileno(), sys.stdout.fileno())
|
os.dup2(so.fileno(), sys.stdout.fileno())
|
||||||
os.dup2(se.fileno(), sys.stderr.fileno())
|
os.dup2(se.fileno(), sys.stderr.fileno())
|
||||||
|
@ -1086,8 +1089,8 @@ def launch_browser(host, port, root):
|
||||||
|
|
||||||
if host == '0.0.0.0':
|
if host == '0.0.0.0':
|
||||||
host = 'localhost'
|
host = 'localhost'
|
||||||
|
|
||||||
try:
|
try:
|
||||||
webbrowser.open('http://%s:%i%s' % (host, port, root))
|
webbrowser.open('http://%s:%i%s' % (host, port, root))
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.error('Could not launch browser: %s' % e)
|
logger.error('Could not launch browser: %s' % e)
|
||||||
|
@ -1123,7 +1126,7 @@ def config_write():
|
||||||
new_config['General']['https_key'] = HTTPS_KEY
|
new_config['General']['https_key'] = HTTPS_KEY
|
||||||
new_config['General']['https_force_on'] = int(HTTPS_FORCE_ON)
|
new_config['General']['https_force_on'] = int(HTTPS_FORCE_ON)
|
||||||
new_config['General']['api_enabled'] = int(API_ENABLED)
|
new_config['General']['api_enabled'] = int(API_ENABLED)
|
||||||
new_config['General']['api_key'] = API_KEY
|
new_config['General']['api_key'] = API_KEY
|
||||||
new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
|
new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
|
||||||
new_config['General']['auto_update'] = int(AUTO_UPDATE)
|
new_config['General']['auto_update'] = int(AUTO_UPDATE)
|
||||||
new_config['General']['log_dir'] = LOG_DIR
|
new_config['General']['log_dir'] = LOG_DIR
|
||||||
|
@ -1134,7 +1137,7 @@ def config_write():
|
||||||
new_config['General']['annuals_on'] = int(ANNUALS_ON)
|
new_config['General']['annuals_on'] = int(ANNUALS_ON)
|
||||||
new_config['General']['cv_only'] = int(CV_ONLY)
|
new_config['General']['cv_only'] = int(CV_ONLY)
|
||||||
new_config['General']['cv_onetimer'] = int(CV_ONETIMER)
|
new_config['General']['cv_onetimer'] = int(CV_ONETIMER)
|
||||||
new_config['General']['cvapifix'] = int(CVAPIFIX)
|
new_config['General']['cvapifix'] = int(CVAPIFIX)
|
||||||
new_config['General']['check_github'] = int(CHECK_GITHUB)
|
new_config['General']['check_github'] = int(CHECK_GITHUB)
|
||||||
new_config['General']['check_github_on_startup'] = int(CHECK_GITHUB_ON_STARTUP)
|
new_config['General']['check_github_on_startup'] = int(CHECK_GITHUB_ON_STARTUP)
|
||||||
new_config['General']['check_github_interval'] = CHECK_GITHUB_INTERVAL
|
new_config['General']['check_github_interval'] = CHECK_GITHUB_INTERVAL
|
||||||
|
@ -1332,9 +1335,9 @@ def config_write():
|
||||||
new_config['Raw']['raw_groups'] = RAW_GROUPS
|
new_config['Raw']['raw_groups'] = RAW_GROUPS
|
||||||
|
|
||||||
new_config.write()
|
new_config.write()
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
|
|
||||||
global __INITIALIZED__, started
|
global __INITIALIZED__, started
|
||||||
#dbUpdateScheduler, searchScheduler, RSSScheduler, \
|
#dbUpdateScheduler, searchScheduler, RSSScheduler, \
|
||||||
#WeeklyScheduler, VersionScheduler, FolderMonitorScheduler
|
#WeeklyScheduler, VersionScheduler, FolderMonitorScheduler
|
||||||
|
@ -1342,7 +1345,7 @@ def start():
|
||||||
with INIT_LOCK:
|
with INIT_LOCK:
|
||||||
|
|
||||||
if __INITIALIZED__:
|
if __INITIALIZED__:
|
||||||
|
|
||||||
# Start our scheduled background tasks
|
# Start our scheduled background tasks
|
||||||
#from mylar import updater, search, PostProcessor
|
#from mylar import updater, search, PostProcessor
|
||||||
|
|
||||||
|
@ -1369,7 +1372,7 @@ def start():
|
||||||
#RSSScheduler.thread.start()
|
#RSSScheduler.thread.start()
|
||||||
logger.info('Initiating startup-RSS feed checks.')
|
logger.info('Initiating startup-RSS feed checks.')
|
||||||
rsscheck.tehMain()
|
rsscheck.tehMain()
|
||||||
|
|
||||||
|
|
||||||
#weekly pull list gets messed up if it's not populated first, so let's populate it then set the scheduler.
|
#weekly pull list gets messed up if it's not populated first, so let's populate it then set the scheduler.
|
||||||
logger.info('Checking for existance of Weekly Comic listing...')
|
logger.info('Checking for existance of Weekly Comic listing...')
|
||||||
|
@ -1378,7 +1381,7 @@ def start():
|
||||||
#now the scheduler (check every 24 hours)
|
#now the scheduler (check every 24 hours)
|
||||||
SCHED.add_interval_job(weeklypull.pullit, hours=24)
|
SCHED.add_interval_job(weeklypull.pullit, hours=24)
|
||||||
#WeeklyScheduler.thread.start()
|
#WeeklyScheduler.thread.start()
|
||||||
|
|
||||||
#let's do a run at the Wanted issues here (on startup) if enabled.
|
#let's do a run at the Wanted issues here (on startup) if enabled.
|
||||||
if NZB_STARTUP_SEARCH:
|
if NZB_STARTUP_SEARCH:
|
||||||
threading.Thread(target=search.searchforissue).start()
|
threading.Thread(target=search.searchforissue).start()
|
||||||
|
@ -1386,7 +1389,7 @@ def start():
|
||||||
if CHECK_GITHUB:
|
if CHECK_GITHUB:
|
||||||
#VersionScheduler.thread.start()
|
#VersionScheduler.thread.start()
|
||||||
SCHED.add_interval_job(versioncheck.checkGithub, minutes=CHECK_GITHUB_INTERVAL)
|
SCHED.add_interval_job(versioncheck.checkGithub, minutes=CHECK_GITHUB_INTERVAL)
|
||||||
|
|
||||||
#run checkFolder every X minutes (basically Manual Run Post-Processing)
|
#run checkFolder every X minutes (basically Manual Run Post-Processing)
|
||||||
if ENABLE_CHECK_FOLDER:
|
if ENABLE_CHECK_FOLDER:
|
||||||
if DOWNLOAD_SCAN_INTERVAL >0:
|
if DOWNLOAD_SCAN_INTERVAL >0:
|
||||||
|
@ -1396,9 +1399,9 @@ def start():
|
||||||
else:
|
else:
|
||||||
logger.error('You need to specify a monitoring time for the check folder option to work')
|
logger.error('You need to specify a monitoring time for the check folder option to work')
|
||||||
SCHED.start()
|
SCHED.start()
|
||||||
|
|
||||||
started = True
|
started = True
|
||||||
|
|
||||||
def dbcheck():
|
def dbcheck():
|
||||||
#if DBCHOICE == 'postgresql':
|
#if DBCHOICE == 'postgresql':
|
||||||
# import psycopg2
|
# import psycopg2
|
||||||
|
@ -1407,10 +1410,10 @@ def dbcheck():
|
||||||
#else:
|
#else:
|
||||||
|
|
||||||
conn = sqlite3.connect(DB_FILE)
|
conn = sqlite3.connect(DB_FILE)
|
||||||
c_error = 'sqlite3.OperationalError'
|
c_error = 'sqlite3.OperationalError'
|
||||||
c=conn.cursor()
|
c=conn.cursor()
|
||||||
|
|
||||||
c.execute('CREATE TABLE IF NOT EXISTS comics (ComicID TEXT UNIQUE, ComicName TEXT, ComicSortName TEXT, ComicYear TEXT, DateAdded TEXT, Status TEXT, IncludeExtras INTEGER, Have INTEGER, Total INTEGER, ComicImage TEXT, ComicPublisher TEXT, ComicLocation TEXT, ComicPublished TEXT, LatestIssue TEXT, LatestDate TEXT, Description TEXT, QUALalt_vers TEXT, QUALtype TEXT, QUALscanner TEXT, QUALquality TEXT, LastUpdated TEXT, AlternateSearch TEXT, UseFuzzy TEXT, ComicVersion TEXT, SortOrder INTEGER, DetailURL TEXT, ForceContinuing INTEGER, ComicName_Filesafe TEXT, AlternateFileName TEXT)')
|
c.execute('CREATE TABLE IF NOT EXISTS comics (ComicID TEXT UNIQUE, ComicName TEXT, ComicSortName TEXT, ComicYear TEXT, DateAdded TEXT, Status TEXT, IncludeExtras INTEGER, Have INTEGER, Total INTEGER, ComicImage TEXT, ComicPublisher TEXT, ComicLocation TEXT, ComicPublished TEXT, LatestIssue TEXT, LatestDate TEXT, Description TEXT, QUALalt_vers TEXT, QUALtype TEXT, QUALscanner TEXT, QUALquality TEXT, LastUpdated TEXT, AlternateSearch TEXT, UseFuzzy TEXT, ComicVersion TEXT, SortOrder INTEGER, DetailURL TEXT, ForceContinuing INTEGER, ComicName_Filesafe TEXT, AlternateFileName TEXT, ComicImageURL TEXT, ComicImageALTURL TEXT)')
|
||||||
c.execute('CREATE TABLE IF NOT EXISTS issues (IssueID TEXT, ComicName TEXT, IssueName TEXT, Issue_Number TEXT, DateAdded TEXT, Status TEXT, Type TEXT, ComicID TEXT, ArtworkURL Text, ReleaseDate TEXT, Location TEXT, IssueDate TEXT, Int_IssueNumber INT, ComicSize TEXT, AltIssueNumber TEXT, IssueDate_Edit TEXT)')
|
c.execute('CREATE TABLE IF NOT EXISTS issues (IssueID TEXT, ComicName TEXT, IssueName TEXT, Issue_Number TEXT, DateAdded TEXT, Status TEXT, Type TEXT, ComicID TEXT, ArtworkURL Text, ReleaseDate TEXT, Location TEXT, IssueDate TEXT, Int_IssueNumber INT, ComicSize TEXT, AltIssueNumber TEXT, IssueDate_Edit TEXT)')
|
||||||
c.execute('CREATE TABLE IF NOT EXISTS snatched (IssueID TEXT, ComicName TEXT, Issue_Number TEXT, Size INTEGER, DateAdded TEXT, Status TEXT, FolderName TEXT, ComicID TEXT, Provider TEXT)')
|
c.execute('CREATE TABLE IF NOT EXISTS snatched (IssueID TEXT, ComicName TEXT, Issue_Number TEXT, Size INTEGER, DateAdded TEXT, Status TEXT, FolderName TEXT, ComicID TEXT, Provider TEXT)')
|
||||||
c.execute('CREATE TABLE IF NOT EXISTS upcoming (ComicName TEXT, IssueNumber TEXT, ComicID TEXT, IssueID TEXT, IssueDate TEXT, Status TEXT, DisplayComicName TEXT)')
|
c.execute('CREATE TABLE IF NOT EXISTS upcoming (ComicName TEXT, IssueNumber TEXT, ComicID TEXT, IssueID TEXT, IssueDate TEXT, Status TEXT, DisplayComicName TEXT)')
|
||||||
|
@ -1431,7 +1434,7 @@ def dbcheck():
|
||||||
|
|
||||||
csv_load()
|
csv_load()
|
||||||
|
|
||||||
|
|
||||||
#add in the late players to the game....
|
#add in the late players to the game....
|
||||||
# -- Comics Table --
|
# -- Comics Table --
|
||||||
|
|
||||||
|
@ -1497,6 +1500,16 @@ def dbcheck():
|
||||||
except sqlite3.OperationalError:
|
except sqlite3.OperationalError:
|
||||||
c.execute('ALTER TABLE comics ADD COLUMN AlternateFileName TEXT')
|
c.execute('ALTER TABLE comics ADD COLUMN AlternateFileName TEXT')
|
||||||
|
|
||||||
|
try:
|
||||||
|
c.execute('SELECT ComicImageURL from comics')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
c.execute('ALTER TABLE comics ADD COLUMN ComicImageURL TEXT')
|
||||||
|
|
||||||
|
try:
|
||||||
|
c.execute('SELECT ComicImageALTURL from comics')
|
||||||
|
except sqlite3.OperationalError:
|
||||||
|
c.execute('ALTER TABLE comics ADD COLUMN ComicImageALTURL TEXT')
|
||||||
|
|
||||||
# -- Issues Table --
|
# -- Issues Table --
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -1680,7 +1693,7 @@ def dbcheck():
|
||||||
|
|
||||||
|
|
||||||
## -- Snatched Table --
|
## -- Snatched Table --
|
||||||
|
|
||||||
try:
|
try:
|
||||||
c.execute('SELECT Provider from snatched')
|
c.execute('SELECT Provider from snatched')
|
||||||
except sqlite3.OperationalError:
|
except sqlite3.OperationalError:
|
||||||
|
@ -1750,7 +1763,7 @@ def dbcheck():
|
||||||
|
|
||||||
|
|
||||||
#if it's prior to Wednesday, the issue counts will be inflated by one as the online db's everywhere
|
#if it's prior to Wednesday, the issue counts will be inflated by one as the online db's everywhere
|
||||||
#prepare for the next 'new' release of a series. It's caught in updater.py, so let's just store the
|
#prepare for the next 'new' release of a series. It's caught in updater.py, so let's just store the
|
||||||
#value in the sql so we can display it in the details screen for everyone to wonder at.
|
#value in the sql so we can display it in the details screen for everyone to wonder at.
|
||||||
try:
|
try:
|
||||||
c.execute('SELECT not_updated_db from comics')
|
c.execute('SELECT not_updated_db from comics')
|
||||||
|
@ -1781,7 +1794,7 @@ def dbcheck():
|
||||||
|
|
||||||
logger.info('Correcting Null entries that make the main page break on startup.')
|
logger.info('Correcting Null entries that make the main page break on startup.')
|
||||||
c.execute("UPDATE Comics SET LatestDate='Unknown' WHERE LatestDate='None' or LatestDate is NULL")
|
c.execute("UPDATE Comics SET LatestDate='Unknown' WHERE LatestDate='None' or LatestDate is NULL")
|
||||||
|
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
c.close()
|
c.close()
|
||||||
|
@ -1815,7 +1828,7 @@ def csv_load():
|
||||||
shutil.copy(os.path.join(DATA_DIR,"custom_exceptions_sample.csv"), EXCEPTIONS_FILE)
|
shutil.copy(os.path.join(DATA_DIR,"custom_exceptions_sample.csv"), EXCEPTIONS_FILE)
|
||||||
except (OSError,IOError):
|
except (OSError,IOError):
|
||||||
logger.error('Cannot create custom_exceptions.csv in ' + str(DATA_DIR) + '. Make sure _sample.csv is present and/or check permissions.')
|
logger.error('Cannot create custom_exceptions.csv in ' + str(DATA_DIR) + '. Make sure _sample.csv is present and/or check permissions.')
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
logger.error('Could not locate ' + str(EXCEPTIONS[i]) + ' file. Make sure it is in datadir: ' + DATA_DIR)
|
logger.error('Could not locate ' + str(EXCEPTIONS[i]) + ' file. Make sure it is in datadir: ' + DATA_DIR)
|
||||||
break
|
break
|
||||||
|
@ -1839,7 +1852,7 @@ def csv_load():
|
||||||
i+=1
|
i+=1
|
||||||
|
|
||||||
conn.commit()
|
conn.commit()
|
||||||
c.close()
|
c.close()
|
||||||
|
|
||||||
#def halt():
|
#def halt():
|
||||||
# global __INITIALIZED__, dbUpdateScheduler, seachScheduler, RSSScheduler, WeeklyScheduler, \
|
# global __INITIALIZED__, dbUpdateScheduler, seachScheduler, RSSScheduler, WeeklyScheduler, \
|
||||||
|
@ -1904,7 +1917,7 @@ def shutdown(restart=False, update=False):
|
||||||
cherrypy.engine.exit()
|
cherrypy.engine.exit()
|
||||||
|
|
||||||
SCHED.shutdown(wait=False)
|
SCHED.shutdown(wait=False)
|
||||||
|
|
||||||
config_write()
|
config_write()
|
||||||
|
|
||||||
if not restart and not update:
|
if not restart and not update:
|
||||||
|
@ -1914,12 +1927,12 @@ def shutdown(restart=False, update=False):
|
||||||
try:
|
try:
|
||||||
versioncheck.update()
|
versioncheck.update()
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.warn('Mylar failed to update: %s. Restarting.' % e)
|
logger.warn('Mylar failed to update: %s. Restarting.' % e)
|
||||||
|
|
||||||
if CREATEPID:
|
if CREATEPID:
|
||||||
logger.info('Removing pidfile %s' % PIDFILE)
|
logger.info('Removing pidfile %s' % PIDFILE)
|
||||||
os.remove(PIDFILE)
|
os.remove(PIDFILE)
|
||||||
|
|
||||||
if restart:
|
if restart:
|
||||||
logger.info('Mylar is restarting...')
|
logger.info('Mylar is restarting...')
|
||||||
popen_list = [sys.executable, FULL_PATH]
|
popen_list = [sys.executable, FULL_PATH]
|
||||||
|
@ -1928,5 +1941,5 @@ def shutdown(restart=False, update=False):
|
||||||
popen_list += ['--nolaunch']
|
popen_list += ['--nolaunch']
|
||||||
logger.info('Restarting Mylar with ' + str(popen_list))
|
logger.info('Restarting Mylar with ' + str(popen_list))
|
||||||
subprocess.Popen(popen_list, cwd=os.getcwd())
|
subprocess.Popen(popen_list, cwd=os.getcwd())
|
||||||
|
|
||||||
os._exit(0)
|
os._exit(0)
|
||||||
|
|
202
mylar/api.py
202
mylar/api.py
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# This file is part of Mylar.
|
# This file is part of Mylar.
|
||||||
#
|
#
|
||||||
# Mylar is free software: you can redistribute it and/or modify
|
# Mylar is free software: you can redistribute it and/or modify
|
||||||
|
@ -14,35 +17,35 @@
|
||||||
# along with Mylar. If not, see <http://www.gnu.org/licenses/>.
|
# along with Mylar. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import mylar
|
import mylar
|
||||||
|
from mylar import db, importer, search, PostProcessor, versioncheck, logger
|
||||||
from mylar import db, mb, importer, search, PostProcessor, versioncheck, logger
|
|
||||||
|
|
||||||
import lib.simplejson as simplejson
|
import lib.simplejson as simplejson
|
||||||
from xml.dom.minidom import Document
|
import cherrypy
|
||||||
import copy
|
import os
|
||||||
|
import urllib2
|
||||||
|
import cache
|
||||||
|
import imghdr
|
||||||
|
from cherrypy.lib.static import serve_file
|
||||||
|
|
||||||
cmd_list = [ 'getIndex', 'getComic', 'getComic', 'getUpcoming', 'getWanted', 'getHistory', 'getLogs',
|
cmd_list = ['getIndex', 'getComic', 'getUpcoming', 'getWanted', 'getHistory', 'getLogs',
|
||||||
'findComic', 'findIssue', 'addComic', 'delComic', 'pauseComic', 'resumeComic', 'refreshComic',
|
'findComic', 'findIssue', 'addComic', 'delComic', 'pauseComic', 'resumeComic', 'refreshComic',
|
||||||
'addIssue', 'queueIssue', 'unqueueIssue', 'forceSearch', 'forceProcess', 'getVersion', 'checkGithub',
|
'addIssue', 'queueIssue', 'unqueueIssue', 'forceSearch', 'forceProcess', 'getVersion', 'checkGithub',
|
||||||
'shutdown', 'restart', 'update', 'getComicInfo', 'getIssueInfo']
|
'shutdown', 'restart', 'update', 'getComicInfo', 'getIssueInfo', 'getArt']
|
||||||
|
|
||||||
|
|
||||||
class Api(object):
|
class Api(object):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
||||||
self.apikey = None
|
self.apikey = None
|
||||||
self.cmd = None
|
self.cmd = None
|
||||||
self.id = None
|
self.id = None
|
||||||
|
self.img = None
|
||||||
self.kwargs = None
|
self.kwargs = None
|
||||||
|
|
||||||
self.data = None
|
self.data = None
|
||||||
|
|
||||||
self.callback = None
|
self.callback = None
|
||||||
|
|
||||||
|
|
||||||
def checkParams(self,*args,**kwargs):
|
def checkParams(self,*args,**kwargs):
|
||||||
|
|
||||||
if not mylar.API_ENABLED:
|
if not mylar.API_ENABLED:
|
||||||
self.data = 'API not enabled'
|
self.data = 'API not enabled'
|
||||||
return
|
return
|
||||||
|
@ -52,193 +55,197 @@ class Api(object):
|
||||||
if len(mylar.API_KEY) != 32:
|
if len(mylar.API_KEY) != 32:
|
||||||
self.data = 'API key not generated correctly'
|
self.data = 'API key not generated correctly'
|
||||||
return
|
return
|
||||||
|
|
||||||
if 'apikey' not in kwargs:
|
if 'apikey' not in kwargs:
|
||||||
self.data = 'Missing api key'
|
self.data = 'Missing api key'
|
||||||
return
|
return
|
||||||
|
|
||||||
if kwargs['apikey'] != mylar.API_KEY:
|
if kwargs['apikey'] != mylar.API_KEY:
|
||||||
self.data = 'Incorrect API key'
|
self.data = 'Incorrect API key'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.apikey = kwargs.pop('apikey')
|
self.apikey = kwargs.pop('apikey')
|
||||||
|
|
||||||
if 'cmd' not in kwargs:
|
if 'cmd' not in kwargs:
|
||||||
self.data = 'Missing parameter: cmd'
|
self.data = 'Missing parameter: cmd'
|
||||||
return
|
return
|
||||||
|
|
||||||
if kwargs['cmd'] not in cmd_list:
|
if kwargs['cmd'] not in cmd_list:
|
||||||
self.data = 'Unknown command: %s' % kwargs['cmd']
|
self.data = 'Unknown command: %s' % kwargs['cmd']
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.cmd = kwargs.pop('cmd')
|
self.cmd = kwargs.pop('cmd')
|
||||||
|
|
||||||
self.kwargs = kwargs
|
self.kwargs = kwargs
|
||||||
self.data = 'OK'
|
self.data = 'OK'
|
||||||
|
|
||||||
def fetchData(self):
|
def fetchData(self):
|
||||||
|
|
||||||
if self.data == 'OK':
|
if self.data == 'OK':
|
||||||
logger.info('Recieved API command: ' + self.cmd)
|
logger.info('Recieved API command: ' + self.cmd)
|
||||||
methodToCall = getattr(self, "_" + self.cmd)
|
methodToCall = getattr(self, "_" + self.cmd)
|
||||||
result = methodToCall(**self.kwargs)
|
result = methodToCall(**self.kwargs)
|
||||||
if 'callback' not in self.kwargs:
|
if 'callback' not in self.kwargs:
|
||||||
|
if self.img:
|
||||||
|
return serve_file(path=self.img, content_type='image/jpeg')
|
||||||
if type(self.data) == type(''):
|
if type(self.data) == type(''):
|
||||||
return self.data
|
return self.data
|
||||||
else:
|
else:
|
||||||
|
cherrypy.response.headers['Content-Type'] = "application/json"
|
||||||
return simplejson.dumps(self.data)
|
return simplejson.dumps(self.data)
|
||||||
else:
|
else:
|
||||||
self.callback = self.kwargs['callback']
|
self.callback = self.kwargs['callback']
|
||||||
self.data = simplejson.dumps(self.data)
|
self.data = simplejson.dumps(self.data)
|
||||||
self.data = self.callback + '(' + self.data + ');'
|
self.data = self.callback + '(' + self.data + ');'
|
||||||
|
cherrypy.response.headers['Content-Type'] = "application/javascript"
|
||||||
return self.data
|
return self.data
|
||||||
else:
|
else:
|
||||||
return self.data
|
return self.data
|
||||||
|
|
||||||
def _dic_from_query(self,query):
|
def _dic_from_query(self,query):
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
rows = myDB.select(query)
|
rows = myDB.select(query)
|
||||||
|
|
||||||
rows_as_dic = []
|
rows_as_dic = []
|
||||||
|
|
||||||
for row in rows:
|
for row in rows:
|
||||||
row_as_dic = dict(zip(row.keys(), row))
|
row_as_dic = dict(zip(row.keys(), row))
|
||||||
rows_as_dic.append(row_as_dic)
|
rows_as_dic.append(row_as_dic)
|
||||||
|
|
||||||
return rows_as_dic
|
return rows_as_dic
|
||||||
|
|
||||||
def _getIndex(self, **kwargs):
|
def _getIndex(self, **kwargs):
|
||||||
|
|
||||||
self.data = self._dic_from_query('SELECT * from comics order by ComicSortName COLLATE NOCASE')
|
self.data = self._dic_from_query('SELECT * from comics order by ComicSortName COLLATE NOCASE')
|
||||||
return
|
return
|
||||||
|
|
||||||
def _getComic(self, **kwargs):
|
def _getComic(self, **kwargs):
|
||||||
|
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
comic = self._dic_from_query('SELECT * from comics WHERE ComicID="' + self.id + '"')
|
comic = self._dic_from_query('SELECT * from comics WHERE ComicID="' + self.id + '"')
|
||||||
issues = self._dic_from_query('SELECT * from issues WHERE ComicID="' + self.id + '"order by Int_IssueNumber DESC')
|
issues = self._dic_from_query('SELECT * from issues WHERE ComicID="' + self.id + '"order by Int_IssueNumber DESC')
|
||||||
if mylar.ANNUALS_ON:
|
if mylar.ANNUALS_ON:
|
||||||
annuals = self._dic_from_query('SELECT * FROM annuals WHERE ComicID="' + self.id + '"')
|
annuals = self._dic_from_query('SELECT * FROM annuals WHERE ComicID="' + self.id + '"')
|
||||||
else: annuals = None
|
else: annuals = None
|
||||||
|
|
||||||
self.data = { 'comic': comic, 'issues': issues, 'annuals': annuals }
|
self.data = { 'comic': comic, 'issues': issues, 'annuals': annuals }
|
||||||
return
|
return
|
||||||
|
|
||||||
def _getHistory(self, **kwargs):
|
def _getHistory(self, **kwargs):
|
||||||
self.data = self._dic_from_query('SELECT * from snatched order by DateAdded DESC')
|
self.data = self._dic_from_query('SELECT * from snatched order by DateAdded DESC')
|
||||||
return
|
return
|
||||||
|
|
||||||
def _getUpcoming(self, **kwargs):
|
def _getUpcoming(self, **kwargs):
|
||||||
self.data = self._dic_from_query("SELECT * from upcoming WHERE IssueID is NULL order by IssueDate DESC")
|
self.data = self._dic_from_query("SELECT * from upcoming WHERE IssueID is NULL order by IssueDate DESC")
|
||||||
return
|
return
|
||||||
|
|
||||||
def _getWanted(self, **kwargs):
|
def _getWanted(self, **kwargs):
|
||||||
self.data = self._dic_from_query("SELECT * from issues WHERE Status='Wanted'")
|
self.data = self._dic_from_query("SELECT * from issues WHERE Status='Wanted'")
|
||||||
return
|
return
|
||||||
|
|
||||||
def _getLogs(self, **kwargs):
|
def _getLogs(self, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _delComic(self, **kwargs):
|
def _delComic(self, **kwargs):
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
myDB.action('DELETE from comics WHERE ComicID="' + self.id + '"')
|
myDB.action('DELETE from comics WHERE ComicID="' + self.id + '"')
|
||||||
myDB.action('DELETE from issues WHERE ComicID="' + self.id + '"')
|
myDB.action('DELETE from issues WHERE ComicID="' + self.id + '"')
|
||||||
myDB.action('DELETE from upcoming WHERE ComicID="' + self.id + '"')
|
myDB.action('DELETE from upcoming WHERE ComicID="' + self.id + '"')
|
||||||
|
|
||||||
def _pauseComic(self, **kwargs):
|
def _pauseComic(self, **kwargs):
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
controlValueDict = {'ComicID': self.id}
|
controlValueDict = {'ComicID': self.id}
|
||||||
newValueDict = {'Status': 'Paused'}
|
newValueDict = {'Status': 'Paused'}
|
||||||
myDB.upsert("comics", newValueDict, controlValueDict)
|
myDB.upsert("comics", newValueDict, controlValueDict)
|
||||||
|
|
||||||
def _resumeComic(self, **kwargs):
|
def _resumeComic(self, **kwargs):
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
controlValueDict = {'ComicID': self.id}
|
controlValueDict = {'ComicID': self.id}
|
||||||
newValueDict = {'Status': 'Active'}
|
newValueDict = {'Status': 'Active'}
|
||||||
myDB.upsert("comics", newValueDict, controlValueDict)
|
myDB.upsert("comics", newValueDict, controlValueDict)
|
||||||
|
|
||||||
def _refreshComic(self, **kwargs):
|
def _refreshComic(self, **kwargs):
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
importer.addComictoDB(self.id)
|
importer.addComictoDB(self.id)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.data = e
|
self.data = e
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _addComic(self, **kwargs):
|
def _addComic(self, **kwargs):
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
try:
|
try:
|
||||||
importer.addReleaseById(self.id)
|
importer.addReleaseById(self.id)
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
self.data = e
|
self.data = e
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def _queueIssue(self, **kwargs):
|
def _queueIssue(self, **kwargs):
|
||||||
|
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
controlValueDict = {'IssueID': self.id}
|
controlValueDict = {'IssueID': self.id}
|
||||||
newValueDict = {'Status': 'Wanted'}
|
newValueDict = {'Status': 'Wanted'}
|
||||||
myDB.upsert("issues", newValueDict, controlValueDict)
|
myDB.upsert("issues", newValueDict, controlValueDict)
|
||||||
search.searchforissue(self.id)
|
search.searchforissue(self.id)
|
||||||
|
|
||||||
def _unqueueIssue(self, **kwargs):
|
def _unqueueIssue(self, **kwargs):
|
||||||
|
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
controlValueDict = {'IssueID': self.id}
|
controlValueDict = {'IssueID': self.id}
|
||||||
newValueDict = {'Status': 'Skipped'}
|
newValueDict = {'Status': 'Skipped'}
|
||||||
myDB.upsert("issues", newValueDict, controlValueDict)
|
myDB.upsert("issues", newValueDict, controlValueDict)
|
||||||
|
|
||||||
def _forceSearch(self, **kwargs):
|
def _forceSearch(self, **kwargs):
|
||||||
search.searchforissue()
|
search.searchforissue()
|
||||||
|
|
||||||
def _forceProcess(self, **kwargs):
|
def _forceProcess(self, **kwargs):
|
||||||
if 'nzb_name' not in kwargs:
|
if 'nzb_name' not in kwargs:
|
||||||
self.data = 'Missing parameter: nzb_name'
|
self.data = 'Missing parameter: nzb_name'
|
||||||
|
@ -253,67 +260,108 @@ class Api(object):
|
||||||
self.nzb_folder = kwargs['nzb_folder']
|
self.nzb_folder = kwargs['nzb_folder']
|
||||||
|
|
||||||
forceProcess = PostProcessor.PostProcessor(self.nzb_name, self.nzb_folder)
|
forceProcess = PostProcessor.PostProcessor(self.nzb_name, self.nzb_folder)
|
||||||
forceProcess.Process()
|
forceProcess.Process()
|
||||||
|
|
||||||
def _getVersion(self, **kwargs):
|
def _getVersion(self, **kwargs):
|
||||||
self.data = {
|
self.data = {
|
||||||
'git_path' : mylar.GIT_PATH,
|
'git_path' : mylar.GIT_PATH,
|
||||||
'install_type' : mylar.INSTALL_TYPE,
|
'install_type' : mylar.INSTALL_TYPE,
|
||||||
'current_version' : mylar.CURRENT_VERSION,
|
'current_version' : mylar.CURRENT_VERSION,
|
||||||
'latest_version' : mylar.LATEST_VERSION,
|
'latest_version' : mylar.LATEST_VERSION,
|
||||||
'commits_behind' : mylar.COMMITS_BEHIND,
|
'commits_behind' : mylar.COMMITS_BEHIND,
|
||||||
}
|
}
|
||||||
|
|
||||||
def _checkGithub(self, **kwargs):
|
def _checkGithub(self, **kwargs):
|
||||||
versioncheck.checkGithub()
|
versioncheck.checkGithub()
|
||||||
self._getVersion()
|
self._getVersion()
|
||||||
|
|
||||||
def _shutdown(self, **kwargs):
|
def _shutdown(self, **kwargs):
|
||||||
mylar.SIGNAL = 'shutdown'
|
mylar.SIGNAL = 'shutdown'
|
||||||
|
|
||||||
def _restart(self, **kwargs):
|
def _restart(self, **kwargs):
|
||||||
mylar.SIGNAL = 'restart'
|
mylar.SIGNAL = 'restart'
|
||||||
|
|
||||||
def _update(self, **kwargs):
|
def _update(self, **kwargs):
|
||||||
mylar.SIGNAL = 'update'
|
mylar.SIGNAL = 'update'
|
||||||
|
|
||||||
def _getArtistArt(self, **kwargs):
|
def _getArtistArt(self, **kwargs):
|
||||||
|
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
self.data = cache.getArtwork(ComicID=self.id)
|
self.data = cache.getArtwork(ComicID=self.id)
|
||||||
|
|
||||||
def _getIssueArt(self, **kwargs):
|
def _getIssueArt(self, **kwargs):
|
||||||
|
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
self.data = cache.getArtwork(IssueID=self.id)
|
self.data = cache.getArtwork(IssueID=self.id)
|
||||||
|
|
||||||
def _getComicInfo(self, **kwargs):
|
def _getComicInfo(self, **kwargs):
|
||||||
|
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
self.data = cache.getInfo(ComicID=self.id)
|
self.data = cache.getInfo(ComicID=self.id)
|
||||||
|
|
||||||
def _getIssueInfo(self, **kwargs):
|
def _getIssueInfo(self, **kwargs):
|
||||||
|
|
||||||
if 'id' not in kwargs:
|
if 'id' not in kwargs:
|
||||||
self.data = 'Missing parameter: id'
|
self.data = 'Missing parameter: id'
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
self.id = kwargs['id']
|
self.id = kwargs['id']
|
||||||
|
|
||||||
self.data = cache.getInfo(IssueID=self.id)
|
self.data = cache.getInfo(IssueID=self.id)
|
||||||
|
|
||||||
|
def _getArt(self, **kwargs):
|
||||||
|
|
||||||
|
if 'id' not in kwargs:
|
||||||
|
self.data = 'Missing parameter: id'
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
self.id = kwargs['id']
|
||||||
|
|
||||||
|
img = None
|
||||||
|
image_path = os.path.join(mylar.CACHE_DIR, str(self.id) + '.jpg')
|
||||||
|
|
||||||
|
# Checks if its a valid path and file
|
||||||
|
if os.path.isfile(image_path):
|
||||||
|
# check if its a valid img
|
||||||
|
if imghdr.what(image_path):
|
||||||
|
self.img = image_path
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# If we cant find the image, lets check the db for a url.
|
||||||
|
comic = self._dic_from_query('SELECT * from comics WHERE ComicID="' + self.id + '"')
|
||||||
|
|
||||||
|
# Try every img url in the db
|
||||||
|
try:
|
||||||
|
img = urllib2.urlopen(comic[0]['ComicImageURL']).read()
|
||||||
|
except:
|
||||||
|
try:
|
||||||
|
img = urllib2.urlopen(comic[0]['ComicImageALTURL']).read()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if img:
|
||||||
|
# verify the img stream
|
||||||
|
if imghdr.what(None, img):
|
||||||
|
with open(image_path, 'wb') as f:
|
||||||
|
f.write(img)
|
||||||
|
self.img = image_path
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
self.data = 'Failed return a image'
|
||||||
|
else:
|
||||||
|
self.data = 'Failed to return a image'
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# This file is part of Mylar.
|
# This file is part of Mylar.
|
||||||
#
|
#
|
||||||
# Mylar is free software: you can redistribute it and/or modify
|
# Mylar is free software: you can redistribute it and/or modify
|
||||||
|
@ -29,11 +32,11 @@ import cherrypy
|
||||||
import mylar
|
import mylar
|
||||||
from mylar import logger, helpers, db, mb, albumart, cv, parseit, filechecker, search, updater, moveit, comicbookdb
|
from mylar import logger, helpers, db, mb, albumart, cv, parseit, filechecker, search, updater, moveit, comicbookdb
|
||||||
|
|
||||||
|
|
||||||
def is_exists(comicid):
|
def is_exists(comicid):
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
|
|
||||||
# See if the artist is already in the database
|
# See if the artist is already in the database
|
||||||
comiclist = myDB.select('SELECT ComicID, ComicName from comics WHERE ComicID=?', [comicid])
|
comiclist = myDB.select('SELECT ComicID, ComicName from comics WHERE ComicID=?', [comicid])
|
||||||
|
|
||||||
|
@ -47,9 +50,9 @@ def is_exists(comicid):
|
||||||
def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,calledfrom=None,annload=None,chkwant=None,issuechk=None,issuetype=None,latestissueinfo=None):
|
def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,calledfrom=None,annload=None,chkwant=None,issuechk=None,issuetype=None,latestissueinfo=None):
|
||||||
# Putting this here to get around the circular import. Will try to use this to update images at later date.
|
# Putting this here to get around the circular import. Will try to use this to update images at later date.
|
||||||
# from mylar import cache
|
# from mylar import cache
|
||||||
|
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
|
|
||||||
# We need the current minimal info in the database instantly
|
# We need the current minimal info in the database instantly
|
||||||
# so we don't throw a 500 error when we redirect to the artistPage
|
# so we don't throw a 500 error when we redirect to the artistPage
|
||||||
|
|
||||||
|
@ -88,8 +91,9 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
if pullupd is None:
|
if pullupd is None:
|
||||||
helpers.ComicSort(comicorder=mylar.COMICSORT, imported=comicid)
|
helpers.ComicSort(comicorder=mylar.COMICSORT, imported=comicid)
|
||||||
|
|
||||||
# we need to lookup the info for the requested ComicID in full now
|
# we need to lookup the info for the requested ComicID in full now
|
||||||
comic = cv.getComic(comicid,'comic')
|
comic = cv.getComic(comicid,'comic')
|
||||||
|
logger.fdebug(comic)
|
||||||
|
|
||||||
if not comic:
|
if not comic:
|
||||||
logger.warn('Error fetching comic. ID for : ' + comicid)
|
logger.warn('Error fetching comic. ID for : ' + comicid)
|
||||||
|
@ -101,12 +105,12 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
newValueDict = {"Status": "Active"}
|
newValueDict = {"Status": "Active"}
|
||||||
myDB.upsert("comics", newValueDict, controlValueDict)
|
myDB.upsert("comics", newValueDict, controlValueDict)
|
||||||
return
|
return
|
||||||
|
|
||||||
if comic['ComicName'].startswith('The '):
|
if comic['ComicName'].startswith('The '):
|
||||||
sortname = comic['ComicName'][4:]
|
sortname = comic['ComicName'][4:]
|
||||||
else:
|
else:
|
||||||
sortname = comic['ComicName']
|
sortname = comic['ComicName']
|
||||||
|
|
||||||
|
|
||||||
logger.info('Now adding/updating: ' + comic['ComicName'])
|
logger.info('Now adding/updating: ' + comic['ComicName'])
|
||||||
#--Now that we know ComicName, let's try some scraping
|
#--Now that we know ComicName, let's try some scraping
|
||||||
|
@ -114,7 +118,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
# gcd will return issue details (most importantly publishing date)
|
# gcd will return issue details (most importantly publishing date)
|
||||||
if not mylar.CV_ONLY:
|
if not mylar.CV_ONLY:
|
||||||
if mismatch == "no" or mismatch is None:
|
if mismatch == "no" or mismatch is None:
|
||||||
gcdinfo=parseit.GCDScraper(comic['ComicName'], comic['ComicYear'], comic['ComicIssues'], comicid)
|
gcdinfo=parseit.GCDScraper(comic['ComicName'], comic['ComicYear'], comic['ComicIssues'], comicid)
|
||||||
#print ("gcdinfo: " + str(gcdinfo))
|
#print ("gcdinfo: " + str(gcdinfo))
|
||||||
mismatch_com = "no"
|
mismatch_com = "no"
|
||||||
if gcdinfo == "No Match":
|
if gcdinfo == "No Match":
|
||||||
|
@ -166,16 +170,16 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
if mylar.ANNUALS_ON:
|
if mylar.ANNUALS_ON:
|
||||||
#we need to check first to see if there are pre-existing annuals that have been manually added, or else they'll get
|
#we need to check first to see if there are pre-existing annuals that have been manually added, or else they'll get
|
||||||
#wiped out.
|
#wiped out.
|
||||||
annualids = [] #to be used to make sure an ID isn't double-loaded
|
annualids = [] #to be used to make sure an ID isn't double-loaded
|
||||||
|
|
||||||
if annload is None:
|
if annload is None:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
for manchk in annload:
|
for manchk in annload:
|
||||||
if manchk['ReleaseComicID'] is not None or manchk['ReleaseComicID'] is not None: #if it exists, then it's a pre-existing add.
|
if manchk['ReleaseComicID'] is not None or manchk['ReleaseComicID'] is not None: #if it exists, then it's a pre-existing add.
|
||||||
#print str(manchk['ReleaseComicID']), comic['ComicName'], str(SeriesYear), str(comicid)
|
#print str(manchk['ReleaseComicID']), comic['ComicName'], str(SeriesYear), str(comicid)
|
||||||
manualAnnual(manchk['ReleaseComicID'], comic['ComicName'], SeriesYear, comicid)
|
manualAnnual(manchk['ReleaseComicID'], comic['ComicName'], SeriesYear, comicid)
|
||||||
annualids.append(manchk['ReleaseComicID'])
|
annualids.append(manchk['ReleaseComicID'])
|
||||||
|
|
||||||
annualcomicname = re.sub('[\,\:]', '', comic['ComicName'])
|
annualcomicname = re.sub('[\,\:]', '', comic['ComicName'])
|
||||||
|
|
||||||
|
@ -203,7 +207,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
#print "annissues :" + str(annissues)
|
#print "annissues :" + str(annissues)
|
||||||
|
|
||||||
# annuals happen once / year. determine how many.
|
# annuals happen once / year. determine how many.
|
||||||
annualyear = SeriesYear # no matter what, the year won't be less than this.
|
annualyear = SeriesYear # no matter what, the year won't be less than this.
|
||||||
#if annualval['AnnualYear'] is None:
|
#if annualval['AnnualYear'] is None:
|
||||||
# sresults = mb.findComic(annComicName, mode, issue=annissues)
|
# sresults = mb.findComic(annComicName, mode, issue=annissues)
|
||||||
#else:
|
#else:
|
||||||
|
@ -294,7 +298,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
logger.fdebug('[IMPORTER-ANNUAL] - ' + str(annualyear) + ' is less than ' + str(sr['comicyear']))
|
logger.fdebug('[IMPORTER-ANNUAL] - ' + str(annualyear) + ' is less than ' + str(sr['comicyear']))
|
||||||
if int(sr['issues']) > (2013 - int(sr['comicyear'])):
|
if int(sr['issues']) > (2013 - int(sr['comicyear'])):
|
||||||
logger.fdebug('[IMPORTER-ANNUAL] - Issue count is wrong')
|
logger.fdebug('[IMPORTER-ANNUAL] - Issue count is wrong')
|
||||||
|
|
||||||
#newCtrl = {"IssueID": issueid}
|
#newCtrl = {"IssueID": issueid}
|
||||||
#newVals = {"Issue_Number": annualval['AnnualIssue'],
|
#newVals = {"Issue_Number": annualval['AnnualIssue'],
|
||||||
# "IssueDate": annualval['AnnualDate'],
|
# "IssueDate": annualval['AnnualDate'],
|
||||||
|
@ -325,7 +329,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
chunk_f_f = re.sub('\$VolumeN','',mylar.FILE_FORMAT)
|
chunk_f_f = re.sub('\$VolumeN','',mylar.FILE_FORMAT)
|
||||||
chunk_f = re.compile(r'\s+')
|
chunk_f = re.compile(r'\s+')
|
||||||
mylar.FILE_FORMAT = chunk_f.sub(' ', chunk_f_f)
|
mylar.FILE_FORMAT = chunk_f.sub(' ', chunk_f_f)
|
||||||
|
|
||||||
#do work to generate folder path
|
#do work to generate folder path
|
||||||
|
|
||||||
values = {'$Series': series,
|
values = {'$Series': series,
|
||||||
|
@ -397,7 +401,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
#thisci = urllib.quote_plus(str(comic['ComicImage']))
|
#thisci = urllib.quote_plus(str(comic['ComicImage']))
|
||||||
|
|
||||||
#urllib.urlretrieve(str(thisci), str(coverfile))
|
#urllib.urlretrieve(str(thisci), str(coverfile))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cimage = re.sub('[\+]','%20', comic['ComicImage'])
|
cimage = re.sub('[\+]','%20', comic['ComicImage'])
|
||||||
request = urllib2.Request(cimage)#, headers={'Content-Type': 'application/x-www-form-urlencoded'})
|
request = urllib2.Request(cimage)#, headers={'Content-Type': 'application/x-www-form-urlencoded'})
|
||||||
|
@ -430,7 +434,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
|
|
||||||
logger.info('Successfully retrieved cover for ' + comic['ComicName'])
|
logger.info('Successfully retrieved cover for ' + comic['ComicName'])
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
logger.warn('[%s] Error fetching data using : %s' % (e, comic['ComicImageALT']))
|
logger.warn('[%s] Error fetching data using : %s' % (e, comic['ComicImageALT']))
|
||||||
|
|
||||||
PRComicImage = os.path.join('cache',str(comicid) + ".jpg")
|
PRComicImage = os.path.join('cache',str(comicid) + ".jpg")
|
||||||
ComicImage = helpers.replacetheslash(PRComicImage)
|
ComicImage = helpers.replacetheslash(PRComicImage)
|
||||||
|
@ -469,6 +473,8 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
"ComicName_Filesafe": comicname_filesafe,
|
"ComicName_Filesafe": comicname_filesafe,
|
||||||
"ComicYear": SeriesYear,
|
"ComicYear": SeriesYear,
|
||||||
"ComicImage": ComicImage,
|
"ComicImage": ComicImage,
|
||||||
|
"ComicImageURL": comic.get("ComicImage", ""),
|
||||||
|
"ComicImageALTURL": comic.get("ComicImageALT", ""),
|
||||||
"Total": comicIssues,
|
"Total": comicIssues,
|
||||||
"ComicVersion": comicVol,
|
"ComicVersion": comicVol,
|
||||||
"ComicLocation": comlocation,
|
"ComicLocation": comlocation,
|
||||||
|
@ -479,7 +485,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
"ComicPublished": "Unknown",
|
"ComicPublished": "Unknown",
|
||||||
"DateAdded": helpers.today(),
|
"DateAdded": helpers.today(),
|
||||||
"Status": "Loading"}
|
"Status": "Loading"}
|
||||||
|
|
||||||
myDB.upsert("comics", newValueDict, controlValueDict)
|
myDB.upsert("comics", newValueDict, controlValueDict)
|
||||||
|
|
||||||
#comicsort here...
|
#comicsort here...
|
||||||
|
@ -496,7 +502,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
logger.info('Sucessfully retrieved issue details for ' + comic['ComicName'] )
|
logger.info('Sucessfully retrieved issue details for ' + comic['ComicName'] )
|
||||||
|
|
||||||
#move to own function so can call independently to only refresh issue data
|
#move to own function so can call independently to only refresh issue data
|
||||||
#issued is from cv.getComic, comic['ComicName'] & comicid would both be already known to do independent call.
|
#issued is from cv.getComic, comic['ComicName'] & comicid would both be already known to do independent call.
|
||||||
issuedata = updateissuedata(comicid, comic['ComicName'], issued, comicIssues, calledfrom, SeriesYear=SeriesYear, latestissueinfo=latestissueinfo)
|
issuedata = updateissuedata(comicid, comic['ComicName'], issued, comicIssues, calledfrom, SeriesYear=SeriesYear, latestissueinfo=latestissueinfo)
|
||||||
if issuedata is None:
|
if issuedata is None:
|
||||||
logger.warn('Unable to complete Refreshing / Adding issue data - this WILL create future problems if not addressed.')
|
logger.warn('Unable to complete Refreshing / Adding issue data - this WILL create future problems if not addressed.')
|
||||||
|
@ -506,7 +512,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
if not os.path.exists(os.path.join(comlocation,"cvinfo")) or mylar.CV_ONETIMER:
|
if not os.path.exists(os.path.join(comlocation,"cvinfo")) or mylar.CV_ONETIMER:
|
||||||
with open(os.path.join(comlocation,"cvinfo"),"w") as text_file:
|
with open(os.path.join(comlocation,"cvinfo"),"w") as text_file:
|
||||||
text_file.write(str(comic['ComicURL']))
|
text_file.write(str(comic['ComicURL']))
|
||||||
|
|
||||||
logger.info('Updating complete for: ' + comic['ComicName'])
|
logger.info('Updating complete for: ' + comic['ComicName'])
|
||||||
|
|
||||||
if calledfrom == 'weekly':
|
if calledfrom == 'weekly':
|
||||||
|
@ -565,12 +571,12 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
logger.info('Checking this week pullist for new issues of ' + comic['ComicName'])
|
logger.info('Checking this week pullist for new issues of ' + comic['ComicName'])
|
||||||
if comic['ComicName'] != comicname_filesafe:
|
if comic['ComicName'] != comicname_filesafe:
|
||||||
cn_pull = comicname_filesafe
|
cn_pull = comicname_filesafe
|
||||||
else:
|
else:
|
||||||
cn_pull = comic['ComicName']
|
cn_pull = comic['ComicName']
|
||||||
updater.newpullcheck(ComicName=cn_pull,ComicID=comicid,issue=latestiss)
|
updater.newpullcheck(ComicName=cn_pull,ComicID=comicid,issue=latestiss)
|
||||||
|
|
||||||
#here we grab issues that have been marked as wanted above...
|
#here we grab issues that have been marked as wanted above...
|
||||||
results = []
|
results = []
|
||||||
issresults = myDB.select("SELECT * FROM issues where ComicID=? AND Status='Wanted'", [comicid])
|
issresults = myDB.select("SELECT * FROM issues where ComicID=? AND Status='Wanted'", [comicid])
|
||||||
if issresults:
|
if issresults:
|
||||||
for issr in issresults:
|
for issr in issresults:
|
||||||
|
@ -590,7 +596,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
|
|
||||||
if results:
|
if results:
|
||||||
logger.info('Attempting to grab wanted issues for : ' + comic['ComicName'])
|
logger.info('Attempting to grab wanted issues for : ' + comic['ComicName'])
|
||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
logger.fdebug('Searching for : ' + str(result['Issue_Number']))
|
logger.fdebug('Searching for : ' + str(result['Issue_Number']))
|
||||||
logger.fdebug('Status of : ' + str(result['Status']))
|
logger.fdebug('Status of : ' + str(result['Status']))
|
||||||
|
@ -621,7 +627,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c
|
||||||
|
|
||||||
if imported == 'futurecheck':
|
if imported == 'futurecheck':
|
||||||
logger.info('Returning to Future-Check module to complete the add & remove entry.')
|
logger.info('Returning to Future-Check module to complete the add & remove entry.')
|
||||||
return
|
return
|
||||||
|
|
||||||
if imported == 'yes':
|
if imported == 'yes':
|
||||||
logger.info('Successfully imported : ' + comic['ComicName'])
|
logger.info('Successfully imported : ' + comic['ComicName'])
|
||||||
|
@ -646,7 +652,7 @@ def GCDimport(gcomicid, pullupd=None,imported=None,ogcname=None):
|
||||||
|
|
||||||
# because Comicvine ComicID and GCD ComicID could be identical at some random point, let's distinguish.
|
# because Comicvine ComicID and GCD ComicID could be identical at some random point, let's distinguish.
|
||||||
# CV = comicid, GCD = gcomicid :) (ie. CV=2740, GCD=G3719)
|
# CV = comicid, GCD = gcomicid :) (ie. CV=2740, GCD=G3719)
|
||||||
|
|
||||||
gcdcomicid = gcomicid
|
gcdcomicid = gcomicid
|
||||||
myDB = db.DBConnection()
|
myDB = db.DBConnection()
|
||||||
|
|
||||||
|
@ -706,7 +712,7 @@ def GCDimport(gcomicid, pullupd=None,imported=None,ogcname=None):
|
||||||
logger.info(u"Sucessfully retrieved details for " + ComicName )
|
logger.info(u"Sucessfully retrieved details for " + ComicName )
|
||||||
# print ("Series Published" + parseit.resultPublished)
|
# print ("Series Published" + parseit.resultPublished)
|
||||||
#--End
|
#--End
|
||||||
|
|
||||||
ComicImage = gcdinfo['ComicImage']
|
ComicImage = gcdinfo['ComicImage']
|
||||||
|
|
||||||
#comic book location on machine
|
#comic book location on machine
|
||||||
|
@ -722,7 +728,7 @@ def GCDimport(gcomicid, pullupd=None,imported=None,ogcname=None):
|
||||||
if '/' in comicdir:
|
if '/' in comicdir:
|
||||||
comicdir = comicdir.replace('/','-')
|
comicdir = comicdir.replace('/','-')
|
||||||
if ',' in comicdir:
|
if ',' in comicdir:
|
||||||
comicdir = comicdir.replace(',','')
|
comicdir = comicdir.replace(',','')
|
||||||
else: comicdir = u_comicname
|
else: comicdir = u_comicname
|
||||||
|
|
||||||
series = comicdir
|
series = comicdir
|
||||||
|
@ -795,7 +801,7 @@ def GCDimport(gcomicid, pullupd=None,imported=None,ogcname=None):
|
||||||
shutil.copy(ComicImage,comiclocal)
|
shutil.copy(ComicImage,comiclocal)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
logger.error(u"Unable to save cover locally at this time.")
|
logger.error(u"Unable to save cover locally at this time.")
|
||||||
|
|
||||||
#if comic['ComicVersion'].isdigit():
|
#if comic['ComicVersion'].isdigit():
|
||||||
# comicVol = "v" + comic['ComicVersion']
|
# comicVol = "v" + comic['ComicVersion']
|
||||||
#else:
|
#else:
|
||||||
|
@ -810,6 +816,8 @@ def GCDimport(gcomicid, pullupd=None,imported=None,ogcname=None):
|
||||||
"ComicLocation": comlocation,
|
"ComicLocation": comlocation,
|
||||||
#"ComicVersion": comicVol,
|
#"ComicVersion": comicVol,
|
||||||
"ComicImage": ComicImage,
|
"ComicImage": ComicImage,
|
||||||
|
"ComicImageURL": comic.get('ComicImage', ''),
|
||||||
|
"ComicImageALTURL": comic.get('ComicImageALT', ''),
|
||||||
#"ComicPublisher": comic['ComicPublisher'],
|
#"ComicPublisher": comic['ComicPublisher'],
|
||||||
#"ComicPublished": comicPublished,
|
#"ComicPublished": comicPublished,
|
||||||
"DateAdded": helpers.today(),
|
"DateAdded": helpers.today(),
|
||||||
|
@ -890,7 +898,7 @@ def GCDimport(gcomicid, pullupd=None,imported=None,ogcname=None):
|
||||||
|
|
||||||
#adjust for inconsistencies in GCD date format - some dates have ? which borks up things.
|
#adjust for inconsistencies in GCD date format - some dates have ? which borks up things.
|
||||||
if "?" in str(issdate):
|
if "?" in str(issdate):
|
||||||
issdate = "0000-00-00"
|
issdate = "0000-00-00"
|
||||||
|
|
||||||
controlValueDict = {"IssueID": issid}
|
controlValueDict = {"IssueID": issid}
|
||||||
newValueDict = {"ComicID": gcomicid,
|
newValueDict = {"ComicID": gcomicid,
|
||||||
|
@ -985,7 +993,7 @@ def issue_collection(issuedata,nostatus):
|
||||||
nowdate = datetime.datetime.now()
|
nowdate = datetime.datetime.now()
|
||||||
nowtime = nowdate.strftime("%Y%m%d")
|
nowtime = nowdate.strftime("%Y%m%d")
|
||||||
|
|
||||||
if issuedata:
|
if issuedata:
|
||||||
for issue in issuedata:
|
for issue in issuedata:
|
||||||
|
|
||||||
|
|
||||||
|
@ -1128,7 +1136,7 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
|
||||||
return
|
return
|
||||||
|
|
||||||
# poll against annuals here - to make sure annuals are uptodate.
|
# poll against annuals here - to make sure annuals are uptodate.
|
||||||
weeklyissue_check = annual_check(comicname, SeriesYear, comicid, issuetype, issuechk, weeklyissue_check)
|
weeklyissue_check = annual_check(comicname, SeriesYear, comicid, issuetype, issuechk, weeklyissue_check)
|
||||||
if weeklyissue_check is None:
|
if weeklyissue_check is None:
|
||||||
weeklyissue_check = []
|
weeklyissue_check = []
|
||||||
logger.fdebug('Finshed Annual checking.')
|
logger.fdebug('Finshed Annual checking.')
|
||||||
|
@ -1169,7 +1177,7 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
|
||||||
if issnum.isdigit():
|
if issnum.isdigit():
|
||||||
int_issnum = int( issnum ) * 1000
|
int_issnum = int( issnum ) * 1000
|
||||||
else:
|
else:
|
||||||
if 'a.i.' in issnum.lower() or 'ai' in issnum.lower():
|
if 'a.i.' in issnum.lower() or 'ai' in issnum.lower():
|
||||||
issnum = re.sub('\.', '', issnum)
|
issnum = re.sub('\.', '', issnum)
|
||||||
#int_issnum = (int(issnum[:-2]) * 1000) + ord('a') + ord('i')
|
#int_issnum = (int(issnum[:-2]) * 1000) + ord('a') + ord('i')
|
||||||
if 'au' in issnum.lower():
|
if 'au' in issnum.lower():
|
||||||
|
@ -1343,7 +1351,7 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
|
||||||
|
|
||||||
n_date = datetime.date.today()
|
n_date = datetime.date.today()
|
||||||
recentchk = (n_date - c_date).days
|
recentchk = (n_date - c_date).days
|
||||||
|
|
||||||
if recentchk <= 55:
|
if recentchk <= 55:
|
||||||
lastpubdate = 'Present'
|
lastpubdate = 'Present'
|
||||||
else:
|
else:
|
||||||
|
@ -1356,7 +1364,7 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
|
||||||
latestiss = latestissueinfo[0]['latestiss']
|
latestiss = latestissueinfo[0]['latestiss']
|
||||||
lastpubdate = 'Present'
|
lastpubdate = 'Present'
|
||||||
publishfigure = str(SeriesYear) + ' - ' + str(lastpubdate)
|
publishfigure = str(SeriesYear) + ' - ' + str(lastpubdate)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
controlValueStat = {"ComicID": comicid}
|
controlValueStat = {"ComicID": comicid}
|
||||||
|
@ -1461,7 +1469,7 @@ def annual_check(ComicName, SeriesYear, comicid, issuetype, issuechk, weeklyissu
|
||||||
except IndexError:
|
except IndexError:
|
||||||
break
|
break
|
||||||
try:
|
try:
|
||||||
cleanname = helpers.cleanName(firstval['Issue_Name'])
|
cleanname = helpers.cleanName(firstval['Issue_Name'])
|
||||||
except:
|
except:
|
||||||
cleanname = 'None'
|
cleanname = 'None'
|
||||||
issid = str(firstval['Issue_ID'])
|
issid = str(firstval['Issue_ID'])
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# This file is part of Headphones.
|
# This file is part of Headphones.
|
||||||
#
|
#
|
||||||
# Headphones is free software: you can redistribute it and/or modify
|
# Headphones is free software: you can redistribute it and/or modify
|
||||||
|
@ -76,7 +79,7 @@ def initialize(options):
|
||||||
|
|
||||||
conf = {
|
conf = {
|
||||||
'/': {
|
'/': {
|
||||||
'tools.staticdir.root': os.path.join(mylar.PROG_DIR, 'data')
|
'tools.staticdir.root': os.path.join(mylar.PROG_DIR, 'data')
|
||||||
},
|
},
|
||||||
'/interfaces':{
|
'/interfaces':{
|
||||||
'tools.staticdir.on': True,
|
'tools.staticdir.on': True,
|
||||||
|
@ -100,10 +103,11 @@ def initialize(options):
|
||||||
},
|
},
|
||||||
'/cache':{
|
'/cache':{
|
||||||
'tools.staticdir.on': True,
|
'tools.staticdir.on': True,
|
||||||
'tools.staticdir.dir': mylar.CACHE_DIR
|
'tools.staticdir.dir': mylar.CACHE_DIR,
|
||||||
|
'tools.auth_basic.on': False
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if options['http_password'] != "":
|
if options['http_password'] != "":
|
||||||
conf['/'].update({
|
conf['/'].update({
|
||||||
'tools.auth_basic.on': True,
|
'tools.auth_basic.on': True,
|
||||||
|
@ -115,16 +119,14 @@ def initialize(options):
|
||||||
|
|
||||||
# Prevent time-outs
|
# Prevent time-outs
|
||||||
cherrypy.engine.timeout_monitor.unsubscribe()
|
cherrypy.engine.timeout_monitor.unsubscribe()
|
||||||
|
|
||||||
cherrypy.tree.mount(WebInterface(), options['http_root'], config = conf)
|
cherrypy.tree.mount(WebInterface(), options['http_root'], config = conf)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
cherrypy.process.servers.check_port(options['http_host'], options['http_port'])
|
cherrypy.process.servers.check_port(options['http_host'], options['http_port'])
|
||||||
cherrypy.server.start()
|
cherrypy.server.start()
|
||||||
except IOError:
|
except IOError:
|
||||||
print 'Failed to start on port: %i. Is something else running?' % (options['http_port'])
|
print 'Failed to start on port: %i. Is something else running?' % (options['http_port'])
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
cherrypy.server.wait()
|
cherrypy.server.wait()
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue