MovieSug / app.py
RakanAlsheraiwi's picture
Update app.py
e3b51dc verified
import gradio as gr
def movie_suggestion(genre):
movies = {
"action": [
{"title": "Mad Max: Fury Road", "description": "A high-octane post-apocalyptic thriller. πŸš—πŸ’₯"},
{"title": "John Wick", "description": "A retired hitman seeks vengeance. πŸ•΅οΈβ€β™‚οΈπŸ”«"},
{"title": "Die Hard", "description": "An NYPD officer tries to save his wife and others taken hostage by terrorists. πŸš“πŸ§¨"}
],
"comedy": [
{"title": "The Grand Budapest Hotel", "description": "A quirky comedy set in a famous European hotel. πŸ¨πŸ˜‚"},
{"title": "Superbad", "description": "Two friends try to make the most of their last days of high school. πŸŽ“πŸ€£"},
{"title": "Step Brothers", "description": "Two middle-aged men become step brothers and cause chaos. πŸ‘¨β€πŸ¦±πŸ‘¨β€πŸ¦°πŸ€ͺ"}
],
"drama": [
{"title": "The Pursuit of Happyness", "description": "A man's struggle with homelessness while raising his son. πŸ‘¨β€πŸ‘¦πŸ˜’"},
{"title": "Forrest Gump", "description": "The story of a man's extraordinary life. πŸƒβ€β™‚οΈπŸŽ–οΈ"},
{"title": "The Shawshank Redemption", "description": "A man imprisoned for a crime he didn't commit forms a friendship with a fellow inmate. πŸš”πŸ€"}
],
"sci-fi": [
{"title": "Dune", "description": "A young man faces his destiny on a desert planet. πŸœοΈπŸ‘¨β€πŸš€"},
{"title": "Blade Runner 2049", "description": "A futuristic detective uncovers secrets about human existence. πŸ€–πŸ”"},
{"title": "Interstellar", "description": "A team of explorers travel through a wormhole in space. πŸŒŒπŸš€"}
]
}
if genre.lower() in movies:
genre_movies = movies[genre.lower()]
suggestions = "Here are some movie suggestions based on your selected genre:\n\n"
for movie in genre_movies:
suggestions += f"**{movie['title']}**: {movie['description']}\n\n"
return suggestions
else:
return "Sorry, we don't have suggestions for that genre yet!"
interface = gr.Interface(
fn=movie_suggestion,
inputs=gr.Dropdown(["Action", "Comedy", "Drama", "Sci-Fi"], label="Choose a genre"),
outputs=gr.Markdown(),
title="Movie Suggestions",
description="Choose your preferred genre to receive a list of recommended movies."
)
interface.launch()