Giter Club home page Giter Club logo

tmdbsimple's Introduction

tmdbsimple

Python package codecov pypi pypi

A wrapper for The Movie Database API v3

tmdbsimple is a wrapper, written in Python, for The Movie Database (TMDb) API v3. By calling the functions available in tmdbsimple you can simplify your code and easily access a vast amount of movie, tv, and cast data. To learn more about The Movie Database API, check out the overview and documentation.

Features

  • COMPLETELY UPDATED AND FULLY TESTED.
  • Supports only Python versions with TLS 1.2. Keep it simple!
  • Tested with Python 3.6, 3.7, and 3.8.
  • One-to-one mapping between tmdbsimple methods and TMDb endpoints.
  • Implements all TMDb methods, including Accounts and Authentication.
  • Easy to access data using Python class attributes.
  • Easy to experiment with tmdbsimple functions inside the Python interpreter.
  • Code tested with unittests. Refer to the unittest code for method call syntax.

Installation

tmdbsimple is available on the Python Package Index (PyPI) at https://pypi.python.org/pypi/tmdbsimple.

You can install tmdbsimple using one of the following techniques.

  • Use pip:
pip install tmdbsimple
  • Download the .zip or .tar.gz file from PyPI and install it yourself
  • Download the source from Github and install it yourself

If you install it yourself, also install requests.

API Key

You will need an API key to The Movie Database to access the API. To obtain a key, follow these steps:

  1. Register for and verify an account.
  2. Log into your account.
  3. Select the API section on left side of your account page.
  4. Click on the link to generate a new API key and follow the instructions.

Examples

Once you have the tmdbsimple package installed and a TMDb API key, you can start to play with the data.

First, import the library and assign your API_KEY.

import tmdbsimple as tmdb
tmdb.API_KEY = 'YOUR_API_KEY_HERE'

Optionally, set a timeout for requests. See here for more info.

tmdb.REQUESTS_TIMEOUT = 5  # seconds, for both connect and read

or

tmdb.REQUESTS_TIMEOUT = (2, 5)  # seconds, for connect and read specifically 

Optionally, configure the library to use your own REQUESTS_SESSION. See here for more info.

import requests
tmdb.REQUESTS_SESSION = requests.Session()

To communicate with The Movie Database API, create an instance of one of the object types, call one of the methods on the instance, and access the instance attributes. Use keys to access the values of attributes that are dictionaries. In this example, we create a movie instance for 'The Matrix' and determine the budget and certification.

    >>> movie = tmdb.Movies(603)
    >>> response = movie.info()
    >>> movie.title
    'The Matrix'
    >>> movie.budget
    63000000
    >>> response = movie.releases()
    >>> for c in movie.countries:
    ...    if c['iso_3166_1'] == 'US':
    ...         print(c['certification'])
    ...
    'R'

Let's play with the interface a bit more. Suppose you and your friend are arguing over which movie in the Bourne series was most popular. Your friend says the first in a series is always most popular. You disagree.

    >>> search = tmdb.Search()
    >>> response = search.movie(query='The Bourne')
    >>> for s in search.results:
    ...     print(s['title'], s['id'], s['release_date'], s['popularity'])
    ...
    The Bourne Ultimatum 2503 2007-08-03 55.2447062124256
    The Bourne Supremacy 2502 2004-07-23 43.4553609681985
    The Bourne Identity 2501 2002-06-06 38.5531563780592
    The Bourne Legacy 49040 2012-08-10 9.90635210153143
    The Bourne Identity 8677 1988-05-08 1.53988446573129
    Bette Bourne: It Goes with the Shoes 179304  0.23

You are correct! Now you claim the producers should be able to make sequels cheaper, based on what they learned from making the first movie. To be fair, you compute the budget per minute of runtime. Your friend disagrees, claiming the producers spend more money trying to out do the previous sequel.

    >>> identity = tmdb.Movies(2501)
    >>> response = identity.info()
    >>> identity.budget, identity.runtime
    (60000000, 119)
    >>> int(identity.budget/identity.runtime)
    504201
    >>> supremacy = tmdb.Movies(2502)
    >>> response = supremacy.info()
    >>> supremacy.budget, supremacy.runtime
    (75000000, 108)
    >>> int(supremacy.budget/supremacy.runtime)
    694444
    >>> ultimatum = tmdb.Movies(2503)
    >>> response = ultimatum.info()
    >>> ultimatum.budget, ultimatum.runtime
    (70000000, 115)
    >>> int(ultimatum.budget/ultimatum.runtime)
    608695

