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,256 @@
|
|
|
1
|
+
"""spotifywebapi.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ruff: noqa: E501
|
|
7
|
+
from spotifywebapi.api_helper import APIHelper
|
|
8
|
+
from spotifywebapi.models.paging_artist_object import (
|
|
9
|
+
PagingArtistObject,
|
|
10
|
+
)
|
|
11
|
+
from spotifywebapi.models.paging_playlist_object import (
|
|
12
|
+
PagingPlaylistObject,
|
|
13
|
+
)
|
|
14
|
+
from spotifywebapi.models.paging_simplified_album_object import (
|
|
15
|
+
PagingSimplifiedAlbumObject,
|
|
16
|
+
)
|
|
17
|
+
from spotifywebapi.models.paging_simplified_audiobook_object import (
|
|
18
|
+
PagingSimplifiedAudiobookObject,
|
|
19
|
+
)
|
|
20
|
+
from spotifywebapi.models.paging_simplified_episode_object import (
|
|
21
|
+
PagingSimplifiedEpisodeObject,
|
|
22
|
+
)
|
|
23
|
+
from spotifywebapi.models.paging_simplified_show_object import (
|
|
24
|
+
PagingSimplifiedShowObject,
|
|
25
|
+
)
|
|
26
|
+
from spotifywebapi.models.paging_track_object import (
|
|
27
|
+
PagingTrackObject,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class SearchItems(object):
|
|
32
|
+
"""Implementation of the 'SearchItems' model.
|
|
33
|
+
|
|
34
|
+
Attributes:
|
|
35
|
+
tracks (PagingTrackObject): The model property of type PagingTrackObject.
|
|
36
|
+
artists (PagingArtistObject): The model property of type PagingArtistObject.
|
|
37
|
+
albums (PagingSimplifiedAlbumObject): The model property of type
|
|
38
|
+
PagingSimplifiedAlbumObject.
|
|
39
|
+
playlists (PagingPlaylistObject): The model property of type
|
|
40
|
+
PagingPlaylistObject.
|
|
41
|
+
shows (PagingSimplifiedShowObject): The model property of type
|
|
42
|
+
PagingSimplifiedShowObject.
|
|
43
|
+
episodes (PagingSimplifiedEpisodeObject): The model property of type
|
|
44
|
+
PagingSimplifiedEpisodeObject.
|
|
45
|
+
audiobooks (PagingSimplifiedAudiobookObject): The model property of type
|
|
46
|
+
PagingSimplifiedAudiobookObject.
|
|
47
|
+
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
# Create a mapping from Model property names to API property names
|
|
51
|
+
_names = {
|
|
52
|
+
"tracks": "tracks",
|
|
53
|
+
"artists": "artists",
|
|
54
|
+
"albums": "albums",
|
|
55
|
+
"playlists": "playlists",
|
|
56
|
+
"shows": "shows",
|
|
57
|
+
"episodes": "episodes",
|
|
58
|
+
"audiobooks": "audiobooks",
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
_optionals = [
|
|
62
|
+
"tracks",
|
|
63
|
+
"artists",
|
|
64
|
+
"albums",
|
|
65
|
+
"playlists",
|
|
66
|
+
"shows",
|
|
67
|
+
"episodes",
|
|
68
|
+
"audiobooks",
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
def __init__(
|
|
72
|
+
self,
|
|
73
|
+
tracks=APIHelper.SKIP,
|
|
74
|
+
artists=APIHelper.SKIP,
|
|
75
|
+
albums=APIHelper.SKIP,
|
|
76
|
+
playlists=APIHelper.SKIP,
|
|
77
|
+
shows=APIHelper.SKIP,
|
|
78
|
+
episodes=APIHelper.SKIP,
|
|
79
|
+
audiobooks=APIHelper.SKIP):
|
|
80
|
+
"""Initialize a SearchItems instance."""
|
|
81
|
+
# Initialize members of the class
|
|
82
|
+
if tracks is not APIHelper.SKIP:
|
|
83
|
+
self.tracks = tracks
|
|
84
|
+
if artists is not APIHelper.SKIP:
|
|
85
|
+
self.artists = artists
|
|
86
|
+
if albums is not APIHelper.SKIP:
|
|
87
|
+
self.albums = albums
|
|
88
|
+
if playlists is not APIHelper.SKIP:
|
|
89
|
+
self.playlists = playlists
|
|
90
|
+
if shows is not APIHelper.SKIP:
|
|
91
|
+
self.shows = shows
|
|
92
|
+
if episodes is not APIHelper.SKIP:
|
|
93
|
+
self.episodes = episodes
|
|
94
|
+
if audiobooks is not APIHelper.SKIP:
|
|
95
|
+
self.audiobooks = audiobooks
|
|
96
|
+
|
|
97
|
+
@classmethod
|
|
98
|
+
def from_dictionary(cls,
|
|
99
|
+
dictionary):
|
|
100
|
+
"""Create an instance of this model from a dictionary
|
|
101
|
+
|
|
102
|
+
Args:
|
|
103
|
+
dictionary (dictionary): A dictionary representation of the object
|
|
104
|
+
as obtained from the deserialization of the server's response. The
|
|
105
|
+
keys MUST match property names in the API description.
|
|
106
|
+
|
|
107
|
+
Returns:
|
|
108
|
+
object: An instance of this structure class.
|
|
109
|
+
|
|
110
|
+
"""
|
|
111
|
+
if not isinstance(dictionary, dict) or dictionary is None:
|
|
112
|
+
return None
|
|
113
|
+
|
|
114
|
+
# Extract variables from the dictionary
|
|
115
|
+
tracks =\
|
|
116
|
+
PagingTrackObject.from_dictionary(
|
|
117
|
+
dictionary.get("tracks"))\
|
|
118
|
+
if "tracks" in dictionary.keys()\
|
|
119
|
+
else APIHelper.SKIP
|
|
120
|
+
artists =\
|
|
121
|
+
PagingArtistObject.from_dictionary(
|
|
122
|
+
dictionary.get("artists"))\
|
|
123
|
+
if "artists" in dictionary.keys()\
|
|
124
|
+
else APIHelper.SKIP
|
|
125
|
+
albums =\
|
|
126
|
+
PagingSimplifiedAlbumObject.from_dictionary(
|
|
127
|
+
dictionary.get("albums"))\
|
|
128
|
+
if "albums" in dictionary.keys()\
|
|
129
|
+
else APIHelper.SKIP
|
|
130
|
+
playlists =\
|
|
131
|
+
PagingPlaylistObject.from_dictionary(
|
|
132
|
+
dictionary.get("playlists"))\
|
|
133
|
+
if "playlists" in dictionary.keys()\
|
|
134
|
+
else APIHelper.SKIP
|
|
135
|
+
shows =\
|
|
136
|
+
PagingSimplifiedShowObject.from_dictionary(
|
|
137
|
+
dictionary.get("shows"))\
|
|
138
|
+
if "shows" in dictionary.keys()\
|
|
139
|
+
else APIHelper.SKIP
|
|
140
|
+
episodes =\
|
|
141
|
+
PagingSimplifiedEpisodeObject.from_dictionary(
|
|
142
|
+
dictionary.get("episodes"))\
|
|
143
|
+
if "episodes" in dictionary.keys()\
|
|
144
|
+
else APIHelper.SKIP
|
|
145
|
+
audiobooks =\
|
|
146
|
+
PagingSimplifiedAudiobookObject.from_dictionary(
|
|
147
|
+
dictionary.get("audiobooks"))\
|
|
148
|
+
if "audiobooks" in dictionary.keys()\
|
|
149
|
+
else APIHelper.SKIP
|
|
150
|
+
|
|
151
|
+
# Return an object of this model
|
|
152
|
+
return cls(tracks,
|
|
153
|
+
artists,
|
|
154
|
+
albums,
|
|
155
|
+
playlists,
|
|
156
|
+
shows,
|
|
157
|
+
episodes,
|
|
158
|
+
audiobooks)
|
|
159
|
+
|
|
160
|
+
def __repr__(self):
|
|
161
|
+
"""Return a unambiguous string representation."""
|
|
162
|
+
_tracks=(
|
|
163
|
+
self.tracks
|
|
164
|
+
if hasattr(self, "tracks")
|
|
165
|
+
else None
|
|
166
|
+
)
|
|
167
|
+
_artists=(
|
|
168
|
+
self.artists
|
|
169
|
+
if hasattr(self, "artists")
|
|
170
|
+
else None
|
|
171
|
+
)
|
|
172
|
+
_albums=(
|
|
173
|
+
self.albums
|
|
174
|
+
if hasattr(self, "albums")
|
|
175
|
+
else None
|
|
176
|
+
)
|
|
177
|
+
_playlists=(
|
|
178
|
+
self.playlists
|
|
179
|
+
if hasattr(self, "playlists")
|
|
180
|
+
else None
|
|
181
|
+
)
|
|
182
|
+
_shows=(
|
|
183
|
+
self.shows
|
|
184
|
+
if hasattr(self, "shows")
|
|
185
|
+
else None
|
|
186
|
+
)
|
|
187
|
+
_episodes=(
|
|
188
|
+
self.episodes
|
|
189
|
+
if hasattr(self, "episodes")
|
|
190
|
+
else None
|
|
191
|
+
)
|
|
192
|
+
_audiobooks=(
|
|
193
|
+
self.audiobooks
|
|
194
|
+
if hasattr(self, "audiobooks")
|
|
195
|
+
else None
|
|
196
|
+
)
|
|
197
|
+
return (
|
|
198
|
+
f"{self.__class__.__name__}("
|
|
199
|
+
f"tracks={_tracks!r}, "
|
|
200
|
+
f"artists={_artists!r}, "
|
|
201
|
+
f"albums={_albums!r}, "
|
|
202
|
+
f"playlists={_playlists!r}, "
|
|
203
|
+
f"shows={_shows!r}, "
|
|
204
|
+
f"episodes={_episodes!r}, "
|
|
205
|
+
f"audiobooks={_audiobooks!r}, "
|
|
206
|
+
f")"
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
def __str__(self):
|
|
210
|
+
"""Return a human-readable string representation."""
|
|
211
|
+
_tracks=(
|
|
212
|
+
self.tracks
|
|
213
|
+
if hasattr(self, "tracks")
|
|
214
|
+
else None
|
|
215
|
+
)
|
|
216
|
+
_artists=(
|
|
217
|
+
self.artists
|
|
218
|
+
if hasattr(self, "artists")
|
|
219
|
+
else None
|
|
220
|
+
)
|
|
221
|
+
_albums=(
|
|
222
|
+
self.albums
|
|
223
|
+
if hasattr(self, "albums")
|
|
224
|
+
else None
|
|
225
|
+
)
|
|
226
|
+
_playlists=(
|
|
227
|
+
self.playlists
|
|
228
|
+
if hasattr(self, "playlists")
|
|
229
|
+
else None
|
|
230
|
+
)
|
|
231
|
+
_shows=(
|
|
232
|
+
self.shows
|
|
233
|
+
if hasattr(self, "shows")
|
|
234
|
+
else None
|
|
235
|
+
)
|
|
236
|
+
_episodes=(
|
|
237
|
+
self.episodes
|
|
238
|
+
if hasattr(self, "episodes")
|
|
239
|
+
else None
|
|
240
|
+
)
|
|
241
|
+
_audiobooks=(
|
|
242
|
+
self.audiobooks
|
|
243
|
+
if hasattr(self, "audiobooks")
|
|
244
|
+
else None
|
|
245
|
+
)
|
|
246
|
+
return (
|
|
247
|
+
f"{self.__class__.__name__}("
|
|
248
|
+
f"tracks={_tracks!s}, "
|
|
249
|
+
f"artists={_artists!s}, "
|
|
250
|
+
f"albums={_albums!s}, "
|
|
251
|
+
f"playlists={_playlists!s}, "
|
|
252
|
+
f"shows={_shows!s}, "
|
|
253
|
+
f"episodes={_episodes!s}, "
|
|
254
|
+
f"audiobooks={_audiobooks!s}, "
|
|
255
|
+
f")"
|
|
256
|
+
)
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
"""spotifywebapi.
|
|
2
|
+
|
|
3
|
+
This file was automatically generated by APIMATIC v3.0 ( https://www.apimatic.io ).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
# ruff: noqa: E501
|
|
7
|
+
from spotifywebapi.api_helper import APIHelper
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class SectionObject(object):
|
|
11
|
+
"""Implementation of the 'SectionObject' model.
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
start (float): The starting point (in seconds) of the section.
|
|
15
|
+
duration (float): The duration (in seconds) of the section.
|
|
16
|
+
confidence (float): The confidence, from 0.0 to 1.0, of the reliability of
|
|
17
|
+
the section's "designation".
|
|
18
|
+
loudness (float): The overall loudness of the section in decibels (dB).
|
|
19
|
+
Loudness values are useful for comparing relative loudness of sections
|
|
20
|
+
within tracks.
|
|
21
|
+
tempo (float): The overall estimated tempo of the section in beats per minute
|
|
22
|
+
(BPM). In musical terminology, tempo is the speed or pace of a given
|
|
23
|
+
piece and derives directly from the average beat duration.
|
|
24
|
+
tempo_confidence (float): The confidence, from 0.0 to 1.0, of the reliability
|
|
25
|
+
of the tempo. Some tracks contain tempo changes or sounds which don't
|
|
26
|
+
contain tempo (like pure speech) which would correspond to a low value in
|
|
27
|
+
this field.
|
|
28
|
+
key (int): The estimated overall key of the section. The values in this field
|
|
29
|
+
ranging from 0 to 11 mapping to pitches using standard Pitch Class
|
|
30
|
+
notation (E.g. 0 = C, 1 = C♯/D♭, 2 = D, and so on). If no key was
|
|
31
|
+
detected, the value is -1.
|
|
32
|
+
key_confidence (float): The confidence, from 0.0 to 1.0, of the reliability
|
|
33
|
+
of the key. Songs with many key changes may correspond to low values in
|
|
34
|
+
this field.
|
|
35
|
+
mode (ModeEnum): Indicates the modality (major or minor) of a section, the
|
|
36
|
+
type of scale from which its melodic content is derived. This field will
|
|
37
|
+
contain a 0 for "minor", a 1 for "major", or a -1 for no result. Note
|
|
38
|
+
that the major key (e.g. C major) could more likely be confused with the
|
|
39
|
+
minor key at 3 semitones lower (e.g. A minor) as both keys carry the same
|
|
40
|
+
pitches.
|
|
41
|
+
mode_confidence (float): The confidence, from 0.0 to 1.0, of the reliability
|
|
42
|
+
of the `mode`.
|
|
43
|
+
time_signature (int): An estimated time signature. The time signature (meter)
|
|
44
|
+
is a notational convention to specify how many beats are in each bar (or
|
|
45
|
+
measure). The time signature ranges from 3 to 7 indicating time
|
|
46
|
+
signatures of "3/4", to "7/4".
|
|
47
|
+
time_signature_confidence (float): The confidence, from 0.0 to 1.0, of the
|
|
48
|
+
reliability of the `time_signature`. Sections with time signature changes
|
|
49
|
+
may correspond to low values in this field.
|
|
50
|
+
|
|
51
|
+
"""
|
|
52
|
+
|
|
53
|
+
# Create a mapping from Model property names to API property names
|
|
54
|
+
_names = {
|
|
55
|
+
"start": "start",
|
|
56
|
+
"duration": "duration",
|
|
57
|
+
"confidence": "confidence",
|
|
58
|
+
"loudness": "loudness",
|
|
59
|
+
"tempo": "tempo",
|
|
60
|
+
"tempo_confidence": "tempo_confidence",
|
|
61
|
+
"key": "key",
|
|
62
|
+
"key_confidence": "key_confidence",
|
|
63
|
+
"mode": "mode",
|
|
64
|
+
"mode_confidence": "mode_confidence",
|
|
65
|
+
"time_signature": "time_signature",
|
|
66
|
+
"time_signature_confidence": "time_signature_confidence",
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
_optionals = [
|
|
70
|
+
"start",
|
|
71
|
+
"duration",
|
|
72
|
+
"confidence",
|
|
73
|
+
"loudness",
|
|
74
|
+
"tempo",
|
|
75
|
+
"tempo_confidence",
|
|
76
|
+
"key",
|
|
77
|
+
"key_confidence",
|
|
78
|
+
"mode",
|
|
79
|
+
"mode_confidence",
|
|
80
|
+
"time_signature",
|
|
81
|
+
"time_signature_confidence",
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
def __init__(
|
|
85
|
+
self,
|
|
86
|
+
start=APIHelper.SKIP,
|
|
87
|
+
duration=APIHelper.SKIP,
|
|
88
|
+
confidence=APIHelper.SKIP,
|
|
89
|
+
loudness=APIHelper.SKIP,
|
|
90
|
+
tempo=APIHelper.SKIP,
|
|
91
|
+
tempo_confidence=APIHelper.SKIP,
|
|
92
|
+
key=APIHelper.SKIP,
|
|
93
|
+
key_confidence=APIHelper.SKIP,
|
|
94
|
+
mode=APIHelper.SKIP,
|
|
95
|
+
mode_confidence=APIHelper.SKIP,
|
|
96
|
+
time_signature=APIHelper.SKIP,
|
|
97
|
+
time_signature_confidence=APIHelper.SKIP):
|
|
98
|
+
"""Initialize a SectionObject instance."""
|
|
99
|
+
# Initialize members of the class
|
|
100
|
+
if start is not APIHelper.SKIP:
|
|
101
|
+
self.start = start
|
|
102
|
+
if duration is not APIHelper.SKIP:
|
|
103
|
+
self.duration = duration
|
|
104
|
+
if confidence is not APIHelper.SKIP:
|
|
105
|
+
self.confidence = confidence
|
|
106
|
+
if loudness is not APIHelper.SKIP:
|
|
107
|
+
self.loudness = loudness
|
|
108
|
+
if tempo is not APIHelper.SKIP:
|
|
109
|
+
self.tempo = tempo
|
|
110
|
+
if tempo_confidence is not APIHelper.SKIP:
|
|
111
|
+
self.tempo_confidence = tempo_confidence
|
|
112
|
+
if key is not APIHelper.SKIP:
|
|
113
|
+
self.key = key
|
|
114
|
+
if key_confidence is not APIHelper.SKIP:
|
|
115
|
+
self.key_confidence = key_confidence
|
|
116
|
+
if mode is not APIHelper.SKIP:
|
|
117
|
+
self.mode = mode
|
|
118
|
+
if mode_confidence is not APIHelper.SKIP:
|
|
119
|
+
self.mode_confidence = mode_confidence
|
|
120
|
+
if time_signature is not APIHelper.SKIP:
|
|
121
|
+
self.time_signature = time_signature
|
|
122
|
+
if time_signature_confidence is not APIHelper.SKIP:
|
|
123
|
+
self.time_signature_confidence = time_signature_confidence
|
|
124
|
+
|
|
125
|
+
@classmethod
|
|
126
|
+
def from_dictionary(cls,
|
|
127
|
+
dictionary):
|
|
128
|
+
"""Create an instance of this model from a dictionary
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
dictionary (dictionary): A dictionary representation of the object
|
|
132
|
+
as obtained from the deserialization of the server's response. The
|
|
133
|
+
keys MUST match property names in the API description.
|
|
134
|
+
|
|
135
|
+
Returns:
|
|
136
|
+
object: An instance of this structure class.
|
|
137
|
+
|
|
138
|
+
"""
|
|
139
|
+
if not isinstance(dictionary, dict) or dictionary is None:
|
|
140
|
+
return None
|
|
141
|
+
|
|
142
|
+
# Extract variables from the dictionary
|
|
143
|
+
start =\
|
|
144
|
+
dictionary.get("start")\
|
|
145
|
+
if dictionary.get("start")\
|
|
146
|
+
else APIHelper.SKIP
|
|
147
|
+
duration =\
|
|
148
|
+
dictionary.get("duration")\
|
|
149
|
+
if dictionary.get("duration")\
|
|
150
|
+
else APIHelper.SKIP
|
|
151
|
+
confidence =\
|
|
152
|
+
dictionary.get("confidence")\
|
|
153
|
+
if dictionary.get("confidence")\
|
|
154
|
+
else APIHelper.SKIP
|
|
155
|
+
loudness =\
|
|
156
|
+
dictionary.get("loudness")\
|
|
157
|
+
if dictionary.get("loudness")\
|
|
158
|
+
else APIHelper.SKIP
|
|
159
|
+
tempo =\
|
|
160
|
+
dictionary.get("tempo")\
|
|
161
|
+
if dictionary.get("tempo")\
|
|
162
|
+
else APIHelper.SKIP
|
|
163
|
+
tempo_confidence =\
|
|
164
|
+
dictionary.get("tempo_confidence")\
|
|
165
|
+
if dictionary.get("tempo_confidence")\
|
|
166
|
+
else APIHelper.SKIP
|
|
167
|
+
key =\
|
|
168
|
+
dictionary.get("key")\
|
|
169
|
+
if dictionary.get("key")\
|
|
170
|
+
else APIHelper.SKIP
|
|
171
|
+
key_confidence =\
|
|
172
|
+
dictionary.get("key_confidence")\
|
|
173
|
+
if dictionary.get("key_confidence")\
|
|
174
|
+
else APIHelper.SKIP
|
|
175
|
+
mode =\
|
|
176
|
+
dictionary.get("mode")\
|
|
177
|
+
if dictionary.get("mode")\
|
|
178
|
+
else APIHelper.SKIP
|
|
179
|
+
mode_confidence =\
|
|
180
|
+
dictionary.get("mode_confidence")\
|
|
181
|
+
if dictionary.get("mode_confidence")\
|
|
182
|
+
else APIHelper.SKIP
|
|
183
|
+
time_signature =\
|
|
184
|
+
dictionary.get("time_signature")\
|
|
185
|
+
if dictionary.get("time_signature")\
|
|
186
|
+
else APIHelper.SKIP
|
|
187
|
+
time_signature_confidence =\
|
|
188
|
+
dictionary.get("time_signature_confidence")\
|
|
189
|
+
if dictionary.get("time_signature_confidence")\
|
|
190
|
+
else APIHelper.SKIP
|
|
191
|
+
|
|
192
|
+
# Return an object of this model
|
|
193
|
+
return cls(start,
|
|
194
|
+
duration,
|
|
195
|
+
confidence,
|
|
196
|
+
loudness,
|
|
197
|
+
tempo,
|
|
198
|
+
tempo_confidence,
|
|
199
|
+
key,
|
|
200
|
+
key_confidence,
|
|
201
|
+
mode,
|
|
202
|
+
mode_confidence,
|
|
203
|
+
time_signature,
|
|
204
|
+
time_signature_confidence)
|
|
205
|
+
|
|
206
|
+
def __repr__(self):
|
|
207
|
+
"""Return a unambiguous string representation."""
|
|
208
|
+
_start=(
|
|
209
|
+
self.start
|
|
210
|
+
if hasattr(self, "start")
|
|
211
|
+
else None
|
|
212
|
+
)
|
|
213
|
+
_duration=(
|
|
214
|
+
self.duration
|
|
215
|
+
if hasattr(self, "duration")
|
|
216
|
+
else None
|
|
217
|
+
)
|
|
218
|
+
_confidence=(
|
|
219
|
+
self.confidence
|
|
220
|
+
if hasattr(self, "confidence")
|
|
221
|
+
else None
|
|
222
|
+
)
|
|
223
|
+
_loudness=(
|
|
224
|
+
self.loudness
|
|
225
|
+
if hasattr(self, "loudness")
|
|
226
|
+
else None
|
|
227
|
+
)
|
|
228
|
+
_tempo=(
|
|
229
|
+
self.tempo
|
|
230
|
+
if hasattr(self, "tempo")
|
|
231
|
+
else None
|
|
232
|
+
)
|
|
233
|
+
_tempo_confidence=(
|
|
234
|
+
self.tempo_confidence
|
|
235
|
+
if hasattr(self, "tempo_confidence")
|
|
236
|
+
else None
|
|
237
|
+
)
|
|
238
|
+
_key=(
|
|
239
|
+
self.key
|
|
240
|
+
if hasattr(self, "key")
|
|
241
|
+
else None
|
|
242
|
+
)
|
|
243
|
+
_key_confidence=(
|
|
244
|
+
self.key_confidence
|
|
245
|
+
if hasattr(self, "key_confidence")
|
|
246
|
+
else None
|
|
247
|
+
)
|
|
248
|
+
_mode=(
|
|
249
|
+
self.mode
|
|
250
|
+
if hasattr(self, "mode")
|
|
251
|
+
else None
|
|
252
|
+
)
|
|
253
|
+
_mode_confidence=(
|
|
254
|
+
self.mode_confidence
|
|
255
|
+
if hasattr(self, "mode_confidence")
|
|
256
|
+
else None
|
|
257
|
+
)
|
|
258
|
+
_time_signature=(
|
|
259
|
+
self.time_signature
|
|
260
|
+
if hasattr(self, "time_signature")
|
|
261
|
+
else None
|
|
262
|
+
)
|
|
263
|
+
_time_signature_confidence=(
|
|
264
|
+
self.time_signature_confidence
|
|
265
|
+
if hasattr(self, "time_signature_confidence")
|
|
266
|
+
else None
|
|
267
|
+
)
|
|
268
|
+
return (
|
|
269
|
+
f"{self.__class__.__name__}("
|
|
270
|
+
f"start={_start!r}, "
|
|
271
|
+
f"duration={_duration!r}, "
|
|
272
|
+
f"confidence={_confidence!r}, "
|
|
273
|
+
f"loudness={_loudness!r}, "
|
|
274
|
+
f"tempo={_tempo!r}, "
|
|
275
|
+
f"tempo_confidence={_tempo_confidence!r}, "
|
|
276
|
+
f"key={_key!r}, "
|
|
277
|
+
f"key_confidence={_key_confidence!r}, "
|
|
278
|
+
f"mode={_mode!r}, "
|
|
279
|
+
f"mode_confidence={_mode_confidence!r}, "
|
|
280
|
+
f"time_signature={_time_signature!r}, "
|
|
281
|
+
f"time_signature_confidence={_time_signature_confidence!r}, "
|
|
282
|
+
f")"
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
def __str__(self):
|
|
286
|
+
"""Return a human-readable string representation."""
|
|
287
|
+
_start=(
|
|
288
|
+
self.start
|
|
289
|
+
if hasattr(self, "start")
|
|
290
|
+
else None
|
|
291
|
+
)
|
|
292
|
+
_duration=(
|
|
293
|
+
self.duration
|
|
294
|
+
if hasattr(self, "duration")
|
|
295
|
+
else None
|
|
296
|
+
)
|
|
297
|
+
_confidence=(
|
|
298
|
+
self.confidence
|
|
299
|
+
if hasattr(self, "confidence")
|
|
300
|
+
else None
|
|
301
|
+
)
|
|
302
|
+
_loudness=(
|
|
303
|
+
self.loudness
|
|
304
|
+
if hasattr(self, "loudness")
|
|
305
|
+
else None
|
|
306
|
+
)
|
|
307
|
+
_tempo=(
|
|
308
|
+
self.tempo
|
|
309
|
+
if hasattr(self, "tempo")
|
|
310
|
+
else None
|
|
311
|
+
)
|
|
312
|
+
_tempo_confidence=(
|
|
313
|
+
self.tempo_confidence
|
|
314
|
+
if hasattr(self, "tempo_confidence")
|
|
315
|
+
else None
|
|
316
|
+
)
|
|
317
|
+
_key=(
|
|
318
|
+
self.key
|
|
319
|
+
if hasattr(self, "key")
|
|
320
|
+
else None
|
|
321
|
+
)
|
|
322
|
+
_key_confidence=(
|
|
323
|
+
self.key_confidence
|
|
324
|
+
if hasattr(self, "key_confidence")
|
|
325
|
+
else None
|
|
326
|
+
)
|
|
327
|
+
_mode=(
|
|
328
|
+
self.mode
|
|
329
|
+
if hasattr(self, "mode")
|
|
330
|
+
else None
|
|
331
|
+
)
|
|
332
|
+
_mode_confidence=(
|
|
333
|
+
self.mode_confidence
|
|
334
|
+
if hasattr(self, "mode_confidence")
|
|
335
|
+
else None
|
|
336
|
+
)
|
|
337
|
+
_time_signature=(
|
|
338
|
+
self.time_signature
|
|
339
|
+
if hasattr(self, "time_signature")
|
|
340
|
+
else None
|
|
341
|
+
)
|
|
342
|
+
_time_signature_confidence=(
|
|
343
|
+
self.time_signature_confidence
|
|
344
|
+
if hasattr(self, "time_signature_confidence")
|
|
345
|
+
else None
|
|
346
|
+
)
|
|
347
|
+
return (
|
|
348
|
+
f"{self.__class__.__name__}("
|
|
349
|
+
f"start={_start!s}, "
|
|
350
|
+
f"duration={_duration!s}, "
|
|
351
|
+
f"confidence={_confidence!s}, "
|
|
352
|
+
f"loudness={_loudness!s}, "
|
|
353
|
+
f"tempo={_tempo!s}, "
|
|
354
|
+
f"tempo_confidence={_tempo_confidence!s}, "
|
|
355
|
+
f"key={_key!s}, "
|
|
356
|
+
f"key_confidence={_key_confidence!s}, "
|
|
357
|
+
f"mode={_mode!s}, "
|
|
358
|
+
f"mode_confidence={_mode_confidence!s}, "
|
|
359
|
+
f"time_signature={_time_signature!s}, "
|
|
360
|
+
f"time_signature_confidence={_time_signature_confidence!s}, "
|
|
361
|
+
f")"
|
|
362
|
+
)
|