mirror of
https://github.com/rembo10/headphones.git
synced 2026-05-20 18:45:32 +01:00
Merge branch 'serveroptions'
This commit is contained in:
@@ -432,21 +432,29 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<h3>Muscbrainz Mirror: <select name="mirror"><h3>
|
||||
<h3>Muscbrainz Mirror: <select name="mirror" id="mirror"><h3>
|
||||
%for mirror in config['mirror_list']:
|
||||
<%
|
||||
if mirror == headphones.MIRROR:
|
||||
selected = 'selected="selected"'
|
||||
else:
|
||||
selected = ''
|
||||
if mirror == "localhost":
|
||||
mirrortext = " (use localhost:7143)"
|
||||
else:
|
||||
mirrortext = ''
|
||||
%>
|
||||
<option value="${mirror}" ${selected}>${mirror} ${mirrortext}</option>
|
||||
<option value="${mirror}" ${selected}>${mirror}</option>
|
||||
%endfor
|
||||
</select>
|
||||
|
||||
<div id="customoptions">
|
||||
<h3>Host:<br><input type="text" name="customhost" value="${config['customhost']}" size="20"></h3>
|
||||
<h3>Port:<br><input type="text" name="customport" value="${config['customport']}" size="8"></h3>
|
||||
<h3>Sleep Interval:<br><input type="text" name="customsleep" value="${config['customsleep']}" size="4"></h3>
|
||||
</div>
|
||||
|
||||
<div id="hpserveroptions">
|
||||
<h3>Username:<br><input type="text" name="hpuser" value="${config['hpuser']}" size="20"></h3>
|
||||
<h3>Password:<br><input type="password" name="hppass" value="${config['hppass']}" size="15"></h3>
|
||||
<i class="smalltext2"><a href="http://headphones.codeshy.com">what is this?</a></p>
|
||||
</div>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -457,6 +465,27 @@
|
||||
|
||||
<%def name="javascriptIncludes()">
|
||||
<script>
|
||||
|
||||
hideServerDivs = function () {
|
||||
$("#customoptions").hide("fast");
|
||||
$("#hpserveroptions").hide("fast");
|
||||
};
|
||||
|
||||
handleNewSelection = function () {
|
||||
|
||||
hideServerDivs();
|
||||
|
||||
switch ($(this).val()) {
|
||||
case 'custom':
|
||||
$("#customoptions").show("fast");
|
||||
break;
|
||||
case 'headphones':
|
||||
$("#hpserveroptions").show("fast");
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
$(document).ready(function()
|
||||
{
|
||||
if ($("#encode").is(":checked"))
|
||||
@@ -497,7 +526,12 @@
|
||||
{
|
||||
$("#prowloptions").hide("fast");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#mirror").change(handleNewSelection);
|
||||
handleNewSelection.apply($("#mirror"));
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</%def>
|
||||
|
||||
@@ -134,8 +134,13 @@ PROWL_ENABLED = True
|
||||
PROWL_PRIORITY = 1
|
||||
PROWL_KEYS = None
|
||||
PROWL_ONSNATCH = True
|
||||
MIRRORLIST = ["musicbrainz.org","headphones","tbueter.com","localhost"]
|
||||
MIRRORLIST = ["musicbrainz.org","headphones","tbueter.com","custom"]
|
||||
MIRROR = None
|
||||
CUSTOMHOST = None
|
||||
CUSTOMPORT = None
|
||||
CUSTOMSLEEP = None
|
||||
HPUSER = None
|
||||
HPPASS = None
|
||||
|
||||
def CheckSection(sec):
|
||||
""" Check if INI section exists, if not create it """
|
||||
@@ -197,7 +202,8 @@ def initialize():
|
||||
NZBMATRIX, NZBMATRIX_USERNAME, NZBMATRIX_APIKEY, NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, \
|
||||
NZBSORG, NZBSORG_UID, NZBSORG_HASH, NEWZBIN, NEWZBIN_UID, NEWZBIN_PASSWORD, LASTFM_USERNAME, INTERFACE, FOLDER_PERMISSIONS, \
|
||||
ENCODERFOLDER, ENCODER, BITRATE, SAMPLINGFREQUENCY, ENCODE, ADVANCEDENCODER, ENCODEROUTPUTFORMAT, ENCODERQUALITY, ENCODERVBRCBR, \
|
||||
ENCODERLOSSLESS, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, MIRRORLIST, MIRROR
|
||||
ENCODERLOSSLESS, PROWL_ENABLED, PROWL_PRIORITY, PROWL_KEYS, PROWL_ONSNATCH, MIRRORLIST, MIRROR, CUSTOMHOST, CUSTOMPORT, \
|
||||
CUSTOMSLEEP, HPUSER, HPPASS
|
||||
|
||||
if __INITIALIZED__:
|
||||
return False
|
||||
@@ -304,6 +310,11 @@ def initialize():
|
||||
PROWL_PRIORITY = check_setting_int(CFG, 'Prowl', 'prowl_priority', 0)
|
||||
|
||||
MIRROR = check_setting_str(CFG, 'General', 'mirror', 'headphones')
|
||||
CUSTOMHOST = check_setting_str(CFG, 'General', 'customhost', 'localhost')
|
||||
CUSTOMPORT = check_setting_int(CFG, 'General', 'customport', 5000)
|
||||
CUSTOMSLEEP = check_setting_int(CFG, 'General', 'customsleep', 1)
|
||||
HPUSER = check_setting_str(CFG, 'General', 'hpuser', 'username')
|
||||
HPPASS = check_setting_str(CFG, 'General', 'hppass', 'password')
|
||||
|
||||
if not LOG_DIR:
|
||||
LOG_DIR = os.path.join(DATA_DIR, 'logs')
|
||||
@@ -507,6 +518,11 @@ def config_write():
|
||||
new_config['General']['encoderlossless'] = ENCODERLOSSLESS
|
||||
|
||||
new_config['General']['mirror'] = MIRROR
|
||||
new_config['General']['customhost'] = CUSTOMHOST
|
||||
new_config['General']['customport'] = CUSTOMPORT
|
||||
new_config['General']['customsleep'] = CUSTOMSLEEP
|
||||
new_config['General']['hpuser'] = HPUSER
|
||||
new_config['General']['hppass'] = HPPASS
|
||||
|
||||
new_config.write()
|
||||
|
||||
|
||||
@@ -19,19 +19,25 @@ mb_lock = threading.Lock()
|
||||
# Quick fix to add mirror switching on the fly. Need to probably return the mbhost & mbport that's
|
||||
# being used, so we can send those values to the log
|
||||
def startmb(forcemb=False):
|
||||
|
||||
# just in case someone switches to the headphones server mid-query
|
||||
hpuser=None
|
||||
hppass=None
|
||||
|
||||
if forcemb or headphones.MIRROR == "musicbrainz.org":
|
||||
mbhost = "musicbrainz.org"
|
||||
mbport = 80
|
||||
sleepytime = 1
|
||||
elif headphones.MIRROR == "localhost":
|
||||
mbhost = "localhost"
|
||||
mbport = 7143
|
||||
sleepytime = 0
|
||||
elif headphones.MIRROR == "custom":
|
||||
mbhost = headphones.CUSTOMHOST
|
||||
mbport = headphones.CUSTOMPORT
|
||||
sleepytime = headphones.CUSTOMSLEEP
|
||||
elif headphones.MIRROR == "headphones":
|
||||
mbhost = "178.63.142.150"
|
||||
mbport = 5000
|
||||
sleepytime = 0
|
||||
hpuser = headphones.HPUSER
|
||||
hppass = headphones.HPPASS
|
||||
else:
|
||||
mbhost = "tbueter.com"
|
||||
mbport = 5000
|
||||
@@ -40,8 +46,11 @@ def startmb(forcemb=False):
|
||||
service = ws.WebService(host=mbhost, port=mbport)
|
||||
q = ws.Query(service)
|
||||
|
||||
return (q, sleepytime)
|
||||
logger.debug('Using the following server values:\nMBHost: %s ; MBPort: %i ; Sleep Interval: %i ' % (mbhost, mbport, sleepytime))
|
||||
if headphones.MIRROR == "headphones":
|
||||
logger.debug('Headphones Username: %s ; Headphones Password: %s ' % (hpuser, len(hppass) * '*'))
|
||||
|
||||
return (q, sleepytime)
|
||||
|
||||
def findArtist(name, limit=1):
|
||||
|
||||
|
||||
@@ -384,7 +384,12 @@ class WebInterface(object):
|
||||
"prowl_keys": headphones.PROWL_KEYS,
|
||||
"prowl_priority": headphones.PROWL_PRIORITY,
|
||||
"mirror_list": headphones.MIRRORLIST,
|
||||
"mirror": headphones.MIRROR
|
||||
"mirror": headphones.MIRROR,
|
||||
"customhost": headphones.CUSTOMHOST,
|
||||
"customport": headphones.CUSTOMPORT,
|
||||
"customsleep": headphones.CUSTOMSLEEP,
|
||||
"hpuser": headphones.HPUSER,
|
||||
"hppass": headphones.HPPASS
|
||||
}
|
||||
return serve_template(templatename="config.html", title="Settings", config=config)
|
||||
config.exposed = True
|
||||
@@ -397,7 +402,7 @@ class WebInterface(object):
|
||||
torrentblackhole_dir=None, download_torrent_dir=None, numberofseeders=10, use_isohunt=0, use_kat=0, use_mininova=0,
|
||||
rename_files=0, correct_metadata=0, cleanup_files=0, add_album_art=0, embed_album_art=0, embed_lyrics=0, destination_dir=None, folder_format=None, file_format=None, include_extras=0, interface=None, log_dir=None,
|
||||
encode=0, encoder=None, bitrate=None, samplingfrequency=None, encoderfolder=None, advancedencoder=None, encoderoutputformat=None, encodervbrcbr=None, encoderquality=None, encoderlossless=0,
|
||||
prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=0, mirror=None):
|
||||
prowl_enabled=0, prowl_onsnatch=0, prowl_keys=None, prowl_priority=0, mirror=None, customhost=None, customport=None, customsleep=None, hpuser=None, hppass=None):
|
||||
|
||||
headphones.HTTP_HOST = http_host
|
||||
headphones.HTTP_PORT = http_port
|
||||
@@ -462,6 +467,11 @@ class WebInterface(object):
|
||||
headphones.PROWL_KEYS = prowl_keys
|
||||
headphones.PROWL_PRIORITY = prowl_priority
|
||||
headphones.MIRROR = mirror
|
||||
headphones.CUSTOMHOST = customhost
|
||||
headphones.CUSTOMPORT = customport
|
||||
headphones.CUSTOMSLEEP = customsleep
|
||||
headphones.HPUSER = hpuser
|
||||
headphones.HPPASS
|
||||
|
||||
headphones.config_write()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user