Improved spotify resume/pause intent

This commit is contained in:
Mathieu B 2021-07-31 13:25:37 +02:00
parent 411ddec237
commit 95b5f39381
4 changed files with 21 additions and 11 deletions

View File

@ -22,14 +22,26 @@ class SpotifySkill(Skill, metaclass=SkillRegistering):
spotify.get_spotify().add_to_queue(uri=song_lists_matching[0]['uri'])
spotify.get_spotify().next_track()
# spotify.get_spotify().start_playback(context_uri=song_lists_matching[0]['uri'])
else:
print("Nothing found for :" + str(data))
@intent_file_handler("pause_music.intent", "PauseSpotifyIntent")
def pause_music(self, data):
spotify.get_spotify().pause_playback()
print("[INFO INTENT] - Paused music for Spotify")
if spotify.is_music_playing():
spotify.get_spotify().pause_playback()
print("[INFO INTENT] - Paused music for Spotify")
else:
# TODO: speak : nothing is playing on spotify
pass
@intent_file_handler("resume_music.intent", "ResumeSpotifyIntent")
def resume_music(self, data):
if not spotify.is_music_playing():
spotify.get_spotify().start_playback()
print("[INFO INTENT] - Resumed music for Spotify")
else:
# TODO: speak : already playing song on spotify
pass
@intent_file_handler("current_song.intent", "CurrentSongSpotifyIntent")
def current_song(self, data):

View File

@ -58,6 +58,10 @@ def query_song(song=None, artist=None):
return data
def is_music_playing():
return sp.current_user_playing_track()['is_playing']
def best_confidence(title, query):
"""Find best match for a title against a query.
Some titles include ( Remastered 2016 ) and similar info. This method

View File

@ -1,8 +1 @@
mets la musique sur pause
arrête la musique
coupe la musique
mets sur pause
mets spotify en pause
mets spotify sur pause
pause
mets la musique en pause
(mets|arrête|coupe) (moi voir|) (le|la|) (musique|son|spotify) ((sur|en) pause|)

View File

@ -0,0 +1 @@
(remets|relance|mets) (moi voir|) (la|le) (musique|son)