def run(self, dispatcher, tracker, domain): # from telegram import Voice # from mutagen.mp3 import MP3 movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) logger.debug("movie: " + movie) result = movie_buff.get_director(movie) logger.debug("Result: " + str(result)) if result is None: dispatcher.utter_message( "I'm sorry, I searched everywhere but I found nothing") else: answer = "The director of " + movie + " is " + result # tts = gTTS(answer, lang='en') # tts.save(audio_folder+"/message.mp3") # audio = open(audio_folder+"/message.mp3", "rb") # audio_len = MP3(audio_folder+"/message.mp3").info.length # voice = Voice(audio, audio_len) # dispatcher.utter_audio(audio, answer) dispatcher.utter_message(answer) return [SlotSet("director.name", result)]
def run(self, dispatcher, tracker, domain): infos = get_used_slots(slots, tracker) if infos is not None: movie_buff = MovieBuff(URI) result = movie_buff.get_movie(**infos) if result is not None: dispatcher.utter_message(str(len(result)) + " movies") else: dispatcher.utter_message("I got nothing, sorry") return []
def run(self, dispatcher, tracker, domain): infos = get_used_slots(slots, tracker) if infos is not None: movie_buff = MovieBuff(URI) result = movie_buff.get_movie(**infos) if result is not None: dispatcher.utter_message("I found these movies:") for movie in result: dispatcher.utter_message("\t- " + movie.title) return [SlotSet("movie_list", result)] return []
def run(self, dispatcher, tracker, domain): movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) result = movie_buff.get_gross(movie) if result is None: dispatcher.utter_message("I'm sorry, but I don't know :(") else: dispatcher.utter_message("This movie earned " + str(result) + "$") return [SlotSet("movie.gross_revenue", result)]
def run(self, dispatcher, tracker, domain): movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) result = movie_buff.get_language(movie) if result is None: dispatcher.utter_message("I'm sorry, but I don't know :(") else: dispatcher.utter_message(movie + " was filmed in " + result.lower()) result[SlotSet("movie.language", result)]
def run(self, dispatcher, tracker, domain): movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) result = movie_buff.get_runtime(movie) if result is None: dispatcher.utter_message("I'm sorry, but I don't know :(") else: dispatcher.utter_message(movie + " last " + str(result) + " minutes") return [SlotSet("movie.runtime", result)]
def run(self, dispatcher, tracker, domain): movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) result = movie_buff.get_rating(movie) if result is None: dispatcher.utter_message("I'm sorry, but I don't know :(") else: dispatcher.utter_message("The IMDb score for this movie is: " + str(result)) return [SlotSet("movie.star_rating", result)]
def run(self, dispatcher, tracker, domain): movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) result = movie_buff.get_country(movie) if result is None: dispatcher.utter_message( "I guess it comes from nowhere, because I found nothing") else: dispatcher.utter_message(movie + " was made in " + result) return [SlotSet("movie.location", result)]
def run(self, dispatcher, tracker, domain): movie_buff = MovieBuff(URI) result = movie_buff.get_directors_movies() if result is None: dispatcher.utter_message("Sorry, something went wrong") else: dispatcher.utter_message( "I selected a bunch of movies of three directors") for el in result: dispatcher.utter_message(el + ":") for movie in result[el]: dispatcher.utter_message("- " + movie.title) return []
def run(self, dispatcher, tracker, domain): movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message( "I'm afraid I didn't understand the movie title") else: movie_buff = MovieBuff(URI) result = movie_buff.get_budget(movie) if result is None: dispatcher.utter_message("I'm sorry, but I don't know :(") else: dispatcher.utter_message("The budget for this movie was " + str(result) + "$") return [SlotSet("movie.budget", result)]
def run(self, dispatcher, tracker, domain): infos = get_used_slots(slots, tracker) movie_buff = MovieBuff(URI) if infos is None: movies = movie_buff.get_movies_revenues(**infos) else: movies = movie_buff.get_movies_revenues(infos=None) if movies is None: dispatcher.utter_message("I got nothing :(") else: dispatcher.utter_message("Here are some results I found:") for movie in movies: logger.debug(movie) dispatcher.utter_message(movie.title + ": " + movie.gross + "$") return []
def run(self, dispatcher, tracker, domain): dispatcher.utter_message("I'm searching for the year of production") movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) result = movie_buff.get_year(movie) if result is None: dispatcher.utter_message( "I'm sorry, I searched everywhere but I found nothing") else: year = str(result) answer = "This movie was made in " + year dispatcher.utter_message(answer) return [SlotSet("movie.release_date", str(result))]
def run(self, dispatcher, tracker, domain): dispatcher.utter_message("I'm searching for a movie") # director = tracker.get_slot("director") # movie = tracker.get_slot("movie") # producer = tracker.get_slot("producer") current_slots = {} for slot in slots: current_slots[slot] = tracker.get_slot(slot) movie_buff = MovieBuff(URI) # result = movie_buff.get_movie(director=director, movie=movie, producer=producer) result = movie_buff.get_titles(**current_slots) if result is None: dispatcher.utter_message("No movie found") return [] else: dispatcher.utter_message("I found this: " + result[0]) return [SlotSet("movie", result[0])]
def run(self, dispatcher, tracker, domain): vowels = ["a", "e", "i", "o", "u"] movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) result = movie_buff.get_genre(movie) if result is None: dispatcher.utter_message("I'm sorry, but I don't know :(") else: genre = result.split("|")[0] if genre[0].lower() in vowels: article = "an" else: article = "a" dispatcher.utter_message(movie + " is " + article + " " + genre + " movie") return [SlotSet("movie.genre", genre)]
def run(self, dispatcher, tracker, domain): movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) result = movie_buff.get_actors(movie) if result is None: dispatcher.utter_message( "Either this is a movie without actors or I got nothing in my database" ) else: if "|" in result: actor = result.split("|")[0] else: actor = result dispatcher.utter_message("Maybe " + actor + " is the actor you are looking for") return [SlotSet("actor.name", actor)]
def run(self, dispatcher, tracker, domain): movie = tracker.get_slot("movie.name") if movie is None: dispatcher.utter_message(didnt_get_title()) else: movie_buff = MovieBuff(URI) result = movie_buff.get_actors(movie) if result is None: dispatcher.utter_message( "Either this is a movie without actors or I got nothing in my database" ) else: results = [] for el in result.split("|"): if el != "": results.append(el) if len(results) > 0: dispatcher.utter_message("I got these actors: ") for el in results: dispatcher.utter_message("- " + el) return []