celiao / tmdbsimple

A wrapper for The Movie Database API v3.
GNU General Public License v3.0
579 stars 122 forks source link

Decouple request #50

Closed webtweakers closed 4 years ago

webtweakers commented 6 years ago

With this pull request, using a rate-limiter, eg. RespectfulRequester, becomes as simple as defining the inner request method, like so:

def respectful_request(method, url, params=None, data=None, headers=None):
    return rr.request(lambda: requests.request(
        method, url, params=params, data=data, headers=headers), realms=["TheMovieDB"], wait=True)

And in the module where tmdbsimple is used:

from somewhere import respectful_request
import tmdbsimple as tmdb

tmdb.API_KEY = '...'
tmdb.perform_request = respectful_request

And voila: a rate-limited version of tmdbsimple!

celiao commented 6 years ago

Thanks. Please provide unit tests.

webtweakers commented 6 years ago

Fair enough. Added two unit tests that proof that the request function can be changed and that it's used by tmdbsimple.

webtweakers commented 6 years ago

Any progress?

celiao commented 4 years ago

Great news! Rate limiting of The Movie Database API has been disabled as of December 16, 2019.

image

Closing this merge request.