mirror of
https://github.com/SickGear/SickGear.git
synced 2024-12-18 08:43:37 +00:00
Merge branch 'feature/UpdateTmdbSimple' into dev
This commit is contained in:
commit
8576768b64
13 changed files with 135 additions and 79 deletions
|
@ -4,6 +4,7 @@
|
|||
* Add Filelock 3.9.0 (ce3e891)
|
||||
* Remove Lockfile no longer used by Cachecontrol
|
||||
* 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 unidecode module 1.1.1 (632af82) to 1.3.6 (4141992)
|
||||
|
||||
|
|
|
@ -12,17 +12,18 @@ http://www.themoviedb.org/documentation/api and documentation page
|
|||
https://developers.themoviedb.org/3/getting-started
|
||||
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
|
||||
"""
|
||||
|
||||
__title__ = 'tmdbsimple'
|
||||
__version__ = '2.6.6'
|
||||
__version__ = '2.9.1'
|
||||
__author__ = 'Celia Oakley'
|
||||
__copyright__ = 'Copyright (c) 2013-2020 Celia Oakley'
|
||||
__copyright__ = 'Copyright (c) 2013-2022 Celia Oakley'
|
||||
__license__ = 'GPLv3'
|
||||
|
||||
import os
|
||||
import requests
|
||||
|
||||
from .account import Account, Authentication, GuestSessions, Lists
|
||||
from .base import APIKeyError
|
||||
|
@ -51,3 +52,5 @@ __all__ = ['Account', 'Authentication', 'GuestSessions', 'Lists',
|
|||
|
||||
API_KEY = os.environ.get('TMDB_API_KEY', None)
|
||||
API_VERSION = '3'
|
||||
REQUESTS_SESSION = None
|
||||
REQUESTS_TIMEOUT = os.environ.get('TMDB_REQUESTS_TIMEOUT', None)
|
||||
|
|
|
@ -8,7 +8,7 @@ of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ This module implements the base class of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
@ -27,9 +27,11 @@ class TMDB(object):
|
|||
URLS = {}
|
||||
|
||||
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 += '/{version}'.format(version=API_VERSION)
|
||||
self.session = REQUESTS_SESSION
|
||||
self.timeout = REQUESTS_TIMEOUT
|
||||
|
||||
def _get_path(self, key):
|
||||
return self.BASE_PATH + self.URLS[key]
|
||||
|
@ -80,10 +82,25 @@ class TMDB(object):
|
|||
url = self._get_complete_url(path)
|
||||
params = self._get_params(params)
|
||||
|
||||
response = requests.request(
|
||||
method, url, params=params,
|
||||
data=json.dumps(payload) if payload else payload,
|
||||
headers=self.headers, verify=False)
|
||||
# Create a new request session if no global session is defined
|
||||
if self.session is None:
|
||||
response = requests.request(
|
||||
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.encoding = 'utf-8'
|
||||
|
|
|
@ -7,7 +7,7 @@ This module implements the Changes functionality of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ This module implements the Discover functionality of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
@ -112,7 +112,7 @@ class Discover(TMDB):
|
|||
have a rating that is less than or equal to the specified value.
|
||||
Minimum 0.
|
||||
with_cast: (optional) A comma separated list of person ID's. Only
|
||||
include movies that have one of the ID's added as an actor.
|
||||
include movies that have one of the ID's added as an actor.
|
||||
with_crew: (optional) A comma separated list of person ID's. Only
|
||||
include movies that have one of the ID's added as a crew member.
|
||||
with_people: (optional) A comma separated list of person ID's. Only
|
||||
|
@ -221,20 +221,20 @@ class Discover(TMDB):
|
|||
an episode runtime that is less than or equal to a value.
|
||||
include_null_first_air_dates: (optional) Use this filter to include
|
||||
TV shows that don't have an air date while using any of the
|
||||
"first_air_date" filters.
|
||||
"first_air_date" filters.
|
||||
with_original_language: (optional) Specify an ISO 639-1 string to
|
||||
filter results by their original language value.
|
||||
filter results by their original language value.
|
||||
without_keywords: (optional) Exclude items with certain keywords.
|
||||
You can comma and pipe seperate these values to create an 'AND'
|
||||
or 'OR' logic.
|
||||
or 'OR' logic.
|
||||
screened_theatrically: (optional) Filter results to include items
|
||||
that have been screened theatrically.
|
||||
that have been screened theatrically.
|
||||
with_companies: (optional) A comma separated list of production
|
||||
company ID's. Only include movies that have one of the ID's
|
||||
added as a production company.
|
||||
added as a production company.
|
||||
with_keywords: (optional) A comma separated list of keyword ID's.
|
||||
Only includes TV shows that have one of the ID's added as a
|
||||
keyword.
|
||||
keyword.
|
||||
|
||||
Returns:
|
||||
A dict respresentation of the JSON returned from the API.
|
||||
|
|
|
@ -7,7 +7,7 @@ This module implements the Find functionality of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Find(TMDB):
|
|||
language: (optional) ISO 639-1 code.
|
||||
external_source: Allowed Values: imdb_id, freebase_mid,
|
||||
freebase_id, tvdb_id, tvrage_id, facebook_id, twitter_id,
|
||||
instagram_id
|
||||
instagram_id
|
||||
|
||||
Returns:
|
||||
A dict respresentation of the JSON returned from the API.
|
||||
|
|
|
@ -7,7 +7,7 @@ This module implements the Genres functionality of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ Reviews functionality of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
@ -31,13 +31,14 @@ class Movies(TMDB):
|
|||
'external_ids': '/{id}/external_ids',
|
||||
'images': '/{id}/images',
|
||||
'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',
|
||||
'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_delete': '/{id}/rating',
|
||||
'latest': '/latest',
|
||||
|
@ -208,6 +209,40 @@ class Movies(TMDB):
|
|||
self._set_attrs_to_values(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):
|
||||
"""
|
||||
Get the release date along with the certification for a movie.
|
||||
|
@ -233,41 +268,9 @@ class Movies(TMDB):
|
|||
self._set_attrs_to_values(response)
|
||||
return response
|
||||
|
||||
def videos(self, **kwargs):
|
||||
def reviews(self, **kwargs):
|
||||
"""
|
||||
Get the videos that have been added to 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.
|
||||
Get the user reviews for a movie.
|
||||
|
||||
Args:
|
||||
language: (optional) ISO 639-1 code.
|
||||
|
@ -276,7 +279,7 @@ class Movies(TMDB):
|
|||
Returns:
|
||||
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)
|
||||
self._set_attrs_to_values(response)
|
||||
|
@ -302,35 +305,49 @@ class Movies(TMDB):
|
|||
self._set_attrs_to_values(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:
|
||||
language: (optional) ISO 639-1 code.
|
||||
page: (optional) Minimum 1, maximum 1000, default 1.
|
||||
None
|
||||
|
||||
Returns:
|
||||
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)
|
||||
self._set_attrs_to_values(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:
|
||||
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')
|
||||
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)
|
||||
self._set_attrs_to_values(response)
|
||||
|
|
|
@ -7,7 +7,7 @@ This module implements the People and Credits functionality of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ This module implements the Search functionality of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ functionality of tmdbsimple.
|
|||
|
||||
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
|
||||
"""
|
||||
|
||||
|
@ -38,6 +38,7 @@ class TV(TMDB):
|
|||
'similar': '/{id}/similar',
|
||||
'translations': '/{id}/translations',
|
||||
'videos': '/{id}/videos',
|
||||
'watch_providers': '/{id}/watch/providers',
|
||||
'rating': '/{id}/rating',
|
||||
'latest': '/latest',
|
||||
'airing_today': '/airing_today',
|
||||
|
@ -320,6 +321,21 @@ class TV(TMDB):
|
|||
self._set_attrs_to_values(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):
|
||||
"""
|
||||
Rate a TV show.
|
||||
|
@ -659,7 +675,8 @@ class TV_Episodes(TMDB):
|
|||
Returns:
|
||||
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)
|
||||
self._set_attrs_to_values(response)
|
||||
|
@ -736,7 +753,8 @@ class TV_Episodes(TMDB):
|
|||
Returns:
|
||||
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)
|
||||
self._set_attrs_to_values(response)
|
||||
|
|
Loading…
Reference in a new issue