reformating subsonicupdate.py

Co-authored-by: Jef LeCompte <jeffreylec@gmail.com>
This commit is contained in:
Vincent Ducamps 2021-01-11 22:30:14 +01:00 committed by vincent
parent b37c55bc0b
commit 03a665861d
2 changed files with 6 additions and 8 deletions

View file

@ -34,7 +34,7 @@ from beets import config
from beets.plugins import BeetsPlugin from beets.plugins import BeetsPlugin
__author__ = 'https://github.com/maffo999' __author__ = 'https://github.com/maffo999'
authtokenversion = '1.12' AUTH_TOKEN_VERSION = '1.12'
class SubsonicUpdate(BeetsPlugin): class SubsonicUpdate(BeetsPlugin):
@ -47,14 +47,12 @@ class SubsonicUpdate(BeetsPlugin):
'url': 'http://localhost:4040', 'url': 'http://localhost:4040',
}) })
self.version = self.__get_version() self.version = self.__get_version()
if self.version > authtokenversion: if self.version > AUTH_TOKEN_VERSION:
self._log.info(
u'use token authent method')
self.auth = "token" self.auth = "token"
else: else:
self.auth = "password" self.auth = "password"
self._log.info( self._log.info(
u'use password authent method') u"using '{}' authentication method".format(self.auth))
config['subsonic']['pass'].redact = True config['subsonic']['pass'].redact = True
self.register_listener('import', self.start_scan) self.register_listener('import', self.start_scan)
@ -77,7 +75,7 @@ class SubsonicUpdate(BeetsPlugin):
@staticmethod @staticmethod
def __format_url(endpoint): def __format_url(endpoint):
"""Get the Subsonic URL to trigger a endpoint put in paramater. """Get the Subsonic URL to trigger the given endpoint.
Uses either the url config option or the deprecated host, port, Uses either the url config option or the deprecated host, port,
and context_path config options together. and context_path config options together.

View file

@ -49,7 +49,7 @@ class SubsonicPluginTest(_common.TestCase, TestHelper):
PING_BODY = ''' PING_BODY = '''
{ {
"subsonic-response": { "subsonic-response": {
"status": "failled", "status": "failed",
"version": "1.15.0" "version": "1.15.0"
} }
} }