Skip to content

Commit

Permalink
Add WatchMusicVideo Intent.
Browse files Browse the repository at this point in the history
  • Loading branch information
jingai committed Aug 10, 2017
1 parent a599059 commit 48bd7d6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
18 changes: 18 additions & 0 deletions alexa.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 9 additions & 0 deletions speech_assets/IntentSchema.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@
}
]
},
{
"intent": "WatchMusicVideo",
"slots": [
{
"name": "MusicVideo",
"type": "MUSICVIDEOS"
}
]
},
{
"intent": "WatchRandomMusicVideo",
"slots": [
Expand Down
4 changes: 4 additions & 0 deletions speech_assets/SampleUtterances.txt
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,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}
Expand Down
4 changes: 4 additions & 0 deletions templates.en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}?"
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 2 additions & 0 deletions utterances.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 48bd7d6

Please sign in to comment.