Package: omdb
Python wrapper aroundThe Open Movie Database API(a.k.a.OMDb API):http://omdbapi.com/NOTE:This library and its author are not endorsed by or affiliated withOMDbAPI.com.InstallationUsingpip:pip install omdbDependenciesrequests >= 2.0.1APIEachomdb.pymethod supports the same parameters as theOMDb API.ParamtersOMDb API Paramomdb.py ParamValueDescriptionssearchstring(optional)title of media to search foriimdbidstring(optional)a valid IMDb IDttitlestring(optional)title of media to returnyyearyear(optional)year of mediapagepagepage(optional)page to returnSeasonseasonseason(optional)season numberEpisodeepisodeepisode(optional)episode numbertypemedia_typestring(optional)media type to return (one ofmovie,episode, orseries)plot=fullfullplot=Truefullinclude extended plotplot=shortfullplot=Falseshortinclude short plot(default)tomatoes=truetomatoes=Truetrue(optional)add Rotten Tomatoes data to responseNOTE:By default allOMDb APIresponses are formatted asJSON. However,OMDb APIalso supports responses formatted asXML. Sinceomdb.pywill handleJSONtodictconversion automatically, it’s generally not necessary (nor is it supported by the mainombd.pymethods) to returnXMLformatted responses. But this can be accomplished by directly usingomdb.request:importomdb# must use OMDb API parametersres=omdb.request(t='True Grit',y=1969,r='xml')xml_content=res.contentMethodsAll methods are accessible via:importomdb# omdb.<method>MethodDescriptionReturnsget(**params)Generic request to OMDb API (requires keyword argument passing of all parameters).dictsearch(search, **params)Search by string.listsearch_movie(search, **params)Search movies by string.listsearch_episode(search, **params)Search episodes by string.listsearch_series(search, **params)Search series by string.listimdbid(imdbid, **params)Get by IMDB IDdicttitle(title, **params)Get by titledictset_default(key, default)Set default request parameterNoneClientInstead of using theomdbmodule to access the OMDb API, one can create anOMDBClientinstance:fromomdbimportOMDBClientclient=OMDBClient(apikey=API_KEY)Class MethodsDescriptionReturnsget(**omdb_params)Generic request to OMDb API which can be used for any type of query.listordictrequest(**omdbapi_params)Lower-level request to OMDb API which accepts URL query parameters supported by OMDb API.request.Responseset_default(key, default)Set default request parameter.NoneAPI DataAPI data returned from theOMDb APIis returned as a dictionary with their fields converted fromCamelCasetounderscore_case.Search Model FieldsOMDb API Fieldomdb.py FieldTitletitleYearyearTypetypeimdbIDimdb_idGet Model Fields (tomatoes=False)OMDb API Fieldomdb.py FieldTitletitleYearyearTypetypeActorsactorsAwardsawardsCountrycountryDirectordirectorGenregenreEpisodeepisodeEpisodesepisodesSeasonseasonSeriesIDseries_idLanguagelanguageMetascoremetascorePlotplotPosterposterRatedratedRatingsratingsReleasedreleasedResponseresponseRuntimeruntimeWriterwriterimdbIDimdb_idimdbRatingimdb_ratingimdbVotesimdb_votesGet Model Fields (tomatoes=True)OMDb API Fieldomdb.py FieldTitletitleYearyearTypetypeActorsactorsAwardsawardsCountrycountryDirectordirectorGenregenreEpisodeepisodeSeasonseasonSeriesIDseries_idLanguagelanguageMetascoremetascorePlotplotPosterposterRatedratedRatingsratingsReleasedreleasedRuntimeruntimeWriterwriterimdbIDimdb_idimdbRatingimdb_ratingimdbVotesimdb_votesBoxOfficebox_officeDVDdvdProductionproductionWebsitewebsitetomatoConsensustomato_consensustomatoFreshtomato_freshtomatoImagetomato_imagetomatoMetertomato_metertomatoRatingtomato_ratingtomatoReviewstomato_reviewstomatoRottentomato_rottentomatoUserMetertomato_user_metertomatoUserRatingtomato_user_ratingtomatoUserReviewstomato_user_reviewsUsageGeneral ImportimportomdbNoteAll functions below support atimeoutkeyword argument that will be forwarded to the underlyingrequests.getfunction call. You can also set a global default usingomdb.set_default('timeout',<timeout>)that will be used whentimeoutis not explicitly provided.API KeyUsage of the OMDb API currently requires an API key. Set the OMDb API key withomdb.set_defaultor when creating a newomdb.OMDBClientinstance:# if using the module level clientomdb.set_default('apikey',API_KEY)# if creating a new client instanceclient=omdb.OMDBClient(apikey=API_KEY)omdb.get()# include full plot and Rotten Tomatoes dataomdb.get(title='True Grit',year=1969,fullplot=True,tomatoes=True)# set timeout of 5 seconds for this requestomdb.get(title='True Grit',year=1969,fullplot=True,tomatoes=True,timeout=5)omdb.search()# search by stringomdb.search('True Grit')omdb.search('True Grit',timeout=5)omdb.search('true',page=2)omdb.search_movie()# search movies by stringomdb.search_movie('True Grit')omdb.search_movie('True Grit',timeout=5)omdb.search_movie('true',page=2)omdb.search_episode()# search episodes by stringomdb.search_episode('True Grit')omdb.search_episode('True Grit',timeout=5)omdb.search_episode('true',page=2)omdb.search_series()# search series by stringomdb.search_series('True Grit')omdb.search_series('True Grit',timeout=5)omdb.search_series('true',page=2)omdb.imdbid()# get by IMDB idomdb.imdbid('tt0065126')omdb.imdbid('tt0065126',timeout=5)omdb.title()# get by titleomdb.title('True Grit')omdb.title('True Grit',timeout=5)omdb.set_default()# include tomatoes data by defaultomdb.set_default('tomatoes',True)omdb.title('True Grit')==omdb.title('True Grit',tomatoes=True)# set a global timeout of 5 seconds for all HTTP requestsomdb.set_default('timeout',5)omdb.request()# lower level API requestomdb.request(t='True Grit',y=1969,plot='full',tomatoes='true',timeout=5)Returns:Arequests.Responseobject.Errors and ExceptionsUnder the hood,omdb.pyuses therequestslibrary. For a listing of explicit exceptions raised byrequests, seeRequests: Errors and Exceptions.By defaultrequestswill not raise anExceptionwhen an HTTP response’s status code is not200. However,omdb.pyWILLraise anrequests.exceptions.HTTPErrorerror for any response with a non-200 status code.Changelogv0.10.1 (2018-12-10)Fix mishandling offullplot,tomatoes, andtimeoutparameters inOMDBClient.get()that did not work correctly in conjuction withOMDBClient.set_default().Fix mishandling oftypeparameter which was not being serialized to API request.v0.10.0 (2018-04-08)Add methods toOMDBClientthat mirror module functions:search()search_movie()search_episode()search_series()imdbid()title()v0.9.1 (2018-03-24)Removeomdb.modelsmodule and return plain dictionaries from search results instead of custom model classes. (breaking change)Previously, one could access result items using attributes (e.g.result.title) or indexes (e.g.result['title']). Now, results aredictobjects so must useresult['title'].Renameomdb.Clienttoomdb.OMDBClient. (breaking change)Makeomdb.request|omdb.OMDBClient.requestuse an API key if it’s set.v0.8.1 (2017-08-10)Add support for OMDb API key viaomdb.set_default(apikey=API_KEY)orclient = omdb.Client(apikey=API_KEY). Thanksoshribr!AddEpiodesOMDb API fields asepisodesmodel field.v0.7.0 (2016-08-03)Add support forpageparameter tosearch. Thankstaserian!v0.6.0 (2016-05-22)Add support fortimeoutparameter to all HTTP requests.v0.5.0 (2015-07-29)Add support forSeason/EpisodeOMDb parameter viaseason/episodearguments to every main API function. Thankscihansahin!v0.4.0 (2015-04-29)AddSeason,Episode, andSeriesIDOMDb API fields asseason,episode, andseries_idmodel fields.v0.3.1 (2015-01-27)Add metadata to main module:__title____summary____url____version____author____email____license__v0.3.0 (2015-01-13)Addsearch_movie.Addsearch_episode.Addsearch_series.Add support fortypeOMDb parameter viamedia_typeargument to every main API function.v0.2.0 (2014-10-16)Updatemodels.Itemwith additionalOMDb APIfields:Awards,Country,Language, andMetascore.Addomdb.requestmethod for easier access to raw request response.Initialization ofomdb.Clientnow accepts keyword arguments for API request parameter defaults. Previously, adictobject needed to be passed in.Full PEP8 compliance.Integratetoxtesting intosetup.py.v0.1.1 (2014-02-09)Python3 support. Thanksagronholm!PEP8 compliance excluding max-line-length. Thanksagronholm!Wheel support. Thanksagronholm!v0.1.0 (2013-11-24)Convert API response to data models (see omdb/models.py).Add /tests folder and move appropriate doctests there.Return empty data forsearchandgetrequests which return no record(s).Addomdb.set_default()for setting default request parameters (e.g.set_default(tomatoes=True)to always include tomatoes data)v0.0.1 (2013-11-12)Initial release.