mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-22 08:53:59 +01:00
Initial work on the api - backend stuff to allow api as a config option
This commit is contained in:
@@ -109,6 +109,7 @@ def main():
|
|||||||
'http_root': headphones.HTTP_ROOT,
|
'http_root': headphones.HTTP_ROOT,
|
||||||
'http_username': headphones.HTTP_USERNAME,
|
'http_username': headphones.HTTP_USERNAME,
|
||||||
'http_password': headphones.HTTP_PASSWORD,
|
'http_password': headphones.HTTP_PASSWORD,
|
||||||
|
'api': headphones.API,
|
||||||
})
|
})
|
||||||
|
|
||||||
logger.info('Starting Headphones on port: %i' % http_port)
|
logger.info('Starting Headphones on port: %i' % http_port)
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ HTTP_PASSWORD = None
|
|||||||
HTTP_ROOT = None
|
HTTP_ROOT = None
|
||||||
LAUNCH_BROWSER = False
|
LAUNCH_BROWSER = False
|
||||||
|
|
||||||
|
API_ENABLED = False
|
||||||
|
API_KEY = None
|
||||||
|
|
||||||
GIT_PATH = None
|
GIT_PATH = None
|
||||||
INSTALL_TYPE = None
|
INSTALL_TYPE = None
|
||||||
CURRENT_VERSION = None
|
CURRENT_VERSION = None
|
||||||
@@ -201,7 +204,7 @@ def initialize():
|
|||||||
with INIT_LOCK:
|
with INIT_LOCK:
|
||||||
|
|
||||||
global __INITIALIZED__, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, DATA_DIR, CONFIG_FILE, CFG, LOG_DIR, CACHE_DIR, \
|
global __INITIALIZED__, FULL_PATH, PROG_DIR, VERBOSE, DAEMON, DATA_DIR, CONFIG_FILE, CFG, LOG_DIR, CACHE_DIR, \
|
||||||
HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, LAUNCH_BROWSER, GIT_PATH, \
|
HTTP_PORT, HTTP_HOST, HTTP_USERNAME, HTTP_PASSWORD, HTTP_ROOT, LAUNCH_BROWSER, API_ENABLED, API_KEY, GIT_PATH, \
|
||||||
CURRENT_VERSION, LATEST_VERSION, MUSIC_DIR, DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, \
|
CURRENT_VERSION, LATEST_VERSION, MUSIC_DIR, DESTINATION_DIR, PREFERRED_QUALITY, PREFERRED_BITRATE, DETECT_BITRATE, \
|
||||||
ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, \
|
ADD_ARTISTS, CORRECT_METADATA, MOVE_FILES, RENAME_FILES, FOLDER_FORMAT, FILE_FORMAT, CLEANUP_FILES, INCLUDE_EXTRAS, \
|
||||||
ADD_ALBUM_ART, EMBED_ALBUM_ART, EMBED_LYRICS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \
|
ADD_ALBUM_ART, EMBED_ALBUM_ART, EMBED_LYRICS, DOWNLOAD_DIR, BLACKHOLE, BLACKHOLE_DIR, USENET_RETENTION, SEARCH_INTERVAL, \
|
||||||
@@ -240,6 +243,8 @@ def initialize():
|
|||||||
HTTP_PASSWORD = check_setting_str(CFG, 'General', 'http_password', '')
|
HTTP_PASSWORD = check_setting_str(CFG, 'General', 'http_password', '')
|
||||||
HTTP_ROOT = check_setting_str(CFG, 'General', 'http_root', '/')
|
HTTP_ROOT = check_setting_str(CFG, 'General', 'http_root', '/')
|
||||||
LAUNCH_BROWSER = bool(check_setting_int(CFG, 'General', 'launch_browser', 1))
|
LAUNCH_BROWSER = bool(check_setting_int(CFG, 'General', 'launch_browser', 1))
|
||||||
|
API_ENABLED = bool(check_setting_int(CFG, 'General', 'api_enabled', 0))
|
||||||
|
API_KEY = check_setting_str(CFG, 'General', 'api_key', '')
|
||||||
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', '')
|
||||||
|
|
||||||
@@ -451,6 +456,8 @@ def config_write():
|
|||||||
new_config['General']['http_password'] = HTTP_PASSWORD
|
new_config['General']['http_password'] = HTTP_PASSWORD
|
||||||
new_config['General']['http_root'] = HTTP_ROOT
|
new_config['General']['http_root'] = HTTP_ROOT
|
||||||
new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
|
new_config['General']['launch_browser'] = int(LAUNCH_BROWSER)
|
||||||
|
new_config['General']['api_enabled'] = int(API_ENABLED)
|
||||||
|
new_config['General']['api_key'] = API_KEY
|
||||||
new_config['General']['log_dir'] = LOG_DIR
|
new_config['General']['log_dir'] = LOG_DIR
|
||||||
new_config['General']['git_path'] = GIT_PATH
|
new_config['General']['git_path'] = GIT_PATH
|
||||||
|
|
||||||
|
|||||||
@@ -324,6 +324,8 @@ class WebInterface(object):
|
|||||||
"http_port" : headphones.HTTP_PORT,
|
"http_port" : headphones.HTTP_PORT,
|
||||||
"http_pass" : headphones.HTTP_PASSWORD,
|
"http_pass" : headphones.HTTP_PASSWORD,
|
||||||
"launch_browser" : checked(headphones.LAUNCH_BROWSER),
|
"launch_browser" : checked(headphones.LAUNCH_BROWSER),
|
||||||
|
"api_enabled" : checked(headphones.API_ENABLED),
|
||||||
|
"api_key" : headphones.API_KEY,
|
||||||
"download_scan_interval" : headphones.DOWNLOAD_SCAN_INTERVAL,
|
"download_scan_interval" : headphones.DOWNLOAD_SCAN_INTERVAL,
|
||||||
"nzb_search_interval" : headphones.SEARCH_INTERVAL,
|
"nzb_search_interval" : headphones.SEARCH_INTERVAL,
|
||||||
"libraryscan_interval" : headphones.LIBRARYSCAN_INTERVAL,
|
"libraryscan_interval" : headphones.LIBRARYSCAN_INTERVAL,
|
||||||
@@ -405,7 +407,7 @@ class WebInterface(object):
|
|||||||
config.exposed = True
|
config.exposed = True
|
||||||
|
|
||||||
|
|
||||||
def configUpdate(self, http_host='0.0.0.0', http_username=None, http_port=8181, http_password=None, launch_browser=0, download_scan_interval=None, nzb_search_interval=None, libraryscan_interval=None,
|
def configUpdate(self, http_host='0.0.0.0', http_username=None, http_port=8181, http_password=None, launch_browser=0, api_enabled=0, api_key=None, download_scan_interval=None, nzb_search_interval=None, libraryscan_interval=None,
|
||||||
sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, download_dir=None, blackhole=0, blackhole_dir=None,
|
sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, download_dir=None, blackhole=0, blackhole_dir=None,
|
||||||
usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, newznab=0, newznab_host=None, newznab_apikey=None,
|
usenet_retention=None, nzbmatrix=0, nzbmatrix_username=None, nzbmatrix_apikey=None, newznab=0, newznab_host=None, newznab_apikey=None,
|
||||||
nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None, newzbin_password=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0,
|
nzbsorg=0, nzbsorg_uid=None, nzbsorg_hash=None, newzbin=0, newzbin_uid=None, newzbin_password=None, preferred_quality=0, preferred_bitrate=None, detect_bitrate=0, move_files=0,
|
||||||
@@ -420,6 +422,8 @@ class WebInterface(object):
|
|||||||
headphones.HTTP_USERNAME = http_username
|
headphones.HTTP_USERNAME = http_username
|
||||||
headphones.HTTP_PASSWORD = http_password
|
headphones.HTTP_PASSWORD = http_password
|
||||||
headphones.LAUNCH_BROWSER = launch_browser
|
headphones.LAUNCH_BROWSER = launch_browser
|
||||||
|
headphones.API_ENABLED = api_enabled
|
||||||
|
headphones.API_KEY = api_key
|
||||||
headphones.DOWNLOAD_SCAN_INTERVAL = download_scan_interval
|
headphones.DOWNLOAD_SCAN_INTERVAL = download_scan_interval
|
||||||
headphones.SEARCH_INTERVAL = nzb_search_interval
|
headphones.SEARCH_INTERVAL = nzb_search_interval
|
||||||
headphones.LIBRARYSCAN_INTERVAL = libraryscan_interval
|
headphones.LIBRARYSCAN_INTERVAL = libraryscan_interval
|
||||||
|
|||||||
@@ -44,6 +44,8 @@ def initialize(options={}):
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options['api']:
|
||||||
|
conf['/api'] = {'tools.staticdir.on': True, 'tools.staticdir.dir': "api"}
|
||||||
|
|
||||||
if options['http_password'] != "":
|
if options['http_password'] != "":
|
||||||
conf['/'].update({
|
conf['/'].update({
|
||||||
|
|||||||
Reference in New Issue
Block a user