In this case you are both correct. The third movie was cheaper than the second, which was more expensive than the first.

You also can call one of the methods without explicitly instanciating an object.

    >>> response = tmdb.Movies(603).info()
    >>> response['budget']
    63000000

If you use Authentication to access a user Account, be sure to check out https://www.themoviedb.org/documentation/api/sessions.

If you like this wrapper, and would like access to even more movie and TV data, check out rtsimple https://pypi.python.org/pypi/rtsimple, a wrapper for the Rotten Tomatoes API.

tmdbsimple's People

Contributors

3lixy avatar adilosa avatar archmonger avatar aulemahal avatar briix avatar ca1m-py avatar celiao avatar darrbezz avatar f3rn4nd0-c354r avatar geekinutah avatar hamza-jutt avatar hanbnrd avatar kevgathuku avatar mgoeminne avatar oli4 avatar p0psicles avatar sharkykh avatar spootdev avatar vinay-krishna9 avatar webtweakers avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tmdbsimple's Issues

Documentation improvement: how to close connection

On mutiple calls I get:
../usr/lib/python3.5/socket.py:646: ResourceWarning: unclosed <socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=6, laddr=('150.164.200.104', 51940), raddr=('54.243.67.237', 443)>
self._sock = None

Nothing in the documentation regards best practices for usage or maybe an example code of how to avoid that. Any thoughts on that?

TV_Seasons overwrites its parent series id when info() is called.

When calling TV_Seasons.info(), the id field in the response overwrites the series id originally stored in TV_Seasons.id making any further request (another info(), images() or videos(), etc...) raise a 404 error.

I think the same mechanism as in TV_Episodes could be implemented there: the series id in series_id with a new function _get_series_id_season_number_path. That should fix it.

