def alexa_what_new_movies(slots): card_title = 'Newly added movies' print card_title sys.stdout.flush() # Get the list of unwatched movies from Kodi new_movies = kodi.GetUnwatchedMovies() new_movie_names = list(set([sanitize_name(x['title']) for x in new_movies])) num_movies = len(new_movie_names) if num_movies == 0: # There's been nothing added to Kodi recently answers = [ "You don't have any new movies to watch.", "There are no new movies to watch.", ] answer = random.choice(answers) answer += suggest_alternate_activity() else: random.shuffle(new_movie_names) limited_new_movie_names = new_movie_names[0:5] movie_list = limited_new_movie_names[0] for one_movie in limited_new_movie_names[1:-1]: movie_list += ", " + one_movie if num_movies > 5: movie_list += ", " + limited_new_movie_names[-1] + ", and more" else: movie_list += ", and" + limited_new_movie_names[-1] answer = "You have %(movie_list)s." % {"movie_list":movie_list} return build_alexa_response(answer, card_title)
def alexa_pick_random_movie(slots): movies_response = kodi.GetUnwatchedMovies() movies = movies_response['result']['movies'] random_movie = random.choice(movies) kodi.ClearVideoPlaylist() kodi.PrepMoviePlaylist(random_movie['movieid']) kodi.StartVideoPlaylist() return build_alexa_response('Playing %s' % (random_movie['label']))
def alexa_pick_random_movie(slots): print('Trying to play a random movie') sys.stdout.flush() movies_response = kodi.GetUnwatchedMovies() if 'result' in movies_response and 'movies' in movies_response['result']: movies = movies_response['result']['movies'] random_movie = random.choice(movies) kodi.ClearVideoPlaylist() kodi.PrepMoviePlaylist(random_movie['movieid']) kodi.StartVideoPlaylist() return build_alexa_response('Playing %s' % (random_movie['label'])) else: return build_alexa_response('Error parsing results.')
def alexa_play_random_movie(slots): card_title = 'Playing a random movie' print card_title sys.stdout.flush() movies = kodi.GetUnwatchedMovies() if not 'movies' in movies['result']: # Fall back to all movies if no unwatched available movies = kodi.GetMovies() if 'result' in movies and 'movies' in movies['result']: movies_array = movies['result']['movies'] random_movie = random.choice(movies_array) kodi.PlayMovie(random_movie['movieid'], False) return build_alexa_response('Playing %s' % (random_movie['label']), card_title) else: return build_alexa_response('Error parsing results', card_title)