mirror of
https://github.com/rembo10/headphones.git
synced 2026-07-21 08:24:00 +01:00
Allow authentication on custom MusicBrainz servers using Basic HTTP Authentication.
This commit is contained in:
@@ -271,6 +271,7 @@ user = password = ""
|
||||
hostname = "musicbrainz.org"
|
||||
_client = ""
|
||||
_useragent = ""
|
||||
mb_auth = False
|
||||
|
||||
def auth(u, p):
|
||||
"""Set the username and password to be used in subsequent queries to
|
||||
@@ -284,9 +285,16 @@ def hpauth(u, p):
|
||||
"""Set the username and password to be used in subsequent queries to
|
||||
the MusicBrainz XML API that require authentication.
|
||||
"""
|
||||
global hpuser, hppassword
|
||||
global hpuser, hppassword, mb_auth
|
||||
hpuser = u
|
||||
hppassword = p
|
||||
mb_auth = True
|
||||
|
||||
def disable_hpauth():
|
||||
"""Disable the authentication for MusicBrainz XML API
|
||||
"""
|
||||
global mb_auth
|
||||
mb_auth = False
|
||||
|
||||
def set_useragent(app, version, contact=None):
|
||||
"""Set the User-Agent to be used for requests to the MusicBrainz webservice.
|
||||
@@ -635,7 +643,7 @@ def _mb_request(path, method='GET', auth_required=False, client_required=False,
|
||||
req.add_header('User-Agent', _useragent)
|
||||
|
||||
# Add headphones credentials
|
||||
if hostname == '144.76.94.239:8181':
|
||||
if mb_auth:
|
||||
base64string = base64.encodestring('%s:%s' % (hpuser, hppassword)).replace('\n', '')
|
||||
req.add_header("Authorization", "Basic %s" % base64string)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user