Update tmdbsimple 2.6.6 (679e343) → 2.9.1 (9da400a).

This commit is contained in:
JackDandy 2023-01-12 20:46:02 +00:00
parent 9f0c04a374
commit a59de3b1cd
13 changed files with 135 additions and 79 deletions

View file

@ -4,6 +4,7 @@
* Add Filelock 3.9.0 (ce3e891) * Add Filelock 3.9.0 (ce3e891)
* Remove Lockfile no longer used by Cachecontrol * Remove Lockfile no longer used by Cachecontrol
* Update Msgpack 1.0.0 (fa7d744) to 1.0.4 (b5acfd5) * Update Msgpack 1.0.0 (fa7d744) to 1.0.4 (b5acfd5)
* Update tmdbsimple 2.6.6 (679e343) to 2.9.1 (9da400a)
* Update torrent_parser 0.3.0 (2a4eecb) to 0.4.0 (23b9e11) * Update torrent_parser 0.3.0 (2a4eecb) to 0.4.0 (23b9e11)
* Update unidecode module 1.1.1 (632af82) to 1.3.6 (4141992) * Update unidecode module 1.1.1 (632af82) to 1.3.6 (4141992)

View file

@ -12,17 +12,18 @@ http://www.themoviedb.org/documentation/api and documentation page
https://developers.themoviedb.org/3/getting-started https://developers.themoviedb.org/3/getting-started
https://www.themoviedb.org/documentation/api/status-codes https://www.themoviedb.org/documentation/api/status-codes
:copyright: (c) 2013-2020 by Celia Oakley. :copyright: (c) 2013-2022 by Celia Oakley.
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """
__title__ = 'tmdbsimple' __title__ = 'tmdbsimple'
__version__ = '2.6.6' __version__ = '2.9.1'
__author__ = 'Celia Oakley' __author__ = 'Celia Oakley'
__copyright__ = 'Copyright (c) 2013-2020 Celia Oakley' __copyright__ = 'Copyright (c) 2013-2022 Celia Oakley'
__license__ = 'GPLv3' __license__ = 'GPLv3'
import os import os
import requests
from .account import Account, Authentication, GuestSessions, Lists from .account import Account, Authentication, GuestSessions, Lists
from .base import APIKeyError from .base import APIKeyError
@ -51,3 +52,5 @@ __all__ = ['Account', 'Authentication', 'GuestSessions', 'Lists',
API_KEY = os.environ.get('TMDB_API_KEY', None) API_KEY = os.environ.get('TMDB_API_KEY', None)
API_VERSION = '3' API_VERSION = '3'
REQUESTS_SESSION = None
REQUESTS_TIMEOUT = os.environ.get('TMDB_REQUESTS_TIMEOUT', None)

View file

@ -8,7 +8,7 @@ of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """

View file

@ -7,7 +7,7 @@ This module implements the base class of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """
@ -27,9 +27,11 @@ class TMDB(object):
URLS = {} URLS = {}
def __init__(self): def __init__(self):
from . import API_VERSION from . import API_VERSION, REQUESTS_SESSION, REQUESTS_TIMEOUT
self.base_uri = 'https://api.themoviedb.org' self.base_uri = 'https://api.themoviedb.org'
self.base_uri += '/{version}'.format(version=API_VERSION) self.base_uri += '/{version}'.format(version=API_VERSION)
self.session = REQUESTS_SESSION
self.timeout = REQUESTS_TIMEOUT
def _get_path(self, key): def _get_path(self, key):
return self.BASE_PATH + self.URLS[key] return self.BASE_PATH + self.URLS[key]
@ -80,10 +82,25 @@ class TMDB(object):
url = self._get_complete_url(path) url = self._get_complete_url(path)
params = self._get_params(params) params = self._get_params(params)
response = requests.request( # Create a new request session if no global session is defined
method, url, params=params, if self.session is None:
data=json.dumps(payload) if payload else payload, response = requests.request(
headers=self.headers, verify=False) method,
url,
params=params,
data=json.dumps(payload) if payload else payload,
headers=self.headers, timeout=self.timeout, verify=False
)
# Use the global requests session the user provided
else:
response = self.session.request(
method,
url,
params=params,
data=json.dumps(payload) if payload else payload,
headers=self.headers, timeout=self.timeout
)
response.raise_for_status() response.raise_for_status()
response.encoding = 'utf-8' response.encoding = 'utf-8'

View file

@ -7,7 +7,7 @@ This module implements the Changes functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """

View file

@ -9,7 +9,7 @@ tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """

View file

@ -7,7 +7,7 @@ This module implements the Discover functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """

View file

@ -7,7 +7,7 @@ This module implements the Find functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """

View file

@ -7,7 +7,7 @@ This module implements the Genres functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """

View file

