Spaces:
Sleeping
Sleeping
Moiz
commited on
Commit
·
90326d2
1
Parent(s):
8ac4279
movie display
Browse files
app.py
CHANGED
@@ -1,20 +1,31 @@
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
-
# Function to fetch movie details
|
5 |
-
def
|
6 |
api_key = "f2443b04"
|
7 |
-
|
|
|
8 |
response = requests.get(url)
|
9 |
|
10 |
if response.status_code == 200:
|
11 |
movie_data = response.json()
|
12 |
if movie_data.get("Response") == "True":
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
else:
|
19 |
return f"Error: {movie_data.get('Error', 'Movie not found.')}"
|
20 |
else:
|
@@ -22,17 +33,13 @@ def fetch_and_rate_movie(movie_id, rating):
|
|
22 |
|
23 |
# Gradio interface
|
24 |
with gr.Blocks(css="styles.css") as app:
|
25 |
-
gr.Markdown("# Movie
|
26 |
-
|
27 |
-
|
28 |
-
minimum=0,
|
29 |
-
maximum=10,
|
30 |
-
step=0.25,
|
31 |
-
elem_id="custom-slider" # Add a custom ID
|
32 |
)
|
33 |
-
|
34 |
-
output = gr.Textbox(label="Your Feedback")
|
35 |
|
36 |
-
|
|
|
37 |
|
38 |
app.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import requests
|
3 |
|
4 |
+
# Function to fetch movie details using the fixed movieID
|
5 |
+
def fetch_movie_info():
|
6 |
api_key = "f2443b04"
|
7 |
+
movie_id = "tt1305806" # Fixed movie ID
|
8 |
+
url = f"http://www.omdbapi.com/?apikey={api_key}&i={movie_id}&plot=full"
|
9 |
response = requests.get(url)
|
10 |
|
11 |
if response.status_code == 200:
|
12 |
movie_data = response.json()
|
13 |
if movie_data.get("Response") == "True":
|
14 |
+
title = movie_data.get("Title", "N/A")
|
15 |
+
year = movie_data.get("Year", "N/A")
|
16 |
+
plot = movie_data.get("Plot", "N/A")
|
17 |
+
imdb_rating = movie_data.get("imdbRating", "N/A")
|
18 |
+
box_office = movie_data.get("BoxOffice", "N/A")
|
19 |
+
genre = movie_data.get("Genre", "N/A")
|
20 |
+
|
21 |
+
return (
|
22 |
+
f"**Title:** {title}\n"
|
23 |
+
f"**Year:** {year}\n"
|
24 |
+
f"**Genre:** {genre}\n"
|
25 |
+
f"**Plot:** {plot}\n"
|
26 |
+
f"**IMDb Rating:** {imdb_rating}/10\n"
|
27 |
+
f"**Box Office:** {box_office}\n"
|
28 |
+
)
|
29 |
else:
|
30 |
return f"Error: {movie_data.get('Error', 'Movie not found.')}"
|
31 |
else:
|
|
|
33 |
|
34 |
# Gradio interface
|
35 |
with gr.Blocks(css="styles.css") as app:
|
36 |
+
gr.Markdown("# Movie Information Display")
|
37 |
+
gr.Markdown(
|
38 |
+
"This app automatically fetches and displays information about the movie: *The Secret in Their Eyes*."
|
|
|
|
|
|
|
|
|
39 |
)
|
40 |
+
output = gr.Textbox(label="Movie Details", lines=10)
|
|
|
41 |
|
42 |
+
# Automatically populate the textbox when the app starts
|
43 |
+
output.update(value=fetch_movie_info())
|
44 |
|
45 |
app.launch()
|