This colab notebook named catafest_050.ipynb will let you to get images from imdb.com by the name of the actor/actress.
You can find this notebook on my GitHub project.
Is a blog about python programming language. You can see my work with python programming language, tutorials and news.
C:\Python373\Scripts>pip3 install imdbpy
Collecting imdbpy
...
Installing collected packages: imdbpy
Successfully installed imdbpy-6.8
Let's test the new features:C:\Python373>python.exe
Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 21:26:53) [MSC v.1916 32 bit (Inte
l)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import imdb
>>> ia = imdb.IMDb()
>>> movies = ia.search_movie_advanced('debby does dallas', adult=True)
>>> print(movies)
...
>>> people = ia.search_person('Clark Gregg')
>>> print(people)
Let's test it:import imdb
from imdb import IMDb
ia = imdb.IMDb()
# create a file to put the output
file1 = open("_imdb_data.txt","w", encoding='utf-8')
# get movies by movie
# example: Alien
def get_by_movie():
my_movie = str(input('Type the movie name: '))
movies = ia.search_movie_advanced(my_movie, adult=True)
print(type(movies))
return movies
# get filmography by id
filmography_list = []
def get_filmography_by_id(id):
actor_results = ia.get_person_filmography(id)
for item in actor_results['data']['filmography']:
filmography_list.append(str(item))
return filmography_list
# the main function
def main():
a = get_by_movie()
for i in a:
print("________________________")
print("i: ",i)
# you can uncomment this to test Movie class functions
#print("Type:",type(i))
#print("Summary:",i.summary())
#print("ID: ",i.getID())
#print("Smart cannonical title: ",i.smartCanonicalTitle())
#print("caracters ref: ",i.get_charactersRefs())
#print("current info: ",i.get_current_info())
#print("cinematographic process: ",i.get('cinematographic process'))
#print(i["title"])
#print informations items from Movie class
print("~~~~~~~~~~~~~~~~~~~~~~~~")
for k, v in i.items():
print(k, v)
# write to the file the value of a
txt = str(k)+":"+str(v)+"\n"
file1.write(txt)
print("------------------------")
# add a new line on each movie
file1.write('-----^-----\n')
#get filmography by id
id_filmography=get_filmography_by_id('0078748')
# print the filmography
for item in id_filmography:
print(item)
#after write, close the file
file1.close()
if __name__ == '__main__':
main()
This is the first part of the output file named _imdb_data:title:Alien
certificates:['R']
runtimes:['117']
genres:['Horror', 'Sci-Fi']
rating:8.5
votes:719508
metascore:89
gross:78900000
plot:After a space merchant vessel perceives an unknown transmission as a distress call, its landing on the source moon finds one of the crew attacked by a mysterious lifeform, and they soon realize that its life cycle has merely begun.
directors:[]
cast:[, , , ]
cover url:https://m.media-amazon.com/images/M/MV5BMmQ2MmU3NzktZjAxOC00ZDZhLTk4YzEtMDMyMzcxY2IwMDAyXkEyXkFqcGdeQXVyNzkwMjQ5NzM@._V1_UX67_CR0,0,67,98_AL_.jpg
year:1979
kind:movie
canonical title:Alien
long imdb title:Alien (1979)
long imdb canonical title:Alien (1979)
smart canonical title:Alien
smart long imdb canonical title:Alien (1979)
full-size cover url:https://m.media-amazon.com/images/M/MV5BMmQ2MmU3NzktZjAxOC00ZDZhLTk4YzEtMDMyMzcxY2IwMDAyXkEyXkFqcGdeQXVyNzkwMjQ5NzM@.jpg
-----^-----
title:Aliens
certificates:['R']
runtimes:['137']
...
[mythcat@desk ~]$ pip install imdbpy --user
Collecting imdbpy
...
Successfully installed SQLAlchemy-1.3.1 imdbpy-6.6
I used an example of a person's search in the IMDB database to test this method.>>> from imdb import IMDb, IMDbError
>>> try:
... im=IMDb()
... people = im.search_person('Mel Gibson')
... except IMDbError as exc:
... print(exc)
Using the dir and print function will show the resulting output configuration and will have the following form:>>> print(people)
[, , , , , , , , , , , , , , , , , , , ]
I have used the dir function for a relative view of the options we have:>>> print(dir(people))
['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__delslice__', '__doc__',
'__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__getslice__',
'__gt__', '__hash__', '__iadd__', '__imul__', '__init__', '__iter__', '__le__', '__len__',
'__lt__', '__mul__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__reversed__',
'__rmul__', '__setattr__', '__setitem__', '__setslice__', '__sizeof__', '__str__', '__subclasshook__',
'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']
>>> print(dir(people[0]))
['_Container__role', '__bool__', '__class__', '__contains__', '__deepcopy__', '__delattr__',
'__delitem__', '__dict__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',
'__getitem__', '__gt__', '__hash__', '__init__', '__le__', '__len__', '__lt__', '__module__',
'__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setitem__',
'__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_additional_keys', '_clear',
'_get_currentRole', '_get_roleID', '_getitem', '_image_key', '_init', '_reset', '_roleClass',
'_roleIsPerson', '_set_currentRole', '_set_roleID', 'accessSystem', 'add_to_current_info',
'append_item', 'asXML', 'billingPos', 'charactersRefs', 'clear', 'cmpFunct', 'copy', 'currentRole',
'current_info', 'data', 'default_info', 'get', 'getAsXML', 'getID', 'get_charactersRefs',
'get_current_info', 'get_fullsizeURL', 'get_namesRefs', 'get_titlesRefs', 'has_current_info',
'has_key', 'infoset2keys', 'isSame', 'isSameName', 'isSamePerson', 'items', 'iteritems',
'iterkeys', 'itervalues', 'key2infoset', 'keys', 'keys_alias', 'keys_tomodify', 'keys_tomodify_list',
'modFunct', 'myID', 'myName', 'namesRefs', 'notes', 'personID', 'pop', 'popitem', 'reset', 'roleID',
'set_current_info', 'set_data', 'set_item', 'set_mod_funct', 'set_name', 'setdefault', 'summary',
'titlesRefs', 'update', 'update_charactersRefs', 'update_infoset_map', 'update_namesRefs',
'update_titlesRefs', 'values']
Here are some simple examples of displaying using the print function to view content in output:
>>> print(people[0].values())
[u'Catalin', u'II', u'Catalin', u'Catalin (II)', u'Catalin (II)']
>>> print(people[0].data)
{u'name': u'Catalin', u'imdbIndex': u'II'}
>>> print(people[1].data.viewitems())
dict_items([(u'name', u'Moreno, Catalina Sandino')])
>>> print(people[1].data.values())
[u'Moreno, Catalina Sandino']
>>> print(people[0].getID())
2165704
>>> print(people[0].itervalues())
The built-in function iter takes an iterable object and returns an iterator.>>> print(people[0].itervalues().next())
Catalin
>>> print(people[0].asXML())
The last line of code will return XML content.C:\Python364\Scripts>pip install IMDbPY
Requirement already satisfied: IMDbPY in c:\python364\lib\site-packages
Requirement already satisfied: lxml in c:\python364\lib\site-packages (from IMDbPY)
Requirement already satisfied: sqlalchemy-migrate in c:\python364\lib\site-packages (from IMDbPY)
Requirement already satisfied: SQLAlchemy in c:\python364\lib\site-packages (from IMDbPY)
Requirement already satisfied: pbr>=1.8 in c:\python364\lib\site-packages (from sqlalchemy-migrate->IMDbPY)
Requirement already satisfied: decorator in c:\python364\lib\site-packages (from sqlalchemy-migrate->IMDbPY)
Requirement already satisfied: six>=1.7.0 in c:\python364\lib\site-packages (from sqlalchemy-migrate->IMDbPY)
Requirement already satisfied: sqlparse in c:\python364\lib\site-packages (from sqlalchemy-migrate->IMDbPY)
Requirement already satisfied: Tempita>=0.4 in c:\python364\lib\site-packages (from sqlalchemy-migrate->IMDbPY)
This is my source code to test it and working well.# start with IMDb python class
from imdb import IMDb
imd = IMDb('http')
print("-===-")
# search movies by title
# and show the long imdb canonical title and movieID of the results.
title = imd.search_movie("Under the Dome")
for item in title:
print(item['long imdb canonical title'], item.movieID)
print("-===-")
# search for a person
for person in imd.search_person("Ana de Armas"):
print(person.personID, person['name'])
print("-===-")
# get 5 movies tagged with a keyword
movies_keyword = imd.get_keyword('novel', results=5)
for item in movies_keyword:
print(item['long imdb canonical title'], item.movieID)
print("-===-")
# get top 250 from top movies
top250 = imd.get_top250_movies()
for item in top250:
print(item['long imdb canonical title'], item.movieID)
print("-===-")
print("top 250 -=> ")
# get bottom 100 from top movies
bottom100 = imd.get_bottom100_movies()
print("bottom 100 -=> ")
for item in top250:
print(item['long imdb canonical title'], item.movieID)