forked from Ishaan28malik/Hacktoberfest-2024
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imdb.py
52 lines (50 loc) · 1.64 KB
/
imdb.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import imdb # importing the module
ia = imdb.IMDb() # creating instance of IMDB
print("=======================")
name = input("Enter movie, tv series name : ") # movie name
search = ia.search_movie(name) # searching the movie
lst = list() # defining a list
lst1 = list()
lst2 = list()
for j in range(len(search)) :
id = search[j].movieID
lst1.append(search[j]["title"] + " : " + id)
lst2.append(id)
print(lst1)
print("====================================")
print("As there might me many unwanted results. Please select the movie you want the plot of")
print("\n")
movie = input("Enter the id of the movie or tv series whose plot you want : ")
index = lst2.index(movie)
Movie = search[index]
ia.update(Movie, info = ["plot"]) # to get the plot of the movie
print(Movie["plot"])
print("\n")
print("Cast of the movie or tv series : ")
movies = ia.get_movie(movie)
cast = movies["cast"] # to get the cast of the movie
for i in cast :
actor = i
print(actor)
print("\n")
print("Director of film or writer of series : ")
try :
for director in movies["directors"] : # try and except is used to prevent error messages that show up while compiling
print(director["name"])
except :
for writer in movies["writer"] :
print(writer["name"])
print("\n")
try :
print("Ratings : ")
rating = movies.data["rating"]
print(rating)
except :
print("Sorry something went wrong, could't get the ratings :(")
print("\n")
try :
print("Genres : ")
genre = movies.data["genres"]
print(genre)
except :
print("Sorry something went wrong, could't get the genres :(")