Compare commits
11 Commits
2ee1abd813
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 496ff9bb52 | |||
| b27b77c572 | |||
| e0b8cb71e4 | |||
| a702b1befd | |||
| d748ee2602 | |||
| 609109dd17 | |||
| c44b22d486 | |||
| 4a36f0561b | |||
| 4e9d03e774 | |||
| 46e9203677 | |||
| aa4d19aafd |
29
Dockerfile
29
Dockerfile
@@ -1,34 +1,23 @@
|
||||
FROM alpine:3.22.1 AS build
|
||||
LABEL maintainer="Ross Stewart <rosskouk@gmail.com>"
|
||||
LABEL org.opencontainers.image.source=https://github.com/rosskouk/asknavidrome
|
||||
|
||||
RUN apk add python3 py3-pip git build-base python3-dev libffi-dev openssl-dev
|
||||
|
||||
WORKDIR /opt
|
||||
|
||||
RUN pwd
|
||||
RUN python3 -m venv env
|
||||
|
||||
RUN git clone https://github.com/rosskouk/asknavidrome.git
|
||||
|
||||
WORKDIR /opt/asknavidrome
|
||||
|
||||
RUN ls -la
|
||||
RUN git clone https://g.nunks.org/nunks/asknavidrome-cafofo.git
|
||||
RUN ls -la asknavidrome-cafofo
|
||||
WORKDIR /opt/asknavidrome-cafofo
|
||||
RUN pwd
|
||||
RUN ls -la
|
||||
RUN source ../env/bin/activate && pip --no-cache-dir install wheel && pip --no-cache-dir install -r skill/requirements-docker.txt
|
||||
|
||||
|
||||
FROM alpine:3.22.1
|
||||
LABEL maintainer="Ross Stewart <rosskouk@gmail.com>"
|
||||
LABEL org.opencontainers.image.source=https://github.com/rosskouk/asknavidrome
|
||||
|
||||
RUN apk add python3
|
||||
|
||||
COPY --from=build /opt/env /opt/env
|
||||
COPY --from=build /opt/asknavidrome/skill /opt/asknavidrome/
|
||||
|
||||
COPY --from=build /opt/asknavidrome-cafofo/skill /opt/asknavidrome/
|
||||
WORKDIR /opt/asknavidrome
|
||||
|
||||
# Activate Python Virtual Environment
|
||||
ENV PATH="/opt/env/bin:$PATH"
|
||||
|
||||
EXPOSE 5000
|
||||
|
||||
ENTRYPOINT ["python3", "app.py"]
|
||||
ENTRYPOINT ["python3", "app.py"]
|
||||
|
||||
17
alexa.json
17
alexa.json
@@ -73,6 +73,14 @@
|
||||
"Tocar o disco {album} da {artist}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NaviSonicPlayMusicByCurrentAlbum",
|
||||
"slots": [],
|
||||
"samples": [
|
||||
"Tocar mais músicas desse album",
|
||||
"Tocar mais músicas desse disco"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NaviSonicPlayPlaylist",
|
||||
"slots": [
|
||||
@@ -138,6 +146,15 @@
|
||||
"Tocar {song} da {artist}"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NaviSonicPlayMusicByCurrentArtist",
|
||||
"slots": [],
|
||||
"samples": [
|
||||
"Tocar mais músicas desse artista",
|
||||
"Tocar mais músicas desse grupo",
|
||||
"Tocar mais músicas dessa banda"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "NaviSonicPlayFavouriteSongs",
|
||||
"slots": [],
|
||||
|
||||
100
skill/app.py
100
skill/app.py
@@ -341,6 +341,97 @@ class NaviSonicPlayMusicByArtist(AbstractRequestHandler):
|
||||
track_details = play_queue.get_next_track()
|
||||
return controller.start_playback('play', speech, card, track_details, handler_input)
|
||||
|
||||
def get_current_song_details():
|
||||
current_track = play_queue.get_current_track()
|
||||
logger.debug(current_track)
|
||||
return {
|
||||
"title": current_track.title,
|
||||
"artist": current_track.artist,
|
||||
"album": current_track.album,
|
||||
"_sanitized": {
|
||||
"title": sanitise_speech_output(current_track.title),
|
||||
"artist": sanitise_speech_output(current_track.artist),
|
||||
"album": sanitise_speech_output(current_track.album)
|
||||
}
|
||||
}
|
||||
|
||||
class NaviSonicPlayMusicByCurrentArtist(AbstractRequestHandler):
|
||||
"""Handle NaviSonicPlayMusicByCurrentArtist Intent
|
||||
|
||||
Plays more music of the current playing Artist
|
||||
"""
|
||||
|
||||
def can_handle(self, handler_input: HandlerInput) -> bool:
|
||||
return is_intent_name('NaviSonicPlayMusicByCurrentArtist')(handler_input)
|
||||
|
||||
def handle(self, handler_input: HandlerInput) -> Response:
|
||||
global backgroundProcess
|
||||
logger.debug('In NaviSonicPlayMusicByCurrentArtist Handler (custom)')
|
||||
if backgroundProcess is not None:
|
||||
backgroundProcess.terminate()
|
||||
backgroundProcess.join()
|
||||
|
||||
t = get_current_song_details() #current "T"rack
|
||||
|
||||
artist_lookup = connection.search_artist(t["artist"])
|
||||
artist_album_lookup = connection.albums_by_artist(artist_lookup[0].get('id'))
|
||||
song_id_list = connection.build_song_list_from_albums(artist_album_lookup, min_song_count)
|
||||
play_queue.clear()
|
||||
|
||||
controller.enqueue_songs(connection, play_queue, [song_id_list[0], song_id_list[1]]) # When generating the playlist return the first two tracks.
|
||||
backgroundProcess = Process(target=queue_worker_thread, args=(connection, play_queue, song_id_list[2:])) # Create a thread to enqueue the remaining tracks
|
||||
backgroundProcess.start() # Start the additional thread
|
||||
|
||||
speech = sanitise_speech_output(f'Tocando mais músicas de {t["artist"]}')
|
||||
logger.info(speech)
|
||||
|
||||
card = {'title': 'AskNavidrome',
|
||||
'text': speech
|
||||
}
|
||||
|
||||
play_queue.shuffle()
|
||||
track_details = play_queue.get_next_track()
|
||||
return controller.start_playback('play', speech, card, track_details, handler_input)
|
||||
|
||||
class NaviSonicPlayMusicByCurrentAlbum(AbstractRequestHandler):
|
||||
"""Handle NaviSonicPlayMusicByCurrentAlbum Intent
|
||||
|
||||
Plays more music of the current playing Album
|
||||
"""
|
||||
|
||||
def can_handle(self, handler_input: HandlerInput) -> bool:
|
||||
return is_intent_name('NaviSonicPlayMusicByCurrentAlbum')(handler_input)
|
||||
|
||||
def handle(self, handler_input: HandlerInput) -> Response:
|
||||
global backgroundProcess
|
||||
logger.debug('In NaviSonicPlayMusicByCurrentAlbum Handler (custom)')
|
||||
if backgroundProcess is not None:
|
||||
backgroundProcess.terminate()
|
||||
backgroundProcess.join()
|
||||
|
||||
t = get_current_song_details() #current "T"rack
|
||||
|
||||
artist_lookup = connection.search_artist(t["artist"])
|
||||
artist_album_lookup = connection.albums_by_artist(artist_lookup[0].get('id'))
|
||||
result = [album_result for album_result in artist_album_lookup if album_result.get('name').lower() == t["album"].lower()]
|
||||
|
||||
song_id_list = connection.build_song_list_from_albums(result, -1)
|
||||
play_queue.clear()
|
||||
|
||||
controller.enqueue_songs(connection, play_queue, [song_id_list[0], song_id_list[1]]) # When generating the playlist return the first two tracks.
|
||||
backgroundProcess = Process(target=queue_worker_thread, args=(connection, play_queue, song_id_list[2:])) # Create a thread to enqueue the remaining tracks
|
||||
backgroundProcess.start() # Start the additional thread
|
||||
|
||||
speech = sanitise_speech_output(f'Tocando mais músicas do album {t["album"]}, de {t["artist"]}')
|
||||
logger.info(speech)
|
||||
|
||||
card = {'title': 'AskNavidrome',
|
||||
'text': speech
|
||||
}
|
||||
|
||||
play_queue.shuffle()
|
||||
track_details = play_queue.get_next_track()
|
||||
return controller.start_playback('play', speech, card, track_details, handler_input)
|
||||
|
||||
class NaviSonicPlayAlbumByArtist(AbstractRequestHandler):
|
||||
"""Handle NaviSonicPlayAlbumByArtist
|
||||
@@ -670,7 +761,7 @@ class NaviSonicPlayFavouriteSongs(AbstractRequestHandler):
|
||||
song_id_list = connection.build_song_list_from_favourites()
|
||||
|
||||
if song_id_list is None:
|
||||
text = sanitise_speech_output("Você não tem nada nos favoritos.")
|
||||
text = sanitise_speech_output("Não tenho nada nos favoritos.")
|
||||
handler_input.response_builder.speak(text).ask(text)
|
||||
|
||||
return handler_input.response_builder.response
|
||||
@@ -730,7 +821,8 @@ class NaviSonicSongDetails(AbstractRequestHandler):
|
||||
artist = sanitise_speech_output(current_track.artist)
|
||||
album = sanitise_speech_output(current_track.album)
|
||||
|
||||
text = f'This is {title} by {artist}, from the album {album}'
|
||||
# text = f'This is {title} by {artist}, from the album {album}'
|
||||
text = f'Essa é {title} de {artist}, do album {album}'
|
||||
handler_input.response_builder.speak(text)
|
||||
|
||||
return handler_input.response_builder.response
|
||||
@@ -997,7 +1089,7 @@ class SystemExceptionHandler(AbstractExceptionHandler):
|
||||
logger.error(f'Intent Name Was: {get_intent_name(handler_input)}')
|
||||
|
||||
#speech = sanitise_speech_output("Sorry, I didn't get that. Can you please say it again!!")
|
||||
speech = sanitise_speech_output("Foi mal, não entendi. Pode repetir!!")
|
||||
speech = sanitise_speech_output("Foi mal, não entendi.")
|
||||
handler_input.response_builder.speak(speech).ask(speech)
|
||||
|
||||
return handler_input.response_builder.response
|
||||
@@ -1123,6 +1215,8 @@ sb.add_request_handler(NaviSonicPlayPlaylist())
|
||||
sb.add_request_handler(NaviSonicPlayFavouriteSongs())
|
||||
sb.add_request_handler(NaviSonicPlayMusicByGenre())
|
||||
sb.add_request_handler(NaviSonicPlayMusicRandom())
|
||||
sb.add_request_handler(NaviSonicPlayMusicByCurrentArtist())
|
||||
sb.add_request_handler(NaviSonicPlayMusicByCurrentAlbum())
|
||||
sb.add_request_handler(NaviSonicRandomiseQueue())
|
||||
sb.add_request_handler(NaviSonicSongDetails())
|
||||
sb.add_request_handler(NaviSonicStarSong())
|
||||
|
||||
Reference in New Issue
Block a user