1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
# -*- coding: utf-8 -*-
"""
tmdbsimple.configuration
~~~~~~~~~~~~~~~~~~~~~~~~
This module implements the Configuration and Certifications functionality of
tmdbsimple.
Created by Celia Oakley on 2013-10-31.
:copyright: (c) 2013-2022 by Celia Oakley
:license: GPLv3, see LICENSE for more details
"""
from .base import TMDB
class Configuration(TMDB):
"""
Configuration functionality.
See: https://developers.themoviedb.org/3/configuration
"""
BASE_PATH = 'configuration'
URLS = {
'info': '',
'countries': '/countries',
'jobs': '/jobs',
'languages': '/languages',
'primary_translations': '/primary_translations',
'timezones': '/timezones',
}
def info(self, **kwargs):
"""
Get the system wide configuration information. Some elements of the API
require some knowledge of this configuration data. The purpose of this
is to try and keep the actual API responses as light as possible. It is
recommended you cache this data within your application and check for
updates every few days.
This method currently holds the data relevant to building image URLs as
well as the change key map.
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:
https://image.tmdb.org/t/p/w500/8uO0gUM8aNqYLs1OsTBQiXu0fEv.jpg
The configuration method also contains the list of change keys which
can be useful if you are building an app that consumes data from the
change feed.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('info')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def countries(self, **kwargs):
"""
Get the list of countries (ISO 3166-1 tags) used throughout TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('countries')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def jobs(self, **kwargs):
"""
Get a list of the jobs and departments we use on TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('jobs')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def languages(self, **kwargs):
"""
Get the list of languages (ISO 639-1 tags) used throughout TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('languages')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def primary_translations(self, **kwargs):
"""
Get a list of the officially supported translations on TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('primary_translations')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def timezones(self, **kwargs):
"""
Get the list of timezones used throughout TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('timezones')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
class Certifications(TMDB):
"""
Certifications functionality.
See: https://developers.themoviedb.org/3/certifications
"""
BASE_PATH = 'certification'
URLS = {
'movie_list': '/movie/list',
'tv_list': '/tv/list',
}
def movie_list(self, **kwargs):
"""
Get an up to date list of the officially supported movie certifications on TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('movie_list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
def tv_list(self, **kwargs):
"""
Get an up to date list of the officially supported TV show certifications on TMDb.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('tv_list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
# backward compatability, when only /movie/list existed
def list(self, **kwargs):
"""
Get the list of supported certifications for movies.
Args:
None
Returns:
A dict respresentation of the JSON returned from the API.
"""
path = self._get_path('movie_list')
response = self._GET(path, kwargs)
self._set_attrs_to_values(response)
return response
|