Skip to content
This repository was archived by the owner on Sep 1, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion alexa.intents
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@
"type": "AMAZON.NUMBER"
}
]
},
{
"intent": "CurrentPlayItemInquiry",
"slots": []
}
]
}
}
21 changes: 21 additions & 0 deletions alexa.utterances
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,24 @@ WhatNewShows what shows do you have
WhatNewShows what shows i have
WhatNewShows what shows we have
WhatNewShows what shows you have
CurrentPlayItemInquiry what is this
CurrentPlayItemInquiry what song is this
CurrentPlayItemInquiry what audio is this
CurrentPlayItemInquiry what video is this
CurrentPlayItemInquiry what movie is this
CurrentPlayItemInquiry what episode is this
CurrentPlayItemInquiry what show is this
CurrentPlayItemInquiry what is playing
CurrentPlayItemInquiry what song is playing
CurrentPlayItemInquiry what audio is playing
CurrentPlayItemInquiry what video is playing
CurrentPlayItemInquiry what movie is playing
CurrentPlayItemInquiry what episode is playing
CurrentPlayItemInquiry what show is playing
CurrentPlayItemInquiry what is currently playing
CurrentPlayItemInquiry what song is currently playing
CurrentPlayItemInquiry what audio is currently playing
CurrentPlayItemInquiry what video is currently playing
CurrentPlayItemInquiry what movie is currently playing
CurrentPlayItemInquiry what episode is currently playing
CurrentPlayItemInquiry what show is currently playing
10 changes: 5 additions & 5 deletions kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,13 @@ def GetShowDetails(show=0):
return data['result']['tvshowdetails']


# Information about the video that's currently playing
# Information about the video or audio that's currently playing

def GetVideoPlayItem():
def GetActivePlayItem():
playerid = GetPlayerID()
if playerid:
data = SendCommand(RPCString("Player.GetItem", {"playerid":playerid, "properties":["episode","showtitle", "tvshowid", "season", "description"]}))
return data["result"]["item"]
if playerid is not None:
data = SendCommand(RPCString("Player.GetItem", {"playerid":playerid, "properties":["title", "album", "artist", "season", "episode", "showtitle", "tvshowid", "description"]}))
return data['result']['item']


# Returns information useful for building a progress bar to show a video's play time
Expand Down
2 changes: 2 additions & 0 deletions utterances.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,5 @@ PartyMode listen to random music
DoSearch search for {Show}
DoSearch search for {Movie}
DoSearch search for {Artist}

CurrentPlayItemInquiry what (/song/audio/video/movie/episode/show) is (this/playing/currently playing)
56 changes: 56 additions & 0 deletions wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,61 @@ def alexa_new_show_inquiry(slots):
else:
return build_alexa_response('Error parsing results.')

# Handle the CurrentPlayItemInquiry intent.

def alexa_current_playitem_inquiry(slots):
print('Trying to get info about current player item')
sys.stdout.flush()

speech_output = 'The current'
speech_output_append = 'ly playing item is unknown'

try:
curitem = kodi.GetActivePlayItem()
except:
speech_output = 'There is nothing current'
speech_output_append = 'ly playing'
else:
if curitem is not None:
if curitem['type'] == 'episode':
# is a tv show
speech_output += ' TV show is'
speech_output_append = ' unknown'
if curitem['showtitle']:
speech_output += ' %s,' % (curitem['showtitle'])
speech_output_append = ''
if curitem['season']:
speech_output += ' season %s,' % (curitem['season'])
speech_output_append = ''
if curitem['episode']:
speech_output += ' episode %s,' % (curitem['episode'])
speech_output_append = ''
if curitem['title']:
speech_output += ' %s' % (curitem['title'])
speech_output_append = ''
elif curitem['type'] == 'song' or curitem['type'] == 'musicvideo':
# is a song (music video or audio)
speech_output += ' song is'
speech_output_append = ' unknown'
if curitem['title']:
speech_output += ' %s,' % (curitem['title'])
speech_output_append = ''
if curitem['artist']:
speech_output += ' by %s,' % (curitem['artist'][0])
speech_output_append = ''
if curitem['album']:
speech_output += ' on the album %s' % (curitem['album'])
speech_output_append = ''
elif curitem['type'] == 'movie':
# is a video
speech_output += ' movie is'
speech_output_append = ' unknown'
if curitem['title']:
speech_output += ' %s' % (curitem['title'])
speech_output_append = ''

return build_alexa_response('%s%s.' % (speech_output, speech_output_append))

#Pause Kodi
def alexa_play_pause(slots):
print('Playing or Pausing')
Expand Down Expand Up @@ -642,6 +697,7 @@ def prepare_help_message():
INTENTS = [
['CheckNewShows', alexa_check_new_episodes],
['NewShowInquiry', alexa_new_show_inquiry],
['CurrentPlayItemInquiry', alexa_current_playitem_inquiry],
['WhatNewShows', alexa_what_new_episodes],
['PlayPause', alexa_play_pause],
['Stop', alexa_stop],
Expand Down