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 @@
diff --git a/headphones/mb.py b/headphones/mb.py index 02ce5c9d..8143e889 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" @@ -33,25 +32,20 @@ def startmb(forcemb=False): mbport = headphones.CUSTOMPORT sleepytime = headphones.CUSTOMSLEEP elif headphones.MIRROR == "headphones": - mbhost = "178.63.142.150" - mbport = 5000 + mbhost = "codeshy.com" + 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)