Merge branch 'server-update'

This commit is contained in:
rembo10
2012-03-19 09:51:01 +00:00
5 changed files with 73 additions and 24 deletions
+1 -1
View File
@@ -453,7 +453,7 @@
<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>
<i class="smalltext2"><a href="http://headphones.codeshy.com/vip">Get an Account</a></p>
</div>
</table>
</div>
+58 -8
View File
@@ -227,7 +227,7 @@
<tr>
<td>
<br><br><br><br><h2>Torrent:</h2><br>
<h2>Torrent:</h2><br>
</td>
</tr>
@@ -420,17 +420,41 @@
<h3>Path to Encoder:</h3><input type="text" name="encoderfolder" value="${config['encoderfolder']}" size="43">
</div>
</td>
<td>
<h2>Prowl Notification:</h2>
<br>
<h3><input type="checkbox" name="prowl_enabled" id="prowl" value="1" ${config['prowl_enabled']} />Enabled Prowl Notification</h3><br>
<td>
<h2>Prowl Notification:</h2><br>
<h3><input type="checkbox" name="prowl_enabled" id="prowl" value="1" ${config['prowl_enabled']} />Enable Prowl Notifications</h3><br>
<div id="prowloptions">
<h3>API key:</h3><input type="text" name="prowl_keys" value="${config['prowl_keys']}" size="50"><br><br>
<h3>API key:</h3><input type="text" name="prowl_keys" value="${config['prowl_keys']}" size="50"><br><br>
<h3><input type="checkbox" name="prowl_onsnatch" value="1" ${config['prowl_onsnatch']} />Notify on snatch?</h3><br>
<h3>Priority (-2,-1,0,1 or 2):</h3><input type="text" name="prowl_priority" value="${config['prowl_priority']}" size="2">
</div>
</td>
</td>
</tr>
<tr>
<td>
<h3>Muscbrainz Mirror: <select name="mirror" id="mirror"><h3>
%for mirror in config['mirror_list']:
<%
if mirror == headphones.MIRROR:
selected = 'selected="selected"'
else:
selected = ''
%>
<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/vip">Get an Account</a></p>
</div>
</table>
</div>
@@ -441,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"))
@@ -481,7 +526,12 @@
{
$("#prowloptions").hide("fast");
}
});
});
$("#mirror").change(handleNewSelection);
handleNewSelection.apply($("#mirror"));
});
</script>
</%def>
+1 -1
View File
@@ -309,7 +309,7 @@ def initialize():
PROWL_ONSNATCH = bool(check_setting_int(CFG, 'Prowl', 'prowl_onsnatch', 0))
PROWL_PRIORITY = check_setting_int(CFG, 'Prowl', 'prowl_priority', 0)
MIRROR = check_setting_str(CFG, 'General', 'mirror', 'headphones')
MIRROR = check_setting_str(CFG, 'General', 'mirror', 'musicbrainz.org')
CUSTOMHOST = check_setting_str(CFG, 'General', 'customhost', 'localhost')
CUSTOMPORT = check_setting_int(CFG, 'General', 'customport', 5000)
CUSTOMSLEEP = check_setting_int(CFG, 'General', 'customsleep', 1)
+7 -13
View File
@@ -20,9 +20,8 @@ mb_lock = threading.Lock()
# 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
mbuser = None
mbpass = None
if forcemb or headphones.MIRROR == "musicbrainz.org":
mbhost = "musicbrainz.org"
@@ -34,24 +33,19 @@ def startmb(forcemb=False):
sleepytime = headphones.CUSTOMSLEEP
elif headphones.MIRROR == "headphones":
mbhost = "178.63.142.150"
mbport = 5000
mbport = 3333
mbuser = headphones.HPUSER
mbpass = headphones.HPPASS
sleepytime = 0
hpuser = headphones.HPUSER
hppass = headphones.HPPASS
else:
mbhost = "tbueter.com"
mbport = 5000
sleepytime = 0
service = ws.WebService(host=mbhost, port=mbport)
service = ws.WebService(host=mbhost, port=mbport, username=mbuser, password=mbpass, mirror=headphones.MIRROR)
q = ws.Query(service)
logger.debug('Using the following server values:\nMBHost: %s ; MBPort: %i ; Sleep Interval: %i ' % (mbhost, mbport, sleepytime))
if headphones.MIRROR == "headphones" and not forcemb:
try:
logger.debug('Headphones Username: %s ; Headphones Password: %s%s%s' % (hpuser, hppass[0],(len(hppass)-2) * '*', hppass[-1]))
except Exception, e:
logger.debug('Error logging hpuser or hppass: %s. Check your settings' % e)
return (q, sleepytime)
@@ -177,7 +171,7 @@ def getArtist(artistid, extrasonly=False):
artist = q.getArtistById(artistid, inc)
break
except WebServiceError, e:
logger.warn('Attempt to retrieve artist information from MusicBrainz failed for artistid: %s. Sleeping 5 seconds' % artistid)
logger.warn('Attempt to retrieve artist information from MusicBrainz failed for artistid: %s. Sleeping 5 seconds: %s' % (artistid, e))
attempt += 1
time.sleep(5)
+6 -1
View File
@@ -17,6 +17,7 @@ __revision__ = '$Id: webservice.py 12973 2011-04-29 11:49:31Z luks $'
import re
import urllib
import urllib2
import base64
import urlparse
import logging
import os.path
@@ -191,7 +192,7 @@ class WebService(IWebService):
def __init__(self, host='musicbrainz.org', port=80, pathPrefix='/ws',
username=None, password=None, realm='musicbrainz.org',
opener=None):
opener=None, mirror=None):
"""Constructor.
This can be used without parameters. In this case, the
@@ -212,6 +213,7 @@ class WebService(IWebService):
self._realm = realm
self._pathPrefix = pathPrefix
self._log = logging.getLogger(str(self.__class__))
self._mirror = mirror
if opener is None:
self._opener = urllib2.build_opener()
@@ -249,6 +251,9 @@ class WebService(IWebService):
userAgent = 'python-headphones/' + musicbrainz2.__version__
req = urllib2.Request(url)
req.add_header('User-Agent', userAgent)
if self._mirror == 'headphones':
base64string = base64.encodestring('%s:%s' % (self._username, self._password)).replace('\n', '')
req.add_header("Authorization", "Basic %s" % base64string)
return self._opener.open(req, data)