Getting a list of of everyone's filmography from an entire list

8 views
Skip to first unread message

Ann Laura Walker

unread,
Apr 9, 2021, 3:14:43 PM4/9/21
to imdbpy-users
Hello! 

I was wondering if someone could help me get a list of all the actor's actress's filmography from a single show? 

full_cast = ia.get_movie('0203259', 'full credits')
full_cast = full_cast['cast']
full_cast

I can get the filmography of one person using:
ice_t=i.get_person('0001384')
for job in ice_t['filmography'].keys():
    print('# Job:', job)
    for movie in ice_t['filmography'][job]:
        print('\t t%s %s (role: %s)' % (movie.movieID, movie['title'], movie.currentRole))

but i dont know how to apply the function above to full_cast. Can someone help? 

Thank you
Laura

Davide Alberani

unread,
Apr 11, 2021, 10:06:26 AM4/11/21
to imdbpy...@googlegroups.com
Hi Ann,
if I understand correctly, you want to iterate over each episode of a TV show,
and for each one of them collect the cast list.

I think something similar was done in this answer to a recent issue:
https://github.com/alberanid/imdbpy/issues/307#issuecomment-787101268

The author was using it to collect runtimes, you just need to extend
the 'for' cycle to do what you need with the cast.

Something like this (not tested):

for ep in episodes:
api.update(ep, ['main'])
cast = ep.get('cast', [])
for person in cast:
....your code here...


Hope this helps.
> --
> You received this message because you are subscribed to the Google Groups "imdbpy-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to imdbpy-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/imdbpy-users/0d982c90-2ec4-4b60-85fb-9074b4f07a63n%40googlegroups.com.



--
Davide Alberani <davide....@gmail.com> [PGP KeyID: 0x3845A3D4AC9B61AD]
http://www.mimante.net/

Ann Laura Walker

unread,
Apr 12, 2021, 11:12:46 AM4/12/21
to imdbpy...@googlegroups.com
This is so close and I thank you Davide!

I have the entire cast, all 7K people. I'd like to get each person's filmography. Is this possible?

Laura

You received this message because you are subscribed to a topic in the Google Groups "imdbpy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/imdbpy-users/AvoAw_tjdgM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to imdbpy-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/imdbpy-users/CAHmiXyMb1R7uZ%2B2rFkQZmhSw%2BvBtguuemOaHQ98H-dRFXLH4UA%40mail.gmail.com.

Davide Alberani

unread,
Apr 12, 2021, 4:35:17 PM4/12/21
to imdbpy...@googlegroups.com, Ann Laura Walker
Hi Ann Laura,
sure, it should be easy (but it could take some time for 7k persons).

In short, when you are iterating over the cast list using the "person" variable
you have an instance of the Person class.
Since it was create with just the information available in the episode page,
it contains very little data (name, imdbID and maybe their role and notes).

Fortunately, you can easily update a Person instance with the the
missing information;
to do so you have to use the "update" method of the IMDb instance you
have created
at the beginning of your script (in the above example, the "api" variable).

Something like that should be close to what you need:

for ep in episodes:
api.update(ep, ['main'])
cast = ep.get('cast', [])
for person in cast:
api.update(person)
for movie in person.get('filmography', []):
...your code that uses the "movie" object here...

In the same way if you now need more information about the "movie" object
you can just call api.update(movie), but beware that it will also do a lot of
queries to the IMDb servers, and so it will be really slow.

For more information about the available data sets, see
https://imdbpy.readthedocs.io/en/latest/usage/data-interface.html


Bye,

On Mon, Apr 12, 2021 at 5:12 PM Ann Laura Walker
> To view this discussion on the web visit https://groups.google.com/d/msgid/imdbpy-users/CA%2BSsSx5nEsH13S%3Dj4o3HvmqmDQeo-h4byGc4pKvdB-k4ZhmMqQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages