Use https and http appropriately when connecting to MusicBrainz

Fixed some bugs:
- MusicBrainz submit URL always has https as protocol: hardcoded, even when
inappropriate. It's just a graphical issue.
- Whipper appears to always communicate with MusicBrainz using musicbrainzngs
over http. The musicbrainzngs.set_hostname(server).
- `musicbrainzngs.set_hostname(server)` always defaults to http. Since musicbrainzngs
version 0.7 the method `set_hostname` takes an optional argument named `use_https`
(defaults to False) which whipper never passes.

Changed behaviour of `server` option (`musicbrainz` section of whipper's configuration file).
Now it expects an URL with a valid scheme (scheme must be `http` or `http`, empty scheme isn't allowed anymore).
Only the scheme and netloc parts of the URL are taken into account.

Fixes #437.

Signed-off-by: JoeLametta <JoeLametta@users.noreply.github.com>
This commit is contained in:
JoeLametta
2020-01-16 20:44:35 +07:00
parent caa2c8b27d
commit 1206552bd2
5 changed files with 29 additions and 20 deletions

View File

@@ -20,7 +20,13 @@ logger = logging.getLogger(__name__)
def main():
server = config.Config().get_musicbrainz_server()
musicbrainzngs.set_hostname(server)
https_enabled = server['scheme'] == 'https'
try:
musicbrainzngs.set_hostname(server['netloc'], https_enabled)
# Parameter 'use_https' is missing in versions of musicbrainzngs < 0.7
except TypeError as e:
logger.warning(e)
musicbrainzngs.set_hostname(server['netloc'])
# Find whipper's plugins paths (local paths have higher priority)
plugins_p = [directory.data_path('plugins')] # local path (in $HOME)