-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathomdb.py
29 lines (21 loc) · 1.03 KB
/
omdb.py
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
import keys, requests
from fileio import write_to_file
def movie_info(movie):
rotten_tomatoes_rating=str(round(10-float(movie['imdbRating']),2))
result_str="\nTitle: "+movie['Title']+";"+'Year: '+movie['Year']+";" +'IMDB rating: '+movie['imdbRating']+";"+'Rotten Tomatoes Rating:'+rotten_tomatoes_rating+";"+'Country: '+movie['Country']+";"+'Language: '+movie['Language']+";"+'Plot: '+movie['Plot']+";"+'Actors: '+movie['Actors']
write_to_file(result_str.replace(";","\n"))
print("_______________________________________________")
for item in result_str.split(";"):
print(item)
print("_______________________________________________")
def search_movie(movie_name):
default_movie = "Mr. Nobody"
if not movie_name:
movie_name = default_movie
apikey = keys.omdb["apikey"]
url = keys.omdb["url"]+"/?apikey="+apikey+"&t="+movie_name
result = requests.get(url).json()
if result['Response'] == 'True':
movie_info(result)
else:
print(result['Error'])