dgilland / omdb.py

Python wrapper around OMDb API (Open Movie Database): http://omdbapi.com
http://omdbpy.readthedocs.org
Other
98 stars 23 forks source link

omdb private api #11

Closed b-rockx closed 7 years ago

b-rockx commented 7 years ago

omdb requires a private api key now. Please add support.

b-rockx commented 7 years ago

I've managed to solve the issue myself and will fork it sometime this week.

fix is to add a param to the client.py file parms_map dictionary.

'apikey' : 'api',

Then set the param

`title = omdb() title.set_default('api', 'keygoeshere')

test api key

print(title.imdbid('tt0279077'))`

dgilland commented 7 years ago

That approach sounds good. I'd probably just stick with just apikey as the name though.

dgilland commented 7 years ago

For others coming here for a workaround with the current version, you can do:

Using the module level omdb client:

import omdb

omdb.api._client.params_map['apikey'] = 'apikey'
omdb.set_default('apikey', 'myapikey')

Using an separate instance of the omdb client:

from omdb import Client

params_map = Client.params_map.copy()
params_map['apikey'] = 'apikey'

class OMDBClient(Client):
    params_map = params_map

# if on Python 3.5+
#class OMDBClient(Client):
#    params_map = {**Client.params_map, **{'apikey': 'apikey'}}

omdb = OMDBClient(apikey='myapikey')
dgilland commented 7 years ago

Implemented via #12