### Install tmdbsimple using pip Source: https://github.com/celiao/tmdbsimple/blob/master/README.md Install the library using pip. If installing manually, also install the 'requests' library. ```bash pip install tmdbsimple ``` -------------------------------- ### Fetch Movie Info Directly Source: https://github.com/celiao/tmdbsimple/blob/master/README.md This example shows how to retrieve movie information, specifically the budget, by calling the .info() method directly on the tmdb.Movies object without explicit instantiation. ```python response = tmdb.Movies(603).info() response['budget'] ``` -------------------------------- ### Get Movie Information and Releases Source: https://github.com/celiao/tmdbsimple/blob/master/README.md Instantiate a Movies object with an ID, fetch its info, and then retrieve release information to find the US certification. ```python movie = tmdb.Movies(603) response = movie.info() print(movie.title) print(movie.budget) response = movie.releases() for c in movie.countries: if c['iso_3166_1'] == 'US': print(c['certification']) ``` -------------------------------- ### Initialize tmdbsimple with API Key Source: https://github.com/celiao/tmdbsimple/blob/master/README.md Import the library and set your TMDb API key. Replace 'YOUR_API_KEY_HERE' with your actual key. ```python import tmdbsimple as tmdb tmdb.API_KEY = 'YOUR_API_KEY_HERE' ``` -------------------------------- ### Calculate Budget Per Runtime for Movies Source: https://github.com/celiao/tmdbsimple/blob/master/README.md Use this snippet to fetch movie details and calculate the budget per minute of runtime. It demonstrates fetching data for multiple movies and comparing their cost-effectiveness. ```python identity = tmdb.Movies(2501) response = identity.info() identity.budget, identity.runtime int(identity.budget/identity.runtime) ``` ```python supremacy = tmdb.Movies(2502) response = supremacy.info() supremacy.budget, supremacy.runtime int(supremacy.budget/supremacy.runtime) ``` ```python ultimatum = tmdb.Movies(2503) response = ultimatum.info() ultimatum.budget, ultimatum.runtime int(ultimatum.budget/ultimatum.runtime) ``` -------------------------------- ### Enable Bearer Token Authentication Source: https://github.com/celiao/tmdbsimple/blob/master/README.md Optionally, configure the library to use bearer token authentication instead of the default API key query parameter. ```python tmdb.USE_BEARER_AUTH = True ``` -------------------------------- ### Search for Movies and Display Results Source: https://github.com/celiao/tmdbsimple/blob/master/README.md Use the Search object to find movies by query. Iterate through the results to print title, ID, release date, and popularity. ```python search = tmdb.Search() response = search.movie(query='The Bourne') for s in search.results: print(s['title'], s['id'], s['release_date'], s['popularity']) ``` -------------------------------- ### Configure Custom Requests Session Source: https://github.com/celiao/tmdbsimple/blob/master/README.md Optionally, configure the library to use your own requests.Session object for advanced usage. ```python import requests tmdb.REQUESTS_SESSION = requests.Session() ``` -------------------------------- ### Configure Request Timeout Source: https://github.com/celiao/tmdbsimple/blob/master/README.md Optionally set a timeout for requests. This can be a single value for both connect and read, or a tuple for specific values. ```python tmdb.REQUESTS_TIMEOUT = 5 # seconds, for both connect and read ``` ```python tmdb.REQUESTS_TIMEOUT = (2, 5) # seconds, for connect and read specifically ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.