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,320 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .copyright import Copyright
|
|
6
|
+
from .externalurls import ExternalUrls
|
|
7
|
+
from .imageobject import ImageObject
|
|
8
|
+
|
|
9
|
+
@export
|
|
10
|
+
class ShowSimplified:
|
|
11
|
+
"""
|
|
12
|
+
Spotify Web API SimplifiedShow 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
|
+
self._AvailableMarkets:list[str] = []
|
|
25
|
+
self._Copyrights:list[Copyright] = []
|
|
26
|
+
self._Description:str = None
|
|
27
|
+
self._Explicit:bool = None
|
|
28
|
+
self._ExternalUrls:ExternalUrls = None
|
|
29
|
+
self._Href:str = None
|
|
30
|
+
self._HtmlDescription:str = None
|
|
31
|
+
self._Id:int = None
|
|
32
|
+
self._Images:list[ImageObject] = []
|
|
33
|
+
self._IsExternallyHosted:bool = None
|
|
34
|
+
self._Languages:list[str] = []
|
|
35
|
+
self._MediaType:str = None
|
|
36
|
+
self._Name:str = None
|
|
37
|
+
self._Publisher:str = None
|
|
38
|
+
self._TotalEpisodes:int = None
|
|
39
|
+
self._Type:str = None
|
|
40
|
+
self._Uri:str = None
|
|
41
|
+
|
|
42
|
+
if (root is None):
|
|
43
|
+
|
|
44
|
+
pass
|
|
45
|
+
|
|
46
|
+
else:
|
|
47
|
+
|
|
48
|
+
self._AvailableMarkets = root.get('available_markets', None) or []
|
|
49
|
+
self._Description = root.get('description', None)
|
|
50
|
+
self._Explicit = root.get('explicit', None)
|
|
51
|
+
self._Href = root.get('href', None)
|
|
52
|
+
self._HtmlDescription = root.get('html_description', None)
|
|
53
|
+
self._Id = root.get('id', None)
|
|
54
|
+
self._IsExternallyHosted = root.get('is_externally_hosted', None)
|
|
55
|
+
self._Languages = root.get('languages', None) or []
|
|
56
|
+
self._MediaType = root.get('media_type', None)
|
|
57
|
+
self._Name = root.get('name', None)
|
|
58
|
+
self._Publisher = root.get('publisher', None)
|
|
59
|
+
self._TotalEpisodes = root.get('total_episodes', None)
|
|
60
|
+
self._Type = root.get('type', None)
|
|
61
|
+
self._Uri = root.get('uri', None)
|
|
62
|
+
|
|
63
|
+
# process all collections and objects.
|
|
64
|
+
items:list = root.get('copyrights',None)
|
|
65
|
+
if items is not None:
|
|
66
|
+
for item in items:
|
|
67
|
+
self._Copyrights.append(Copyright(root=item))
|
|
68
|
+
|
|
69
|
+
item:dict = root.get('external_urls',None)
|
|
70
|
+
if item is not None:
|
|
71
|
+
self._ExternalUrls = ExternalUrls(root=item)
|
|
72
|
+
|
|
73
|
+
items:list = root.get('images',None)
|
|
74
|
+
if items is not None:
|
|
75
|
+
for item in items:
|
|
76
|
+
self._Images.append(ImageObject(root=item))
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def __repr__(self) -> str:
|
|
80
|
+
return self.ToString()
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def __str__(self) -> str:
|
|
84
|
+
return self.ToString()
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
# implement sorting support.
|
|
88
|
+
def __eq__(self, other):
|
|
89
|
+
try:
|
|
90
|
+
return self.Name == other.Name
|
|
91
|
+
except Exception:
|
|
92
|
+
if (isinstance(self, ShowSimplified )) and (isinstance(other, ShowSimplified )):
|
|
93
|
+
return self.Name == other.Name
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
def __lt__(self, other):
|
|
97
|
+
try:
|
|
98
|
+
return self.Name < other.Name
|
|
99
|
+
except Exception:
|
|
100
|
+
if (isinstance(self, ShowSimplified )) and (isinstance(other, ShowSimplified )):
|
|
101
|
+
return self.Name < other.Name
|
|
102
|
+
return False
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
@property
|
|
106
|
+
def AvailableMarkets(self) -> list[str]:
|
|
107
|
+
"""
|
|
108
|
+
A list of the countries in which the show can be played, identified by their ISO 3166-1 alpha-2 code.
|
|
109
|
+
"""
|
|
110
|
+
return self._AvailableMarkets
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
@property
|
|
114
|
+
def Copyrights(self) -> list[Copyright]:
|
|
115
|
+
"""
|
|
116
|
+
The copyright statements of the show.
|
|
117
|
+
"""
|
|
118
|
+
return self._Copyrights
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
@property
|
|
122
|
+
def Description(self) -> str:
|
|
123
|
+
"""
|
|
124
|
+
A description of the show.
|
|
125
|
+
HTML tags are stripped away from this field, use `HtmlDescription` property in case HTML tags are needed.
|
|
126
|
+
"""
|
|
127
|
+
return self._Description
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
@property
|
|
131
|
+
def Explicit(self) -> bool:
|
|
132
|
+
"""
|
|
133
|
+
Whether or not the show has explicit content (true = yes it does; false = no it does not OR unknown).
|
|
134
|
+
"""
|
|
135
|
+
return self._Explicit
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@property
|
|
139
|
+
def ExternalUrls(self) -> ExternalUrls:
|
|
140
|
+
"""
|
|
141
|
+
Known external URLs for the show.
|
|
142
|
+
"""
|
|
143
|
+
return self._ExternalUrls
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
@property
|
|
147
|
+
def Href(self) -> str:
|
|
148
|
+
"""
|
|
149
|
+
A link to the Web API endpoint providing full details of the show.
|
|
150
|
+
Example: `https://api.spotify.com/v1/shows/3IM0lmZxpFAY7CwMuv9H4g?locale=en-US%2Cen%3Bq%3D0.9`
|
|
151
|
+
"""
|
|
152
|
+
return self._Href
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
@property
|
|
156
|
+
def HtmlDescription(self) -> str:
|
|
157
|
+
"""
|
|
158
|
+
A description of the show.
|
|
159
|
+
This field may contain HTML tags.
|
|
160
|
+
"""
|
|
161
|
+
return self._HtmlDescription
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
@property
|
|
165
|
+
def Id(self) -> str:
|
|
166
|
+
"""
|
|
167
|
+
The Spotify ID for the show.
|
|
168
|
+
Example: `3IM0lmZxpFAY7CwMuv9H4g`
|
|
169
|
+
"""
|
|
170
|
+
return self._Id
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
@property
|
|
174
|
+
def Images(self) -> list[ImageObject]:
|
|
175
|
+
"""
|
|
176
|
+
The cover art for the show in various sizes, widest first.
|
|
177
|
+
"""
|
|
178
|
+
return self._Images
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
@property
|
|
182
|
+
def ImageUrl(self) -> str:
|
|
183
|
+
"""
|
|
184
|
+
Gets the first image url in the `Images` list, if images are defined;
|
|
185
|
+
otherwise, null.
|
|
186
|
+
"""
|
|
187
|
+
return ImageObject.GetImageHighestResolution(self._Images)
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
@property
|
|
191
|
+
def IsExternallyHosted(self) -> bool:
|
|
192
|
+
"""
|
|
193
|
+
True if all of the shows episodes are hosted outside of Spotify's CDN.
|
|
194
|
+
This field might be null in some cases.
|
|
195
|
+
"""
|
|
196
|
+
return self._IsExternallyHosted
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
@property
|
|
200
|
+
def Languages(self) -> list[str]:
|
|
201
|
+
"""
|
|
202
|
+
A list of the languages used in the show, identified by their ISO 639-1 code.
|
|
203
|
+
|
|
204
|
+
Example: `[fr,en]`
|
|
205
|
+
"""
|
|
206
|
+
return self._Languages
|
|
207
|
+
|
|
208
|
+
|
|
209
|
+
@property
|
|
210
|
+
def MediaType(self) -> str:
|
|
211
|
+
"""
|
|
212
|
+
The media type of the show.
|
|
213
|
+
|
|
214
|
+
Example: `audio`
|
|
215
|
+
"""
|
|
216
|
+
return self._MediaType
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
@property
|
|
220
|
+
def Name(self) -> str:
|
|
221
|
+
"""
|
|
222
|
+
The name of the show.
|
|
223
|
+
"""
|
|
224
|
+
return self._Name
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@property
|
|
228
|
+
def Publisher(self) -> str:
|
|
229
|
+
"""
|
|
230
|
+
The publisher of the show.
|
|
231
|
+
"""
|
|
232
|
+
return self._Publisher
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
@property
|
|
236
|
+
def TotalEpisodes(self) -> int:
|
|
237
|
+
"""
|
|
238
|
+
The total number of episodes in the show.
|
|
239
|
+
"""
|
|
240
|
+
return self._TotalEpisodes
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
@property
|
|
244
|
+
def Type(self) -> str:
|
|
245
|
+
"""
|
|
246
|
+
The object type: `show`.
|
|
247
|
+
"""
|
|
248
|
+
return self._Type
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
@property
|
|
252
|
+
def Uri(self) -> str:
|
|
253
|
+
"""
|
|
254
|
+
The Spotify URI for the show.
|
|
255
|
+
"""
|
|
256
|
+
return self._Uri
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def ToDictionary(self) -> dict:
|
|
260
|
+
"""
|
|
261
|
+
Returns a dictionary representation of the class.
|
|
262
|
+
"""
|
|
263
|
+
externalUrls:dict = {}
|
|
264
|
+
if self._ExternalUrls is not None:
|
|
265
|
+
externalUrls = self._ExternalUrls.ToDictionary()
|
|
266
|
+
|
|
267
|
+
result:dict = \
|
|
268
|
+
{
|
|
269
|
+
'available_markets': [ item for item in self._AvailableMarkets ],
|
|
270
|
+
'copyrights': [ item.ToDictionary() for item in self._Copyrights ],
|
|
271
|
+
'description': self._Description,
|
|
272
|
+
'explicit': self._Explicit,
|
|
273
|
+
'external_urls': externalUrls,
|
|
274
|
+
'href': self._Href,
|
|
275
|
+
'html_description': self._HtmlDescription,
|
|
276
|
+
'id': self._Id,
|
|
277
|
+
'image_url': self.ImageUrl,
|
|
278
|
+
'images': [ item.ToDictionary() for item in self._Images ],
|
|
279
|
+
'is_externally_hosted': self._IsExternallyHosted,
|
|
280
|
+
'languages': [ item for item in self._Languages ],
|
|
281
|
+
'media_type': self._MediaType,
|
|
282
|
+
'name': self._Name,
|
|
283
|
+
'publisher': self._Publisher,
|
|
284
|
+
'total_episodes': self._TotalEpisodes,
|
|
285
|
+
'type': self._Type,
|
|
286
|
+
'uri': self._Uri,
|
|
287
|
+
}
|
|
288
|
+
return result
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def ToString(self, includeTitle:bool=True) -> str:
|
|
292
|
+
"""
|
|
293
|
+
Returns a displayable string representation of the class.
|
|
294
|
+
|
|
295
|
+
Args:
|
|
296
|
+
includeTitle (str):
|
|
297
|
+
True to include the class name title prefix.
|
|
298
|
+
"""
|
|
299
|
+
msg:str = ''
|
|
300
|
+
if includeTitle:
|
|
301
|
+
msg = 'ShowSimplified:'
|
|
302
|
+
|
|
303
|
+
if self._Name is not None: msg = '%s\n Name="%s"' % (msg, str(self._Name))
|
|
304
|
+
if self._Uri is not None: msg = '%s\n Uri="%s"' % (msg, str(self._Uri))
|
|
305
|
+
if self._AvailableMarkets is not None: msg = '%s\n AvailableMarkets Count=%s' % (msg, str(len(self._AvailableMarkets)))
|
|
306
|
+
#if self._Copyrights is not None: msg = '%s\n %s' % (msg, str(self._Copyrights))
|
|
307
|
+
if self._Description is not None: msg = '%s\n Description="%s"' % (msg, str(self._Description))
|
|
308
|
+
if self._Explicit is not None: msg = '%s\n Explicit="%s"' % (msg, str(self._Explicit))
|
|
309
|
+
#if self._ExternalUrls is not None: msg = '%s\n %s' % (msg, str(self._ExternalUrls))
|
|
310
|
+
if self._Href is not None: msg = '%s\n Href="%s"' % (msg, str(self._Href))
|
|
311
|
+
if self._HtmlDescription is not None: msg = '%s\n HtmlDescription="%s"' % (msg, str(self._HtmlDescription))
|
|
312
|
+
if self._Id is not None: msg = '%s\n Id="%s"' % (msg, str(self._Id))
|
|
313
|
+
if self._Images is not None: msg = '%s\n Images Count=%s' % (msg, str(len(self._Images)))
|
|
314
|
+
if self._IsExternallyHosted is not None: msg = '%s\n IsExternallyHosted="%s"' % (msg, str(self._IsExternallyHosted))
|
|
315
|
+
if self._Languages is not None: msg = '%s\n Languages="%s"' % (msg, str(self._Languages))
|
|
316
|
+
if self._MediaType is not None: msg = '%s\n MediaType="%s"' % (msg, str(self._MediaType))
|
|
317
|
+
if self._Publisher is not None: msg = '%s\n Publisher="%s"' % (msg, str(self._Publisher))
|
|
318
|
+
if self._TotalEpisodes is not None: msg = '%s\n TotalEpisodes="%s"' % (msg, str(self._TotalEpisodes))
|
|
319
|
+
if self._Type is not None: msg = '%s\n Type="%s"' % (msg, str(self._Type))
|
|
320
|
+
return msg
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .zeroconfdiscoveryresult import ZeroconfDiscoveryResult
|
|
6
|
+
from spotifywebapipython.zeroconfapi import ZeroconfGetInfo, ZeroconfResponse
|
|
7
|
+
|
|
8
|
+
@export
|
|
9
|
+
class SpotifyConnectDevice():
|
|
10
|
+
"""
|
|
11
|
+
Spotify Connect Device object.
|
|
12
|
+
|
|
13
|
+
Information about the Spotify Connect device, which is a combination of the
|
|
14
|
+
`ZeroconfDiscoveryResult` and `ZeroconfGetInfo` classes.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(self) -> None:
|
|
18
|
+
"""
|
|
19
|
+
Initializes a new instance of the class.
|
|
20
|
+
"""
|
|
21
|
+
self._DeviceIdActivated:str = None
|
|
22
|
+
self._DiscoveryResult:ZeroconfDiscoveryResult = None
|
|
23
|
+
self._DeviceInfo:ZeroconfGetInfo = None
|
|
24
|
+
self._Id:str = None
|
|
25
|
+
self._IsActiveDevice:bool = False
|
|
26
|
+
self._IsInDeviceList:bool = False
|
|
27
|
+
self._IsRestricted:bool = False
|
|
28
|
+
self._Name:str = None
|
|
29
|
+
self._ZeroconfResponseInfo:ZeroconfResponse = ZeroconfResponse()
|
|
30
|
+
self._WasReConnected:bool = False
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def __repr__(self) -> str:
|
|
34
|
+
return self.ToString()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def __str__(self) -> str:
|
|
38
|
+
return self.ToString()
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def DeviceIdActivated(self) -> str:
|
|
43
|
+
"""
|
|
44
|
+
Google Cast device id value (e.g. "30fbc80e35598f3c242f2120413c943dfd9715fe")
|
|
45
|
+
that was activated by the Spotify Cast App;
|
|
46
|
+
Otherwise, None if the device has not been activated yet.
|
|
47
|
+
|
|
48
|
+
This value can be different from the `Id` value for cast groups that send connect
|
|
49
|
+
commands to the group coordinator instead of the group itself.
|
|
50
|
+
|
|
51
|
+
It is only populated by Google Cast processing; Spotify Connect Zeroconf does not
|
|
52
|
+
populate this property.
|
|
53
|
+
"""
|
|
54
|
+
return self._DeviceIdActivated
|
|
55
|
+
|
|
56
|
+
@DeviceIdActivated.setter
|
|
57
|
+
def DeviceIdActivated(self, value:str):
|
|
58
|
+
"""
|
|
59
|
+
Sets the DeviceIdActivated property value.
|
|
60
|
+
"""
|
|
61
|
+
self._DeviceIdActivated = value
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def DiscoveryResult(self) -> ZeroconfDiscoveryResult:
|
|
66
|
+
"""
|
|
67
|
+
Information about the Zeroconf entry for a SpotifyConnect device as found by Zeroconf (mDNS).
|
|
68
|
+
"""
|
|
69
|
+
return self._DiscoveryResult
|
|
70
|
+
|
|
71
|
+
@DiscoveryResult.setter
|
|
72
|
+
def DiscoveryResult(self, value:ZeroconfDiscoveryResult):
|
|
73
|
+
"""
|
|
74
|
+
Sets the DiscoveryResult property value.
|
|
75
|
+
"""
|
|
76
|
+
if isinstance(value, ZeroconfDiscoveryResult):
|
|
77
|
+
self._DiscoveryResult = value
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
@property
|
|
81
|
+
def DeviceInfo(self) -> ZeroconfGetInfo:
|
|
82
|
+
"""
|
|
83
|
+
Spotify Zeroconf API GetInfo response object.
|
|
84
|
+
"""
|
|
85
|
+
return self._DeviceInfo
|
|
86
|
+
|
|
87
|
+
@DeviceInfo.setter
|
|
88
|
+
def DeviceInfo(self, value:ZeroconfGetInfo):
|
|
89
|
+
"""
|
|
90
|
+
Sets the DeviceInfo property value.
|
|
91
|
+
"""
|
|
92
|
+
if isinstance(value, ZeroconfGetInfo):
|
|
93
|
+
self._DeviceInfo = value
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@property
|
|
97
|
+
def Id(self) -> str:
|
|
98
|
+
"""
|
|
99
|
+
Spotify Connect device id value (e.g. "30fbc80e35598f3c242f2120413c943dfd9715fe").
|
|
100
|
+
"""
|
|
101
|
+
return self._Id
|
|
102
|
+
|
|
103
|
+
@Id.setter
|
|
104
|
+
def Id(self, value:str):
|
|
105
|
+
"""
|
|
106
|
+
Sets the Id property value.
|
|
107
|
+
"""
|
|
108
|
+
self._Id = value
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@property
|
|
112
|
+
def IsActiveDevice(self) -> bool:
|
|
113
|
+
"""
|
|
114
|
+
Returns True if this device is the currently active Spotify Web API player device;
|
|
115
|
+
otherwise, False.
|
|
116
|
+
"""
|
|
117
|
+
return self._IsActiveDevice
|
|
118
|
+
|
|
119
|
+
@IsActiveDevice.setter
|
|
120
|
+
def IsActiveDevice(self, value:bool):
|
|
121
|
+
"""
|
|
122
|
+
Sets the IsActiveDevice property value.
|
|
123
|
+
"""
|
|
124
|
+
if isinstance(value, bool):
|
|
125
|
+
self._IsActiveDevice = value
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@property
|
|
129
|
+
def IsAmazonDevice(self) -> bool:
|
|
130
|
+
"""
|
|
131
|
+
True if the device is an Amazon device; otherwise, False.
|
|
132
|
+
"""
|
|
133
|
+
if (isinstance(self._Id, str)):
|
|
134
|
+
|
|
135
|
+
# simple check for an Amazon-like device id (e.g. "04a02956-eb74-4a98-8bce-e37b21a8aee5_amzn_1").
|
|
136
|
+
value:str = self._Id.lower()
|
|
137
|
+
if (value.find("_amzn_") > -1) and (value.count("-") > 2):
|
|
138
|
+
return True
|
|
139
|
+
|
|
140
|
+
return False
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
@property
|
|
144
|
+
def IsChromeCast(self) -> bool:
|
|
145
|
+
"""
|
|
146
|
+
True if the device is a Google ChromeCast device; otherwise, False.
|
|
147
|
+
"""
|
|
148
|
+
if (self._DiscoveryResult is not None):
|
|
149
|
+
return self._DiscoveryResult.IsChromeCast
|
|
150
|
+
return False
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
@property
|
|
154
|
+
def IsInDeviceList(self) -> bool:
|
|
155
|
+
"""
|
|
156
|
+
Returns True if this device is a member of the Spotify Web API player device list;
|
|
157
|
+
otherwise, False.
|
|
158
|
+
"""
|
|
159
|
+
return self._IsInDeviceList
|
|
160
|
+
|
|
161
|
+
@IsInDeviceList.setter
|
|
162
|
+
def IsInDeviceList(self, value:bool):
|
|
163
|
+
"""
|
|
164
|
+
Sets the IsInDeviceList property value.
|
|
165
|
+
"""
|
|
166
|
+
if isinstance(value, bool):
|
|
167
|
+
self._IsInDeviceList = value
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
@property
|
|
171
|
+
def IsRestricted(self) -> bool:
|
|
172
|
+
"""
|
|
173
|
+
Returns True if this device is a member of the Spotify Web API player device list;
|
|
174
|
+
otherwise, False.
|
|
175
|
+
"""
|
|
176
|
+
return self._IsRestricted
|
|
177
|
+
|
|
178
|
+
@IsRestricted.setter
|
|
179
|
+
def IsRestricted(self, value:bool):
|
|
180
|
+
"""
|
|
181
|
+
Sets the IsRestricted property value.
|
|
182
|
+
"""
|
|
183
|
+
if isinstance(value, bool):
|
|
184
|
+
self._IsRestricted = value
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
@property
|
|
188
|
+
def IsSonos(self) -> bool:
|
|
189
|
+
"""
|
|
190
|
+
True if the device is a Sonos device; otherwise, False.
|
|
191
|
+
"""
|
|
192
|
+
if (self._DeviceInfo is not None):
|
|
193
|
+
return self._DeviceInfo.IsBrandSonos
|
|
194
|
+
return False
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@property
|
|
198
|
+
def Name(self) -> str:
|
|
199
|
+
"""
|
|
200
|
+
Spotify Connect device name value (e.g. "Bose-ST10-1").
|
|
201
|
+
"""
|
|
202
|
+
return self._Name
|
|
203
|
+
|
|
204
|
+
@Name.setter
|
|
205
|
+
def Name(self, value:str):
|
|
206
|
+
"""
|
|
207
|
+
Sets the Name property value.
|
|
208
|
+
"""
|
|
209
|
+
self._Name = value
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@property
|
|
213
|
+
def Title(self) -> str:
|
|
214
|
+
"""
|
|
215
|
+
Spotify Connect device name and id value (e.g. "Bose-ST10-1" (30fbc80e35598f3c242f2120413c943dfd9715fe)).
|
|
216
|
+
"""
|
|
217
|
+
return "\"%s\" (%s)" % (self._Name, self._Id)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
@property
|
|
221
|
+
def WasReConnected(self) -> bool:
|
|
222
|
+
"""
|
|
223
|
+
True if the device was re-connected, after being inactive or disconnected.
|
|
224
|
+
"""
|
|
225
|
+
return self._WasReConnected
|
|
226
|
+
|
|
227
|
+
@WasReConnected.setter
|
|
228
|
+
def WasReConnected(self, value:bool):
|
|
229
|
+
"""
|
|
230
|
+
Sets the WasReConnected property value.
|
|
231
|
+
"""
|
|
232
|
+
self._WasReConnected = value
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
@property
|
|
236
|
+
def ZeroconfResponseInfo(self) -> ZeroconfResponse:
|
|
237
|
+
"""
|
|
238
|
+
Spotify Zeroconf API Zeroconf response object.
|
|
239
|
+
"""
|
|
240
|
+
return self._ZeroconfResponseInfo
|
|
241
|
+
|
|
242
|
+
@ZeroconfResponseInfo.setter
|
|
243
|
+
def ZeroconfResponseInfo(self, value:ZeroconfResponse):
|
|
244
|
+
"""
|
|
245
|
+
Sets the ZeroconfResponseInfo property value.
|
|
246
|
+
"""
|
|
247
|
+
if isinstance(value, ZeroconfResponse):
|
|
248
|
+
self._ZeroconfResponseInfo = value
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def Equals(self, obj) -> bool:
|
|
252
|
+
"""
|
|
253
|
+
Returns true if the specified object instance contains the same argument
|
|
254
|
+
values as our object instance values; otherwise, False.
|
|
255
|
+
|
|
256
|
+
Args:
|
|
257
|
+
obj (SpotifyConnectDevice):
|
|
258
|
+
Object instance to compare.
|
|
259
|
+
"""
|
|
260
|
+
result:bool = False
|
|
261
|
+
if (not isinstance(obj, type(self))):
|
|
262
|
+
return result
|
|
263
|
+
|
|
264
|
+
# compare attributes for equality.
|
|
265
|
+
if (self._Id != obj._Id): return result
|
|
266
|
+
if (self._Name != obj._Name): return result
|
|
267
|
+
if (not self._DeviceInfo.Equals(obj._DeviceInfo)): return result
|
|
268
|
+
if (not self._DiscoveryResult.Equals(obj._DiscoveryResult)): return result
|
|
269
|
+
|
|
270
|
+
# objects attributes are equal.
|
|
271
|
+
return True
|
|
272
|
+
|
|
273
|
+
|
|
274
|
+
def ToDictionary(self) -> dict:
|
|
275
|
+
"""
|
|
276
|
+
Returns a dictionary representation of the class.
|
|
277
|
+
"""
|
|
278
|
+
result:dict = \
|
|
279
|
+
{
|
|
280
|
+
'Id': self._Id,
|
|
281
|
+
'Name': self._Name,
|
|
282
|
+
'Title': self.Title,
|
|
283
|
+
'IsActiveDevice': self._IsActiveDevice,
|
|
284
|
+
'IsChromeCast': self.IsChromeCast,
|
|
285
|
+
'IsInDeviceList': self._IsInDeviceList,
|
|
286
|
+
'IsRestricted': self._IsRestricted,
|
|
287
|
+
'IsSonos': self.IsSonos,
|
|
288
|
+
'WasReConnected': self._WasReConnected,
|
|
289
|
+
'DeviceIdActivated': self._DeviceIdActivated,
|
|
290
|
+
'DeviceInfo': self._DeviceInfo.ToDictionary(),
|
|
291
|
+
'DiscoveryResult': self._DiscoveryResult.ToDictionary(),
|
|
292
|
+
'ZeroconfResponseInfo': self._ZeroconfResponseInfo.ToDictionary(),
|
|
293
|
+
}
|
|
294
|
+
return result
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def ToString(self, includeTitle:bool=True) -> str:
|
|
298
|
+
"""
|
|
299
|
+
Returns a displayable string representation of the class.
|
|
300
|
+
|
|
301
|
+
Args:
|
|
302
|
+
includeTitle (str):
|
|
303
|
+
True to include the class name title prefix.
|
|
304
|
+
"""
|
|
305
|
+
msg:str = ''
|
|
306
|
+
if includeTitle:
|
|
307
|
+
msg = 'Device: "%s" (%s)' % (self._Name, self._Id)
|
|
308
|
+
msg = '%s\n IsActiveDevice="%s"' % (msg, str(self._IsActiveDevice))
|
|
309
|
+
msg = '%s\n IsChromecast="%s"' % (msg, str(self.IsChromeCast))
|
|
310
|
+
msg = '%s\n IsInDeviceList="%s"' % (msg, str(self._IsInDeviceList))
|
|
311
|
+
msg = '%s\n IsRestricted="%s"' % (msg, str(self._IsRestricted))
|
|
312
|
+
msg = '%s\n IsSonos="%s"' % (msg, str(self.IsSonos))
|
|
313
|
+
msg = '%s\n WasReConnected="%s"' % (msg, str(self._WasReConnected))
|
|
314
|
+
msg = '%s\n DeviceIdActivated="%s"' % (msg, str(self._DeviceIdActivated))
|
|
315
|
+
msg = '%s\n' % (msg)
|
|
316
|
+
|
|
317
|
+
# build result.
|
|
318
|
+
msg = '%s\n %s\n' % (msg, str(self._DeviceInfo.ToString(True)))
|
|
319
|
+
msg = '%s\n %s\n' % (msg, str(self._DiscoveryResult.ToString(True)))
|
|
320
|
+
msg = '%s\n %s\n' % (msg, str(self._ZeroconfResponseInfo.ToString(True)))
|
|
321
|
+
return msg
|