(Sorry for two issues opening back to back, if I have time I'll suggest a pull request fixing these! And thanks for the nice module!)

Discover.py returning same results

When i run discover.py in this command:

genres=878, votecount=800, averagescore=5.5, fromdate='1970-01-01'

discover = tmdb.Discover()
kwargs = {'vote_count.gte': votecount, 'vote_average.gte': averagescore, 'release_date.gte': fromdate, 'with_genres': genres}
response = discover.movie(**kwargs)

it returns this list over and over again:
299534 429617 27205 299536 454626 284054 181812 62688 63247 99861 419704 338762 157336 570670 11 87101 24428 131631 443791 19995 299537 290859

Leading to a problem that discover.py is really not useful as a suggestion engine which it is supposed to be. Is there anything i am missing that is causing this issue?

Movies, People, Tv

Hi! I have to do a university exam project. I should create a graph that has the actors as nodes, and as a link if they made a film in common. I was wondering if there were any functions to take a list of all the movies, TV series and actors. Thank you!

"GET" functions overwrite themselves when attribute in response has same name

This is concerning the movies.Movies object.
When the keywords() method is called, it overwrites itself by creating the keywords attribute. Thus making any further call to keywords() raise a TypeError: 'list' object is not callable.

In the API's docs (here) there is not additionnal query parameter listed (other than the api_key). Therefore, the only potential argument is append_to_response.
This said, one easy solution could be simply transforming the method to a property (with @property), but this would eliminate the possibility of using append_to_response. I don't have other suggestions for now...

output nothing? Discover.py

EDIT:

def getmovie():
    search = tmdb.Discover()
    response = search.movie(genres='Science Fiction')

gives any movie from any genre...

Also, id like to get random 50 movies each time i do getmovie()....

No ability to search for TV shows based on genre

Seems there is the ability to search for Movies of a certain genre using the tmdb.Genres.movies() function, but there is no option to search for TV shows based on a genre. (Unless the movie function also returns TV shows, which would be a different issue).

Movie.releases() does not line up with API

Differences I see are "primary" doesn't exist and "type" is not represented.

From API:

{"id":1891,"results":[{"iso_3166_1":"US","release_dates":[{"certification":"PG","iso_639_1":"en","note":"Premiere","release_date":"1980-05-17T00:00:00.000Z","type":3},{"certification":"PG","iso_639_1":"en","note":"Renewed Edition","release_date":"1997-04-04T00:00:00.000Z","type":5}]},{"iso_3166_1":"GR","release_dates":[{"certification":"","iso_639_1":"","note":"","release_date":"1980-12-19T00:00:00.000Z","type":3}]},{"iso_3166_1":"BG","release_dates":[{"certification":"ж","iso_639_1":"","note":"","release_date":"1985-12-06T00:00:00.000Z","type":3}]},{"iso_3166_1":"DK","release_dates":[{"certification":"11","iso_639_1":"","note":"","release_date":"1980-08-15T00:00:00.000Z","type":3}]},{"iso_3166_1":"GB","release_dates":[{"certification":"U","iso_639_1":"","note":"","release_date":"1980-05-21T00:00:00.000Z","type":3}]},{"iso_3166_1":"KR","release_dates":[{"certification":"12세 이상 관람가","iso_639_1":"","note":"","release_date":"1997-04-26T00:00:00.000Z","type":3}]},{"iso_3166_1":"HU","release_dates":[{"certification":"12","iso_639_1":"","note":"","release_date":"1982-01-28T00:00:00.000Z","type":3}]},{"iso_3166_1":"FI","release_dates":[{"certification":"K-12","iso_639_1":"","note":"","release_date":"1980-08-14T00:00:00.000Z","type":3}]},{"iso_3166_1":"PL","release_dates":[{"certification":"","iso_639_1":"pl","note":"","release_date":"1980-05-20T00:00:00.000Z","type":3},{"certification":"","iso_639_1":"pl","note":"Odnowiona","release_date":"1997-04-04T00:00:00.000Z","type":5}]},{"iso_3166_1":"FR","release_dates":[{"certification":"U","iso_639_1":"","note":"","release_date":"1980-08-20T00:00:00.000Z","type":3}]},{"iso_3166_1":"NL","release_dates":[{"certification":"12","iso_639_1":"","note":"","release_date":"1980-12-11T00:00:00.000Z","type":3}]},{"iso_3166_1":"BR","release_dates":[{"certification":"L","iso_639_1":"pt","release_date":"1980-05-21T00:00:00.000Z","type":3}]},{"iso_3166_1":"ES","release_dates":[{"certification":"","iso_639_1":"","note":"","release_date":"1980-10-02T00:00:00.000Z","type":3}]},{"iso_3166_1":"AU","release_dates":[{"certification":"PG","iso_639_1":"","note":"","release_date":"1980-05-21T00:00:00.000Z","type":3}]},{"iso_3166_1":"DE","release_dates":[{"certification":"12","iso_639_1":"","note":"","release_date":"1980-12-10T00:00:00.000Z","type":3}]},{"iso_3166_1":"IT","release_dates":[{"certification":"","iso_639_1":"","note":"","release_date":"1980-09-19T00:00:00.000Z","type":3}]}]}

From tmdbsimple:

m = tmdb.Movies(1891)
m.releases()
{u'id': 1891, u'countries': [{u'iso_3166_1': u'GB', u'release_date': u'1980-05-21', u'primary': False, u'certification': u'U'}, {u'iso_3166_1': u'DE', u'release_date': u'1980-12-10', u'primary': False, u'certification': u'12'}, {u'iso_3166_1': u'FR', u'release_date': u'1980-08-20', u'primary': False, u'certification': u'U'}, {u'iso_3166_1': u'HU', u'release_date': u'1982-01-28', u'primary': False, u'certification': u'12'}, {u'iso_3166_1': u'NL', u'release_date': u'1980-12-11', u'primary': False, u'certification': u'12'}, {u'iso_3166_1': u'DK', u'release_date': u'1980-08-15', u'primary': False, u'certification': u'11'}, {u'iso_3166_1': u'BG', u'release_date': u'1985-12-06', u'primary': False, u'certification': u'\u0436'}, {u'iso_3166_1': u'FI', u'release_date': u'1980-08-14', u'primary': False, u'certification': u'K-12'}, {u'iso_3166_1': u'IT', u'release_date': u'1980-09-19', u'primary': False, u'certification': u''}, {u'iso_3166_1': u'KR', u'release_date': u'1997-04-26', u'primary': False, u'certification': u'12\uc138 \uc774\uc0c1 \uad00\ub78c\uac00'}, {u'iso_3166_1': u'AU', u'release_date': u'1980-05-21', u'primary': False, u'certification': u'PG'}, {u'iso_3166_1': u'ES', u'release_date': u'1980-10-02', u'primary': False, u'certification': u''}, {u'iso_3166_1': u'GR', u'release_date': u'1980-12-19', u'primary': False, u'certification': u''}, {u'iso_3166_1': u'BR', u'release_date': u'1980-05-21', u'primary': False, u'certification': u'L'}, {u'iso_3166_1': u'PL', u'release_date': u'1980-05-20', u'primary': False, u'certification': u''}, {u'iso_3166_1': u'US', u'release_date': u'1980-05-17', u'primary': False, u'certification': u'PG'}, {u'iso_3166_1': u'PL', u'release_date': u'1997-04-04', u'primary': False, u'certification': u''}, {u'iso_3166_1': u'US', u'release_date': u'1997-04-04', u'primary': False, u'certification': u'PG'}]}

Do not update `id` of a TV_Episode

When looking for an episode, the syntax is :
episode = tmdb.TV_Episodes(series_id, season, episode)

Then when looking at the informations, episode.info() is called. But after this method call, the id of the TV_Episodes class is updated to the id of the episode. Then the next call to episode.info() or any other method will fail because the url in the api will have the following form :
'/3/tv/<episode_id>/season/<season_number>/episode/<episode_number>'
instead of '/3/tv/<series_id>/...'
id should not be updated for an episode, or a distinction should be made between the episode id and the series id.

Get all of the TV-series

Is it possible to get all of the TV-series in the database as a list? I mean names of the shows and some basic info.

V4 api

Hi,
Was wondering if there was any plans to update this for use with the version 4 tmdb api?
Thanks.

No module named 'tmdbsimple'

I have installed tmdbsimple and using it from python prompt in terminal it works fine. When I attempt to use it from Jupyter Notebook, it gives an Error: No module named 'tmdbsimple'

I have tested it with both python versions 3.8.12 and 3.9.7 in a Mac running macOS Big Sur 11.6.1

Not able call videos() on movie object

search = tmdb.Search()
search.movie(query=movie_title)
movie_id  = search.results[0]['id']
movie = tmdb.Movies(movie_id).info()
videos = movie.videos()['results']

Error:
AttributeError: 'dict' object has no attribute 'videos'

Is there anything that I am missing?

Empty lists

I added it to my ad on it shows my watchlist and my favorites but when I click on it they are empty but on the website itself they show up there is no way to send you a log do you have any suggestions for me thank you

Discover().Movie() vote_count.gte argument

When using the tmdb.Disocver( ).Movie( ) function (link) with arguments like sort_by it works fine but the arguments such as vote_count.gte, which include a period raise the error keyword can't be an expression

Discover movies

Excellent wrapper!
Is there an example with code on how to "discover" movies based on filter (eg., language=EN, genre=Thriller AND Drama, etc.)? This would be great. Thanks.

Full Image URLs

Is there a method to create the full url for an image that I'm not seeing?

I don't mind creating a pull request if not. Just wanted to double check I'm not missing anything.

documentation

To build an image URL, you will need 3 pieces of data. The base_url, size and file_path. Simply
combine them all and you will have a fully qualified URL. Here’s an example URL:
http://image.tmdb.org/t/p/w500/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg

Help getting list of actors and images

hi
love the code, but having trouble getting a list of people from a tv series. any assist, please?

import tmdbsimple as tmdb

tmdb.API_KEY = 'x'

tv_show = tmdb.TV(1400) #seinfeld
for person in tv_show.credits():
    #print person
    p = tmdb.People(person)

Get TV year and search by url

I am trying to get the first_air_date but I have no luck.
Furthermore, how can I search by url (not only the id)?

Connection Error while calling Function

Code: tmdbsimple.TV().airing_today()

Expected Behavior: Method should return a list of TV objects

Observed Behavior: Connection to server getting aborted because of Connection Error.

Possible Problem: The code is trying to reuse the connection but the server is closing it because it has been idle for too long.

Find method doesn't work

Hello, I think the API has changed, the find method requires the request to be accompanied by the type of ID you're providing, so you need to add a "&external_source=imdb_id" for example at the end of the request for it to work.
I made it work for me by adding it manually in the package, but I don't know how to cater for the other types of IDs without breaking the API, so I thought you should take a look at it.
For reference:
https://developers.themoviedb.org/3/find

Tv search by IMDB ID

The following works for a movie search using imdb id.
tmdb.Movies('tt0373926').info()

however
tmdb.TV('tt0108778').info() does not.

I can't seem to find a search by imdb for tv series.

tmdbsimple.base.APIKeyError

Following the examples from the README an APIKeyError is raised after ">>> response = movie.info()". The api key works with the generated url in firefox and with python module tmdb3. Any idea what is wrong?

Thanks in advance :-)

