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,308 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .artistsimplified import ArtistSimplified
|
|
6
|
+
from .externalurls import ExternalUrls
|
|
7
|
+
from .imageobject import ImageObject
|
|
8
|
+
from .restrictions import Restrictions
|
|
9
|
+
|
|
10
|
+
@export
|
|
11
|
+
class AlbumSimplified:
|
|
12
|
+
"""
|
|
13
|
+
Spotify Web API Simplified Album object.
|
|
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
|
+
self._AlbumType:str = None
|
|
26
|
+
self._Artists:list[ArtistSimplified] = []
|
|
27
|
+
self._AvailableMarkets:list[str] = []
|
|
28
|
+
self._ExternalUrls:ExternalUrls = None
|
|
29
|
+
self._Href:str = None
|
|
30
|
+
self._Id:str = None
|
|
31
|
+
self._Images:list[ImageObject] = []
|
|
32
|
+
self._Name:str = None
|
|
33
|
+
self._ReleaseDate:str = None
|
|
34
|
+
self._ReleaseDatePrecision:str = None
|
|
35
|
+
self._Restrictions:Restrictions = None
|
|
36
|
+
self._TotalTracks:int = None
|
|
37
|
+
self._Type:str = None
|
|
38
|
+
self._Uri:str = None
|
|
39
|
+
|
|
40
|
+
if (root is None):
|
|
41
|
+
|
|
42
|
+
pass
|
|
43
|
+
|
|
44
|
+
else:
|
|
45
|
+
|
|
46
|
+
self._AlbumType = root.get('album_type', None)
|
|
47
|
+
self._AvailableMarkets = root.get('available_markets', None) or []
|
|
48
|
+
self._Href = root.get('href', None)
|
|
49
|
+
self._Id = root.get('id', None)
|
|
50
|
+
self._Name = root.get('name', None)
|
|
51
|
+
self._ReleaseDate = root.get('release_date', None)
|
|
52
|
+
self._ReleaseDatePrecision = root.get('release_date_precision', None)
|
|
53
|
+
self._TotalTracks = root.get('total_tracks', None)
|
|
54
|
+
self._Type = root.get('type', None)
|
|
55
|
+
self._Uri = root.get('uri', None)
|
|
56
|
+
|
|
57
|
+
# process all collections and objects.
|
|
58
|
+
items:list = root.get('artists',None)
|
|
59
|
+
if items is not None:
|
|
60
|
+
for item in items:
|
|
61
|
+
self._Artists.append(ArtistSimplified(root=item))
|
|
62
|
+
|
|
63
|
+
item:dict = root.get('external_urls',None)
|
|
64
|
+
if item is not None:
|
|
65
|
+
self._ExternalUrls = ExternalUrls(root=item)
|
|
66
|
+
|
|
67
|
+
items:list = root.get('images',None)
|
|
68
|
+
if items is not None:
|
|
69
|
+
for item in items:
|
|
70
|
+
self._Images.append(ImageObject(root=item))
|
|
71
|
+
|
|
72
|
+
item:dict = root.get('restrictions',None)
|
|
73
|
+
if item is not None:
|
|
74
|
+
self._Restrictions = Restrictions(root=item)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def __repr__(self) -> str:
|
|
78
|
+
return self.ToString()
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def __str__(self) -> str:
|
|
82
|
+
return self.ToString()
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
# implement sorting support.
|
|
86
|
+
def __eq__(self, other):
|
|
87
|
+
try:
|
|
88
|
+
return self.Name == other.Name
|
|
89
|
+
except Exception:
|
|
90
|
+
if (isinstance(self, AlbumSimplified )) and (isinstance(other, AlbumSimplified )):
|
|
91
|
+
return self.Name == other.Name
|
|
92
|
+
return False
|
|
93
|
+
|
|
94
|
+
def __lt__(self, other):
|
|
95
|
+
try:
|
|
96
|
+
return self.Name < other.Name
|
|
97
|
+
except Exception:
|
|
98
|
+
if (isinstance(self, AlbumSimplified )) and (isinstance(other, AlbumSimplified )):
|
|
99
|
+
return self.Name < other.Name
|
|
100
|
+
return False
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@property
|
|
104
|
+
def AlbumType(self) -> str:
|
|
105
|
+
"""
|
|
106
|
+
The type of the album.
|
|
107
|
+
|
|
108
|
+
Allowed values: `album`, `single`, `compilation`.
|
|
109
|
+
|
|
110
|
+
Example: `album`
|
|
111
|
+
"""
|
|
112
|
+
return self._AlbumType
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@property
|
|
116
|
+
def Artists(self) -> list[ArtistSimplified]:
|
|
117
|
+
"""
|
|
118
|
+
The artists of the album.
|
|
119
|
+
|
|
120
|
+
Each artist object includes a link in href to more detailed information about the artist.
|
|
121
|
+
"""
|
|
122
|
+
return self._Artists
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@property
|
|
126
|
+
def AvailableMarkets(self) -> list[str]:
|
|
127
|
+
"""
|
|
128
|
+
The markets in which the album is available: ISO 3166-1 alpha-2 country codes.
|
|
129
|
+
|
|
130
|
+
NOTE: an album is considered available in a market when at least 1 of its tracks is available in that market.
|
|
131
|
+
|
|
132
|
+
Example: `["CA","BR","IT"]`
|
|
133
|
+
"""
|
|
134
|
+
return self._AvailableMarkets
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@property
|
|
138
|
+
def ExternalUrls(self) -> ExternalUrls:
|
|
139
|
+
"""
|
|
140
|
+
Known external URLs for the album.
|
|
141
|
+
"""
|
|
142
|
+
return self._ExternalUrls
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
@property
|
|
146
|
+
def Href(self) -> str:
|
|
147
|
+
"""
|
|
148
|
+
A link to the Web API endpoint providing full details of the album.
|
|
149
|
+
"""
|
|
150
|
+
return self._Href
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def Id(self) -> str:
|
|
155
|
+
"""
|
|
156
|
+
The Spotify ID for the album.
|
|
157
|
+
|
|
158
|
+
Example: `2up3OPMp9Tb4dAKM2erWXQ`
|
|
159
|
+
"""
|
|
160
|
+
return self._Id
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
@property
|
|
164
|
+
def Images(self) -> list[ImageObject]:
|
|
165
|
+
"""
|
|
166
|
+
The cover art for the album in various sizes, widest first.
|
|
167
|
+
"""
|
|
168
|
+
return self._Images
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
@property
|
|
172
|
+
def ImageUrl(self) -> str:
|
|
173
|
+
"""
|
|
174
|
+
Returns the highest resolution order image from the `Images` list, if images
|
|
175
|
+
are defined; otherwise, null.
|
|
176
|
+
"""
|
|
177
|
+
return ImageObject.GetImageHighestResolution(self._Images)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
@property
|
|
181
|
+
def Name(self) -> str:
|
|
182
|
+
"""
|
|
183
|
+
The name of the album.
|
|
184
|
+
|
|
185
|
+
In case of an album takedown, the value may be an empty string.
|
|
186
|
+
"""
|
|
187
|
+
return self._Name
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def ReleaseDate(self) -> str:
|
|
192
|
+
"""
|
|
193
|
+
The date the album was first released.
|
|
194
|
+
|
|
195
|
+
Example: `1981-12`
|
|
196
|
+
"""
|
|
197
|
+
return self._ReleaseDate
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@property
|
|
201
|
+
def ReleaseDatePrecision(self) -> str:
|
|
202
|
+
"""
|
|
203
|
+
The precision with which release_date value is known.
|
|
204
|
+
Allowed values: `year`, `month`, `day`.
|
|
205
|
+
|
|
206
|
+
Example: `year`
|
|
207
|
+
"""
|
|
208
|
+
return self._ReleaseDatePrecision
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
@property
|
|
212
|
+
def Restrictions(self) -> Restrictions:
|
|
213
|
+
"""
|
|
214
|
+
Included in the response when a content restriction is applied.
|
|
215
|
+
"""
|
|
216
|
+
return self._Restrictions
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
@property
|
|
220
|
+
def TotalTracks(self) -> int:
|
|
221
|
+
"""
|
|
222
|
+
The number of tracks in the album.
|
|
223
|
+
"""
|
|
224
|
+
return self._TotalTracks
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@property
|
|
228
|
+
def Type(self) -> str:
|
|
229
|
+
"""
|
|
230
|
+
The object type: `album`.
|
|
231
|
+
"""
|
|
232
|
+
return self._Type
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
@property
|
|
236
|
+
def Uri(self) -> str:
|
|
237
|
+
"""
|
|
238
|
+
The Spotify URI for the album.
|
|
239
|
+
|
|
240
|
+
Example: `spotify:album:2up3OPMp9Tb4dAKM2erWXQ`
|
|
241
|
+
"""
|
|
242
|
+
return self._Uri
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def ToDictionary(self) -> dict:
|
|
246
|
+
"""
|
|
247
|
+
Returns a dictionary representation of the class.
|
|
248
|
+
"""
|
|
249
|
+
externalUrls:dict = {}
|
|
250
|
+
if self._ExternalUrls is not None:
|
|
251
|
+
externalUrls = self._ExternalUrls.ToDictionary()
|
|
252
|
+
|
|
253
|
+
restrictions:dict = {}
|
|
254
|
+
if self._Restrictions is not None:
|
|
255
|
+
restrictions = self._Restrictions.ToDictionary()
|
|
256
|
+
|
|
257
|
+
result:dict = \
|
|
258
|
+
{
|
|
259
|
+
'album_type': self._AlbumType,
|
|
260
|
+
'artists': [ item.ToDictionary() for item in self._Artists ],
|
|
261
|
+
'available_markets': [ item for item in self._AvailableMarkets ],
|
|
262
|
+
'external_urls': externalUrls,
|
|
263
|
+
'href': self._Href,
|
|
264
|
+
'id': self._Id,
|
|
265
|
+
'image_url': self.ImageUrl,
|
|
266
|
+
'images': [ item.ToDictionary() for item in self._Images ],
|
|
267
|
+
'name': self._Name,
|
|
268
|
+
'release_date': self._ReleaseDate,
|
|
269
|
+
'release_date_precision': self._ReleaseDatePrecision,
|
|
270
|
+
'restrictions': restrictions,
|
|
271
|
+
'total_tracks': self._TotalTracks,
|
|
272
|
+
'type': self._Type,
|
|
273
|
+
'uri': self._Uri,
|
|
274
|
+
}
|
|
275
|
+
return result
|
|
276
|
+
|
|
277
|
+
|
|
278
|
+
def ToString(self, includeTitle:bool=True) -> str:
|
|
279
|
+
"""
|
|
280
|
+
Returns a displayable string representation of the class.
|
|
281
|
+
|
|
282
|
+
Args:
|
|
283
|
+
includeTitle (str):
|
|
284
|
+
True to include the class name title prefix.
|
|
285
|
+
"""
|
|
286
|
+
msg:str = ''
|
|
287
|
+
if includeTitle:
|
|
288
|
+
msg = 'AlbumSimplified:'
|
|
289
|
+
|
|
290
|
+
if self._Name is not None: msg = '%s\n Name="%s"' % (msg, str(self._Name))
|
|
291
|
+
if self._Uri is not None: msg = '%s\n Uri="%s"' % (msg, str(self._Uri))
|
|
292
|
+
if self._AlbumType is not None: msg = '%s\n AlbumType="%s"' % (msg, str(self._AlbumType))
|
|
293
|
+
if self._Artists is not None:
|
|
294
|
+
cnt:int = len(self._Artists)
|
|
295
|
+
if cnt > 0:
|
|
296
|
+
msg = '%s\n Artist="%s" (%s)' % (msg, str(self._Artists[0].Name), str(self._Artists[0].Id))
|
|
297
|
+
msg = '%s\n Artists Count=%s' % (msg, str(cnt))
|
|
298
|
+
if self._AvailableMarkets is not None: msg = '%s\n AvailableMarkets Count=%s' % (msg, str(len(self._AvailableMarkets)))
|
|
299
|
+
#if self._ExternalUrls is not None: msg = '%s\n %s' % (msg, str(self._ExternalUrls))
|
|
300
|
+
if self._Href is not None: msg = '%s\n Href="%s"' % (msg, str(self._Href))
|
|
301
|
+
if self._Id is not None: msg = '%s\n Id="%s"' % (msg, str(self._Id))
|
|
302
|
+
if self._Images is not None: msg = '%s\n Images Count=%s' % (msg, str(len(self._Images)))
|
|
303
|
+
if self._ReleaseDate is not None: msg = '%s\n ReleaseDate="%s"' % (msg, str(self._ReleaseDate))
|
|
304
|
+
if self._ReleaseDatePrecision is not None: msg = '%s\n ReleaseDatePrecision="%s"' % (msg, str(self._ReleaseDatePrecision))
|
|
305
|
+
#if self._Restrictions is not None: msg = '%s\n %s' % (msg, str(self._Restrictions))
|
|
306
|
+
if self._TotalTracks is not None: msg = '%s\n TotalTracks="%s"' % (msg, str(self._TotalTracks))
|
|
307
|
+
if self._Type is not None: msg = '%s\n Type="%s"' % (msg, str(self._Type))
|
|
308
|
+
return msg
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .artistsimplified import ArtistSimplified
|
|
6
|
+
from .followers import Followers
|
|
7
|
+
from .imageobject import ImageObject
|
|
8
|
+
|
|
9
|
+
@export
|
|
10
|
+
class Artist(ArtistSimplified):
|
|
11
|
+
"""
|
|
12
|
+
Spotify Web API Artist object.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
def __init__(self, root:dict=None) -> None:
|
|
16
|
+
"""
|
|
17
|
+
Initializes a new instance of the class.
|
|
18
|
+
|
|
19
|
+
Args:
|
|
20
|
+
root (dict):
|
|
21
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
22
|
+
attributes; otherwise, None to not load attributes.
|
|
23
|
+
"""
|
|
24
|
+
# initialize base class.
|
|
25
|
+
super().__init__(root)
|
|
26
|
+
|
|
27
|
+
# initialize storage.
|
|
28
|
+
self._Followers:Followers = None
|
|
29
|
+
self._Genres:list[str] = []
|
|
30
|
+
self._Images:list[ImageObject] = []
|
|
31
|
+
self._Popularity:int = None
|
|
32
|
+
|
|
33
|
+
if (root is None):
|
|
34
|
+
|
|
35
|
+
pass
|
|
36
|
+
|
|
37
|
+
else:
|
|
38
|
+
|
|
39
|
+
self._Popularity = root.get('popularity', None)
|
|
40
|
+
|
|
41
|
+
# process all collections and objects.
|
|
42
|
+
item:dict = root.get('followers',None)
|
|
43
|
+
if item is not None:
|
|
44
|
+
self._Followers = Followers(root=item)
|
|
45
|
+
|
|
46
|
+
items:list[str] = root.get('genres',None)
|
|
47
|
+
if items is not None:
|
|
48
|
+
for item in items:
|
|
49
|
+
self._Genres.append(item)
|
|
50
|
+
|
|
51
|
+
items:list = root.get('images',None)
|
|
52
|
+
if items is not None:
|
|
53
|
+
for item in items:
|
|
54
|
+
self._Images.append(ImageObject(root=item))
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def __repr__(self) -> str:
|
|
58
|
+
return self.ToString()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def __str__(self) -> str:
|
|
62
|
+
return self.ToString()
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@property
|
|
66
|
+
def Followers(self) -> Followers:
|
|
67
|
+
"""
|
|
68
|
+
Information about the followers of the artist.
|
|
69
|
+
"""
|
|
70
|
+
return self._Followers
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
@property
|
|
74
|
+
def Genres(self) -> list[str]:
|
|
75
|
+
"""
|
|
76
|
+
A list of the genres the artist is associated with; if not yet classified, the array is empty.
|
|
77
|
+
|
|
78
|
+
Example: `["Prog rock","Grunge"]`
|
|
79
|
+
"""
|
|
80
|
+
return self._Genres
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
@property
|
|
84
|
+
def Images(self) -> list[ImageObject]:
|
|
85
|
+
"""
|
|
86
|
+
Images of the artist in various sizes, widest first.
|
|
87
|
+
"""
|
|
88
|
+
return self._Images
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
@property
|
|
92
|
+
def ImageUrl(self) -> str:
|
|
93
|
+
"""
|
|
94
|
+
Returns the highest resolution order image from the `Images` list, if images
|
|
95
|
+
are defined; otherwise, null.
|
|
96
|
+
"""
|
|
97
|
+
return ImageObject.GetImageHighestResolution(self._Images)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@property
|
|
101
|
+
def Popularity(self) -> int:
|
|
102
|
+
"""
|
|
103
|
+
The popularity of the artist.
|
|
104
|
+
The value will be between 0 and 100, with 100 being the most popular.
|
|
105
|
+
The artist's popularity is calculated from the popularity of all the artist's tracks.
|
|
106
|
+
"""
|
|
107
|
+
return self._Popularity
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def ToDictionary(self) -> dict:
|
|
111
|
+
"""
|
|
112
|
+
Returns a dictionary representation of the class.
|
|
113
|
+
"""
|
|
114
|
+
# get base class result.
|
|
115
|
+
resultBase:dict = super().ToDictionary()
|
|
116
|
+
|
|
117
|
+
followers:dict = {}
|
|
118
|
+
if self._Followers is not None:
|
|
119
|
+
followers = self._Followers.ToDictionary()
|
|
120
|
+
|
|
121
|
+
result:dict = \
|
|
122
|
+
{
|
|
123
|
+
'followers': followers,
|
|
124
|
+
'genres': [ item for item in self._Genres ],
|
|
125
|
+
'image_url': self.ImageUrl,
|
|
126
|
+
'images': [ item.ToDictionary() for item in self._Images ],
|
|
127
|
+
'popularity': self._Popularity
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# combine base class results with these results.
|
|
131
|
+
resultBase.update(result)
|
|
132
|
+
|
|
133
|
+
# return a sorted dictionary.
|
|
134
|
+
return dict(sorted(resultBase.items()))
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
def ToString(self) -> str:
|
|
138
|
+
"""
|
|
139
|
+
Returns a displayable string representation of the class.
|
|
140
|
+
"""
|
|
141
|
+
msg:str = 'Artist: %s' % super().ToString(False)
|
|
142
|
+
#if self._Followers is not None: msg = '%s\n %s' % (msg, str(self._Followers))
|
|
143
|
+
if self._Genres is not None: msg = '%s\n Genres Count=%s' % (msg, str(len(self._Genres)))
|
|
144
|
+
if self._Images is not None: msg = '%s\n Images Count=%s' % (msg, str(len(self._Images)))
|
|
145
|
+
if self._Popularity is not None: msg = '%s\n Popularity="%s"' % (msg, str(self._Popularity))
|
|
146
|
+
return msg
|