AmirShabani commited on
Commit
966b550
1 Parent(s): bf5ecf9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -5
app.py CHANGED
@@ -35,6 +35,7 @@ def get_data(movie):
35
  data = response.json()
36
 
37
  if data['Response'] == 'True': # Check if the response is successful
 
38
  poster = data["Poster"]
39
  title = data["Title"]
40
  year = data["Year"]
@@ -44,7 +45,7 @@ def get_data(movie):
44
  rating = data["imdbRating"]
45
  # Return a dictionary with the information
46
  return {
47
-
48
  "poster": poster,
49
  "title": title,
50
  "director": director,
@@ -105,9 +106,10 @@ def display_movie(movie, rating):
105
 
106
  global user_input
107
  data = get_data(movie)
108
- user_input[f"{data['title']} ({data['year']})"] = rating
109
- poster = get_poster(movie)
110
-
 
111
  if len(user_input) == 5:
112
  # Get the recommended movies from the input
113
  r_movies, r_posters = get_recommendations(user_input)
@@ -119,10 +121,12 @@ def display_movie(movie, rating):
119
  # Return the output
120
  return f"Your movies are ready!\nPlease check the recommendations below.", np.zeros((500, 500, 3)), html_code
121
 
122
- else:
123
 
124
  # Return the input movie name and poster
125
  return f"You entered {movie} with rating {rating}", poster, ""
 
 
126
 
127
  # Interface
128
  iface = gr.Interface(
 
35
  data = response.json()
36
 
37
  if data['Response'] == 'True': # Check if the response is successful
38
+ status = data['Response']
39
  poster = data["Poster"]
40
  title = data["Title"]
41
  year = data["Year"]
 
45
  rating = data["imdbRating"]
46
  # Return a dictionary with the information
47
  return {
48
+ "status": status,
49
  "poster": poster,
50
  "title": title,
51
  "director": director,
 
106
 
107
  global user_input
108
  data = get_data(movie)
109
+ if data['status'] == True:
110
+ user_input[f"{data['title']} ({data['year']})"] = rating
111
+ poster = get_poster(data['title'])
112
+
113
  if len(user_input) == 5:
114
  # Get the recommended movies from the input
115
  r_movies, r_posters = get_recommendations(user_input)
 
121
  # Return the output
122
  return f"Your movies are ready!\nPlease check the recommendations below.", np.zeros((500, 500, 3)), html_code
123
 
124
+ elif data['status'] == True:
125
 
126
  # Return the input movie name and poster
127
  return f"You entered {movie} with rating {rating}", poster, ""
128
+ else:
129
+ return f"we can't find {movie} please try again", np.zeros((500, 500, 3)), ""
130
 
131
  # Interface
132
  iface = gr.Interface(