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,649 @@
|
|
|
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.cursor_paged_artists import (
|
|
32
|
+
CursorPagedArtists,
|
|
33
|
+
)
|
|
34
|
+
from spotifywebapi.models.paging_artist_object import (
|
|
35
|
+
PagingArtistObject,
|
|
36
|
+
)
|
|
37
|
+
from spotifywebapi.models.paging_track_object import (
|
|
38
|
+
PagingTrackObject,
|
|
39
|
+
)
|
|
40
|
+
from spotifywebapi.models.private_user_object import (
|
|
41
|
+
PrivateUserObject,
|
|
42
|
+
)
|
|
43
|
+
from spotifywebapi.models.public_user_object import (
|
|
44
|
+
PublicUserObject,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class UsersController(BaseController):
|
|
49
|
+
"""A Controller to access Endpoints in the spotifywebapi API."""
|
|
50
|
+
|
|
51
|
+
def __init__(self, config):
|
|
52
|
+
"""Initialize UsersController object."""
|
|
53
|
+
super(UsersController, self).__init__(config)
|
|
54
|
+
|
|
55
|
+
def get_current_users_profile(self):
|
|
56
|
+
"""Perform a GET request to /me.
|
|
57
|
+
|
|
58
|
+
Get detailed profile information about the current user (including the
|
|
59
|
+
current user's username).
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
ApiResponse: An object with the response value as well as other useful
|
|
63
|
+
information such as status codes and headers. A user
|
|
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("/me")
|
|
74
|
+
.http_method(HttpMethodEnum.GET)
|
|
75
|
+
.header_param(Parameter()
|
|
76
|
+
.key("accept")
|
|
77
|
+
.value("application/json"))
|
|
78
|
+
.auth(Single("oauth_2_0")),
|
|
79
|
+
).response(
|
|
80
|
+
ResponseHandler()
|
|
81
|
+
.deserializer(APIHelper.json_deserialize)
|
|
82
|
+
.deserialize_into(PrivateUserObject.from_dictionary)
|
|
83
|
+
.is_api_response(True)
|
|
84
|
+
.local_error("401",
|
|
85
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
86
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
87
|
+
"\n",
|
|
88
|
+
UnauthorizedException)
|
|
89
|
+
.local_error("403",
|
|
90
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
91
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
92
|
+
ForbiddenException)
|
|
93
|
+
.local_error("429",
|
|
94
|
+
"The app has exceeded its rate limits.\n",
|
|
95
|
+
TooManyRequestsException),
|
|
96
|
+
).execute()
|
|
97
|
+
|
|
98
|
+
def get_users_profile(self,
|
|
99
|
+
user_id):
|
|
100
|
+
"""Perform a GET request to /users/{user_id}.
|
|
101
|
+
|
|
102
|
+
Get public profile information about a Spotify user.
|
|
103
|
+
|
|
104
|
+
Args:
|
|
105
|
+
user_id (str): The request template parameter.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
ApiResponse: An object with the response value as well as other useful
|
|
109
|
+
information such as status codes and headers. A user
|
|
110
|
+
|
|
111
|
+
Raises:
|
|
112
|
+
APIException: When an error occurs while fetching the data from the
|
|
113
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
114
|
+
message, and the HTTP body that was received in the request.
|
|
115
|
+
|
|
116
|
+
"""
|
|
117
|
+
return super().new_api_call_builder.request(
|
|
118
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
119
|
+
.path("/users/{user_id}")
|
|
120
|
+
.http_method(HttpMethodEnum.GET)
|
|
121
|
+
.template_param(Parameter()
|
|
122
|
+
.key("user_id")
|
|
123
|
+
.value(user_id)
|
|
124
|
+
.should_encode(True))
|
|
125
|
+
.header_param(Parameter()
|
|
126
|
+
.key("accept")
|
|
127
|
+
.value("application/json"))
|
|
128
|
+
.auth(Single("oauth_2_0")),
|
|
129
|
+
).response(
|
|
130
|
+
ResponseHandler()
|
|
131
|
+
.deserializer(APIHelper.json_deserialize)
|
|
132
|
+
.deserialize_into(PublicUserObject.from_dictionary)
|
|
133
|
+
.is_api_response(True)
|
|
134
|
+
.local_error("401",
|
|
135
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
136
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
137
|
+
"\n",
|
|
138
|
+
UnauthorizedException)
|
|
139
|
+
.local_error("403",
|
|
140
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
141
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
142
|
+
ForbiddenException)
|
|
143
|
+
.local_error("429",
|
|
144
|
+
"The app has exceeded its rate limits.\n",
|
|
145
|
+
TooManyRequestsException),
|
|
146
|
+
).execute()
|
|
147
|
+
|
|
148
|
+
def follow_playlist(self,
|
|
149
|
+
playlist_id,
|
|
150
|
+
body=None):
|
|
151
|
+
"""Perform a PUT request to /playlists/{playlist_id}/followers.
|
|
152
|
+
|
|
153
|
+
Add the current user as a follower of a playlist.
|
|
154
|
+
|
|
155
|
+
Args:
|
|
156
|
+
playlist_id (str): The request template parameter.
|
|
157
|
+
body (PlaylistsFollowersRequest, optional): The request body parameter.
|
|
158
|
+
|
|
159
|
+
Returns:
|
|
160
|
+
ApiResponse: An object with the response value as well as other useful
|
|
161
|
+
information such as status codes and headers. Playlist followed
|
|
162
|
+
|
|
163
|
+
Raises:
|
|
164
|
+
APIException: When an error occurs while fetching the data from the
|
|
165
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
166
|
+
message, and the HTTP body that was received in the request.
|
|
167
|
+
|
|
168
|
+
"""
|
|
169
|
+
return super().new_api_call_builder.request(
|
|
170
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
171
|
+
.path("/playlists/{playlist_id}/followers")
|
|
172
|
+
.http_method(HttpMethodEnum.PUT)
|
|
173
|
+
.template_param(Parameter()
|
|
174
|
+
.key("playlist_id")
|
|
175
|
+
.value(playlist_id)
|
|
176
|
+
.should_encode(True))
|
|
177
|
+
.header_param(Parameter()
|
|
178
|
+
.key("Content-Type")
|
|
179
|
+
.value("application/json"))
|
|
180
|
+
.body_param(Parameter()
|
|
181
|
+
.value(body))
|
|
182
|
+
.body_serializer(APIHelper.json_serialize)
|
|
183
|
+
.auth(Single("oauth_2_0")),
|
|
184
|
+
).response(
|
|
185
|
+
ResponseHandler()
|
|
186
|
+
.is_api_response(True)
|
|
187
|
+
.local_error("401",
|
|
188
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
189
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
190
|
+
"\n",
|
|
191
|
+
UnauthorizedException)
|
|
192
|
+
.local_error("403",
|
|
193
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
194
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
195
|
+
ForbiddenException)
|
|
196
|
+
.local_error("429",
|
|
197
|
+
"The app has exceeded its rate limits.\n",
|
|
198
|
+
TooManyRequestsException),
|
|
199
|
+
).execute()
|
|
200
|
+
|
|
201
|
+
def unfollow_playlist(self,
|
|
202
|
+
playlist_id):
|
|
203
|
+
"""Perform a DELETE request to /playlists/{playlist_id}/followers.
|
|
204
|
+
|
|
205
|
+
Remove the current user as a follower of a playlist.
|
|
206
|
+
|
|
207
|
+
Args:
|
|
208
|
+
playlist_id (str): The request template parameter.
|
|
209
|
+
|
|
210
|
+
Returns:
|
|
211
|
+
ApiResponse: An object with the response value as well as other useful
|
|
212
|
+
information such as status codes and headers. Playlist unfollowed
|
|
213
|
+
|
|
214
|
+
Raises:
|
|
215
|
+
APIException: When an error occurs while fetching the data from the
|
|
216
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
217
|
+
message, and the HTTP body that was received in the request.
|
|
218
|
+
|
|
219
|
+
"""
|
|
220
|
+
return super().new_api_call_builder.request(
|
|
221
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
222
|
+
.path("/playlists/{playlist_id}/followers")
|
|
223
|
+
.http_method(HttpMethodEnum.DELETE)
|
|
224
|
+
.template_param(Parameter()
|
|
225
|
+
.key("playlist_id")
|
|
226
|
+
.value(playlist_id)
|
|
227
|
+
.should_encode(True))
|
|
228
|
+
.auth(Single("oauth_2_0")),
|
|
229
|
+
).response(
|
|
230
|
+
ResponseHandler()
|
|
231
|
+
.is_api_response(True)
|
|
232
|
+
.local_error("401",
|
|
233
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
234
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
235
|
+
"\n",
|
|
236
|
+
UnauthorizedException)
|
|
237
|
+
.local_error("403",
|
|
238
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
239
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
240
|
+
ForbiddenException)
|
|
241
|
+
.local_error("429",
|
|
242
|
+
"The app has exceeded its rate limits.\n",
|
|
243
|
+
TooManyRequestsException),
|
|
244
|
+
).execute()
|
|
245
|
+
|
|
246
|
+
def get_followed(self,
|
|
247
|
+
mtype,
|
|
248
|
+
after=None,
|
|
249
|
+
limit=20):
|
|
250
|
+
"""Perform a GET request to /me/following.
|
|
251
|
+
|
|
252
|
+
Get the current user's followed artists.
|
|
253
|
+
|
|
254
|
+
Args:
|
|
255
|
+
mtype (ItemType1Enum): The request query parameter.
|
|
256
|
+
after (str, optional): The request query parameter.
|
|
257
|
+
limit (int, optional): The request query parameter. Example: 20
|
|
258
|
+
|
|
259
|
+
Returns:
|
|
260
|
+
ApiResponse: An object with the response value as well as other useful
|
|
261
|
+
information such as status codes and headers. A paged set of artists
|
|
262
|
+
|
|
263
|
+
Raises:
|
|
264
|
+
APIException: When an error occurs while fetching the data from the
|
|
265
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
266
|
+
message, and the HTTP body that was received in the request.
|
|
267
|
+
|
|
268
|
+
"""
|
|
269
|
+
return super().new_api_call_builder.request(
|
|
270
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
271
|
+
.path("/me/following")
|
|
272
|
+
.http_method(HttpMethodEnum.GET)
|
|
273
|
+
.query_param(Parameter()
|
|
274
|
+
.key("type")
|
|
275
|
+
.value(mtype))
|
|
276
|
+
.query_param(Parameter()
|
|
277
|
+
.key("after")
|
|
278
|
+
.value(after))
|
|
279
|
+
.query_param(Parameter()
|
|
280
|
+
.key("limit")
|
|
281
|
+
.value(limit))
|
|
282
|
+
.header_param(Parameter()
|
|
283
|
+
.key("accept")
|
|
284
|
+
.value("application/json"))
|
|
285
|
+
.auth(Single("oauth_2_0")),
|
|
286
|
+
).response(
|
|
287
|
+
ResponseHandler()
|
|
288
|
+
.deserializer(APIHelper.json_deserialize)
|
|
289
|
+
.deserialize_into(CursorPagedArtists.from_dictionary)
|
|
290
|
+
.is_api_response(True)
|
|
291
|
+
.local_error("401",
|
|
292
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
293
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
294
|
+
"\n",
|
|
295
|
+
UnauthorizedException)
|
|
296
|
+
.local_error("403",
|
|
297
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
298
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
299
|
+
ForbiddenException)
|
|
300
|
+
.local_error("429",
|
|
301
|
+
"The app has exceeded its rate limits.\n",
|
|
302
|
+
TooManyRequestsException),
|
|
303
|
+
).execute()
|
|
304
|
+
|
|
305
|
+
def follow_artists_users(self,
|
|
306
|
+
mtype,
|
|
307
|
+
ids,
|
|
308
|
+
body=None):
|
|
309
|
+
"""Perform a PUT request to /me/following.
|
|
310
|
+
|
|
311
|
+
Add the current user as a follower of one or more artists or other Spotify
|
|
312
|
+
users.
|
|
313
|
+
|
|
314
|
+
Args:
|
|
315
|
+
mtype (ItemType2Enum): The request query parameter.
|
|
316
|
+
ids (str): The request query parameter.
|
|
317
|
+
body (MeFollowingRequest, optional): The request body parameter.
|
|
318
|
+
|
|
319
|
+
Returns:
|
|
320
|
+
ApiResponse: An object with the response value as well as other useful
|
|
321
|
+
information such as status codes and headers. Artist or user followed
|
|
322
|
+
|
|
323
|
+
Raises:
|
|
324
|
+
APIException: When an error occurs while fetching the data from the
|
|
325
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
326
|
+
message, and the HTTP body that was received in the request.
|
|
327
|
+
|
|
328
|
+
"""
|
|
329
|
+
return super().new_api_call_builder.request(
|
|
330
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
331
|
+
.path("/me/following")
|
|
332
|
+
.http_method(HttpMethodEnum.PUT)
|
|
333
|
+
.query_param(Parameter()
|
|
334
|
+
.key("type")
|
|
335
|
+
.value(mtype))
|
|
336
|
+
.query_param(Parameter()
|
|
337
|
+
.key("ids")
|
|
338
|
+
.value(ids))
|
|
339
|
+
.header_param(Parameter()
|
|
340
|
+
.key("Content-Type")
|
|
341
|
+
.value("application/json"))
|
|
342
|
+
.body_param(Parameter()
|
|
343
|
+
.value(body))
|
|
344
|
+
.body_serializer(APIHelper.json_serialize)
|
|
345
|
+
.auth(Single("oauth_2_0")),
|
|
346
|
+
).response(
|
|
347
|
+
ResponseHandler()
|
|
348
|
+
.is_api_response(True)
|
|
349
|
+
.local_error("401",
|
|
350
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
351
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
352
|
+
"\n",
|
|
353
|
+
UnauthorizedException)
|
|
354
|
+
.local_error("403",
|
|
355
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
356
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
357
|
+
ForbiddenException)
|
|
358
|
+
.local_error("429",
|
|
359
|
+
"The app has exceeded its rate limits.\n",
|
|
360
|
+
TooManyRequestsException),
|
|
361
|
+
).execute()
|
|
362
|
+
|
|
363
|
+
def unfollow_artists_users(self,
|
|
364
|
+
mtype,
|
|
365
|
+
ids,
|
|
366
|
+
body=None):
|
|
367
|
+
"""Perform a DELETE request to /me/following.
|
|
368
|
+
|
|
369
|
+
Remove the current user as a follower of one or more artists or other Spotify
|
|
370
|
+
users.
|
|
371
|
+
|
|
372
|
+
Args:
|
|
373
|
+
mtype (ItemType3Enum): The request query parameter.
|
|
374
|
+
ids (str): The request query parameter.
|
|
375
|
+
body (MeFollowingRequest1, optional): The request body parameter.
|
|
376
|
+
|
|
377
|
+
Returns:
|
|
378
|
+
ApiResponse: An object with the response value as well as other useful
|
|
379
|
+
information such as status codes and headers. Artist or user
|
|
380
|
+
unfollowed
|
|
381
|
+
|
|
382
|
+
Raises:
|
|
383
|
+
APIException: When an error occurs while fetching the data from the
|
|
384
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
385
|
+
message, and the HTTP body that was received in the request.
|
|
386
|
+
|
|
387
|
+
"""
|
|
388
|
+
return super().new_api_call_builder.request(
|
|
389
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
390
|
+
.path("/me/following")
|
|
391
|
+
.http_method(HttpMethodEnum.DELETE)
|
|
392
|
+
.query_param(Parameter()
|
|
393
|
+
.key("type")
|
|
394
|
+
.value(mtype))
|
|
395
|
+
.query_param(Parameter()
|
|
396
|
+
.key("ids")
|
|
397
|
+
.value(ids))
|
|
398
|
+
.header_param(Parameter()
|
|
399
|
+
.key("Content-Type")
|
|
400
|
+
.value("application/json"))
|
|
401
|
+
.body_param(Parameter()
|
|
402
|
+
.value(body))
|
|
403
|
+
.body_serializer(APIHelper.json_serialize)
|
|
404
|
+
.auth(Single("oauth_2_0")),
|
|
405
|
+
).response(
|
|
406
|
+
ResponseHandler()
|
|
407
|
+
.is_api_response(True)
|
|
408
|
+
.local_error("401",
|
|
409
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
410
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
411
|
+
"\n",
|
|
412
|
+
UnauthorizedException)
|
|
413
|
+
.local_error("403",
|
|
414
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
415
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
416
|
+
ForbiddenException)
|
|
417
|
+
.local_error("429",
|
|
418
|
+
"The app has exceeded its rate limits.\n",
|
|
419
|
+
TooManyRequestsException),
|
|
420
|
+
).execute()
|
|
421
|
+
|
|
422
|
+
def check_current_user_follows(self,
|
|
423
|
+
mtype,
|
|
424
|
+
ids):
|
|
425
|
+
"""Perform a GET request to /me/following/contains.
|
|
426
|
+
|
|
427
|
+
Check to see if the current user is following one or more artists or other
|
|
428
|
+
Spotify users.
|
|
429
|
+
|
|
430
|
+
Args:
|
|
431
|
+
mtype (ItemType3Enum): The request query parameter.
|
|
432
|
+
ids (str): The request query parameter.
|
|
433
|
+
|
|
434
|
+
Returns:
|
|
435
|
+
ApiResponse: An object with the response value as well as other useful
|
|
436
|
+
information such as status codes and headers. Array of booleans
|
|
437
|
+
|
|
438
|
+
Raises:
|
|
439
|
+
APIException: When an error occurs while fetching the data from the
|
|
440
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
441
|
+
message, and the HTTP body that was received in the request.
|
|
442
|
+
|
|
443
|
+
"""
|
|
444
|
+
return super().new_api_call_builder.request(
|
|
445
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
446
|
+
.path("/me/following/contains")
|
|
447
|
+
.http_method(HttpMethodEnum.GET)
|
|
448
|
+
.query_param(Parameter()
|
|
449
|
+
.key("type")
|
|
450
|
+
.value(mtype))
|
|
451
|
+
.query_param(Parameter()
|
|
452
|
+
.key("ids")
|
|
453
|
+
.value(ids))
|
|
454
|
+
.header_param(Parameter()
|
|
455
|
+
.key("accept")
|
|
456
|
+
.value("application/json"))
|
|
457
|
+
.auth(Single("oauth_2_0")),
|
|
458
|
+
).response(
|
|
459
|
+
ResponseHandler()
|
|
460
|
+
.deserializer(APIHelper.json_deserialize)
|
|
461
|
+
.is_api_response(True)
|
|
462
|
+
.local_error("401",
|
|
463
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
464
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
465
|
+
"\n",
|
|
466
|
+
UnauthorizedException)
|
|
467
|
+
.local_error("403",
|
|
468
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
469
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
470
|
+
ForbiddenException)
|
|
471
|
+
.local_error("429",
|
|
472
|
+
"The app has exceeded its rate limits.\n",
|
|
473
|
+
TooManyRequestsException),
|
|
474
|
+
).execute()
|
|
475
|
+
|
|
476
|
+
def check_if_user_follows_playlist(self,
|
|
477
|
+
playlist_id,
|
|
478
|
+
ids):
|
|
479
|
+
"""Perform a GET request to
|
|
480
|
+
/playlists/{playlist_id}/followers/contains.
|
|
481
|
+
|
|
482
|
+
Check to see if one or more Spotify users are following a specified playlist.
|
|
483
|
+
|
|
484
|
+
Args:
|
|
485
|
+
playlist_id (str): The request template parameter.
|
|
486
|
+
ids (str): The request query parameter.
|
|
487
|
+
|
|
488
|
+
Returns:
|
|
489
|
+
ApiResponse: An object with the response value as well as other useful
|
|
490
|
+
information such as status codes and headers. Array of booleans
|
|
491
|
+
|
|
492
|
+
Raises:
|
|
493
|
+
APIException: When an error occurs while fetching the data from the
|
|
494
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
495
|
+
message, and the HTTP body that was received in the request.
|
|
496
|
+
|
|
497
|
+
"""
|
|
498
|
+
return super().new_api_call_builder.request(
|
|
499
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
500
|
+
.path("/playlists/{playlist_id}/followers/contains")
|
|
501
|
+
.http_method(HttpMethodEnum.GET)
|
|
502
|
+
.template_param(Parameter()
|
|
503
|
+
.key("playlist_id")
|
|
504
|
+
.value(playlist_id)
|
|
505
|
+
.should_encode(True))
|
|
506
|
+
.query_param(Parameter()
|
|
507
|
+
.key("ids")
|
|
508
|
+
.value(ids))
|
|
509
|
+
.header_param(Parameter()
|
|
510
|
+
.key("accept")
|
|
511
|
+
.value("application/json"))
|
|
512
|
+
.auth(Single("oauth_2_0")),
|
|
513
|
+
).response(
|
|
514
|
+
ResponseHandler()
|
|
515
|
+
.deserializer(APIHelper.json_deserialize)
|
|
516
|
+
.is_api_response(True)
|
|
517
|
+
.local_error("401",
|
|
518
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
519
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
520
|
+
"\n",
|
|
521
|
+
UnauthorizedException)
|
|
522
|
+
.local_error("403",
|
|
523
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
524
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
525
|
+
ForbiddenException)
|
|
526
|
+
.local_error("429",
|
|
527
|
+
"The app has exceeded its rate limits.\n",
|
|
528
|
+
TooManyRequestsException),
|
|
529
|
+
).execute()
|
|
530
|
+
|
|
531
|
+
def get_users_top_artists(self,
|
|
532
|
+
time_range="medium_term",
|
|
533
|
+
limit=20,
|
|
534
|
+
offset=0):
|
|
535
|
+
"""Perform a GET request to /me/top/artists.
|
|
536
|
+
|
|
537
|
+
Get the current user's top artists based on calculated affinity.
|
|
538
|
+
|
|
539
|
+
Args:
|
|
540
|
+
time_range (str, optional): The request query parameter. Example:
|
|
541
|
+
medium_term
|
|
542
|
+
limit (int, optional): The request query parameter. Example: 20
|
|
543
|
+
offset (int, optional): The request query parameter. Example: 0
|
|
544
|
+
|
|
545
|
+
Returns:
|
|
546
|
+
ApiResponse: An object with the response value as well as other useful
|
|
547
|
+
information such as status codes and headers. Pages of artists
|
|
548
|
+
|
|
549
|
+
Raises:
|
|
550
|
+
APIException: When an error occurs while fetching the data from the
|
|
551
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
552
|
+
message, and the HTTP body that was received in the request.
|
|
553
|
+
|
|
554
|
+
"""
|
|
555
|
+
return super().new_api_call_builder.request(
|
|
556
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
557
|
+
.path("/me/top/artists")
|
|
558
|
+
.http_method(HttpMethodEnum.GET)
|
|
559
|
+
.query_param(Parameter()
|
|
560
|
+
.key("time_range")
|
|
561
|
+
.value(time_range))
|
|
562
|
+
.query_param(Parameter()
|
|
563
|
+
.key("limit")
|
|
564
|
+
.value(limit))
|
|
565
|
+
.query_param(Parameter()
|
|
566
|
+
.key("offset")
|
|
567
|
+
.value(offset))
|
|
568
|
+
.header_param(Parameter()
|
|
569
|
+
.key("accept")
|
|
570
|
+
.value("application/json"))
|
|
571
|
+
.auth(Single("oauth_2_0")),
|
|
572
|
+
).response(
|
|
573
|
+
ResponseHandler()
|
|
574
|
+
.deserializer(APIHelper.json_deserialize)
|
|
575
|
+
.deserialize_into(PagingArtistObject.from_dictionary)
|
|
576
|
+
.is_api_response(True)
|
|
577
|
+
.local_error("401",
|
|
578
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
579
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
580
|
+
"\n",
|
|
581
|
+
UnauthorizedException)
|
|
582
|
+
.local_error("403",
|
|
583
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
584
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
585
|
+
ForbiddenException)
|
|
586
|
+
.local_error("429",
|
|
587
|
+
"The app has exceeded its rate limits.\n",
|
|
588
|
+
TooManyRequestsException),
|
|
589
|
+
).execute()
|
|
590
|
+
|
|
591
|
+
def get_users_top_tracks(self,
|
|
592
|
+
time_range="medium_term",
|
|
593
|
+
limit=20,
|
|
594
|
+
offset=0):
|
|
595
|
+
"""Perform a GET request to /me/top/tracks.
|
|
596
|
+
|
|
597
|
+
Get the current user's top tracks based on calculated affinity.
|
|
598
|
+
|
|
599
|
+
Args:
|
|
600
|
+
time_range (str, optional): The request query parameter. Example:
|
|
601
|
+
medium_term
|
|
602
|
+
limit (int, optional): The request query parameter. Example: 20
|
|
603
|
+
offset (int, optional): The request query parameter. Example: 0
|
|
604
|
+
|
|
605
|
+
Returns:
|
|
606
|
+
ApiResponse: An object with the response value as well as other useful
|
|
607
|
+
information such as status codes and headers. Pages of tracks
|
|
608
|
+
|
|
609
|
+
Raises:
|
|
610
|
+
APIException: When an error occurs while fetching the data from the
|
|
611
|
+
remote API. This exception includes the HTTP Response code, an error
|
|
612
|
+
message, and the HTTP body that was received in the request.
|
|
613
|
+
|
|
614
|
+
"""
|
|
615
|
+
return super().new_api_call_builder.request(
|
|
616
|
+
RequestBuilder().server(Server.DEFAULT)
|
|
617
|
+
.path("/me/top/tracks")
|
|
618
|
+
.http_method(HttpMethodEnum.GET)
|
|
619
|
+
.query_param(Parameter()
|
|
620
|
+
.key("time_range")
|
|
621
|
+
.value(time_range))
|
|
622
|
+
.query_param(Parameter()
|
|
623
|
+
.key("limit")
|
|
624
|
+
.value(limit))
|
|
625
|
+
.query_param(Parameter()
|
|
626
|
+
.key("offset")
|
|
627
|
+
.value(offset))
|
|
628
|
+
.header_param(Parameter()
|
|
629
|
+
.key("accept")
|
|
630
|
+
.value("application/json"))
|
|
631
|
+
.auth(Single("oauth_2_0")),
|
|
632
|
+
).response(
|
|
633
|
+
ResponseHandler()
|
|
634
|
+
.deserializer(APIHelper.json_deserialize)
|
|
635
|
+
.deserialize_into(PagingTrackObject.from_dictionary)
|
|
636
|
+
.is_api_response(True)
|
|
637
|
+
.local_error("401",
|
|
638
|
+
"Bad or expired token. This can happen if the user revoked a token or"
|
|
639
|
+
"\nthe access token has expired. You should re-authenticate the user."
|
|
640
|
+
"\n",
|
|
641
|
+
UnauthorizedException)
|
|
642
|
+
.local_error("403",
|
|
643
|
+
"Bad OAuth request (wrong consumer key, bad nonce, expired\ntimestamp"
|
|
644
|
+
"...). Unfortunately, re-authenticating the user won't help here.\n",
|
|
645
|
+
ForbiddenException)
|
|
646
|
+
.local_error("429",
|
|
647
|
+
"The app has exceeded its rate limits.\n",
|
|
648
|
+
TooManyRequestsException),
|
|
649
|
+
).execute()
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# ruff: noqa: D104 | Missing docstring in public package
|
|
2
|
+
# ruff: noqa: RUF022 | `__all__` is not sorted
|
|
3
|
+
__all__ = [
|
|
4
|
+
"api_exception",
|
|
5
|
+
"bad_request_exception",
|
|
6
|
+
"forbidden_exception",
|
|
7
|
+
"not_found_exception",
|
|
8
|
+
"o_auth_provider_exception",
|
|
9
|
+
"too_many_requests_exception",
|
|
10
|
+
"unauthorized_exception",
|
|
11
|
+
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""spotifywebapi.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class APIException(Exception):
|
|
8
|
+
"""Class that handles HTTP Exceptions when fetching API Endpoints.
|
|
9
|
+
|
|
10
|
+
Attributes:
|
|
11
|
+
response_code (int): The status code of the response.
|
|
12
|
+
response (HttpResponse): The HttpResponse of the API call.
|
|
13
|
+
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self,
|
|
17
|
+
reason,
|
|
18
|
+
response):
|
|
19
|
+
"""Initialize APIException object.
|
|
20
|
+
|
|
21
|
+
Args:
|
|
22
|
+
reason (string): The reason (or error message) for the Exception
|
|
23
|
+
to be raised.
|
|
24
|
+
response (HttpResponse): The HttpResponse of the API call.
|
|
25
|
+
|
|
26
|
+
"""
|
|
27
|
+
super(APIException, self).__init__(reason)
|
|
28
|
+
self.reason = reason
|
|
29
|
+
self.response = response
|
|
30
|
+
self.response_code = response.status_code
|
|
31
|
+
|
|
32
|
+
def __str__(self):
|
|
33
|
+
"""Return a human-readable string representation."""
|
|
34
|
+
return (f"{self.__class__.__name__}("
|
|
35
|
+
f"status_code={self.response_code!s}, "
|
|
36
|
+
f"message={self.reason!s})")
|