Enable connecting to a custom MusicBrainz server
Under the new [musicbrainz] section in the config, you can set a server to connect to. Closes #172.
This commit is contained in:
@@ -166,6 +166,9 @@ The possible sections are:
|
||||
- Main section: `[main]`
|
||||
- `path_filter_fat`: whether to filter path components for FAT file systems
|
||||
- `path_filter_special`: whether to filter path components for special characters
|
||||
|
||||
- MusicBrainz section: `[musicbrainz]`
|
||||
- `server`: the MusicBrainz server to connect to, in `host:[port]` format. Defaults to `musicbrainz.org`.
|
||||
|
||||
- Drive section: `[drive:IDENTIFIER]`, one for each configured drive. All these values are probed by whipper and should not be edited by hand.
|
||||
- `defeats_cache`: whether this drive can defeat the audio cache
|
||||
|
||||
@@ -10,7 +10,7 @@ import whipper
|
||||
|
||||
from whipper.command import cd, offset, drive, image, accurip, debug
|
||||
from whipper.command.basecommand import BaseCommand
|
||||
from whipper.common import common, directory
|
||||
from whipper.common import common, directory, config
|
||||
from whipper.extern.task import task
|
||||
from whipper.program.utils import eject_device
|
||||
|
||||
@@ -22,6 +22,7 @@ def main():
|
||||
# set user agent
|
||||
musicbrainzngs.set_useragent("whipper", whipper.__version__,
|
||||
"https://github.com/JoeLametta/whipper")
|
||||
musicbrainzngs.set_hostname(config.Config().get_musicbrainz_server())
|
||||
# register plugins with pkg_resources
|
||||
distributions, _ = pkg_resources.working_set.find_plugins(
|
||||
pkg_resources.Environment([directory.data_path('plugins')])
|
||||
|
||||
@@ -21,9 +21,11 @@
|
||||
import ConfigParser
|
||||
import codecs
|
||||
import os.path
|
||||
import re
|
||||
import shutil
|
||||
import tempfile
|
||||
import urllib
|
||||
from urlparse import urlparse
|
||||
|
||||
from whipper.common import directory
|
||||
|
||||
@@ -72,6 +74,13 @@ class Config:
|
||||
def getboolean(self, section, option):
|
||||
return self._getter('boolean', section, option)
|
||||
|
||||
# musicbrainz section
|
||||
|
||||
def get_musicbrainz_server(self):
|
||||
server = self.get('musicbrainz', 'server') or 'musicbrainz.org'
|
||||
server_url = server if re.match(r'^\D*//', server) else '//' + server
|
||||
return urlparse(server_url).netloc
|
||||
|
||||
# drive sections
|
||||
|
||||
def setReadOffset(self, vendor, model, release, offset):
|
||||
|
||||
@@ -28,7 +28,7 @@ import urlparse
|
||||
|
||||
import whipper
|
||||
|
||||
from whipper.common import common
|
||||
from whipper.common import common, config
|
||||
|
||||
import logging
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -390,7 +390,7 @@ class Table(object):
|
||||
return result
|
||||
|
||||
def getMusicBrainzSubmitURL(self):
|
||||
host = 'musicbrainz.org'
|
||||
host = config.Config().get_musicbrainz_server()
|
||||
|
||||
discid = self.getMusicBrainzDiscId()
|
||||
values = self._getMusicBrainzValues()
|
||||
|
||||
Reference in New Issue
Block a user