I'm using tmdbsimple on Ubuntu 16.04 with virtualenv and installed it with pip.

$ pip freeze
certifi==2018.4.16
chardet==3.0.4
idna==2.6
pkg-resources==0.0.0
requests==2.18.4
tmdbsimple==2.2.0
urllib3==1.22

Due to security reason the value of tmdb.APY_KEY was modified to 'APIKEY'.
When trying the command the real key was assigned.

$ python
Python 2.7.12 (default, Dec 4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import tmdbsimple as tmdb
tmdb.APY_KEY = 'APIKEY'
movie = tmdb.Movies(603)
response = movie.info()
Traceback (most recent call last):
File "", line 1, in
File "/home/sjuk/env/tmdb/local/lib/python2.7/site-packages/tmdbsimple/movies.py", line 66, in info
response = self._GET(path, kwargs)
File "/home/sjuk/env/tmdb/local/lib/python2.7/site-packages/tmdbsimple/base.py", line 85, in _GET
return self._request('GET', path, params=params)
File "/home/sjuk/env/tmdb/local/lib/python2.7/site-packages/tmdbsimple/base.py", line 73, in _request
params = self._get_params(params)
File "/home/sjuk/env/tmdb/local/lib/python2.7/site-packages/tmdbsimple/base.py", line 62, in _get_params
raise APIKeyError
tmdbsimple.base.APIKeyError

poster_path is None even tho a poster exists

I recently added a poster to a movie. I re-ran my code but poster_path is still None. Movie is https://www.themoviedb.org/movie/308796

{'adult': False,
 'backdrop_path': None,
 'belongs_to_collection': None,
 'budget': 0,
 'genres': [{'id': 18, 'name': 'Drama'}],
 'homepage': '',
 'id': 308796,
 'imdb_id': 'tt0114772',
 'original_language': 'ja',
 'original_title': '海ほおずき',
 'overview': 'This film is inspired by a true incident involving a Japanese '
             'girl who went missing in Taiwan (and then was found murdered by '
             'a taxi driver) several years ago. Haida, once a famous private '
             'detective, is now down and out and running out of reasons to '
             'live. One day, while engaging in a group volunteer project to '
             "clean up a river, he loses what's left of his will to live and "
             'lets the water carry him away. He ends up rescuing a drowning '
             'man who alters his view of life totally. Soon he gets a job '
             'investigating the mysterious disappearance of a student who sent '
             'her mother a cryptic letter, "Wait a bit, Mother. I\'m sending '
             'my breath. It will arrive soon."',
 'popularity': 0.65,
 'poster_path': None,
 'production_companies': [],
 'production_countries': [{'iso_3166_1': 'JP', 'name': 'Japan'}],
 'release_date': '1995-09-10',
 'revenue': 0,
 'runtime': 138,
 'spoken_languages': [{'english_name': 'Japanese',
                       'iso_639_1': 'ja',
                       'name': '日本語'}],
 'status': 'Released',
 'tagline': '',
 'title': 'The Breath',
 'video': False,
 'vote_average': 5.5,
 'vote_count': 2}

Question about Videos

This is a great utility! Thanks for putting it together.

I am pulling movie objects like so:

movie = tmdb.Movies('tt1074638').info()

When I traverse the dictionary, I have noticed that most movies that I return list "False" for the "video" value.

print("Video: ", movie.get('video'))
Video:  False

Is there another way to return the video elements? To be sure, I looked at Skyfall on TMDB and noticed that it has a trailer associated with it on the site.

Thanks

HTTP requests concurrency problems v2.7.0

urllib3 by default limits concurrent requests to 10.

So for tmdbsiple, if you have multiple threads executing, you'll get WARNING urllib3.connectionpool: Connection pool is full, discarding connection.

I'd assume that it's related to the new global REQUESTS_SESSION, as this wasn't an issue on v2.6.0.

SSL issues recently?

Just curious if anyone else has noticed some ssl errors as of recent. It looks like api.themoviedb.org recently updated certs on the servers that I know of and am getting sporadic issues. Debugging right now but wondering if anyone else had seen this yet.

I installed a fresh install as well of ubuntu and python 3.7 etc.. to ensure my system was outdated with ssl or something that changed with ciphers etc...

Example

    return self._request('GET', path, params=params)
  File "/usr/local/lib/python3.6/dist-packages/tmdbsimple-2.7.0-py3.6.egg/tmdbsimple/base.py", line 86, in _request
    headers=self.headers)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 520, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3/dist-packages/requests/sessions.py", line 630, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3/dist-packages/requests/adapters.py", line 506, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host='api.themoviedb.org', port=443): Max retries exceeded with url: /3/movie/338967/release_dates?api_key=SOMEKEY (Caused by SSLError(SSLError(1, '[SSL: DECRYPTION_FAILED_OR_BAD_RECORD_MAC] decryption failed or bad record mac (_ssl.c:2309)'),))

