From cd5582bc3cf089ff5992e6acc4db78bded47a4d6 Mon Sep 17 00:00:00 2001 From: jingai Date: Thu, 10 Aug 2017 00:54:24 -0400 Subject: [PATCH] Add WatchMusicVideo Intent. --- alexa.py | 18 ++++++++++++++++++ speech_assets/IntentSchema.json | 9 +++++++++ speech_assets/SampleUtterances.txt | 4 ++++ templates.en.yaml | 4 ++++ utterances.txt | 2 ++ 5 files changed, 37 insertions(+) diff --git a/alexa.py b/alexa.py index 77f48d0..5c85ed2 100644 --- a/alexa.py +++ b/alexa.py @@ -2218,6 +2218,24 @@ def alexa_watch_random_music_video(MusicVideoGenre): return statement(response_text).simple_card(card_title, response_text) +# Handle the WatchMusicVideo intent. +@ask.intent('WatchMusicVideo') +def alexa_watch_music_video(MusicVideo): + card_title = render_template('playing_musicvideo_card').encode("utf-8") + print card_title + + kodi = Kodi(config, context) + musicvideo = kodi.FindMusicVideo(MusicVideo) + if len(musicvideo) > 0: + musicvideo_details = kodi.GetMusicVideoDetails(musicvideo[0][0]) + kodi.PlayMusicVideo(musicvideo[0][0]) + response_text = render_template('playing_musicvideo', musicvideo_name=musicvideo[0][1], artist_name=musicvideo_details['artist'][0]).encode("utf-8") + else: + response_text = render_template('could_not_find_musicvideo', heard_musicvideo=MusicVideo).encode("utf-8") + + return statement(response_text).simple_card(card_title, response_text) + + # Handle the ShuffleMusicVideos intent. @ask.intent('ShuffleMusicVideos') def alexa_shuffle_music_videos(MusicVideoGenre): diff --git a/speech_assets/IntentSchema.json b/speech_assets/IntentSchema.json index 37b8a3a..ce65801 100644 --- a/speech_assets/IntentSchema.json +++ b/speech_assets/IntentSchema.json @@ -383,6 +383,15 @@ } ] }, + { + "intent": "WatchMusicVideo", + "slots": [ + { + "name": "MusicVideo", + "type": "MUSICVIDEOS" + } + ] + }, { "intent": "WatchRandomMusicVideo", "slots": [ diff --git a/speech_assets/SampleUtterances.txt b/speech_assets/SampleUtterances.txt index 9803d24..278b424 100644 --- a/speech_assets/SampleUtterances.txt +++ b/speech_assets/SampleUtterances.txt @@ -925,6 +925,10 @@ WatchMovieTrailer watch the trailer WatchMovieTrailer watch the trailer for {Movie} WatchMovieTrailer watch trailer WatchMovieTrailer watch trailer for {Movie} +WatchMusicVideo play music video {MusicVideo} +WatchMusicVideo play the music video {MusicVideo} +WatchMusicVideo watch music video {MusicVideo} +WatchMusicVideo watch the music video {MusicVideo} WatchNextEpisode play next episode of {Show} WatchNextEpisode play the next episode of {Show} WatchNextEpisode watch next episode of {Show} diff --git a/templates.en.yaml b/templates.en.yaml index 2b80fe9..f881bd7 100644 --- a/templates.en.yaml +++ b/templates.en.yaml @@ -38,6 +38,8 @@ could_not_find_show: "Could not find a show named {{ heard_show }}" could_not_find_episode_show: "Could not find season {{ season }} episode {{ episode }} of {{ show_name }}" +could_not_find_musicvideo: "Could not find a music video called {{ heard_musicvideo }}" + no_recommendations: "I'm sorry, I have nothing to recommend" recommend_movie: "How about the movie {{ movie_name }}?" @@ -329,6 +331,8 @@ playing_next_unwatched_episode: "Playing the next unwatched episode of {{ heard_ playing_newest_episode: "Playing the newest episode of {{ heard_show }}" +playing_musicvideo_card: "Playing music video" + shuffling_musicvideos: "Shuffling music videos" shuffling_musicvideos_genre: "Shuffling {{ genre }} music videos" diff --git a/utterances.txt b/utterances.txt index 24d8748..ab381a9 100644 --- a/utterances.txt +++ b/utterances.txt @@ -154,6 +154,8 @@ WatchLastShow continue (/watching/playing) (/last/the last) show WatchLatestEpisode (play/watch) (/the) (newest/latest) episode of {Show} +WatchMusicVideo (play/watch) (/the) music video {MusicVideo} + WatchRandomMusicVideo (play/watch) (/a) random (/{MusicVideoGenre}) music video WatchVideoPlaylist (play/watch) (/the) (movie/show/video) playlist {VideoPlaylist}