spotifywebapiPython 1.0.242__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.
- spotifywebapipython/__init__.py +35 -0
- spotifywebapipython/const.py +114 -0
- spotifywebapipython/docs/__init__.html +2156 -0
- spotifywebapipython/docs/codecopy.js +70 -0
- spotifywebapipython/docs/index.html +514 -0
- spotifywebapipython/docs/search.js +46 -0
- spotifywebapipython/docs/spotifywebapipython/const.html +636 -0
- spotifywebapipython/docs/spotifywebapipython/saappmessages.html +540 -0
- spotifywebapipython/docs/spotifywebapipython/sautils.html +620 -0
- spotifywebapipython/docs/spotifywebapipython/spotifyapierror.html +341 -0
- spotifywebapipython/docs/spotifywebapipython/spotifyapimessage.html +598 -0
- spotifywebapipython/docs/spotifywebapipython/spotifyauthtoken.html +612 -0
- spotifywebapipython/docs/spotifywebapipython/spotifyclient.html +16557 -0
- spotifywebapipython/docs/spotifywebapipython/spotifydiscovery.html +518 -0
- spotifywebapipython/docs/spotifywebapipython/spotifywebapiauthenticationerror.html +421 -0
- spotifywebapipython/docs/spotifywebapipython/spotifywebapierror.html +400 -0
- spotifywebapipython/docs/spotifywebapipython/spotifywebplayertoken.html +635 -0
- spotifywebapipython/docs/spotifywebapipython.ico +0 -0
- spotifywebapipython/docs/spotifywebapipython_OLD.ico +0 -0
- spotifywebapipython/models/__init__.py +121 -0
- spotifywebapipython/models/album.py +170 -0
- spotifywebapipython/models/albumpagesaved.py +85 -0
- spotifywebapipython/models/albumpagesimplified.py +88 -0
- spotifywebapipython/models/albumsaved.py +102 -0
- spotifywebapipython/models/albumsimplified.py +308 -0
- spotifywebapipython/models/artist.py +146 -0
- spotifywebapipython/models/artistinfo.py +282 -0
- spotifywebapipython/models/artistinfotourevent.py +127 -0
- spotifywebapipython/models/artistpage.py +70 -0
- spotifywebapipython/models/artistsimplified.py +163 -0
- spotifywebapipython/models/audiobook.py +87 -0
- spotifywebapipython/models/audiobookpagesimplified.py +88 -0
- spotifywebapipython/models/audiobooksimplified.py +362 -0
- spotifywebapipython/models/audiofeatures.py +333 -0
- spotifywebapipython/models/author.py +67 -0
- spotifywebapipython/models/category.py +168 -0
- spotifywebapipython/models/categorypage.py +70 -0
- spotifywebapipython/models/chapter.py +84 -0
- spotifywebapipython/models/chapterpagesimplified.py +88 -0
- spotifywebapipython/models/chaptersimplified.py +387 -0
- spotifywebapipython/models/context.py +113 -0
- spotifywebapipython/models/copyright.py +79 -0
- spotifywebapipython/models/device.py +301 -0
- spotifywebapipython/models/episode.py +84 -0
- spotifywebapipython/models/episodepagesaved.py +85 -0
- spotifywebapipython/models/episodepagesimplified.py +88 -0
- spotifywebapipython/models/episodesaved.py +99 -0
- spotifywebapipython/models/episodesimplified.py +370 -0
- spotifywebapipython/models/explicitcontent.py +80 -0
- spotifywebapipython/models/externalids.py +91 -0
- spotifywebapipython/models/externalurls.py +104 -0
- spotifywebapipython/models/followers.py +81 -0
- spotifywebapipython/models/imageobject.py +193 -0
- spotifywebapipython/models/imagevibrantcolors.py +182 -0
- spotifywebapipython/models/linkedfrom.py +165 -0
- spotifywebapipython/models/narrator.py +67 -0
- spotifywebapipython/models/owner.py +162 -0
- spotifywebapipython/models/pageobject.py +343 -0
- spotifywebapipython/models/playeractions.py +196 -0
- spotifywebapipython/models/playerlastplayedinfo.py +334 -0
- spotifywebapipython/models/playerplaystate.py +467 -0
- spotifywebapipython/models/playerqueueinfo.py +207 -0
- spotifywebapipython/models/playhistory.py +136 -0
- spotifywebapipython/models/playhistorypage.py +85 -0
- spotifywebapipython/models/playlist.py +125 -0
- spotifywebapipython/models/playlistpage.py +85 -0
- spotifywebapipython/models/playlistpagesimplified.py +107 -0
- spotifywebapipython/models/playlistsimplified.py +334 -0
- spotifywebapipython/models/playlisttrack.py +143 -0
- spotifywebapipython/models/playlisttracksummary.py +80 -0
- spotifywebapipython/models/recommendationseed.py +135 -0
- spotifywebapipython/models/restrictions.py +86 -0
- spotifywebapipython/models/resumepoint.py +79 -0
- spotifywebapipython/models/searchresponse.py +391 -0
- spotifywebapipython/models/searchresultbase.py +299 -0
- spotifywebapipython/models/show.py +87 -0
- spotifywebapipython/models/showpagesaved.py +85 -0
- spotifywebapipython/models/showpagesimplified.py +88 -0
- spotifywebapipython/models/showsaved.py +99 -0
- spotifywebapipython/models/showsimplified.py +320 -0
- spotifywebapipython/models/spotifyconnectdevice.py +321 -0
- spotifywebapipython/models/spotifyconnectdevices.py +441 -0
- spotifywebapipython/models/track.py +142 -0
- spotifywebapipython/models/trackpage.py +110 -0
- spotifywebapipython/models/trackpagesaved.py +85 -0
- spotifywebapipython/models/trackpagesimplified.py +88 -0
- spotifywebapipython/models/trackrecommendations.py +88 -0
- spotifywebapipython/models/tracksaved.py +99 -0
- spotifywebapipython/models/tracksimplified.py +398 -0
- spotifywebapipython/models/userprofile.py +184 -0
- spotifywebapipython/models/userprofilesimplified.py +206 -0
- spotifywebapipython/models/zeroconfdiscoveryresult.py +592 -0
- spotifywebapipython/models/zeroconfproperty.py +93 -0
- spotifywebapipython/oauthcli/__init__.py +7 -0
- spotifywebapipython/oauthcli/authclient.py +1229 -0
- spotifywebapipython/saappmessages.py +86 -0
- spotifywebapipython/sautils.py +285 -0
- spotifywebapipython/spotifyapierror.py +66 -0
- spotifywebapipython/spotifyapimessage.py +269 -0
- spotifywebapipython/spotifyauthtoken.py +264 -0
- spotifywebapipython/spotifyclient.py +17885 -0
- spotifywebapipython/spotifyconnect/__init__.py +19 -0
- spotifywebapipython/spotifyconnect/spotifyconnectdeviceeventargs.py +67 -0
- spotifywebapipython/spotifyconnect/spotifyconnectdirectorytask.py +2564 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastapptask.py +467 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastcontroller.py +701 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastlistener.py +359 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastmultizonelistener.py +212 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfexceptions.py +20 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconflistener.py +335 -0
- spotifywebapipython/spotifydiscovery.py +473 -0
- spotifywebapipython/spotifymediatypes.py +53 -0
- spotifywebapipython/spotifywebapiauthenticationerror.py +122 -0
- spotifywebapipython/spotifywebapierror.py +106 -0
- spotifywebapipython/spotifywebplayertoken.py +743 -0
- spotifywebapipython/vibrant/__init__.py +17 -0
- spotifywebapipython/vibrant/generator.py +261 -0
- spotifywebapipython/vibrant/image.py +100 -0
- spotifywebapipython/vibrant/main.py +34 -0
- spotifywebapipython/vibrant/models.py +93 -0
- spotifywebapipython/vibrant/utils.py +56 -0
- spotifywebapipython/zeroconfapi/__init__.py +23 -0
- spotifywebapipython/zeroconfapi/authenticationtypes.py +38 -0
- spotifywebapipython/zeroconfapi/blobbuilder.py +370 -0
- spotifywebapipython/zeroconfapi/credentials.py +37 -0
- spotifywebapipython/zeroconfapi/cryptodiffiehellman.py +89 -0
- spotifywebapipython/zeroconfapi/helpers.py +64 -0
- spotifywebapipython/zeroconfapi/spotifyzeroconfapierror.py +108 -0
- spotifywebapipython/zeroconfapi/zeroconfconnect.py +1327 -0
- spotifywebapipython/zeroconfapi/zeroconfgetinfo.py +572 -0
- spotifywebapipython/zeroconfapi/zeroconfgetinfoalias.py +109 -0
- spotifywebapipython/zeroconfapi/zeroconfgetinfodrmmediaformat.py +90 -0
- spotifywebapipython/zeroconfapi/zeroconfresponse.py +195 -0
- spotifywebapipython-1.0.242.dist-info/LICENSE +22 -0
- spotifywebapipython-1.0.242.dist-info/METADATA +219 -0
- spotifywebapipython-1.0.242.dist-info/RECORD +138 -0
- spotifywebapipython-1.0.242.dist-info/WHEEL +5 -0
- spotifywebapipython-1.0.242.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
|
|
6
|
+
@export
|
|
7
|
+
class AudioFeatures:
|
|
8
|
+
"""
|
|
9
|
+
Spotify Web API AudioFeatures object.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self, root:dict=None) -> None:
|
|
13
|
+
"""
|
|
14
|
+
Initializes a new instance of the class.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
root (dict):
|
|
18
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
19
|
+
attributes; otherwise, None to not load attributes.
|
|
20
|
+
"""
|
|
21
|
+
self._Acousticness:float = None
|
|
22
|
+
self._AnalysisUrl:str = None
|
|
23
|
+
self._Danceability:float = None
|
|
24
|
+
self._DurationMS:int = None
|
|
25
|
+
self._Energy:float = None
|
|
26
|
+
self._Id:str = None
|
|
27
|
+
self._Instrumentalness:float = None
|
|
28
|
+
self._Key:int = None
|
|
29
|
+
self._Liveness:float = None
|
|
30
|
+
self._Loudness:float = None
|
|
31
|
+
self._Mode:int = None
|
|
32
|
+
self._Speechiness:float = None
|
|
33
|
+
self._Tempo:float = None
|
|
34
|
+
self._TimeSignature:int = None
|
|
35
|
+
self._TrackHref:str = None
|
|
36
|
+
self._Type:str = None
|
|
37
|
+
self._Uri:str = None
|
|
38
|
+
self._Valence:float = None
|
|
39
|
+
|
|
40
|
+
if (root is None):
|
|
41
|
+
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
else:
|
|
45
|
+
|
|
46
|
+
self._Acousticness = root.get('acousticness', None)
|
|
47
|
+
self._AnalysisUrl = root.get('analysis_url', None)
|
|
48
|
+
self._Danceability = root.get('danceability', None)
|
|
49
|
+
self._DurationMS = root.get('duration_ms', None)
|
|
50
|
+
self._Energy = root.get('energy', None)
|
|
51
|
+
self._Id = root.get('id', None)
|
|
52
|
+
self._Instrumentalness = root.get('instrumentalness', None)
|
|
53
|
+
self._Key = root.get('key', None)
|
|
54
|
+
self._Liveness = root.get('liveness', None)
|
|
55
|
+
self._Loudness = root.get('loudness', None)
|
|
56
|
+
self._Mode = root.get('mode', None)
|
|
57
|
+
self._Speechiness = root.get('speechiness', None)
|
|
58
|
+
self._Tempo = root.get('tempo', None)
|
|
59
|
+
self._TimeSignature = root.get('time_signature', None)
|
|
60
|
+
self._TrackHref = root.get('track_href', None)
|
|
61
|
+
self._Type = root.get('type', None)
|
|
62
|
+
self._Uri = root.get('uri', None)
|
|
63
|
+
self._Valence = root.get('valence', None)
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def __repr__(self) -> str:
|
|
67
|
+
return self.ToString()
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def __str__(self) -> str:
|
|
71
|
+
return self.ToString()
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@property
|
|
75
|
+
def Acousticness(self) -> float:
|
|
76
|
+
"""
|
|
77
|
+
A confidence measure from 0.0 to 1.0 of whether the track is acoustic.
|
|
78
|
+
1.0 represents high confidence the track is acoustic.
|
|
79
|
+
Example: `0.00242`
|
|
80
|
+
"""
|
|
81
|
+
return self._Acousticness
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
@property
|
|
85
|
+
def AnalysisUrl(self) -> str:
|
|
86
|
+
"""
|
|
87
|
+
A URL to access the full audio analysis of this track.
|
|
88
|
+
An access token is required to access this data.
|
|
89
|
+
Example: `https://api.spotify.com/v1/audio-analysis/2takcwOaAZWiXQijPHIx7B`
|
|
90
|
+
"""
|
|
91
|
+
return self._AnalysisUrl
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
@property
|
|
95
|
+
def Danceability(self) -> float:
|
|
96
|
+
"""
|
|
97
|
+
Danceability describes how suitable a track is for dancing based on a combination of musical
|
|
98
|
+
elements including tempo, rhythm stability, beat strength, and overall regularity.
|
|
99
|
+
A value of 0.0 is least danceable and 1.0 is most danceable.
|
|
100
|
+
Example: `0.585`
|
|
101
|
+
"""
|
|
102
|
+
return self._Danceability
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def DurationMS(self) -> int:
|
|
107
|
+
"""
|
|
108
|
+
The duration of the track in milliseconds.
|
|
109
|
+
Example: `237040`
|
|
110
|
+
"""
|
|
111
|
+
return self._DurationMS
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
def Energy(self) -> float:
|
|
116
|
+
"""
|
|
117
|
+
Energy is a measure from 0.0 to 1.0 and represents a perceptual measure of intensity and activity.
|
|
118
|
+
Typically, energetic tracks feel fast, loud, and noisy. For example, death metal has high energy,
|
|
119
|
+
while a Bach prelude scores low on the scale. Perceptual features contributing to this attribute
|
|
120
|
+
include dynamic range, perceived loudness, timbre, onset rate, and general entropy.
|
|
121
|
+
Example: `0.842`
|
|
122
|
+
"""
|
|
123
|
+
return self._Energy
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
@property
|
|
127
|
+
def Id(self) -> int:
|
|
128
|
+
"""
|
|
129
|
+
The Spotify ID for the track.
|
|
130
|
+
Example: `2takcwOaAZWiXQijPHIx7B`
|
|
131
|
+
"""
|
|
132
|
+
return self._Id
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
@property
|
|
136
|
+
def Instrumentalness(self) -> float:
|
|
137
|
+
"""
|
|
138
|
+
Predicts whether a track contains no vocals.
|
|
139
|
+
"Ooh" and "aah" sounds are treated as instrumental in this context. Rap or spoken word
|
|
140
|
+
tracks are clearly "vocal". The closer the instrumentalness value is to 1.0, the greater
|
|
141
|
+
likelihood the track contains no vocal content. Values above 0.5 are intended to represent
|
|
142
|
+
instrumental tracks, but confidence is higher as the value approaches 1.0.
|
|
143
|
+
Example: `0.00686`
|
|
144
|
+
"""
|
|
145
|
+
return self._Instrumentalness
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def Key(self) -> int:
|
|
150
|
+
"""
|
|
151
|
+
The key the track is in.
|
|
152
|
+
|
|
153
|
+
Integers map to pitches using standard Pitch Class notation (e.g. 0 = C, 1 = C#,
|
|
154
|
+
2 = D, and so on). If no key was detected, the value is -1.
|
|
155
|
+
|
|
156
|
+
Range: `-1` to `11`
|
|
157
|
+
Example: `9`
|
|
158
|
+
"""
|
|
159
|
+
return self._Key
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
@property
|
|
163
|
+
def Liveness(self) -> float:
|
|
164
|
+
"""
|
|
165
|
+
Detects the presence of an audience in the recording. Higher liveness values represent
|
|
166
|
+
an increased probability that the track was performed live. A value above 0.8 provides
|
|
167
|
+
strong likelihood that the track is live.
|
|
168
|
+
|
|
169
|
+
Example: `0.0866`
|
|
170
|
+
"""
|
|
171
|
+
return self._Liveness
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
@property
|
|
175
|
+
def Loudness(self) -> float:
|
|
176
|
+
"""
|
|
177
|
+
The overall loudness of a track in decibels (dB).
|
|
178
|
+
|
|
179
|
+
Loudness values are averaged across the entire track and are useful for comparing relative
|
|
180
|
+
loudness of tracks. Loudness is the quality of a sound that is the primary psychological
|
|
181
|
+
correlate of physical strength (amplitude). Values typically range between -60 and 0 db.
|
|
182
|
+
|
|
183
|
+
Example: `-5.883`
|
|
184
|
+
"""
|
|
185
|
+
return self._Loudness
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
@property
|
|
189
|
+
def Mode(self) -> int:
|
|
190
|
+
"""
|
|
191
|
+
Mode indicates the modality (major or minor) of a track, the type of scale from which its
|
|
192
|
+
melodic content is derived. Major is represented by 1 and minor is 0.
|
|
193
|
+
|
|
194
|
+
Example: `0`
|
|
195
|
+
"""
|
|
196
|
+
return self._Mode
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
@property
|
|
200
|
+
def Speechiness(self) -> float:
|
|
201
|
+
"""
|
|
202
|
+
Speechiness detects the presence of spoken words in a track. The more exclusively speech-like
|
|
203
|
+
the recording (e.g. talk show, audio book, poetry), the closer to 1.0 the attribute value.
|
|
204
|
+
Values above 0.66 describe tracks that are probably made entirely of spoken words.
|
|
205
|
+
Values between 0.33 and 0.66 describe tracks that may contain both music and speech, either
|
|
206
|
+
in sections or layered, including such cases as rap music. Values below 0.33 most likely
|
|
207
|
+
represent music and other non-speech-like tracks.
|
|
208
|
+
|
|
209
|
+
Example: `0.0556`
|
|
210
|
+
"""
|
|
211
|
+
return self._Speechiness
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
@property
|
|
215
|
+
def Tempo(self) -> float:
|
|
216
|
+
"""
|
|
217
|
+
The overall estimated tempo of a track in beats per minute (BPM).
|
|
218
|
+
|
|
219
|
+
In musical terminology, tempo is the speed or pace of a given piece and derives directly
|
|
220
|
+
from the average beat duration.
|
|
221
|
+
|
|
222
|
+
Example: `118.211`
|
|
223
|
+
"""
|
|
224
|
+
return self._Tempo
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@property
|
|
228
|
+
def TimeSignature(self) -> int:
|
|
229
|
+
"""
|
|
230
|
+
An estimated time signature.
|
|
231
|
+
|
|
232
|
+
The time signature (meter) is a notational convention to specify how many beats are in each
|
|
233
|
+
bar (or measure). The time signature ranges from 3 to 7 indicating time signatures of "3/4", to "7/4".
|
|
234
|
+
|
|
235
|
+
Range: `3` to `7`
|
|
236
|
+
Example: `4`
|
|
237
|
+
"""
|
|
238
|
+
return self._TimeSignature
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
@property
|
|
242
|
+
def TrackHref(self) -> str:
|
|
243
|
+
"""
|
|
244
|
+
A link to the Web API endpoint providing full details of the track.
|
|
245
|
+
|
|
246
|
+
Example: `https://api.spotify.com/v1/tracks/2takcwOaAZWiXQijPHIx7B`
|
|
247
|
+
"""
|
|
248
|
+
return self._TrackHref
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
@property
|
|
252
|
+
def Type(self) -> str:
|
|
253
|
+
"""
|
|
254
|
+
The object type: `audio_features`.
|
|
255
|
+
"""
|
|
256
|
+
return self._Type
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
@property
|
|
260
|
+
def Uri(self) -> str:
|
|
261
|
+
"""
|
|
262
|
+
The Spotify URI for the track.
|
|
263
|
+
|
|
264
|
+
Example: `spotify:track:2takcwOaAZWiXQijPHIx7B`
|
|
265
|
+
"""
|
|
266
|
+
return self._Uri
|
|
267
|
+
|
|
268
|
+
|
|
269
|
+
@property
|
|
270
|
+
def Valence(self) -> float:
|
|
271
|
+
"""
|
|
272
|
+
A measure from 0.0 to 1.0 describing the musical positiveness conveyed by a track.
|
|
273
|
+
|
|
274
|
+
Tracks with high valence sound more positive (e.g. happy, cheerful, euphoric), while
|
|
275
|
+
tracks with low valence sound more negative (e.g. sad, depressed, angry).
|
|
276
|
+
|
|
277
|
+
Range: `0` to `1`
|
|
278
|
+
Example: `0.428`
|
|
279
|
+
"""
|
|
280
|
+
return self._Valence
|
|
281
|
+
|
|
282
|
+
|
|
283
|
+
def ToDictionary(self) -> dict:
|
|
284
|
+
"""
|
|
285
|
+
Returns a dictionary representation of the class.
|
|
286
|
+
"""
|
|
287
|
+
result:dict = \
|
|
288
|
+
{
|
|
289
|
+
'acousticness': self._Acousticness,
|
|
290
|
+
'analysis_url': self._AnalysisUrl,
|
|
291
|
+
'danceability': self._Danceability,
|
|
292
|
+
'duration_ms': self._DurationMS,
|
|
293
|
+
'energy': self._Energy,
|
|
294
|
+
'id': self._Id,
|
|
295
|
+
'instrumentalness': self._Instrumentalness,
|
|
296
|
+
'key': self._Key,
|
|
297
|
+
'liveness': self._Liveness,
|
|
298
|
+
'loudness': self._Loudness,
|
|
299
|
+
'mode': self._Mode,
|
|
300
|
+
'speechiness': self._Speechiness,
|
|
301
|
+
'tempo': self._Tempo,
|
|
302
|
+
'time_signature': self._TimeSignature,
|
|
303
|
+
'track_href': self._TrackHref,
|
|
304
|
+
'type': self._Type,
|
|
305
|
+
'uri': self._Uri,
|
|
306
|
+
'valence': self._Valence,
|
|
307
|
+
}
|
|
308
|
+
return result
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def ToString(self) -> str:
|
|
312
|
+
"""
|
|
313
|
+
Returns a displayable string representation of the class.
|
|
314
|
+
"""
|
|
315
|
+
msg:str = 'AudioFeatures:'
|
|
316
|
+
if self._Uri is not None: msg = '%s\n Uri="%s"' % (msg, str(self._Uri))
|
|
317
|
+
if self._Acousticness is not None: msg = '%s\n Acousticness="%s"' % (msg, str(self._Acousticness))
|
|
318
|
+
if self._AnalysisUrl is not None: msg = '%s\n AnalysisUrl="%s"' % (msg, str(self._AnalysisUrl))
|
|
319
|
+
if self._Danceability is not None: msg = '%s\n Danceability="%s"' % (msg, str(self._Danceability))
|
|
320
|
+
if self._DurationMS is not None: msg = '%s\n DurationMS="%s"' % (msg, str(self._DurationMS))
|
|
321
|
+
if self._Energy is not None: msg = '%s\n Energy="%s"' % (msg, str(self._Energy))
|
|
322
|
+
if self._Id is not None: msg = '%s\n Id="%s"' % (msg, str(self._Id))
|
|
323
|
+
if self._Instrumentalness is not None: msg = '%s\n Instrumentalness="%s"' % (msg, str(self._Instrumentalness))
|
|
324
|
+
if self._Key is not None: msg = '%s\n Key="%s"' % (msg, str(self._Key))
|
|
325
|
+
if self._Liveness is not None: msg = '%s\n Liveness="%s"' % (msg, str(self._Liveness))
|
|
326
|
+
if self._Loudness is not None: msg = '%s\n Loudness="%s"' % (msg, str(self._Loudness))
|
|
327
|
+
if self._Speechiness is not None: msg = '%s\n Speechiness="%s"' % (msg, str(self._Speechiness))
|
|
328
|
+
if self._Tempo is not None: msg = '%s\n Tempo="%s"' % (msg, str(self._Tempo))
|
|
329
|
+
if self._TimeSignature is not None: msg = '%s\n TimeSignature="%s"' % (msg, str(self._TimeSignature))
|
|
330
|
+
if self._TrackHref is not None: msg = '%s\n TrackHref="%s"' % (msg, str(self._TrackHref))
|
|
331
|
+
if self._Type is not None: msg = '%s\n Type="%s"' % (msg, str(self._Type))
|
|
332
|
+
if self._Valence is not None: msg = '%s\n Valence="%s"' % (msg, str(self._Valence))
|
|
333
|
+
return msg
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
|
|
6
|
+
@export
|
|
7
|
+
class Author:
|
|
8
|
+
"""
|
|
9
|
+
Spotify Web API Content Author object.
|
|
10
|
+
|
|
11
|
+
Contains information about content authors.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, root:dict=None) -> None:
|
|
15
|
+
"""
|
|
16
|
+
Initializes a new instance of the class.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
root (dict):
|
|
20
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
21
|
+
attributes; otherwise, None to not load attributes.
|
|
22
|
+
"""
|
|
23
|
+
self._Name:str = None
|
|
24
|
+
|
|
25
|
+
if (root is None):
|
|
26
|
+
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
else:
|
|
30
|
+
|
|
31
|
+
self._Name = root.get('name', None)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def __repr__(self) -> str:
|
|
35
|
+
return self.ToString()
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def __str__(self) -> str:
|
|
39
|
+
return self.ToString()
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def Name(self) -> str:
|
|
44
|
+
"""
|
|
45
|
+
The author name for this content.
|
|
46
|
+
"""
|
|
47
|
+
return self._Name
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def ToDictionary(self) -> dict:
|
|
51
|
+
"""
|
|
52
|
+
Returns a dictionary representation of the class.
|
|
53
|
+
"""
|
|
54
|
+
result:dict = \
|
|
55
|
+
{
|
|
56
|
+
'name': self._Name,
|
|
57
|
+
}
|
|
58
|
+
return result
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def ToString(self) -> str:
|
|
62
|
+
"""
|
|
63
|
+
Returns a displayable string representation of the class.
|
|
64
|
+
"""
|
|
65
|
+
msg:str = 'Author:'
|
|
66
|
+
if self._Name is not None: msg = '%s\n Name="%s"' % (msg, str(self._Name))
|
|
67
|
+
return msg
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .imageobject import ImageObject
|
|
6
|
+
|
|
7
|
+
@export
|
|
8
|
+
class Category:
|
|
9
|
+
"""
|
|
10
|
+
Spotify Web API Category object.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, root:dict=None) -> None:
|
|
14
|
+
"""
|
|
15
|
+
Initializes a new instance of the class.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
root (dict):
|
|
19
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
20
|
+
attributes; otherwise, None to not load attributes.
|
|
21
|
+
"""
|
|
22
|
+
self._Href:str = None
|
|
23
|
+
self._Id:str = None
|
|
24
|
+
self._Icons:list[ImageObject] = []
|
|
25
|
+
self._Name:str = None
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
if (root is None):
|
|
29
|
+
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
else:
|
|
33
|
+
|
|
34
|
+
self._Href = root.get('href', None)
|
|
35
|
+
self._Id = root.get('id', None)
|
|
36
|
+
self._Name = root.get('name', None)
|
|
37
|
+
|
|
38
|
+
# process all collections and objects.
|
|
39
|
+
items:list = root.get('icons',None)
|
|
40
|
+
if items is not None:
|
|
41
|
+
for item in items:
|
|
42
|
+
self._Icons.append(ImageObject(root=item))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def __repr__(self) -> str:
|
|
46
|
+
return self.ToString()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def __str__(self) -> str:
|
|
50
|
+
return self.ToString()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
# implement sorting support.
|
|
54
|
+
def __eq__(self, other):
|
|
55
|
+
try:
|
|
56
|
+
return self.Name == other.Name
|
|
57
|
+
except Exception:
|
|
58
|
+
if (isinstance(self, Category )) and (isinstance(other, Category )):
|
|
59
|
+
return self.Name == other.Name
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
def __lt__(self, other):
|
|
63
|
+
try:
|
|
64
|
+
return self.Name < other.Name
|
|
65
|
+
except Exception:
|
|
66
|
+
if (isinstance(self, Category )) and (isinstance(other, Category )):
|
|
67
|
+
return self.Name < other.Name
|
|
68
|
+
return False
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@property
|
|
72
|
+
def Href(self) -> str:
|
|
73
|
+
"""
|
|
74
|
+
A link to the Web API endpoint returning full details of the category.
|
|
75
|
+
"""
|
|
76
|
+
return self._Href
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@property
|
|
80
|
+
def Id(self) -> str:
|
|
81
|
+
"""
|
|
82
|
+
The Spotify category ID of the category.
|
|
83
|
+
Some ID's are read-able text, while most are a unique id format.
|
|
84
|
+
|
|
85
|
+
Example: `toplists`
|
|
86
|
+
Example: `0JQ5DAqbMKFDXXwE9BDJAr` (e.g. unique id for `Rock`)
|
|
87
|
+
"""
|
|
88
|
+
return self._Id
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def Icons(self) -> list[ImageObject]:
|
|
93
|
+
"""
|
|
94
|
+
The category icon in various sizes, widest first.
|
|
95
|
+
"""
|
|
96
|
+
return self._Icons
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def ImageUrl(self) -> str:
|
|
101
|
+
"""
|
|
102
|
+
Gets the first icon url in the `Icons` list, if images are defined;
|
|
103
|
+
otherwise, null.
|
|
104
|
+
"""
|
|
105
|
+
if len(self._Icons) > 0:
|
|
106
|
+
return self._Icons[0].Url
|
|
107
|
+
return None
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
@property
|
|
111
|
+
def Name(self) -> str:
|
|
112
|
+
"""
|
|
113
|
+
The name of the category.
|
|
114
|
+
"""
|
|
115
|
+
return self._Name
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@property
|
|
119
|
+
def Type(self) -> str:
|
|
120
|
+
"""
|
|
121
|
+
A simulated Spotify type value for the category.
|
|
122
|
+
|
|
123
|
+
This is a helper property - no value with this name is returned from the
|
|
124
|
+
Spotify Web API.
|
|
125
|
+
"""
|
|
126
|
+
return "category"
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@property
|
|
130
|
+
def Uri(self) -> str:
|
|
131
|
+
"""
|
|
132
|
+
A simulated Spotify URI value for the category.
|
|
133
|
+
|
|
134
|
+
This is a helper property - no value with this name is returned from the
|
|
135
|
+
Spotify Web API.
|
|
136
|
+
"""
|
|
137
|
+
return f"spotify:category:{self._Id}"
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def ToDictionary(self) -> dict:
|
|
141
|
+
"""
|
|
142
|
+
Returns a dictionary representation of the class.
|
|
143
|
+
"""
|
|
144
|
+
result:dict = \
|
|
145
|
+
{
|
|
146
|
+
'href': self._Href,
|
|
147
|
+
'icons': [ item.ToDictionary() for item in self._Icons ],
|
|
148
|
+
'image_url': self.ImageUrl,
|
|
149
|
+
'id': self._Id,
|
|
150
|
+
'name': self._Name,
|
|
151
|
+
'type': self.Type,
|
|
152
|
+
'uri': self.Uri,
|
|
153
|
+
}
|
|
154
|
+
return result
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def ToString(self) -> str:
|
|
158
|
+
"""
|
|
159
|
+
Returns a displayable string representation of the class.
|
|
160
|
+
"""
|
|
161
|
+
msg:str = 'Category:'
|
|
162
|
+
if self._Name is not None: msg = '%s\n Name="%s"' % (msg, str(self._Name))
|
|
163
|
+
if self._Href is not None: msg = '%s\n Href="%s"' % (msg, str(self._Href))
|
|
164
|
+
if self._Id is not None: msg = '%s\n Id="%s"' % (msg, str(self._Id))
|
|
165
|
+
if self._Icons is not None: msg = '%s\n Icons Count=%s' % (msg, str(len(self._Icons)))
|
|
166
|
+
if self._Id is not None: msg = '%s\n Type="%s"' % (msg, str(self.Type))
|
|
167
|
+
if self._Id is not None: msg = '%s\n Uri="%s"' % (msg, str(self.Uri))
|
|
168
|
+
return msg
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .pageobject import PageObject
|
|
6
|
+
from .category import Category
|
|
7
|
+
|
|
8
|
+
@export
|
|
9
|
+
class CategoryPage(PageObject):
|
|
10
|
+
"""
|
|
11
|
+
Spotify Web API CategoryPage object.
|
|
12
|
+
|
|
13
|
+
This allows for multiple pages of `Category` objects to be navigated.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, root:dict=None) -> None:
|
|
17
|
+
"""
|
|
18
|
+
Initializes a new instance of the class.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
root (dict):
|
|
22
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
23
|
+
attributes; otherwise, None to not load attributes.
|
|
24
|
+
"""
|
|
25
|
+
# initialize base class.
|
|
26
|
+
super().__init__(root=root)
|
|
27
|
+
|
|
28
|
+
# initialize storage.
|
|
29
|
+
self._Items:list[Category] = []
|
|
30
|
+
|
|
31
|
+
if (root is None):
|
|
32
|
+
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
else:
|
|
36
|
+
|
|
37
|
+
# process all collections and objects.
|
|
38
|
+
items:list = root.get('items',None)
|
|
39
|
+
if items is not None:
|
|
40
|
+
for item in items:
|
|
41
|
+
if item is not None:
|
|
42
|
+
self._Items.append(Category(root=item))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def __repr__(self) -> str:
|
|
46
|
+
return self.ToString()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def __str__(self) -> str:
|
|
50
|
+
return self.ToString()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def Items(self) -> list[Category]:
|
|
55
|
+
"""
|
|
56
|
+
Array of `Category` objects.
|
|
57
|
+
"""
|
|
58
|
+
return self._Items
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def ToString(self, includeItems:bool=False) -> str:
|
|
62
|
+
"""
|
|
63
|
+
Returns a displayable string representation of the class.
|
|
64
|
+
|
|
65
|
+
Args:
|
|
66
|
+
includeItems (bool):
|
|
67
|
+
True to include the Items collection of objects; otherwise, False
|
|
68
|
+
to only return base properties.
|
|
69
|
+
"""
|
|
70
|
+
return 'CategoryPage: %s' % super().ToString(includeItems)
|