diff --git a/data/interfaces/default/config.html b/data/interfaces/default/config.html
index b74bd2a9..bb176af5 100644
--- a/data/interfaces/default/config.html
+++ b/data/interfaces/default/config.html
@@ -453,7 +453,7 @@
+
+ Muscbrainz Mirror:
+
+
+ Host:
+ Port:
+ Sleep Interval:
+
+
+
@@ -441,6 +465,27 @@
<%def name="javascriptIncludes()">
%def>
diff --git a/headphones/__init__.py b/headphones/__init__.py
index 4ea75404..3c834e5b 100644
--- a/headphones/__init__.py
+++ b/headphones/__init__.py
@@ -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)
diff --git a/headphones/mb.py b/headphones/mb.py
index 02ce5c9d..4a83bd68 100644
--- a/headphones/mb.py
+++ b/headphones/mb.py
@@ -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)
diff --git a/lib/musicbrainz2/webservice.py b/lib/musicbrainz2/webservice.py
index 4e7a13c1..c6cc5c99 100644
--- a/lib/musicbrainz2/webservice.py
+++ b/lib/musicbrainz2/webservice.py
@@ -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)
|