예제 #1
0
파일: wsgi.py 프로젝트: Xaelias/kodi-alexa
def alexa_play_newest_episode(slots):
  heard_show = str(slots['Show']['value']).lower().translate(None, string.punctuation)

  card_title = 'Playing the newest episode of %s' % (heard_show)
  print card_title
  sys.stdout.flush()

  shows = kodi.GetTvShows()
  if 'result' in shows and 'tvshows' in shows['result']:
    shows_array = shows['result']['tvshows']

    located = kodi.matchHeard(heard_show, shows_array)

    if located:
      episode = kodi.GetNewestEpisodeFromShow(located['tvshowid'])

      if episode:
        episode_details = kodi.GetEpisodeDetails(episode)['result']['episodedetails']

        kodi.ClearVideoPlaylist()
        kodi.PrepEpisodePlayList(episode)
        kodi.StartVideoPlaylist()

        return build_alexa_response('Playing season %d episode %d of %s' % (episode_details['season'], episode_details['episode'], heard_show), card_title)
      else:
        return build_alexa_response('No new episodes for %s' % (heard_show), card_title)
    else:
      return build_alexa_response('Could not find %s' % (heard_show), card_title)
  else:
    return build_alexa_response('Error parsing results', card_title)
예제 #2
0
파일: wsgi.py 프로젝트: irvingwa/kodi-alexa
def alexa_play_newest_episode(slots):
    heard_show = str(slots['Show']['value']).lower().translate(
        None, string.punctuation)

    print('Trying to play the newest episode of %s' % (heard_show))
    sys.stdout.flush()

    shows = kodi.GetTvShows()
    if 'result' in shows and 'tvshows' in shows['result']:
        shows_array = shows['result']['tvshows']

        located = kodi.matchHeard(heard_show, shows_array)

        if located:
            episode_result = kodi.GetNewestEpisodeFromShow(located['tvshowid'])

            if episode_result:
                kodi.ClearVideoPlaylist()
                kodi.PrepEpisodePlayList(episode_result)
                kodi.StartVideoPlaylist()

                return build_alexa_response('Playing latest episode of %s' %
                                            (heard_show))

            else:
                return build_alexa_response(
                    'Could not find newest episode of %s' % (heard_show))
        else:
            return build_alexa_response('Could not find %s' % (heard_show))
    else:
        return build_alexa_response('Error parsing results.')
예제 #3
0
def alexa_play_newest_episode(slots):
  heard_show = str(slots['Show']['value']).lower().translate(None, string.punctuation)

  card_title = 'Playing the newest episode of %s' % (heard_show)
  print card_title
  sys.stdout.flush()

  shows = kodi.GetTvShows()
  if 'result' in shows and 'tvshows' in shows['result']:
    shows_array = shows['result']['tvshows']

    located = kodi.matchHeard(heard_show, shows_array)

    if located:
      episode_id = kodi.GetNewestEpisodeFromShow(located['tvshowid'])

      if episode_id:
        episode_details = kodi.GetEpisodeDetails(episode_id)

        if episode_details['resume']['position'] > 0:
          action = 'Resuming'
        else:
          action = 'Playing'

        kodi.PlayEpisode(episode_id)

        return build_alexa_response('%s season %d episode %d of %s' % (action, episode_details['season'], episode_details['episode'], heard_show), card_title)
      else:
        return build_alexa_response('No new episodes for %s' % (heard_show), card_title)
    else:
      return build_alexa_response('Could not find %s' % (heard_show), card_title)
  else:
    return build_alexa_response('Error parsing results', card_title)