###################################################################### # URL: https://github.com/alberanid/imdbpy # # install-best: pip install git+https://github.com/alberanid/imdbpy # # install: pip install imdbpy # # # # 08-14-2021: added support for actor's real names # # July 2021: created. # ###################################################################### # Davide Alberani's most excellent module, without which this script would # not be possible from imdb import IMDb import datetime import sys import argparse # first parameter is required; # second and third parameters are optional parser = argparse.ArgumentParser(description="Gets an actors filmography from the ImBD (Internet Movie Database)[http://www.imdb.com].") parser.add_argument("imdbID", type=str, help="Actor's ID (required)") parser.add_argument("-f", "--filename", type=str, default="Filmography", help="Alternate .HTM filename for output, default='Filmography") parser.add_argument("-r", "--realname", type=str, default="cornBunion", help="Actor's real name") lstCommandLine = parser.parse_args() if(lstCommandLine.realname != "cornBunion"): strRealName = '(' + lstCommandLine.realname + ')' else: strRealName = "()" # fetch an actor's filmography and dump to webpage with checkmark support def Create_Actor_Filmography(strImdbID, strWebPageName, strPersonRealName): # create an instance of the IMDb class objIMDB = IMDb() # open the file objWebPage = open(strWebPageName + '.htm', 'w') # get a person - say, Lindsay Wagner ('0905993'). We just want the filmography object objActor = objIMDB.get_person(strImdbID, info=['filmography']) # beginning tags objWebPage.writelines('' + '\n\n') objWebPage.writelines('' + '\n\n') objWebPage.writelines('' + '\n') objWebPage.writelines('\t' + objActor['name'] + ' - Filmography' + '\n') objWebPage.writelines('\t' + '\n') objWebPage.writelines('\t' + '\n') objWebPage.writelines('\t' + '\n') objWebPage.writelines('\t' + '\n') objWebPage.writelines('' + '\n\n') objWebPage.writelines('' + '\n\n') # Header objWebPage.writelines('\t

' + objActor['name'] + '

\n') objWebPage.writelines('\t

' + strPersonRealName + '

\n\n') objWebPage.writelines('\t
last updated ' + datetime.datetime.now().strftime("%x") + '

\n\n') # Table objWebPage.writelines('\t' '\n') objWebPage.writelines('\t\t\n') # Movie List for job in objActor['filmography'].keys(): for movie in objActor['filmography'][job]: # movie['year'] won't work if it's a TV series, we just want movies anyway (actress, self) and (job == "actress") if (movie['kind'] == 'movie' or movie['kind'] == 'tv movie') and (job == "actress" or job == "actor"): objWebPage.writelines('\t\t\n') # ending tags objWebPage.writelines('\t
ObtainedMovie
 ') try: objWebPage.writelines('%s [role: %s] (%s)' % (movie['title'], movie.currentRole, movie['year'])) except: objWebPage.writelines('%s [role: %s] [%s]' % (movie['title'], movie.currentRole, 'In Production')) objWebPage.writelines('
\n\n') objWebPage.writelines('\n') objWebPage.writelines('\n') # close the file objWebPage.close() print('\nCreated ' + objActor['name'] + ' filmography web page.\n') # Call the function Create_Actor_Filmography(lstCommandLine.imdbID , lstCommandLine.filename, strRealName)