Added API version setting for backward compatability

This commit is contained in:
Jolny 2017-05-15 00:12:49 +02:00
parent 8226a35bc2
commit f8e1311866
4 changed files with 9 additions and 5 deletions

View file

@ -23,6 +23,7 @@ class SubidyExtension(ext.Extension):
schema['username'] = config.String()
schema['password'] = config.Secret()
schema['legacy_auth'] = config.Boolean(optional=True)
schema['api_version'] = config.String(optional=True)
return schema
def setup(self, registry):

View file

@ -10,7 +10,8 @@ class SubidyBackend(pykka.ThreadingActor, backend.Backend):
url=subidy_config['url'],
username=subidy_config['username'],
password=subidy_config['password'],
legacy_auth=subidy_config['legacy_auth'])
legacy_auth=subidy_config['legacy_auth'],
api_version=subidy_config['api_version'])
self.library = library.SubidyLibraryProvider(backend=self)
self.playback = playback.SubidyPlaybackProvider(audio=audio, backend=self)
self.playlists = playlists.SubidyPlaylistsProvider(backend=self)

View file

@ -4,3 +4,4 @@ url =
username =
password =
legacy_auth = no
api_version = 1.14.0

View file

@ -37,7 +37,7 @@ def diritem_sort_key(item):
return (isdir, key)
class SubsonicApi():
def __init__(self, url, username, password, legacy_auth):
def __init__(self, url, username, password, legacy_auth, api_version):
parsed = urlparse(url)
self.port = parsed.port if parsed.port else \
443 if parsed.scheme == 'https' else 80
@ -48,15 +48,16 @@ class SubsonicApi():
password,
self.port,
parsed.path + '/rest',
legacyAuth=legacy_auth)
legacyAuth=legacy_auth,
apiVersion=api_version)
self.url = url + '/rest'
self.username = username
self.password = password
logger.info('Connecting to subsonic server on url %s as user %s' % (url, username))
logger.info('Connecting to subsonic server on url %s as user %s, API version %s' % (url, username, api_version))
try:
self.connection.ping()
except Exception as e:
logger.error('Unabled to reach subsonic server: %s' % e)
logger.error('Unable to reach subsonic server: %s' % e)
exit()
def get_subsonic_uri(self, view_name, params, censor=False):