Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bf73f99907 | |||
| e0b6be24c1 | |||
| cd3575d514 | |||
| 77e8546baa | |||
| 122d328de4 | |||
| f3846a2311 | |||
| 0cf1c52743 | |||
| fcce6a8d11 |
+3
-1
@@ -3491,7 +3491,9 @@ embedded in the URI</p>
|
||||
<span class="sig-name descname"><span class="pre">ping</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span> <span class="sig-return"><span class="sig-return-icon">→</span> <span class="sig-return-typehint"><span class="pre">bool</span></span></span><a class="headerlink" href="#asknavidrome.subsonic_api.SubsonicConnection.ping" title="Link to this definition">#</a></dt>
|
||||
<dd><p>Ping a Subsonic API server</p>
|
||||
<p>Verify the connection to a Subsonic compatible API server
|
||||
is working</p>
|
||||
is working. Enhanced logging has been added to examine the
|
||||
HTTP response returned from the server to assist with troubleshooting
|
||||
connection issues.</p>
|
||||
<dl class="field-list simple">
|
||||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
||||
<dd class="field-odd"><p>True if the connection works, False if it does not</p>
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+5
-3
@@ -42,7 +42,7 @@ logger.addHandler(handler)
|
||||
# Get service configuration
|
||||
#
|
||||
|
||||
logger.info('AskNavidrome 0.9!')
|
||||
logger.info('AskNavidrome 0.10!')
|
||||
logger.debug('Getting configuration from the environment...')
|
||||
|
||||
try:
|
||||
@@ -1004,7 +1004,8 @@ class NextPlaybackHandler(AbstractRequestHandler):
|
||||
"""Handle NextIntent"""
|
||||
|
||||
def can_handle(self, handler_input: HandlerInput) -> bool:
|
||||
return is_intent_name('AMAZON.NextIntent')(handler_input)
|
||||
return (is_intent_name('AMAZON.NextIntent')(handler_input) or
|
||||
is_request_type('PlaybackController.NextCommandIssued')(handler_input))
|
||||
|
||||
def handle(self, handler_input: HandlerInput) -> Response:
|
||||
logger.debug('In NextPlaybackHandler')
|
||||
@@ -1021,7 +1022,8 @@ class PreviousPlaybackHandler(AbstractRequestHandler):
|
||||
"""Handle PreviousIntent"""
|
||||
|
||||
def can_handle(self, handler_input: HandlerInput) -> bool:
|
||||
return is_intent_name('AMAZON.PreviousIntent')(handler_input)
|
||||
return (is_intent_name('AMAZON.PreviousIntent')(handler_input) or
|
||||
is_request_type('PlaybackController.PreviousCommandIssued')(handler_input))
|
||||
|
||||
def handle(self, handler_input: HandlerInput) -> Response:
|
||||
logger.debug('In PreviousPlaybackHandler')
|
||||
|
||||
Regular → Executable
+15
-3
@@ -42,7 +42,19 @@ def start_playback(mode: str, text: str, card_data: dict, track_details: Track,
|
||||
:return: Amazon Alexa Response class
|
||||
:rtype: Response
|
||||
"""
|
||||
|
||||
metadata = AudioItemMetadata(
|
||||
title=track_details.title,
|
||||
subtitle=track_details.artist,
|
||||
art=display.Image(
|
||||
content_description=track_details.title,
|
||||
sources=[
|
||||
display.ImageInstance(
|
||||
url='https://github.com/navidrome/navidrome/raw/master/resources/logo-192x192.png'
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
if mode == 'play':
|
||||
# Starting playback
|
||||
logger.debug('In start_playback() - play mode')
|
||||
@@ -67,7 +79,7 @@ def start_playback(mode: str, text: str, card_data: dict, track_details: Track,
|
||||
url=track_details.uri,
|
||||
offset_in_milliseconds=track_details.offset,
|
||||
expected_previous_token=None),
|
||||
metadata=add_screen_background(card_data) if card_data else None
|
||||
metadata=metadata
|
||||
)
|
||||
)
|
||||
).set_should_end_session(True)
|
||||
@@ -95,7 +107,7 @@ def start_playback(mode: str, text: str, card_data: dict, track_details: Track,
|
||||
# if the Previous intent is used
|
||||
offset_in_milliseconds=0,
|
||||
expected_previous_token=track_details.previous_id),
|
||||
metadata=None
|
||||
metadata=metadata
|
||||
)
|
||||
)
|
||||
).set_should_end_session(True)
|
||||
|
||||
@@ -40,29 +40,41 @@ class SubsonicConnection:
|
||||
self.api_version,
|
||||
False)
|
||||
|
||||
self.logger.debug('Connected to Navidrome')
|
||||
self.logger.debug('Connecting to Navidrome.....')
|
||||
|
||||
def ping(self) -> bool:
|
||||
"""Ping a Subsonic 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
|
||||
:rtype: bool
|
||||
"""
|
||||
|
||||
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:
|
||||
# Success
|
||||
self.logger.debug('ping() response from server: %s', http_request_result)
|
||||
status = http_request_result.get('status')
|
||||
if status == 'ok':
|
||||
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:
|
||||
# Fail
|
||||
self.logger.error('Failed to connect to Navidrome')
|
||||
|
||||
return self.conn.ping()
|
||||
self.logger.error('Unexpected error when connecting to Navidrome: %r', status)
|
||||
return False
|
||||
|
||||
def scrobble(self, track_id: str, time: int) -> None:
|
||||
"""Scrobble the given track
|
||||
|
||||
Reference in New Issue
Block a user