Sep-04-2023, 02:14 PM
(Sep-04-2023, 01:54 PM)deanhystad Wrote: Post full error message and trace. Or would it be better if I installed the module so I can run your code snd maybe see the error?
My guess would be that tt4154796 is not a valid id. I did type this in as a search on imdb.com and it pulled up Avengers: End Game, so maybe the problem is something else. Hard to say without any information about the error.
Why are you using this package instead of something like Cinemagoer (used to be imdbPy)?
ok so basically i updated my code a bit. I first look for a movie based on title. I then confirm that is the movie the user is looking for. After that i try to receive information about the movie based on the movie ID. However i still have the same problem. Basically i want to be able to get movie data from the movie id variable and use that to print out data like director(s),actor(s) etc. My code is:
import imdb as im from tkinter import * from tkinter import simpledialog,messagebox from imdby.imdb import imdb def get_data(movie_id): details=imdb(movie_id) print(details) messagebox.showinfo(title="Movie Information",message=f"{details}") def search_for_film(name): cg = im.Cinemagoer() search = cg.search_movie(name) for i in range(len(search)): if messagebox.askokcancel(title=f"Movie Title",message=f"Is {search[i]} the movie you are looking for?"): id=search[i].movieID get_data(id) return id window=Tk() ia=im.IMDb() window.config(padx=50,pady=50) window.title("Movie Information App") canvas=Canvas(width=523,height=523) pic=PhotoImage(file="./IMDb_Jobs_Header_Mobile.png") bg_img=canvas.create_image(272,272,image=pic) canvas.grid(row=1,column=0) movie_name=simpledialog.askstring(title="Movie Information",prompt="Choose a film") movie_id=search_for_film(movie_name) window.mainloop()My current error code is:
Error:Traceback (most recent call last):
File "C:\Users\giorg\PycharmProjects\pythonProject2\IMDB\main.py", line 30, in <module>
movie_id=search_for_film(movie_name)
File "C:\Users\giorg\PycharmProjects\pythonProject2\IMDB\main.py", line 18, in search_for_film
get_data(id)
File "C:\Users\giorg\PycharmProjects\pythonProject2\IMDB\main.py", line 7, in get_data
details=imdb(movie_id)
File "C:\Users\giorg\AppData\Local\Programs\Python\Python39\lib\site-packages\imdby\imdb.py", line 23, in __init__
release_info.__init__(self, titleid)
File "C:\Users\giorg\AppData\Local\Programs\Python\Python39\lib\site-packages\imdby\release_info.py", line 28, in __init__
releases_index = [i for i in range(len(soup.select('h4'))) if 'release' in ' '.join(soup.select('h4')[i].text.split()).lower()][0]
IndexError: list index out of range