From 4775151409a2a5858458de876eca46005340fa4e Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 19 Mar 2012 09:16:04 +0000 Subject: [PATCH 1/4] Changes to get private server working with user/pass. Added additional header to req in lib/musicbrainz2/webservice.py, some small changes to mb.py --- data/interfaces/default/config.html | 2 +- headphones/mb.py | 22 ++++++++-------------- lib/musicbrainz2/webservice.py | 7 ++++++- 3 files changed, 15 insertions(+), 16 deletions(-) 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 @@

Username:

Password:

- what is this?

+ Get an Account

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) From 735c3143cb5bef2abfeb9f79119c99bf95250064 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 19 Mar 2012 09:25:01 +0000 Subject: [PATCH 2/4] Keeping config pages in sync --- data/interfaces/remix/config.html | 66 +++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/data/interfaces/remix/config.html b/data/interfaces/remix/config.html index 29727398..bb176af5 100644 --- a/data/interfaces/remix/config.html +++ b/data/interfaces/remix/config.html @@ -227,7 +227,7 @@ -



Torrent:


+

Torrent:


@@ -420,17 +420,41 @@

Path to Encoder:

- -

Prowl Notification:

-
-

Enabled Prowl Notification


+ +

Prowl Notification:


+

Enable Prowl Notifications


-

API key:



+

API key:



Notify on snatch?


Priority (-2,-1,0,1 or 2):

- + + + +

Muscbrainz Mirror: + +
+

Host:

+

Port:

+

Sleep Interval:

+
+ +
+

Username:

+

Password:

+ Get an Account

+
@@ -441,6 +465,27 @@ <%def name="javascriptIncludes()"> From b431689a0a94fe994cc0eb9e39cda9bba4ee81e8 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 19 Mar 2012 09:29:06 +0000 Subject: [PATCH 3/4] Changed default mirror back to musicbrainz --- headphones/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) From 85669fc1189dacab64f0dc3537b3de780608d9db Mon Sep 17 00:00:00 2001 From: rembo10 Date: Mon, 19 Mar 2012 09:47:55 +0000 Subject: [PATCH 4/4] hostname change --- headphones/mb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/mb.py b/headphones/mb.py index 8143e889..4a83bd68 100644 --- a/headphones/mb.py +++ b/headphones/mb.py @@ -32,7 +32,7 @@ def startmb(forcemb=False): mbport = headphones.CUSTOMPORT sleepytime = headphones.CUSTOMSLEEP elif headphones.MIRROR == "headphones": - mbhost = "codeshy.com" + mbhost = "178.63.142.150" mbport = 3333 mbuser = headphones.HPUSER mbpass = headphones.HPPASS