Question About Movie Rating

I really like this package. One thing I can't figure out is how to get the movie rating (G, PG etc.) Can you point me toward the correct function?

For that matter is there an API doc for this package that list all functions and variables?

using curl multi

Hello,
I'm running into this scenario: I call the discover API, it send back a bunch of incomplete information (to my requirements), which then leads me to calling the movie info API by looping through each movie and calling the info API for each movie --needless to say you can't multi-thread this--
Using the curl multi interface (https://curl.haxx.se/libcurl/c/libcurl-multi.html) Will allow these multiple requests to be handled using curl, and thus faster response.
If you're up for it i can add it.

Have there been any changes with the API?

I've been using using the wrapper for a little bit, but it is no longer working for me.

import tmdbsimple as tmdb
tmdb.API_KEY = 'MY-API-KEY'


movie = tmdb.Movies(22021)

title = movie.title

print(title)

is returning this error now...

Traceback (most recent call last):
  File "C:/file/...", line 21, in <module>
    title = movie.title
AttributeError: 'Movies' object has no attribute 'title' 

This could be very well be on my end: Only thing I did differently this time was pip install tmdbsimple into a new Python3 conda env. However, scripts I've written on Python 2.7 in a different env are now failing also.

I'm sure this issue is on my end, but I thought I'd check with you just in case to see if it's still working fine for you. Thanks!

Working perfectly on Python 3.5.4

I couldn't test all methods, but the one's related to movies (no tests for tv shows or series) were extensively tested with no problems.

How are you running these unit tests? Maybe I can run them too.

_set_attrs_to_values(response) does not update attributes anymore?

I am new to python and am really sorry if this is a very trivial thing or I have got it wrong in some way.
When we make a search request using:

search = tmdb.Search()  
response = search.movie(query='Harry Potter')

we get to use search.results to access the results.
But after I call the Search.movie() method again, the attributes do not get updated.

Example:
I first make a query of 'The Matrix' and then a query for 'Star Wars' and then pretty-print the first item in search.results and response['results'] respectively.

>>> import pprint as p
>>> import tmdbsimple as tmdb
>>> tmdb.API_KEY = 'xyz'
>>> search = tmdb.Search()
>>> response = search.movie(query='Matrix')
>>> p.pprint(search.results[0])
{'adult': False,
 'backdrop_path': '/7u3pxc0K1wx32IleAkLv78MKgrw.jpg',
 'genre_ids': [28, 878],
 'id': 603,
 'original_language': 'en',
 'original_title': 'The Matrix',
 'overview': 'Set in the 22nd century, The Matrix tells the story of a '
             'computer hacker who joins a group of underground insurgents '
             'fighting the vast and powerful computers who now rule the earth.',
 'popularity': 31.32734,
 'poster_path': '/hEpWvX6Bp79eLxY1kX5ZZJcme5U.jpg',
 'release_date': '1999-03-30',
 'title': 'The Matrix',
 'video': False,
 'vote_average': 7.9,
 'vote_count': 9830}
>>> p.pprint(response['results'][0])
{'adult': False,
 'backdrop_path': '/7u3pxc0K1wx32IleAkLv78MKgrw.jpg',
 'genre_ids': [28, 878],
 'id': 603,
 'original_language': 'en',
 'original_title': 'The Matrix',
 'overview': 'Set in the 22nd century, The Matrix tells the story of a '
             'computer hacker who joins a group of underground insurgents '
             'fighting the vast and powerful computers who now rule the earth.',
 'popularity': 31.32734,
 'poster_path': '/hEpWvX6Bp79eLxY1kX5ZZJcme5U.jpg',
 'release_date': '1999-03-30',
 'title': 'The Matrix',
 'video': False,
 'vote_average': 7.9,
 'vote_count': 9830}
>>> response = search.movie(query='Star Wars')
>>> p.pprint(search.results[0])
{'adult': False,
 'backdrop_path': '/7u3pxc0K1wx32IleAkLv78MKgrw.jpg',
 'genre_ids': [28, 878],
 'id': 603,
 'original_language': 'en',
 'original_title': 'The Matrix',
 'overview': 'Set in the 22nd century, The Matrix tells the story of a '
             'computer hacker who joins a group of underground insurgents '
             'fighting the vast and powerful computers who now rule the earth.',
 'popularity': 31.32734,
 'poster_path': '/hEpWvX6Bp79eLxY1kX5ZZJcme5U.jpg',
 'release_date': '1999-03-30',
 'title': 'The Matrix',
 'video': False,
 'vote_average': 7.9,
 'vote_count': 9830}
>>> p.pprint(response['results'][0])
{'adult': False,
 'backdrop_path': '/5Iw7zQTHVRBOYpA0V6z0yypOPZh.jpg',
 'genre_ids': [28, 12, 14, 878],
 'id': 181808,
 'original_language': 'en',
 'original_title': 'Star Wars: The Last Jedi',
 'overview': 'Rey develops her newly discovered abilities with the guidance of '
             'Luke Skywalker, who is unsettled by the strength of her powers. '
             'Meanwhile, the Resistance prepares to do battle with the First '
             'Order.',
 'popularity': 778.931034,
 'poster_path': '/xGWVjewoXnJhvxKW619cMzppJDQ.jpg',
 'release_date': '2017-12-13',
 'title': 'Star Wars: The Last Jedi',
 'video': False,
 'vote_average': 7.3,
 'vote_count': 2167}

Movies credits incorrect request

The request the library makes is https://api.themoviedb.org/3/movie/0/credits?id=13448&api_key={obfucated_api_key}
when the library should make the request https://api.themoviedb.org/3/movie/13448/credits&api_key={obfucated_api_key}

I think... by reading this link. Please check this

How can I get only Youtube ID?

Hi,

I have the following code:

kwargs = {'append_to_response': 'trailers'}
movie = tmdb.Movies(603).info(**kwargs)
print(movie.get('trailers'))

and the output:

{u'quicktime': [], u'youtube': [{u'source': u'm8e-FF8MsqU', u'type': u'Trailer', u'name': u'Matrix Trailer HD (1999)', u'size': u'HD'}]}

How can I get only the value of the source attribute: m8e-FF8MsqU ?

Thanks in advance!

How to iterate over pages using tmdb.Movies("*")

hi all,
my goal is get the lists of all the movies and in order to do that i use this code :

mov = tmdb.Movies("*") mov.top_rated()

the last istruction is able to rank the movies by rate and say me also another thing :

image
now the question is : how can i iterate over pages ? and also, is there a better way to archive my goal ? 😄

version of tmdbsimple 2.6.6

Boolean arguments don't work.

So query variables that expect a boolean value are case-sensitive. They only accept true or false. However the default string representation of a bool in Python is 'True' and 'False'. Because of this passing a bool argument won't do anything as the API will fallback to whatever the default is.

This example will not return any results because include_adult will fallback to its default of false:
tmdb.Search().movie(query='She\'s so small', include_adult=True)

Passing a string does work:
tmdb.Search().movie(query='She\'s so small', include_adult='true')

Kind of messy to work around that with if-else statements or str(expression).lower().

Search for all currently showing films in python.

Hi!

I'm trying to get a list of all of the currently showing films in cinemas. I am usig Python 2.7 and have started playing around with the wrapper tmdbsimple. I'm struggling, does anyone know how to do it? I saw that "api.movie_now_playing()" was a solution but I cannot get it to work. Any ideas? Thanks

Sorry if this is posted in the wrong place.

Specify a language for returned data

Hello,

Would it be possible to add some form of parameter allowing to pick a different language ?
For instance, I'd like to fetch the movie overview in French rather than English.

To do so, with PHP/cURL I simple add "&language=fr" to the queried URL.

For instance :

http://api.themoviedb.org/3/movie/603?api_key=API_KEY&language=fr
or
http://api.themoviedb.org/3/search/movie?api_key=API_KEY&language=fr&query=matrix

List of genres

I can't seem to find how to list all genres with their ID.
tmdb.Genres.movie_list(language='en') is supposed to do the job, but it won't.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.