spotify-apimatic-sdk 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spotify_apimatic_sdk-1.0.0.dist-info/METADATA +150 -0
- spotify_apimatic_sdk-1.0.0.dist-info/RECORD +186 -0
- spotify_apimatic_sdk-1.0.0.dist-info/WHEEL +5 -0
- spotify_apimatic_sdk-1.0.0.dist-info/licenses/LICENSE +30 -0
- spotify_apimatic_sdk-1.0.0.dist-info/top_level.txt +1 -0
- spotifywebapi/__init__.py +12 -0
- spotifywebapi/api_helper.py +19 -0
- spotifywebapi/configuration.py +318 -0
- spotifywebapi/controllers/__init__.py +20 -0
- spotifywebapi/controllers/albums_controller.py +498 -0
- spotifywebapi/controllers/artists_controller.py +327 -0
- spotifywebapi/controllers/audiobooks_controller.py +441 -0
- spotifywebapi/controllers/base_controller.py +67 -0
- spotifywebapi/controllers/categories_controller.py +161 -0
- spotifywebapi/controllers/chapters_controller.py +157 -0
- spotifywebapi/controllers/episodes_controller.py +390 -0
- spotifywebapi/controllers/genres_controller.py +84 -0
- spotifywebapi/controllers/markets_controller.py +82 -0
- spotifywebapi/controllers/o_auth_authorization_controller.py +156 -0
- spotifywebapi/controllers/player_controller.py +807 -0
- spotifywebapi/controllers/playlists_controller.py +851 -0
- spotifywebapi/controllers/search_controller.py +123 -0
- spotifywebapi/controllers/shows_controller.py +439 -0
- spotifywebapi/controllers/tracks_controller.py +821 -0
- spotifywebapi/controllers/users_controller.py +649 -0
- spotifywebapi/exceptions/__init__.py +11 -0
- spotifywebapi/exceptions/api_exception.py +36 -0
- spotifywebapi/exceptions/bad_request_exception.py +56 -0
- spotifywebapi/exceptions/forbidden_exception.py +56 -0
- spotifywebapi/exceptions/not_found_exception.py +56 -0
- spotifywebapi/exceptions/o_auth_provider_exception.py +73 -0
- spotifywebapi/exceptions/too_many_requests_exception.py +56 -0
- spotifywebapi/exceptions/unauthorized_exception.py +56 -0
- spotifywebapi/http/__init__.py +11 -0
- spotifywebapi/http/api_response.py +67 -0
- spotifywebapi/http/auth/__init__.py +5 -0
- spotifywebapi/http/auth/o_auth_2.py +336 -0
- spotifywebapi/http/http_call_back.py +20 -0
- spotifywebapi/http/http_client_provider.py +23 -0
- spotifywebapi/http/http_method_enum.py +25 -0
- spotifywebapi/http/http_request.py +55 -0
- spotifywebapi/http/http_response.py +45 -0
- spotifywebapi/http/proxy_settings.py +50 -0
- spotifywebapi/models/__init__.py +142 -0
- spotifywebapi/models/album_base.py +264 -0
- spotifywebapi/models/album_group_enum.py +51 -0
- spotifywebapi/models/album_object.py +375 -0
- spotifywebapi/models/album_restriction_object.py +109 -0
- spotifywebapi/models/album_type_enum.py +62 -0
- spotifywebapi/models/artist_discography_album_object.py +298 -0
- spotifywebapi/models/artist_object.py +335 -0
- spotifywebapi/models/audio_analysis_object.py +266 -0
- spotifywebapi/models/audio_features_object.py +518 -0
- spotifywebapi/models/audiobook_base.py +353 -0
- spotifywebapi/models/audiobook_object.py +369 -0
- spotifywebapi/models/author_object.py +85 -0
- spotifywebapi/models/categories.py +162 -0
- spotifywebapi/models/category_object.py +117 -0
- spotifywebapi/models/chapter_base.py +392 -0
- spotifywebapi/models/chapter_object.py +408 -0
- spotifywebapi/models/chapter_restriction_object.py +113 -0
- spotifywebapi/models/context_object.py +181 -0
- spotifywebapi/models/copyright_object.py +130 -0
- spotifywebapi/models/currently_playing_context_object.py +314 -0
- spotifywebapi/models/currently_playing_object.py +241 -0
- spotifywebapi/models/cursor_object.py +108 -0
- spotifywebapi/models/cursor_paged_artists.py +75 -0
- spotifywebapi/models/cursor_paging_object.py +183 -0
- spotifywebapi/models/cursor_paging_play_history_object.py +214 -0
- spotifywebapi/models/cursor_paging_simplified_artist_object.py +213 -0
- spotifywebapi/models/device_object.py +278 -0
- spotifywebapi/models/disallows_object.py +314 -0
- spotifywebapi/models/episode_base.py +394 -0
- spotifywebapi/models/episode_object.py +665 -0
- spotifywebapi/models/episode_restriction_object.py +112 -0
- spotifywebapi/models/error_object.py +85 -0
- spotifywebapi/models/explicit_content_settings_object.py +110 -0
- spotifywebapi/models/external_id_object.py +156 -0
- spotifywebapi/models/external_url_object.py +107 -0
- spotifywebapi/models/followers_object.py +134 -0
- spotifywebapi/models/image_object.py +168 -0
- spotifywebapi/models/include_external_enum.py +45 -0
- spotifywebapi/models/item_type_1_enum.py +56 -0
- spotifywebapi/models/item_type_2_enum.py +45 -0
- spotifywebapi/models/item_type_3_enum.py +45 -0
- spotifywebapi/models/item_type_enum.py +58 -0
- spotifywebapi/models/linked_track_object.py +205 -0
- spotifywebapi/models/many_albums.py +76 -0
- spotifywebapi/models/many_artists.py +76 -0
- spotifywebapi/models/many_audio_features.py +77 -0
- spotifywebapi/models/many_audiobooks.py +77 -0
- spotifywebapi/models/many_chapters.py +77 -0
- spotifywebapi/models/many_devices.py +76 -0
- spotifywebapi/models/many_episodes.py +77 -0
- spotifywebapi/models/many_genres.py +69 -0
- spotifywebapi/models/many_simplified_shows.py +74 -0
- spotifywebapi/models/many_tracks.py +76 -0
- spotifywebapi/models/markets.py +85 -0
- spotifywebapi/models/me_albums_request.py +90 -0
- spotifywebapi/models/me_episodes_request.py +73 -0
- spotifywebapi/models/me_episodes_request_1.py +89 -0
- spotifywebapi/models/me_following_request.py +74 -0
- spotifywebapi/models/me_following_request_1.py +90 -0
- spotifywebapi/models/me_player_play_request.py +165 -0
- spotifywebapi/models/me_player_request.py +103 -0
- spotifywebapi/models/me_shows_request.py +89 -0
- spotifywebapi/models/me_tracks_request.py +74 -0
- spotifywebapi/models/me_tracks_request_1.py +90 -0
- spotifywebapi/models/meta.py +227 -0
- spotifywebapi/models/mode_enum.py +52 -0
- spotifywebapi/models/narrator_object.py +85 -0
- spotifywebapi/models/o_auth_provider_error_enum.py +67 -0
- spotifywebapi/models/o_auth_scope_enum.py +98 -0
- spotifywebapi/models/o_auth_token.py +113 -0
- spotifywebapi/models/paged_albums.py +75 -0
- spotifywebapi/models/paged_categories.py +74 -0
- spotifywebapi/models/paging_artist_discography_album_object.py +163 -0
- spotifywebapi/models/paging_artist_object.py +162 -0
- spotifywebapi/models/paging_featured_playlist_object.py +113 -0
- spotifywebapi/models/paging_object.py +142 -0
- spotifywebapi/models/paging_playlist_object.py +163 -0
- spotifywebapi/models/paging_playlist_track_object.py +163 -0
- spotifywebapi/models/paging_saved_album_object.py +163 -0
- spotifywebapi/models/paging_saved_audiobook_object.py +163 -0
- spotifywebapi/models/paging_saved_episode_object.py +163 -0
- spotifywebapi/models/paging_saved_show_object.py +163 -0
- spotifywebapi/models/paging_saved_track_object.py +163 -0
- spotifywebapi/models/paging_simplified_album_object.py +163 -0
- spotifywebapi/models/paging_simplified_audiobook_object.py +162 -0
- spotifywebapi/models/paging_simplified_chapter_object.py +162 -0
- spotifywebapi/models/paging_simplified_episode_object.py +162 -0
- spotifywebapi/models/paging_simplified_show_object.py +160 -0
- spotifywebapi/models/paging_simplified_track_object.py +163 -0
- spotifywebapi/models/paging_track_object.py +162 -0
- spotifywebapi/models/play_history_object.py +141 -0
- spotifywebapi/models/playlist_object.py +425 -0
- spotifywebapi/models/playlist_owner_object.py +238 -0
- spotifywebapi/models/playlist_snapshot_id.py +85 -0
- spotifywebapi/models/playlist_track_object.py +171 -0
- spotifywebapi/models/playlist_tracks_ref_object.py +109 -0
- spotifywebapi/models/playlist_user_object.py +231 -0
- spotifywebapi/models/playlists_followers_request.py +86 -0
- spotifywebapi/models/playlists_request.py +160 -0
- spotifywebapi/models/playlists_tracks_request.py +121 -0
- spotifywebapi/models/playlists_tracks_request_1.py +188 -0
- spotifywebapi/models/playlists_tracks_request_2.py +109 -0
- spotifywebapi/models/private_user_object.py +379 -0
- spotifywebapi/models/public_user_object.py +268 -0
- spotifywebapi/models/queue_object.py +118 -0
- spotifywebapi/models/reason_enum.py +65 -0
- spotifywebapi/models/recommendation_seed_object.py +208 -0
- spotifywebapi/models/recommendations_object.py +96 -0
- spotifywebapi/models/release_date_precision_enum.py +62 -0
- spotifywebapi/models/resume_point_object.py +131 -0
- spotifywebapi/models/saved_album_object.py +118 -0
- spotifywebapi/models/saved_audiobook_object.py +118 -0
- spotifywebapi/models/saved_episode_object.py +116 -0
- spotifywebapi/models/saved_show_object.py +116 -0
- spotifywebapi/models/saved_track_object.py +118 -0
- spotifywebapi/models/search_items.py +256 -0
- spotifywebapi/models/section_object.py +362 -0
- spotifywebapi/models/segment_object.py +307 -0
- spotifywebapi/models/show_base.py +550 -0
- spotifywebapi/models/show_object.py +319 -0
- spotifywebapi/models/simplified_album_object.py +468 -0
- spotifywebapi/models/simplified_artist_object.py +228 -0
- spotifywebapi/models/simplified_playlist_object.py +398 -0
- spotifywebapi/models/simplified_track_object.py +494 -0
- spotifywebapi/models/time_interval_object.py +132 -0
- spotifywebapi/models/track.py +697 -0
- spotifywebapi/models/track_1.py +85 -0
- spotifywebapi/models/track_object.py +605 -0
- spotifywebapi/models/track_restriction_object.py +112 -0
- spotifywebapi/models/type_2_enum.py +56 -0
- spotifywebapi/models/type_3_enum.py +56 -0
- spotifywebapi/models/type_4_enum.py +56 -0
- spotifywebapi/models/type_5_enum.py +56 -0
- spotifywebapi/models/type_6_enum.py +56 -0
- spotifywebapi/models/type_8_enum.py +42 -0
- spotifywebapi/models/type_9_enum.py +42 -0
- spotifywebapi/models/type_enum.py +56 -0
- spotifywebapi/models/users_playlists_request.py +154 -0
- spotifywebapi/spotifywebapi_client.py +198 -0
- spotifywebapi/utilities/__init__.py +6 -0
- spotifywebapi/utilities/file_wrapper.py +45 -0
- spotifywebapi/utilities/union_type_lookup.py +113 -0
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"""spotifywebapi.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ruff: noqa: E501
|
|
7
|
+
import os
|
|
8
|
+
import warnings
|
|
9
|
+
from enum import Enum
|
|
10
|
+
|
|
11
|
+
from apimatic_core.http.configurations.http_client_configuration import (
|
|
12
|
+
HttpClientConfiguration,
|
|
13
|
+
)
|
|
14
|
+
from apimatic_requests_client_adapter.requests_client import (
|
|
15
|
+
RequestsClient,
|
|
16
|
+
)
|
|
17
|
+
from dotenv import load_dotenv
|
|
18
|
+
|
|
19
|
+
from spotifywebapi.http.proxy_settings import (
|
|
20
|
+
ProxySettings,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Environment(Enum):
|
|
25
|
+
"""An enum for SDK environments."""
|
|
26
|
+
|
|
27
|
+
PRODUCTION = 0
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def from_value(cls, value, default=None):
|
|
31
|
+
"""Convert a value (string or int) to an Environment enum member.
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
value (Union[str, int]): The value to convert.
|
|
35
|
+
default (Environment): The fallback enum member if conversion fails.
|
|
36
|
+
|
|
37
|
+
Returns:
|
|
38
|
+
Environment: Matching enum member or fallback if invalid.
|
|
39
|
+
|
|
40
|
+
"""
|
|
41
|
+
if value is None:
|
|
42
|
+
return default
|
|
43
|
+
|
|
44
|
+
# Try to match directly by enum member
|
|
45
|
+
if isinstance(value, cls):
|
|
46
|
+
return value
|
|
47
|
+
|
|
48
|
+
# Handle integer or string conversion
|
|
49
|
+
for member in cls:
|
|
50
|
+
if (str(member.value).lower() == str(value).lower()
|
|
51
|
+
or member.name.lower() == str(value).lower()):
|
|
52
|
+
return member
|
|
53
|
+
|
|
54
|
+
# Fallback to provided default
|
|
55
|
+
return default
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class Server(Enum):
|
|
59
|
+
"""An enum for API servers."""
|
|
60
|
+
|
|
61
|
+
DEFAULT = 0
|
|
62
|
+
AUTH_SERVER = 1
|
|
63
|
+
|
|
64
|
+
@classmethod
|
|
65
|
+
def from_value(cls, value, default=None):
|
|
66
|
+
"""Convert a value (string or int) to a Server enum member.
|
|
67
|
+
|
|
68
|
+
Args:
|
|
69
|
+
value (Union[str, int]): The value to convert.
|
|
70
|
+
default (Server): The fallback enum member if conversion fails.
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
Server: Matching enum member or fallback if invalid.
|
|
74
|
+
|
|
75
|
+
"""
|
|
76
|
+
if value is None:
|
|
77
|
+
return default
|
|
78
|
+
|
|
79
|
+
# Try to match directly by enum member
|
|
80
|
+
if isinstance(value, cls):
|
|
81
|
+
return value
|
|
82
|
+
|
|
83
|
+
# Handle integer or string conversion
|
|
84
|
+
for member in cls:
|
|
85
|
+
if (str(member.value).lower() == str(value).lower()
|
|
86
|
+
or member.name.lower() == str(value).lower()):
|
|
87
|
+
return member
|
|
88
|
+
|
|
89
|
+
# Fallback to provided default
|
|
90
|
+
return default
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class Configuration(HttpClientConfiguration):
|
|
94
|
+
"""A class used for configuring the SDK by a user."""
|
|
95
|
+
|
|
96
|
+
@property
|
|
97
|
+
def environment(self):
|
|
98
|
+
"""Return current environment."""
|
|
99
|
+
return self._environment
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def o_auth_client_id(self):
|
|
103
|
+
"""Return OAuthClientId from AuthorizationCodeAuthCredentials."""
|
|
104
|
+
return self._authorization_code_auth_credentials.o_auth_client_id
|
|
105
|
+
|
|
106
|
+
@property
|
|
107
|
+
def o_auth_client_secret(self):
|
|
108
|
+
"""Return OAuthClientSecret from AuthorizationCodeAuthCredentials."""
|
|
109
|
+
return self._authorization_code_auth_credentials.o_auth_client_secret
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def o_auth_redirect_uri(self):
|
|
113
|
+
"""Return OAuthRedirectUri from AuthorizationCodeAuthCredentials."""
|
|
114
|
+
return self._authorization_code_auth_credentials.o_auth_redirect_uri
|
|
115
|
+
|
|
116
|
+
@property
|
|
117
|
+
def o_auth_scopes(self):
|
|
118
|
+
"""Return OAuthScopes from AuthorizationCodeAuthCredentials."""
|
|
119
|
+
return self._authorization_code_auth_credentials.o_auth_scopes
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def o_auth_token(self):
|
|
123
|
+
"""Return OAuthToken from AuthorizationCodeAuthCredentials."""
|
|
124
|
+
return self._authorization_code_auth_credentials.o_auth_token
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def authorization_code_auth_credentials(self):
|
|
128
|
+
"""Return AuthorizationCodeAuthCredentials."""
|
|
129
|
+
return self._authorization_code_auth_credentials
|
|
130
|
+
|
|
131
|
+
def __init__(self, http_client_instance=None,
|
|
132
|
+
override_http_client_configuration=False, http_call_back=None,
|
|
133
|
+
timeout=60, max_retries=0, backoff_factor=2, retry_statuses=None,
|
|
134
|
+
retry_methods=None, proxy_settings=None,
|
|
135
|
+
environment=Environment.PRODUCTION, o_auth_client_id=None,
|
|
136
|
+
o_auth_client_secret=None, o_auth_redirect_uri=None,
|
|
137
|
+
o_auth_token=None, o_auth_scopes=None,
|
|
138
|
+
authorization_code_auth_credentials=None):
|
|
139
|
+
"""Initialize Configuration object."""
|
|
140
|
+
if retry_methods is None:
|
|
141
|
+
retry_methods = ["GET", "PUT"]
|
|
142
|
+
|
|
143
|
+
if retry_statuses is None:
|
|
144
|
+
retry_statuses = [408, 413, 429, 500, 502, 503, 504, 521,
|
|
145
|
+
522, 524]
|
|
146
|
+
|
|
147
|
+
super().__init__(
|
|
148
|
+
http_client_instance=http_client_instance,
|
|
149
|
+
override_http_client_configuration=override_http_client_configuration,
|
|
150
|
+
http_call_back=http_call_back, timeout=timeout,
|
|
151
|
+
max_retries=max_retries, backoff_factor=backoff_factor,
|
|
152
|
+
retry_statuses=retry_statuses, retry_methods=retry_methods,
|
|
153
|
+
proxy_settings=proxy_settings,
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Current API environment
|
|
157
|
+
self._environment = environment
|
|
158
|
+
|
|
159
|
+
self._authorization_code_auth_credentials =\
|
|
160
|
+
self.create_auth_credentials_object(
|
|
161
|
+
o_auth_client_id, o_auth_client_secret, o_auth_redirect_uri,
|
|
162
|
+
o_auth_token, o_auth_scopes,
|
|
163
|
+
authorization_code_auth_credentials)
|
|
164
|
+
|
|
165
|
+
# The Http Client to use for making requests.
|
|
166
|
+
self.set_http_client(self.create_http_client())
|
|
167
|
+
|
|
168
|
+
def clone_with(self, http_client_instance=None,
|
|
169
|
+
override_http_client_configuration=None, http_call_back=None,
|
|
170
|
+
timeout=None, max_retries=None, backoff_factor=None,
|
|
171
|
+
retry_statuses=None, retry_methods=None, proxy_settings=None,
|
|
172
|
+
environment=None, o_auth_client_id=None, o_auth_client_secret=None,
|
|
173
|
+
o_auth_redirect_uri=None, o_auth_token=None, o_auth_scopes=None,
|
|
174
|
+
authorization_code_auth_credentials=None):
|
|
175
|
+
"""Clone configuration with overrides."""
|
|
176
|
+
http_client_instance = http_client_instance or self.http_client_instance
|
|
177
|
+
override_http_client_configuration =\
|
|
178
|
+
(override_http_client_configuration
|
|
179
|
+
or self.override_http_client_configuration)
|
|
180
|
+
http_call_back = http_call_back or self.http_callback
|
|
181
|
+
timeout = timeout or self.timeout
|
|
182
|
+
max_retries = max_retries or self.max_retries
|
|
183
|
+
backoff_factor = backoff_factor or self.backoff_factor
|
|
184
|
+
retry_statuses = retry_statuses or self.retry_statuses
|
|
185
|
+
retry_methods = retry_methods or self.retry_methods
|
|
186
|
+
proxy_settings = proxy_settings or self.proxy_settings
|
|
187
|
+
environment = environment or self.environment
|
|
188
|
+
authorization_code_auth_credentials = self.create_auth_credentials_object(
|
|
189
|
+
o_auth_client_id, o_auth_client_secret, o_auth_redirect_uri,
|
|
190
|
+
o_auth_token, o_auth_scopes,
|
|
191
|
+
authorization_code_auth_credentials
|
|
192
|
+
or self.authorization_code_auth_credentials,
|
|
193
|
+
stack_level=3)
|
|
194
|
+
return Configuration(
|
|
195
|
+
http_client_instance=http_client_instance,
|
|
196
|
+
override_http_client_configuration=override_http_client_configuration,
|
|
197
|
+
http_call_back=http_call_back, timeout=timeout, max_retries=max_retries,
|
|
198
|
+
backoff_factor=backoff_factor, retry_statuses=retry_statuses,
|
|
199
|
+
retry_methods=retry_methods, proxy_settings=proxy_settings,
|
|
200
|
+
environment=environment,
|
|
201
|
+
authorization_code_auth_credentials=authorization_code_auth_credentials,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
def create_http_client(self):
|
|
205
|
+
"""Create the HTTP client instance."""
|
|
206
|
+
return RequestsClient(
|
|
207
|
+
timeout=self.timeout, max_retries=self.max_retries,
|
|
208
|
+
backoff_factor=self.backoff_factor, retry_statuses=self.retry_statuses,
|
|
209
|
+
retry_methods=self.retry_methods,
|
|
210
|
+
http_client_instance=self.http_client_instance,
|
|
211
|
+
override_http_client_configuration=self.override_http_client_configuration,
|
|
212
|
+
response_factory=self.http_response_factory,
|
|
213
|
+
proxies=self.proxy_settings.to_proxies() if self.proxy_settings else None,
|
|
214
|
+
)
|
|
215
|
+
|
|
216
|
+
# All the environments the SDK can run in
|
|
217
|
+
environments = {
|
|
218
|
+
Environment.PRODUCTION: {
|
|
219
|
+
Server.DEFAULT: "https://api.spotify.com/v1",
|
|
220
|
+
Server.AUTH_SERVER: "https://accounts.spotify.com",
|
|
221
|
+
},
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
def get_base_uri(self, server=Server.DEFAULT):
|
|
225
|
+
"""Generate the appropriate base URI for the environment and the server.
|
|
226
|
+
|
|
227
|
+
Args:
|
|
228
|
+
server (Configuration.Server): The server enum for which the base
|
|
229
|
+
URI is required.
|
|
230
|
+
|
|
231
|
+
Returns:
|
|
232
|
+
String: The base URI.
|
|
233
|
+
|
|
234
|
+
"""
|
|
235
|
+
return self.environments[self.environment][server]
|
|
236
|
+
|
|
237
|
+
@staticmethod
|
|
238
|
+
def create_auth_credentials_object(o_auth_client_id, o_auth_client_secret,
|
|
239
|
+
o_auth_redirect_uri, o_auth_token,
|
|
240
|
+
o_auth_scopes,
|
|
241
|
+
authorization_code_auth_credentials,
|
|
242
|
+
stack_level=4):
|
|
243
|
+
"""Create auth credentials object."""
|
|
244
|
+
if o_auth_client_id is None \
|
|
245
|
+
and o_auth_client_secret is None \
|
|
246
|
+
and o_auth_redirect_uri is None \
|
|
247
|
+
and o_auth_token is None \
|
|
248
|
+
and o_auth_scopes is None:
|
|
249
|
+
return authorization_code_auth_credentials
|
|
250
|
+
|
|
251
|
+
warnings.warn(message=("The 'o_auth_client_id', 'o_auth_client_secret', 'o_au"
|
|
252
|
+
"th_redirect_uri', 'o_auth_token', 'o_auth_scopes' par"
|
|
253
|
+
"ams are deprecated. Use 'authorization_code_auth_cred"
|
|
254
|
+
"entials' param instead."),
|
|
255
|
+
category=DeprecationWarning,
|
|
256
|
+
stacklevel=stack_level)
|
|
257
|
+
|
|
258
|
+
if authorization_code_auth_credentials is not None:
|
|
259
|
+
return authorization_code_auth_credentials.clone_with(
|
|
260
|
+
o_auth_client_id, o_auth_client_secret, o_auth_redirect_uri,
|
|
261
|
+
o_auth_token, o_auth_scopes)
|
|
262
|
+
|
|
263
|
+
from spotifywebapi.http.auth.o_auth_2 import (
|
|
264
|
+
AuthorizationCodeAuthCredentials,
|
|
265
|
+
)
|
|
266
|
+
return AuthorizationCodeAuthCredentials(o_auth_client_id,
|
|
267
|
+
o_auth_client_secret,
|
|
268
|
+
o_auth_redirect_uri,
|
|
269
|
+
o_auth_token, o_auth_scopes)
|
|
270
|
+
|
|
271
|
+
@classmethod
|
|
272
|
+
def from_environment(cls, dotenv_path=None, **overrides):
|
|
273
|
+
"""Create Configuration object from .env and environment variables.
|
|
274
|
+
|
|
275
|
+
Args:
|
|
276
|
+
dotenv_path (str, optional): Path to the .env file to load.
|
|
277
|
+
If None, the default .env file is used.
|
|
278
|
+
**overrides: Optional values overriding setting from environment variables.
|
|
279
|
+
|
|
280
|
+
Returns:
|
|
281
|
+
Configuration: A configuration object populated with the resolved values.
|
|
282
|
+
|
|
283
|
+
"""
|
|
284
|
+
# load .env automatically
|
|
285
|
+
load_dotenv(dotenv_path or None, override=True)
|
|
286
|
+
|
|
287
|
+
override_http_client_configuration = os.getenv(
|
|
288
|
+
"OVERRIDE_HTTP_CLIENT_CONFIGURATION", "false").lower() == "true"
|
|
289
|
+
timeout = int(os.getenv("TIMEOUT", "60"))
|
|
290
|
+
max_retries = int(os.getenv("MAX_RETRIES", "0"))
|
|
291
|
+
backoff_factor = float(os.getenv("BACKOFF_FACTOR", "2"))
|
|
292
|
+
statuses = os.getenv("RETRY_STATUSES", None)
|
|
293
|
+
retry_statuses = [int(v.strip()) for v in statuses.split(",")
|
|
294
|
+
if v.strip().isdigit()] if statuses else None
|
|
295
|
+
methods = os.getenv("RETRY_METHODS", None)
|
|
296
|
+
retry_methods = [v.strip() for v in methods.split(",") if v.strip()]\
|
|
297
|
+
if methods else None
|
|
298
|
+
environment = Environment.from_value(
|
|
299
|
+
os.getenv("ENVIRONMENT"), Environment.PRODUCTION)
|
|
300
|
+
|
|
301
|
+
from spotifywebapi.http.auth.o_auth_2 import (
|
|
302
|
+
AuthorizationCodeAuthCredentials,
|
|
303
|
+
)
|
|
304
|
+
|
|
305
|
+
# Preparing default configuration
|
|
306
|
+
default_config = cls(
|
|
307
|
+
override_http_client_configuration=override_http_client_configuration,
|
|
308
|
+
timeout=timeout,
|
|
309
|
+
max_retries=max_retries,
|
|
310
|
+
backoff_factor=backoff_factor,
|
|
311
|
+
retry_statuses=retry_statuses,
|
|
312
|
+
retry_methods=retry_methods,
|
|
313
|
+
environment=environment,
|
|
314
|
+
proxy_settings=ProxySettings.from_environment(),
|
|
315
|
+
authorization_code_auth_credentials=AuthorizationCodeAuthCredentials.from_environment(),
|
|
316
|
+
)
|
|
317
|
+
|
|
318
|
+
return default_config.clone_with(**overrides)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# ruff: noqa: D104 | Missing docstring in public package
|
|
2
|
+
# ruff: noqa: RUF022 | `__all__` is not sorted
|
|
3
|
+
__all__ = [
|
|
4
|
+
"albums_controller",
|
|
5
|
+
"artists_controller",
|
|
6
|
+
"audiobooks_controller",
|
|
7
|
+
"base_controller",
|
|
8
|
+
"categories_controller",
|
|
9
|
+
"chapters_controller",
|
|
10
|
+
"episodes_controller",
|
|
11
|
+
"genres_controller",
|
|
12
|
+
"markets_controller",
|
|
13
|
+
"o_auth_authorization_controller",
|
|
14
|
+
"player_controller",
|
|
15
|
+
"playlists_controller",
|
|
16
|
+
"search_controller",
|
|
17
|
+
"shows_controller",
|
|
18
|
+
"tracks_controller",
|
|
19
|
+
"users_controller",
|
|
20
|
+
]
|