File size: 1,945 Bytes
2369a18
8ac4279
2369a18
90326d2
 
8ac4279
90326d2
b754266
8ac4279
 
 
 
 
90326d2
 
 
 
 
 
 
78e8840
8ac4279
78e8840
c6a3e36
8ac4279
2369a18
c6a3e36
1c16e20
90326d2
 
 
c6a3e36
78e8840
 
 
 
 
 
 
 
 
 
 
c6a3e36
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import gradio as gr
import requests

# Function to fetch movie details using the fixed movieID
def fetch_movie_info():
    api_key = "f2443b04"
    movie_id = "tt1305806"  # Fixed movie ID
    url = f"http://www.omdbapi.com/?apikey={api_key}&i={movie_id}"
    response = requests.get(url)
    
    if response.status_code == 200:
        movie_data = response.json()
        if movie_data.get("Response") == "True":
            title = movie_data.get("Title", "N/A")
            year = movie_data.get("Year", "N/A")
            plot = movie_data.get("Plot", "N/A")
            imdb_rating = movie_data.get("imdbRating", "N/A")
            box_office = movie_data.get("BoxOffice", "N/A")
            genre = movie_data.get("Genre", "N/A")
            
            return title, year, genre, plot, imdb_rating, box_office
        else:
            return "Error", "Error", "Error", "Error", "Error", "Error"
    else:
        return f"Failed to fetch movie details. HTTP Status Code: {response.status_code}"

# Gradio interface
with gr.Blocks(css="styles.css") as app:
    gr.Markdown("# Movie Information Display")
    gr.Markdown(
        "This app automatically fetches and displays information about the movie: *The Secret in Their Eyes*."
    )
    
    # Fetch movie details and display in separate elements
    title_output = gr.Textbox(label="Title", lines=1, value=fetch_movie_info()[0])
    year_output = gr.Textbox(label="Year", lines=1, value=fetch_movie_info()[1])
    genre_output = gr.Textbox(label="Genre", lines=1, value=fetch_movie_info()[2])
    plot_output = gr.Textbox(label="Plot", lines=5, value=fetch_movie_info()[3])
    imdb_rating_output = gr.Textbox(label="IMDb Rating", lines=1, value=fetch_movie_info()[4])
    box_office_output = gr.Textbox(label="Box Office", lines=1, value=fetch_movie_info()[5])

    # Adding a slider
    slider = gr.Slider(minimum=0, maximum=10, step=0.25, label="Rating Slider")

app.launch()