Merge pull request #13 from rosskouk/feature-shuffle-9

Feature shuffle 9
This commit is contained in:
rosskouk
2022-10-22 16:00:01 +01:00
committed by GitHub
5 changed files with 35 additions and 3 deletions

3
.gitignore vendored
View File

@@ -1,6 +1,7 @@
__pycache__ __pycache__
env env
sphinx/_build sphinx/_build/*
!sphinx/_build/.gitkeep
sphinx/resources/*.bkp sphinx/resources/*.bkp
sphinx/resources/*.dtmp sphinx/resources/*.dtmp
asknavidrome.log asknavidrome.log

View File

@@ -176,6 +176,16 @@
"Play random music", "Play random music",
"Play random songs" "Play random songs"
] ]
},
{
"name": "NaviSonicRandomiseQueue",
"slots": [],
"samples": [
"randomise the queue",
"randomise",
"shuffle",
"shuffle the queue"
]
} }
], ],
"types": [ "types": [

View File

@@ -39,6 +39,7 @@ logger.addHandler(handler)
# Get service configuration # Get service configuration
# #
logger.info('AskNavidrome 0.6!')
logger.debug('Getting configutration from the environment...') logger.debug('Getting configutration from the environment...')
try: try:
@@ -572,6 +573,24 @@ class NaviSonicPlayFavouriteSongs(AbstractRequestHandler):
return controller.start_playback('play', speech, card, track_details, handler_input) return controller.start_playback('play', speech, card, track_details, handler_input)
class NaviSonicRandomiseQueue(AbstractRequestHandler):
"""Handle NaviSonicRandomiseQueue Intent
Shuffle the current play queue
"""
def can_handle(self, handler_input: HandlerInput) -> bool:
return is_intent_name('NaviSonicRandomiseQueue')(handler_input)
def handle(self, handler_input: HandlerInput) -> Response:
logger.debug('In NaviSonicRandomiseQueue Handler')
play_queue.shuffle()
play_queue.sync()
return handler_input.response_builder.response
class NaviSonicSongDetails(AbstractRequestHandler): class NaviSonicSongDetails(AbstractRequestHandler):
"""Handle NaviSonicSongDetails Intent """Handle NaviSonicSongDetails Intent
@@ -630,7 +649,6 @@ class NaviSonicUnstarSong(AbstractRequestHandler):
return handler_input.response_builder.response return handler_input.response_builder.response
# #
# AudioPlayer Handlers # AudioPlayer Handlers
# #
@@ -899,6 +917,7 @@ sb.add_request_handler(NaviSonicPlayPlaylist())
sb.add_request_handler(NaviSonicPlayFavouriteSongs()) sb.add_request_handler(NaviSonicPlayFavouriteSongs())
sb.add_request_handler(NaviSonicPlayMusicByGenre()) sb.add_request_handler(NaviSonicPlayMusicByGenre())
sb.add_request_handler(NaviSonicPlayMusicRandom()) sb.add_request_handler(NaviSonicPlayMusicRandom())
sb.add_request_handler(NaviSonicRandomiseQueue())
sb.add_request_handler(NaviSonicSongDetails()) sb.add_request_handler(NaviSonicSongDetails())
sb.add_request_handler(NaviSonicStarSong()) sb.add_request_handler(NaviSonicStarSong())
sb.add_request_handler(NaviSonicUnstarSong()) sb.add_request_handler(NaviSonicUnstarSong())

0
sphinx/_build/.gitkeep Normal file
View File

View File

@@ -98,6 +98,8 @@ Supported Intents
+-------------------------------------------+--------------------------------------------+-------------------------------------+ +-------------------------------------------+--------------------------------------------+-------------------------------------+
| :class:`~app.NaviSonicPlayFavouriteSongs` | Play your starred / favourite songs | Play my favourite songs | | :class:`~app.NaviSonicPlayFavouriteSongs` | Play your starred / favourite songs | Play my favourite songs |
+-------------------------------------------+--------------------------------------------+-------------------------------------+ +-------------------------------------------+--------------------------------------------+-------------------------------------+
| :class:`~app.NaviSonicRandomiseQueue` | Shuffle / randomise the current play queue | Shuffle the queue |
+-------------------------------------------+--------------------------------------------+-------------------------------------+
| :class:`~app.NaviSonicSongDetails` | Give details on the playing track | What is playing | | :class:`~app.NaviSonicSongDetails` | Give details on the playing track | What is playing |
+-------------------------------------------+--------------------------------------------+-------------------------------------+ +-------------------------------------------+--------------------------------------------+-------------------------------------+
| :class:`~app.NaviSonicStarSong` | Star / favourite a song | Star this song | | :class:`~app.NaviSonicStarSong` | Star / favourite a song | Star this song |
@@ -413,7 +415,7 @@ Code Documentation
****************** ******************
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 1
:caption: Contents: :caption: Contents:
AskNavidrome main AskNavidrome main