def alexa_play_movie(slots): heard_movie = str(slots['Movie']['value']).lower().translate( None, string.punctuation) card_title = 'Playing the movie %s' % (heard_movie) print card_title sys.stdout.flush() movies = kodi.GetMovies() if 'result' in movies and 'movies' in movies['result']: movies_array = movies['result']['movies'] located = kodi.matchHeard(heard_movie, movies_array) if located: if kodi.GetMovieDetails( located['movieid'])['resume']['position'] > 0: action = 'Resuming' else: action = 'Playing' kodi.PlayMovie(located['movieid']) return build_alexa_response('%s %s' % (action, heard_movie), card_title) else: return build_alexa_response( 'Could not find a movie called %s' % (heard_movie), card_title) else: return build_alexa_response('Error parsing results', card_title)
def alexa_play_movie(slots): heard_movie = str(slots['Movie']['value']).lower().translate( None, string.punctuation) print('Trying to play the movie %s' % (heard_movie)) sys.stdout.flush() movies_response = kodi.GetMovies(kodi.remove_the(heard_movie)) if 'result' in movies_response and 'movies' in movies_response['result']: movies = movies_response['result']['movies'] located = kodi.matchHeard(heard_movie, movies) if located: kodi.ClearVideoPlaylist() kodi.PrepMoviePlaylist(located['movieid']) kodi.StartVideoPlaylist() return build_alexa_response('Playing %s' % (heard_movie)) else: return build_alexa_response('Could not find a movie called %s' % (heard_movie)) else: return build_alexa_response('Could not find a movie called %s' % (heard_movie))
def alexa_play_movie(slots): heard_movie = str(slots['Movie']['value']).lower().translate( None, string.punctuation) card_title = 'Playing the movie %s' % (heard_movie) print card_title sys.stdout.flush() movies = kodi.GetMovies() if 'result' in movies and 'movies' in movies['result']: movies_array = movies['result']['movies'] located = kodi.matchHeard(heard_movie, movies_array) if located: kodi.ClearVideoPlaylist() kodi.PrepMoviePlaylist(located['movieid']) kodi.StartVideoPlaylist() return build_alexa_response('Playing %s' % (heard_movie), card_title) else: return build_alexa_response( 'Could not find a movie called %s' % (heard_movie), card_title) else: return build_alexa_response('Error parsing results', card_title)
def alexa_play_movie(slots): movies_response = kodi.GetMovies() movies = movies_response['result']['movies'] heard_movie = str(slots['Movie']['value']).lower().translate(None, string.punctuation) located = None for movie in movies: ascii_name = movie['label'].encode('ascii', 'replace') movie_name = str(ascii_name).lower().translate(None, string.punctuation) if movie_name == heard_movie: located = movie_name movie_id = movie['movieid'] break if not located: # Try an exact match after removing any leading "the" heard_minus_the = remove_the(heard_movie) for movie in movies: ascii_name = movie['label'].encode('ascii', 'replace') movie_name = str(ascii_name).lower().translate(None, string.punctuation) if remove_the(movie_name) == heard_minus_the: located = movie_name movie_id = movie['movieid'] break if not located: # Last resort -- take out some useless words and see if we have a show with # any of the remaining words in common heard_list = set([x for x in heard_movie.split() if x not in STOPWORDS]) for movie in movies: movie_list = set(movie['label'].split()) if heard_list & movie_list: located = movie['label'] movie_id = movie['movieid'] break if located: kodi.ClearVideoPlaylist() kodi.PrepMoviePlaylist(movie_id) kodi.StartVideoPlaylist() return build_alexa_response('Playing %s' % (located)) else: return build_alexa_response('Could not find a movie called %s' % (heard_movie)) return build_alexa_response('This feature is not added yet')
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)
name_stripped = kodi.sanitize_name(v['label'], True) all.append(name) all.append(name_stripped) cleaned = list(set(all)) cleaned = filter(None, cleaned) random.shuffle(cleaned) cleaned = cleaned[:300] gfile = open('MOVIEGENRES', 'w') for a in cleaned: gfile.write("%s\n" % a) gfile.close() # Generate MOVIES Slot retrieved = kodi.GetMovies() all = [] if 'result' in retrieved and 'movies' in retrieved['result']: for v in retrieved['result']['movies']: name = kodi.sanitize_name(v['label']) name_stripped = kodi.sanitize_name(v['label'], True) all.append(name) all.append(name_stripped) cleaned = list(set(all)) cleaned = filter(None, cleaned) random.shuffle(cleaned) cleaned = cleaned[:300]