Compare commits
7 Commits
496ff9bb52
...
e0b6be24c1
| Author | SHA1 | Date | |
|---|---|---|---|
| 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>
|
<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>
|
<dd><p>Ping a Subsonic API server</p>
|
||||||
<p>Verify the connection to a Subsonic compatible API server
|
<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">
|
<dl class="field-list simple">
|
||||||
<dt class="field-odd">Returns<span class="colon">:</span></dt>
|
<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>
|
<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
|
# Get service configuration
|
||||||
#
|
#
|
||||||
|
|
||||||
logger.info('AskNavidrome 0.9!')
|
logger.info('AskNavidrome 0.10!')
|
||||||
logger.debug('Getting configuration from the environment...')
|
logger.debug('Getting configuration from the environment...')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -903,7 +903,8 @@ class NextPlaybackHandler(AbstractRequestHandler):
|
|||||||
"""Handle NextIntent"""
|
"""Handle NextIntent"""
|
||||||
|
|
||||||
def can_handle(self, handler_input: HandlerInput) -> bool:
|
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:
|
def handle(self, handler_input: HandlerInput) -> Response:
|
||||||
logger.debug('In NextPlaybackHandler')
|
logger.debug('In NextPlaybackHandler')
|
||||||
@@ -920,7 +921,8 @@ class PreviousPlaybackHandler(AbstractRequestHandler):
|
|||||||
"""Handle PreviousIntent"""
|
"""Handle PreviousIntent"""
|
||||||
|
|
||||||
def can_handle(self, handler_input: HandlerInput) -> bool:
|
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:
|
def handle(self, handler_input: HandlerInput) -> Response:
|
||||||
logger.debug('In PreviousPlaybackHandler')
|
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
|
:return: Amazon Alexa Response class
|
||||||
:rtype: Response
|
: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':
|
if mode == 'play':
|
||||||
# Starting playback
|
# Starting playback
|
||||||
logger.debug('In start_playback() - play mode')
|
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,
|
url=track_details.uri,
|
||||||
offset_in_milliseconds=track_details.offset,
|
offset_in_milliseconds=track_details.offset,
|
||||||
expected_previous_token=None),
|
expected_previous_token=None),
|
||||||
metadata=add_screen_background(card_data) if card_data else None
|
metadata=metadata
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).set_should_end_session(True)
|
).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
|
# if the Previous intent is used
|
||||||
offset_in_milliseconds=0,
|
offset_in_milliseconds=0,
|
||||||
expected_previous_token=track_details.previous_id),
|
expected_previous_token=track_details.previous_id),
|
||||||
metadata=None
|
metadata=metadata
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
).set_should_end_session(True)
|
).set_should_end_session(True)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user