Merge pull request #73 from rosskouk/feature-enhanced-debugging

Added enhanced debugging to ping() method
This commit is contained in:
rosskouk
2026-03-06 15:14:33 +00:00
committed by GitHub
+21 -9
View File
@@ -40,29 +40,41 @@ class SubsonicConnection:
self.api_version, self.api_version,
False) False)
self.logger.debug('Connected to Navidrome') self.logger.debug('Connecting to Navidrome.....')
def ping(self) -> bool: def ping(self) -> bool:
"""Ping a Subsonic API server """Ping a Subsonic API server
Verify the connection to a Subsonic compatible API server Verify the connection to a Subsonic compatible API server
is working is working. Enhanced logging has been added to examine the
HTTP response returned from the server to assist with troubleshooting
connection issues.
:return: True if the connection works, False if it does not :return: True if the connection works, False if it does not
:rtype: bool :rtype: bool
""" """
self.logger.debug('In function ping()') self.logger.debug('In function ping()')
status = self.conn.ping() http_request = self.conn._getRequest('ping.view')
try:
http_request_result = self.conn._doInfoReq(http_request)
except Exception as e:
self.logger.error('Failed to connect to Navidrome: %s', e, exc_info=True)
return False
if status: self.logger.debug('ping() response from server: %s', http_request_result)
# Success status = http_request_result.get('status')
if status == 'ok':
self.logger.info('Successfully connected to Navidrome') self.logger.info('Successfully connected to Navidrome')
return True
elif status == 'failed':
err = http_request_result.get('error', {})
self.logger.error('Failed to connect to Navidrome: code=%s msg=%s',
err.get('code'), err.get('message'))
return False
else: else:
# Fail self.logger.error('Unexpected error when connecting to Navidrome: %r', status)
self.logger.error('Failed to connect to Navidrome') return False
return self.conn.ping()
def scrobble(self, track_id: str, time: int) -> None: def scrobble(self, track_id: str, time: int) -> None:
"""Scrobble the given track """Scrobble the given track