Spaces:
Runtime error
Runtime error
tobiasaurer
commited on
Commit
•
5ee2e22
1
Parent(s):
1b3c4fd
adds errorhandling
Browse files
pages/1 - Popularity-Based Recommender.py
CHANGED
@@ -70,12 +70,15 @@ def get_popular_recommendations_streaming(n, genres, time_range, country, url, h
|
|
70 |
for id in imdb_ids:
|
71 |
|
72 |
# make api call
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
76 |
|
77 |
-
|
78 |
-
|
|
|
|
|
79 |
|
80 |
recommendations_ids.rename(columns= {'title': 'Movie Title', 'genres': 'Genres'}, inplace = True)
|
81 |
|
|
|
70 |
for id in imdb_ids:
|
71 |
|
72 |
# make api call
|
73 |
+
try:
|
74 |
+
querystring = {"country":country,"imdb_id":id,"output_language":"en"}
|
75 |
+
response = requests.request("GET", url, headers=headers, params=querystring)
|
76 |
+
streaming_info = response.json()
|
77 |
|
78 |
+
for streaming_service in streaming_info['streamingInfo']:
|
79 |
+
recommendations_ids.loc[recommendations_ids['imdbId'] == id, 'Streaming Availability'] += f"{streaming_service}: {streaming_info['streamingInfo'][streaming_service][country]['link']} \n"
|
80 |
+
except:
|
81 |
+
continue
|
82 |
|
83 |
recommendations_ids.rename(columns= {'title': 'Movie Title', 'genres': 'Genres'}, inplace = True)
|
84 |
|
pages/2 - Similarity-Based Recommender.py
CHANGED
@@ -87,12 +87,15 @@ def get_similar_recommendations_streaming(movie_title, n, genres, time_range, co
|
|
87 |
for id in imdb_ids:
|
88 |
|
89 |
# make api call
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
93 |
|
94 |
-
|
95 |
-
|
|
|
|
|
96 |
|
97 |
recommendations_ids.rename(columns= {'title': 'Movie Title', 'genres': 'Genres'}, inplace = True)
|
98 |
|
|
|
87 |
for id in imdb_ids:
|
88 |
|
89 |
# make api call
|
90 |
+
try:
|
91 |
+
querystring = {"country":country,"imdb_id":id,"output_language":"en"}
|
92 |
+
response = requests.request("GET", url, headers=headers, params=querystring)
|
93 |
+
streaming_info = response.json()
|
94 |
|
95 |
+
for streaming_service in streaming_info['streamingInfo']:
|
96 |
+
recommendations_ids.loc[recommendations_ids['imdbId'] == id, 'Streaming Availability'] += f"{streaming_service}: {streaming_info['streamingInfo'][streaming_service][country]['link']} \n"
|
97 |
+
except:
|
98 |
+
continue
|
99 |
|
100 |
recommendations_ids.rename(columns= {'title': 'Movie Title', 'genres': 'Genres'}, inplace = True)
|
101 |
|