@ -8,7 +8,7 @@ Reviews functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """
@ -31,13 +31,14 @@ class Movies(TMDB):
'external_ids': '/{id}/external_ids', 'external_ids': '/{id}/external_ids',
'images': '/{id}/images', 'images': '/{id}/images',
'keywords': '/{id}/keywords', 'keywords': '/{id}/keywords',
'release_dates': '/{id}/release_dates',
'videos': '/{id}/videos',
'translations': '/{id}/translations',
'recommendations': '/{id}/recommendations',
'similar_movies': '/{id}/similar_movies',
'reviews': '/{id}/reviews',
'lists': '/{id}/lists', 'lists': '/{id}/lists',
'recommendations': '/{id}/recommendations',
'release_dates': '/{id}/release_dates',
'reviews': '/{id}/reviews',
'similar_movies': '/{id}/similar_movies',
'translations': '/{id}/translations',
'videos': '/{id}/videos',
'watch_providers': '/{id}/watch/providers',
'rating': '/{id}/rating', 'rating': '/{id}/rating',
'rating_delete': '/{id}/rating', 'rating_delete': '/{id}/rating',
'latest': '/latest', 'latest': '/latest',
@ -208,6 +209,40 @@ class Movies(TMDB):
self._set_attrs_to_values(response) self._set_attrs_to_values(response)
return response return response
def lists(self, **kwargs):
"""
Get a list of lists that this movie belongs to.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('lists')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def recommendations(self, **kwargs):
"""
Get a list of recommended movies for a movie.
Args:
language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('recommendations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def release_dates(self, **kwargs): def release_dates(self, **kwargs):
""" """
Get the release date along with the certification for a movie. Get the release date along with the certification for a movie.
@ -233,41 +268,9 @@ class Movies(TMDB):
self._set_attrs_to_values(response) self._set_attrs_to_values(response)
return response return response
def videos(self, **kwargs): def reviews(self, **kwargs):
""" """
Get the videos that have been added to a movie. Get the user reviews for a movie.
Args:
language: (optional) ISO 639-1 code.
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('videos')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def translations(self, **kwargs):
"""
Get a list of translations that have been created for a movie.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('translations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def recommendations(self, **kwargs):
"""
Get a list of recommended movies for a movie.
Args: Args:
language: (optional) ISO 639-1 code. language: (optional) ISO 639-1 code.
@ -276,7 +279,7 @@ class Movies(TMDB):
Returns: Returns:
A dict representation of the JSON returned from the API. A dict representation of the JSON returned from the API.
""" """
path = self._get_id_path('recommendations') path = self._get_id_path('reviews')
response = self._GET(path, kwargs) response = self._GET(path, kwargs)
self._set_attrs_to_values(response) self._set_attrs_to_values(response)
@ -302,35 +305,49 @@ class Movies(TMDB):
self._set_attrs_to_values(response) self._set_attrs_to_values(response)
return response return response
def reviews(self, **kwargs): def translations(self, **kwargs):
""" """
Get the user reviews for a movie. Get a list of translations that have been created for a movie.
Args: Args:
language: (optional) ISO 639-1 code. None
page: (optional) Minimum 1, maximum 1000, default 1.
Returns: Returns:
A dict representation of the JSON returned from the API. A dict representation of the JSON returned from the API.
""" """
path = self._get_id_path('reviews') path = self._get_id_path('translations')
response = self._GET(path, kwargs) response = self._GET(path, kwargs)
self._set_attrs_to_values(response) self._set_attrs_to_values(response)
return response return response
def lists(self, **kwargs): def videos(self, **kwargs):
""" """
Get a list of lists that this movie belongs to. Get the videos that have been added to a movie.
Args: Args:
language: (optional) ISO 639-1 code. language: (optional) ISO 639-1 code.
page: (optional) Minimum 1, maximum 1000, default 1.
Returns: Returns:
A dict representation of the JSON returned from the API. A dict representation of the JSON returned from the API.
""" """
path = self._get_id_path('lists') path = self._get_id_path('videos')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def watch_providers(self, **kwargs):
"""
Get a list of the availabilities per country by provider for movies.
Args:
None
Returns:
A dict representation of the JSON returned from the API.
"""
path = self._get_id_path('watch_providers')
response = self._GET(path, kwargs) response = self._GET(path, kwargs)
self._set_attrs_to_values(response) self._set_attrs_to_values(response)

View file

@ -7,7 +7,7 @@ This module implements the People and Credits functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """

View file

@ -7,7 +7,7 @@ This module implements the Search functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """

View file

@ -8,7 +8,7 @@ functionality of tmdbsimple.
Created by Celia Oakley on 2013-10-31. Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2020 by Celia Oakley :copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details :license: GPLv3, see LICENSE for more details
""" """
@ -38,6 +38,7 @@ class TV(TMDB):
'similar': '/{id}/similar', 'similar': '/{id}/similar',
'translations': '/{id}/translations', 'translations': '/{id}/translations',
'videos': '/{id}/videos', 'videos': '/{id}/videos',
'watch_providers': '/{id}/watch/providers',
'rating': '/{id}/rating', 'rating': '/{id}/rating',
'latest': '/latest', 'latest': '/latest',
'airing_today': '/airing_today', 'airing_today': '/airing_today',
@ -320,6 +321,21 @@ class TV(TMDB):
self._set_attrs_to_values(response) self._set_attrs_to_values(response)
return response return response
def watch_providers(self, **kwargs):
"""
Get a list of the availabilities per country by provider for tv.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_id_path('watch_providers')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
def rating(self, **kwargs): def rating(self, **kwargs):
""" """
Rate a TV show. Rate a TV show.
@ -659,7 +675,8 @@ class TV_Episodes(TMDB):
Returns: Returns:
A dict respresentation of the JSON returned from the API. A dict respresentation of the JSON returned from the API.
""" """
path = self._get_tv_id_season_number_episode_number_path('account_states') path = self._get_tv_id_season_number_episode_number_path(
'account_states')
response = self._GET(path, kwargs) response = self._GET(path, kwargs)
self._set_attrs_to_values(response) self._set_attrs_to_values(response)
@ -736,7 +753,8 @@ class TV_Episodes(TMDB):
Returns: Returns:
A dict respresentation of the JSON returned from the API. A dict respresentation of the JSON returned from the API.
""" """
path = self._get_tv_id_season_number_episode_number_path('translations') path = self._get_tv_id_season_number_episode_number_path(
'translations')
response = self._GET(path, kwargs) response = self._GET(path, kwargs)
self._set_attrs_to_values(response) self._set_attrs_to_values(response)