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,441 @@
|
|
|
1
|
+
"""spotifywebapi.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ruff: noqa: D410, E501, E101, D206
|
|
7
|
+
from apimatic_core.authentication.multiple.single_auth import (
|
|
8
|
+
Single,
|
|
9
|
+
)
|
|
10
|
+
from apimatic_core.request_builder import RequestBuilder
|
|
11
|
+
from apimatic_core.response_handler import ResponseHandler
|
|
12
|
+
from apimatic_core.types.parameter import Parameter
|
|
13
|
+
|
|
14
|
+
from spotifywebapi.api_helper import APIHelper
|
|
15
|
+
from spotifywebapi.configuration import Server
|
|
16
|
+
from spotifywebapi.controllers.base_controller import (
|
|
17
|
+
BaseController,
|
|
18
|
+
)
|
|
19
|
+
from spotifywebapi.exceptions.bad_request_exception import (
|
|
20
|
+
BadRequestException,
|
|
21
|
+
)
|
|
22
|
+
from spotifywebapi.exceptions.forbidden_exception import (
|
|
23
|
+
ForbiddenException,
|
|
24
|
+
)
|
|
25
|
+
from spotifywebapi.exceptions.not_found_exception import (
|
|
26
|
+
NotFoundException,
|
|
27
|
+
)
|
|
28
|
+
from spotifywebapi.exceptions.too_many_requests_exception import (
|
|
29
|
+
TooManyRequestsException,
|
|
30
|
+
)
|
|
31
|
+
from spotifywebapi.exceptions.unauthorized_exception import (
|
|
32
|
+
UnauthorizedException,
|
|
33
|
+
)
|
|
34
|
+
from spotifywebapi.http.http_method_enum import (
|
|
35
|
+
HttpMethodEnum,
|
|
36
|
+
)
|
|
37
|
+
from spotifywebapi.models.audiobook_object import (
|
|
38
|
+
AudiobookObject,
|
|
39
|
+
)
|
|
40
|
+
from spotifywebapi.models.many_audiobooks import (
|
|
41
|
+
ManyAudiobooks,
|
|
42
|
+
)
|
|
43
|
+
from spotifywebapi.models.paging_saved_audiobook_object import (
|
|
44
|
+
PagingSavedAudiobookObject,
|
|
45
|
+
)
|
|
46
|
+
from spotifywebapi.models.paging_simplified_chapter_object import (
|
|
47
|
+
PagingSimplifiedChapterObject,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class AudiobooksController(BaseController):
|
|
52
|
+
"""A Controller to access Endpoints in the spotifywebapi API."""
|
|
53
|
+
|
|
54
|
+
def __init__(self, config):
|
|
55
|
+
"""Initialize AudiobooksController object."""
|
|
56
|
+
super(AudiobooksController, self).__init__(config)
|
|
57
|
+
|
|
58
|
+
def get_an_audiobook(self,
|
|
59
|
+
id,
|
|
60
|
+
market=None):
|
|
61
|
+
"""Perform a GET request to /audiobooks/{id}.
|
|
62
|
+
|
|
63
|
+
Get Spotify catalog information for a single audiobook. Audiobooks are only
|
|
64
|
+
available within the US, UK, Canada, Ireland, New Zealand and Australia
|
|
65
|
+
markets.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
id (str): The request template parameter.
|
|
69
|
+
market (str, optional): The request query parameter.
|
|
70
|
+
|
|
71
|
+
Returns:
|
|
72
|
+
ApiResponse: An object with the response value as well as other useful
|
|
73
|
+
information such as status codes and headers. An Audiobook
|
|
74
|
+
|
|
75
|
+
Raises:
|
|
76
|
+
APIException: When an error occurs while fetching the data from the
|
|
77
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
78
|
+
message, and the HTTP body that was received in the request.
|
|
79
|
+
|
|
80
|
+
"""
|
|
81
|
+
return super().new_api_call_builder.request(
|
|
82
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
83
|
+
.path("/audiobooks/{id}")
|
|
84
|
+
.http_method(HttpMethodEnum.GET)
|
|
85
|
+
.template_param(Parameter()
|
|
86
|
+
.key("id")
|
|
87
|
+
.value(id)
|
|
88
|
+
.should_encode(True))
|
|
89
|
+
.query_param(Parameter()
|
|
90
|
+
.key("market")
|
|
91
|
+
.value(market))
|
|
92
|
+
.header_param(Parameter()
|
|
93
|
+
.key("accept")
|
|
94
|
+
.value("application/json"))
|
|
95
|
+
.auth(Single("oauth_2_0")),
|
|
96
|
+
).response(
|
|
97
|
+
ResponseHandler()
|
|
98
|
+
.deserializer(APIHelper.json_deserialize)
|
|
99
|
+
.deserialize_into(AudiobookObject.from_dictionary)
|
|
100
|
+
.is_api_response(True)
|
|
101
|
+
.local_error("400",
|
|
102
|
+
"The request contains malformed data in path, query parameters, or bo"
|
|
103
|
+
"dy.\n",
|
|
104
|
+
BadRequestException)
|
|
105
|
+
.local_error("401",
|
|
106
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
107
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
108
|
+
"\n",
|
|
109
|
+
UnauthorizedException)
|
|
110
|
+
.local_error("403",
|
|
111
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
112
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
113
|
+
ForbiddenException)
|
|
114
|
+
.local_error("404",
|
|
115
|
+
"The requested resource cannot be found.\n",
|
|
116
|
+
NotFoundException)
|
|
117
|
+
.local_error("429",
|
|
118
|
+
"The app has exceeded its rate limits.\n",
|
|
119
|
+
TooManyRequestsException),
|
|
120
|
+
).execute()
|
|
121
|
+
|
|
122
|
+
def get_multiple_audiobooks(self,
|
|
123
|
+
ids,
|
|
124
|
+
market=None):
|
|
125
|
+
"""Perform a GET request to /audiobooks.
|
|
126
|
+
|
|
127
|
+
Get Spotify catalog information for several audiobooks identified by their
|
|
128
|
+
Spotify IDs. Audiobooks are only available within the US, UK, Canada,
|
|
129
|
+
Ireland, New Zealand and Australia markets.
|
|
130
|
+
|
|
131
|
+
Args:
|
|
132
|
+
ids (str): The request query parameter.
|
|
133
|
+
market (str, optional): The request query parameter.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
ApiResponse: An object with the response value as well as other useful
|
|
137
|
+
information such as status codes and headers. A set of audiobooks. If
|
|
138
|
+
one of the requested audiobooks is unavailable then you'll find a
|
|
139
|
+
`null` item in the `audiobooks` array where the audiobook object
|
|
140
|
+
would otherwise be.
|
|
141
|
+
|
|
142
|
+
Raises:
|
|
143
|
+
APIException: When an error occurs while fetching the data from the
|
|
144
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
145
|
+
message, and the HTTP body that was received in the request.
|
|
146
|
+
|
|
147
|
+
"""
|
|
148
|
+
return super().new_api_call_builder.request(
|
|
149
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
150
|
+
.path("/audiobooks")
|
|
151
|
+
.http_method(HttpMethodEnum.GET)
|
|
152
|
+
.query_param(Parameter()
|
|
153
|
+
.key("ids")
|
|
154
|
+
.value(ids))
|
|
155
|
+
.query_param(Parameter()
|
|
156
|
+
.key("market")
|
|
157
|
+
.value(market))
|
|
158
|
+
.header_param(Parameter()
|
|
159
|
+
.key("accept")
|
|
160
|
+
.value("application/json"))
|
|
161
|
+
.auth(Single("oauth_2_0")),
|
|
162
|
+
).response(
|
|
163
|
+
ResponseHandler()
|
|
164
|
+
.deserializer(APIHelper.json_deserialize)
|
|
165
|
+
.deserialize_into(ManyAudiobooks.from_dictionary)
|
|
166
|
+
.is_api_response(True)
|
|
167
|
+
.local_error("401",
|
|
168
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
169
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
170
|
+
"\n",
|
|
171
|
+
UnauthorizedException)
|
|
172
|
+
.local_error("403",
|
|
173
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
174
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
175
|
+
ForbiddenException)
|
|
176
|
+
.local_error("429",
|
|
177
|
+
"The app has exceeded its rate limits.\n",
|
|
178
|
+
TooManyRequestsException),
|
|
179
|
+
).execute()
|
|
180
|
+
|
|
181
|
+
def get_audiobook_chapters(self,
|
|
182
|
+
id,
|
|
183
|
+
market=None,
|
|
184
|
+
limit=20,
|
|
185
|
+
offset=0):
|
|
186
|
+
"""Perform a GET request to /audiobooks/{id}/chapters.
|
|
187
|
+
|
|
188
|
+
Get Spotify catalog information about an audiobook's chapters. Audiobooks are
|
|
189
|
+
only available within the US, UK, Canada, Ireland, New Zealand and Australia
|
|
190
|
+
markets.
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
id (str): The request template parameter.
|
|
194
|
+
market (str, optional): The request query parameter.
|
|
195
|
+
limit (int, optional): The request query parameter. Example: 20
|
|
196
|
+
offset (int, optional): The request query parameter. Example: 0
|
|
197
|
+
|
|
198
|
+
Returns:
|
|
199
|
+
ApiResponse: An object with the response value as well as other useful
|
|
200
|
+
information such as status codes and headers. Pages of chapters
|
|
201
|
+
|
|
202
|
+
Raises:
|
|
203
|
+
APIException: When an error occurs while fetching the data from the
|
|
204
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
205
|
+
message, and the HTTP body that was received in the request.
|
|
206
|
+
|
|
207
|
+
"""
|
|
208
|
+
return super().new_api_call_builder.request(
|
|
209
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
210
|
+
.path("/audiobooks/{id}/chapters")
|
|
211
|
+
.http_method(HttpMethodEnum.GET)
|
|
212
|
+
.template_param(Parameter()
|
|
213
|
+
.key("id")
|
|
214
|
+
.value(id)
|
|
215
|
+
.should_encode(True))
|
|
216
|
+
.query_param(Parameter()
|
|
217
|
+
.key("market")
|
|
218
|
+
.value(market))
|
|
219
|
+
.query_param(Parameter()
|
|
220
|
+
.key("limit")
|
|
221
|
+
.value(limit))
|
|
222
|
+
.query_param(Parameter()
|
|
223
|
+
.key("offset")
|
|
224
|
+
.value(offset))
|
|
225
|
+
.header_param(Parameter()
|
|
226
|
+
.key("accept")
|
|
227
|
+
.value("application/json"))
|
|
228
|
+
.auth(Single("oauth_2_0")),
|
|
229
|
+
).response(
|
|
230
|
+
ResponseHandler()
|
|
231
|
+
.deserializer(APIHelper.json_deserialize)
|
|
232
|
+
.deserialize_into(PagingSimplifiedChapterObject.from_dictionary)
|
|
233
|
+
.is_api_response(True)
|
|
234
|
+
.local_error("401",
|
|
235
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
236
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
237
|
+
"\n",
|
|
238
|
+
UnauthorizedException)
|
|
239
|
+
.local_error("403",
|
|
240
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
241
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
242
|
+
ForbiddenException)
|
|
243
|
+
.local_error("429",
|
|
244
|
+
"The app has exceeded its rate limits.\n",
|
|
245
|
+
TooManyRequestsException),
|
|
246
|
+
).execute()
|
|
247
|
+
|
|
248
|
+
def get_users_saved_audiobooks(self,
|
|
249
|
+
limit=20,
|
|
250
|
+
offset=0):
|
|
251
|
+
"""Perform a GET request to /me/audiobooks.
|
|
252
|
+
|
|
253
|
+
Get a list of the audiobooks saved in the current Spotify user's 'Your Music'
|
|
254
|
+
library.
|
|
255
|
+
|
|
256
|
+
Args:
|
|
257
|
+
limit (int, optional): The request query parameter. Example: 20
|
|
258
|
+
offset (int, optional): The request query parameter. Example: 0
|
|
259
|
+
|
|
260
|
+
Returns:
|
|
261
|
+
ApiResponse: An object with the response value as well as other useful
|
|
262
|
+
information such as status codes and headers. Pages of saved
|
|
263
|
+
audiobooks
|
|
264
|
+
|
|
265
|
+
Raises:
|
|
266
|
+
APIException: When an error occurs while fetching the data from the
|
|
267
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
268
|
+
message, and the HTTP body that was received in the request.
|
|
269
|
+
|
|
270
|
+
"""
|
|
271
|
+
return super().new_api_call_builder.request(
|
|
272
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
273
|
+
.path("/me/audiobooks")
|
|
274
|
+
.http_method(HttpMethodEnum.GET)
|
|
275
|
+
.query_param(Parameter()
|
|
276
|
+
.key("limit")
|
|
277
|
+
.value(limit))
|
|
278
|
+
.query_param(Parameter()
|
|
279
|
+
.key("offset")
|
|
280
|
+
.value(offset))
|
|
281
|
+
.header_param(Parameter()
|
|
282
|
+
.key("accept")
|
|
283
|
+
.value("application/json"))
|
|
284
|
+
.auth(Single("oauth_2_0")),
|
|
285
|
+
).response(
|
|
286
|
+
ResponseHandler()
|
|
287
|
+
.deserializer(APIHelper.json_deserialize)
|
|
288
|
+
.deserialize_into(PagingSavedAudiobookObject.from_dictionary)
|
|
289
|
+
.is_api_response(True)
|
|
290
|
+
.local_error("401",
|
|
291
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
292
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
293
|
+
"\n",
|
|
294
|
+
UnauthorizedException)
|
|
295
|
+
.local_error("403",
|
|
296
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
297
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
298
|
+
ForbiddenException)
|
|
299
|
+
.local_error("429",
|
|
300
|
+
"The app has exceeded its rate limits.\n",
|
|
301
|
+
TooManyRequestsException),
|
|
302
|
+
).execute()
|
|
303
|
+
|
|
304
|
+
def save_audiobooks_user(self,
|
|
305
|
+
ids):
|
|
306
|
+
"""Perform a PUT request to /me/audiobooks.
|
|
307
|
+
|
|
308
|
+
Save one or more audiobooks to the current Spotify user's library.
|
|
309
|
+
|
|
310
|
+
Args:
|
|
311
|
+
ids (str): The request query parameter.
|
|
312
|
+
|
|
313
|
+
Returns:
|
|
314
|
+
ApiResponse: An object with the response value as well as other useful
|
|
315
|
+
information such as status codes and headers. Audiobook(s) are saved
|
|
316
|
+
to the library
|
|
317
|
+
|
|
318
|
+
Raises:
|
|
319
|
+
APIException: When an error occurs while fetching the data from the
|
|
320
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
321
|
+
message, and the HTTP body that was received in the request.
|
|
322
|
+
|
|
323
|
+
"""
|
|
324
|
+
return super().new_api_call_builder.request(
|
|
325
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
326
|
+
.path("/me/audiobooks")
|
|
327
|
+
.http_method(HttpMethodEnum.PUT)
|
|
328
|
+
.query_param(Parameter()
|
|
329
|
+
.key("ids")
|
|
330
|
+
.value(ids))
|
|
331
|
+
.auth(Single("oauth_2_0")),
|
|
332
|
+
).response(
|
|
333
|
+
ResponseHandler()
|
|
334
|
+
.is_api_response(True)
|
|
335
|
+
.local_error("401",
|
|
336
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
337
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
338
|
+
"\n",
|
|
339
|
+
UnauthorizedException)
|
|
340
|
+
.local_error("403",
|
|
341
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
342
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
343
|
+
ForbiddenException)
|
|
344
|
+
.local_error("429",
|
|
345
|
+
"The app has exceeded its rate limits.\n",
|
|
346
|
+
TooManyRequestsException),
|
|
347
|
+
).execute()
|
|
348
|
+
|
|
349
|
+
def remove_audiobooks_user(self,
|
|
350
|
+
ids):
|
|
351
|
+
"""Perform a DELETE request to /me/audiobooks.
|
|
352
|
+
|
|
353
|
+
Remove one or more audiobooks from the Spotify user's library.
|
|
354
|
+
|
|
355
|
+
Args:
|
|
356
|
+
ids (str): The request query parameter.
|
|
357
|
+
|
|
358
|
+
Returns:
|
|
359
|
+
ApiResponse: An object with the response value as well as other useful
|
|
360
|
+
information such as status codes and headers. Audiobook(s) have been
|
|
361
|
+
removed from the library
|
|
362
|
+
|
|
363
|
+
Raises:
|
|
364
|
+
APIException: When an error occurs while fetching the data from the
|
|
365
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
366
|
+
message, and the HTTP body that was received in the request.
|
|
367
|
+
|
|
368
|
+
"""
|
|
369
|
+
return super().new_api_call_builder.request(
|
|
370
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
371
|
+
.path("/me/audiobooks")
|
|
372
|
+
.http_method(HttpMethodEnum.DELETE)
|
|
373
|
+
.query_param(Parameter()
|
|
374
|
+
.key("ids")
|
|
375
|
+
.value(ids))
|
|
376
|
+
.auth(Single("oauth_2_0")),
|
|
377
|
+
).response(
|
|
378
|
+
ResponseHandler()
|
|
379
|
+
.is_api_response(True)
|
|
380
|
+
.local_error("401",
|
|
381
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
382
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
383
|
+
"\n",
|
|
384
|
+
UnauthorizedException)
|
|
385
|
+
.local_error("403",
|
|
386
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
387
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
388
|
+
ForbiddenException)
|
|
389
|
+
.local_error("429",
|
|
390
|
+
"The app has exceeded its rate limits.\n",
|
|
391
|
+
TooManyRequestsException),
|
|
392
|
+
).execute()
|
|
393
|
+
|
|
394
|
+
def check_users_saved_audiobooks(self,
|
|
395
|
+
ids):
|
|
396
|
+
"""Perform a GET request to /me/audiobooks/contains.
|
|
397
|
+
|
|
398
|
+
Check if one or more audiobooks are already saved in the current Spotify
|
|
399
|
+
user's library.
|
|
400
|
+
|
|
401
|
+
Args:
|
|
402
|
+
ids (str): The request query parameter.
|
|
403
|
+
|
|
404
|
+
Returns:
|
|
405
|
+
ApiResponse: An object with the response value as well as other useful
|
|
406
|
+
information such as status codes and headers. Array of booleans
|
|
407
|
+
|
|
408
|
+
Raises:
|
|
409
|
+
APIException: When an error occurs while fetching the data from the
|
|
410
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
411
|
+
message, and the HTTP body that was received in the request.
|
|
412
|
+
|
|
413
|
+
"""
|
|
414
|
+
return super().new_api_call_builder.request(
|
|
415
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
416
|
+
.path("/me/audiobooks/contains")
|
|
417
|
+
.http_method(HttpMethodEnum.GET)
|
|
418
|
+
.query_param(Parameter()
|
|
419
|
+
.key("ids")
|
|
420
|
+
.value(ids))
|
|
421
|
+
.header_param(Parameter()
|
|
422
|
+
.key("accept")
|
|
423
|
+
.value("application/json"))
|
|
424
|
+
.auth(Single("oauth_2_0")),
|
|
425
|
+
).response(
|
|
426
|
+
ResponseHandler()
|
|
427
|
+
.deserializer(APIHelper.json_deserialize)
|
|
428
|
+
.is_api_response(True)
|
|
429
|
+
.local_error("401",
|
|
430
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
431
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
432
|
+
"\n",
|
|
433
|
+
UnauthorizedException)
|
|
434
|
+
.local_error("403",
|
|
435
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
436
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
437
|
+
ForbiddenException)
|
|
438
|
+
.local_error("429",
|
|
439
|
+
"The app has exceeded its rate limits.\n",
|
|
440
|
+
TooManyRequestsException),
|
|
441
|
+
).execute()
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""spotifywebapi.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from apimatic_core.api_call import ApiCall
|
|
7
|
+
from apimatic_core.types.error_case import ErrorCase
|
|
8
|
+
|
|
9
|
+
from spotifywebapi.exceptions.api_exception import (
|
|
10
|
+
APIException,
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class BaseController(object):
|
|
15
|
+
"""All controllers inherit from this base class.
|
|
16
|
+
|
|
17
|
+
Attributes:
|
|
18
|
+
config (Configuration): The HttpClient which a specific controller
|
|
19
|
+
instance will use. By default all the controller objects share
|
|
20
|
+
the same HttpClient. A user can use his own custom HttpClient
|
|
21
|
+
as well.
|
|
22
|
+
http_call_back (HttpCallBack): An object which holds call back
|
|
23
|
+
methods to be called before and after the execution of an HttpRequest.
|
|
24
|
+
new_api_call_builder (APICall): Returns the API Call builder instance.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
|
|
28
|
+
@staticmethod
|
|
29
|
+
def user_agent():
|
|
30
|
+
"""Return UserAgent value."""
|
|
31
|
+
return "APIMATIC 3.0"
|
|
32
|
+
|
|
33
|
+
@staticmethod
|
|
34
|
+
def user_agent_parameters():
|
|
35
|
+
"""Return UserAgentParameters value."""
|
|
36
|
+
return {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@staticmethod
|
|
40
|
+
def global_errors():
|
|
41
|
+
"""Return GlobalErrors value."""
|
|
42
|
+
return {
|
|
43
|
+
"default": ErrorCase()
|
|
44
|
+
.error_message("HTTP response not OK.")
|
|
45
|
+
.exception_type(APIException),
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
def __init__(self, config):
|
|
49
|
+
"""Initialize BaseController object."""
|
|
50
|
+
self._config = config.get_http_client_configuration()
|
|
51
|
+
self._http_call_back = self.config.http_callback
|
|
52
|
+
self.api_call = ApiCall(config)
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def config(self):
|
|
56
|
+
"""Return Configuration object."""
|
|
57
|
+
return self._config
|
|
58
|
+
|
|
59
|
+
@property
|
|
60
|
+
def http_call_back(self):
|
|
61
|
+
"""Return HttpCallBack object."""
|
|
62
|
+
return self._http_call_back
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def new_api_call_builder(self):
|
|
66
|
+
"""Return New ApiCallBuilder object."""
|
|
67
|
+
return self.api_call.new_builder
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""spotifywebapi.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ruff: noqa: D410, E501, E101, D206
|
|
7
|
+
from apimatic_core.authentication.multiple.single_auth import (
|
|
8
|
+
Single,
|
|
9
|
+
)
|
|
10
|
+
from apimatic_core.request_builder import RequestBuilder
|
|
11
|
+
from apimatic_core.response_handler import ResponseHandler
|
|
12
|
+
from apimatic_core.types.parameter import Parameter
|
|
13
|
+
|
|
14
|
+
from spotifywebapi.api_helper import APIHelper
|
|
15
|
+
from spotifywebapi.configuration import Server
|
|
16
|
+
from spotifywebapi.controllers.base_controller import (
|
|
17
|
+
BaseController,
|
|
18
|
+
)
|
|
19
|
+
from spotifywebapi.exceptions.forbidden_exception import (
|
|
20
|
+
ForbiddenException,
|
|
21
|
+
)
|
|
22
|
+
from spotifywebapi.exceptions.too_many_requests_exception import (
|
|
23
|
+
TooManyRequestsException,
|
|
24
|
+
)
|
|
25
|
+
from spotifywebapi.exceptions.unauthorized_exception import (
|
|
26
|
+
UnauthorizedException,
|
|
27
|
+
)
|
|
28
|
+
from spotifywebapi.http.http_method_enum import (
|
|
29
|
+
HttpMethodEnum,
|
|
30
|
+
)
|
|
31
|
+
from spotifywebapi.models.category_object import (
|
|
32
|
+
CategoryObject,
|
|
33
|
+
)
|
|
34
|
+
from spotifywebapi.models.paged_categories import (
|
|
35
|
+
PagedCategories,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class CategoriesController(BaseController):
|
|
40
|
+
"""A Controller to access Endpoints in the spotifywebapi API."""
|
|
41
|
+
|
|
42
|
+
def __init__(self, config):
|
|
43
|
+
"""Initialize CategoriesController object."""
|
|
44
|
+
super(CategoriesController, self).__init__(config)
|
|
45
|
+
|
|
46
|
+
def get_categories(self,
|
|
47
|
+
locale=None,
|
|
48
|
+
limit=20,
|
|
49
|
+
offset=0):
|
|
50
|
+
"""Perform a GET request to /browse/categories.
|
|
51
|
+
|
|
52
|
+
Get a list of categories used to tag items in Spotify (on, for example, the
|
|
53
|
+
Spotify player’s “Browse” tab).
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
locale (str, optional): The request query parameter.
|
|
57
|
+
limit (int, optional): The request query parameter. Example: 20
|
|
58
|
+
offset (int, optional): The request query parameter. Example: 0
|
|
59
|
+
|
|
60
|
+
Returns:
|
|
61
|
+
ApiResponse: An object with the response value as well as other useful
|
|
62
|
+
information such as status codes and headers. A paged set of
|
|
63
|
+
categories
|
|
64
|
+
|
|
65
|
+
Raises:
|
|
66
|
+
APIException: When an error occurs while fetching the data from the
|
|
67
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
68
|
+
message, and the HTTP body that was received in the request.
|
|
69
|
+
|
|
70
|
+
"""
|
|
71
|
+
return super().new_api_call_builder.request(
|
|
72
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
73
|
+
.path("/browse/categories")
|
|
74
|
+
.http_method(HttpMethodEnum.GET)
|
|
75
|
+
.query_param(Parameter()
|
|
76
|
+
.key("locale")
|
|
77
|
+
.value(locale))
|
|
78
|
+
.query_param(Parameter()
|
|
79
|
+
.key("limit")
|
|
80
|
+
.value(limit))
|
|
81
|
+
.query_param(Parameter()
|
|
82
|
+
.key("offset")
|
|
83
|
+
.value(offset))
|
|
84
|
+
.header_param(Parameter()
|
|
85
|
+
.key("accept")
|
|
86
|
+
.value("application/json"))
|
|
87
|
+
.auth(Single("oauth_2_0")),
|
|
88
|
+
).response(
|
|
89
|
+
ResponseHandler()
|
|
90
|
+
.deserializer(APIHelper.json_deserialize)
|
|
91
|
+
.deserialize_into(PagedCategories.from_dictionary)
|
|
92
|
+
.is_api_response(True)
|
|
93
|
+
.local_error("401",
|
|
94
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
95
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
96
|
+
"\n",
|
|
97
|
+
UnauthorizedException)
|
|
98
|
+
.local_error("403",
|
|
99
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
100
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
101
|
+
ForbiddenException)
|
|
102
|
+
.local_error("429",
|
|
103
|
+
"The app has exceeded its rate limits.\n",
|
|
104
|
+
TooManyRequestsException),
|
|
105
|
+
).execute()
|
|
106
|
+
|
|
107
|
+
def get_a_category(self,
|
|
108
|
+
category_id,
|
|
109
|
+
locale=None):
|
|
110
|
+
"""Perform a GET request to /browse/categories/{category_id}.
|
|
111
|
+
|
|
112
|
+
Get a single category used to tag items in Spotify (on, for example, the
|
|
113
|
+
Spotify player’s “Browse” tab).
|
|
114
|
+
|
|
115
|
+
Args:
|
|
116
|
+
category_id (str): The request template parameter.
|
|
117
|
+
locale (str, optional): The request query parameter.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
ApiResponse: An object with the response value as well as other useful
|
|
121
|
+
information such as status codes and headers. A category
|
|
122
|
+
|
|
123
|
+
Raises:
|
|
124
|
+
APIException: When an error occurs while fetching the data from the
|
|
125
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
126
|
+
message, and the HTTP body that was received in the request.
|
|
127
|
+
|
|
128
|
+
"""
|
|
129
|
+
return super().new_api_call_builder.request(
|
|
130
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
131
|
+
.path("/browse/categories/{category_id}")
|
|
132
|
+
.http_method(HttpMethodEnum.GET)
|
|
133
|
+
.template_param(Parameter()
|
|
134
|
+
.key("category_id")
|
|
135
|
+
.value(category_id)
|
|
136
|
+
.should_encode(True))
|
|
137
|
+
.query_param(Parameter()
|
|
138
|
+
.key("locale")
|
|
139
|
+
.value(locale))
|
|
140
|
+
.header_param(Parameter()
|
|
141
|
+
.key("accept")
|
|
142
|
+
.value("application/json"))
|
|
143
|
+
.auth(Single("oauth_2_0")),
|
|
144
|
+
).response(
|
|
145
|
+
ResponseHandler()
|
|
146
|
+
.deserializer(APIHelper.json_deserialize)
|
|
147
|
+
.deserialize_into(CategoryObject.from_dictionary)
|
|
148
|
+
.is_api_response(True)
|
|
149
|
+
.local_error("401",
|
|
150
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
151
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
152
|
+
"\n",
|
|
153
|
+
UnauthorizedException)
|
|
154
|
+
.local_error("403",
|
|
155
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
156
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
157
|
+
ForbiddenException)
|
|
158
|
+
.local_error("429",
|
|
159
|
+
"The app has exceeded its rate limits.\n",
|
|
160
|
+
TooManyRequestsException),
|
|
161
|
+
).execute()
|