I want to be able to be able to give a script a person's IMDB ID and then the script will print out the person's filmography.
Here is the code I have so far:
import imdb
moviesDB = imdb.IMDb()
#PeterDinklage IMDB ID
ActorId = "0227759"
person = moviesDB.get_person(ActorId)
#Actor's name
print (person)
actor_work = moviesDB.get_person_filmography(ActorId)
print (actor_work['data']['filmography']['actor'])
This would give me an output that is messy and looks like this :
[<Movie id:6674864[http] title:_The Dwarf () (None)_>, <Movie id:2028582[http] title:_The Wild Bunch (2022)_>, <Movie id:4058618[http] title:_The Thicket () (None)_>, ...]
I could parse through this output to get the format I desire but I was wondering if there was a cleaner way to grab the information so that the output looked more like this:
The Dwarf ()
The Wild Bunch (2022)
The Thicket ()
...
I realized I could do something with a for loop like this:
for movie in actor_work['data']['filmography']['actor'] :
print (movie)
but this would just give me an output with the movie names and not include the year of the movie or tv show.