spotifywebapiPython 1.0.43__py3-none-any.whl → 1.0.45__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.

Potentially problematic release.


This version of spotifywebapiPython might be problematic. Click here for more details.

Files changed (33) hide show
  1. {spotifywebapiPython-1.0.43.dist-info → spotifywebapiPython-1.0.45.dist-info}/METADATA +1 -1
  2. {spotifywebapiPython-1.0.43.dist-info → spotifywebapiPython-1.0.45.dist-info}/RECORD +33 -26
  3. spotifywebapipython/const.py +1 -1
  4. spotifywebapipython/docs/__init__.html +23 -2
  5. spotifywebapipython/docs/index.html +2 -2
  6. spotifywebapipython/docs/search.js +1 -1
  7. spotifywebapipython/docs/spotifywebapiPython/const.html +3 -3
  8. spotifywebapipython/docs/spotifywebapiPython/saappmessages.html +2 -2
  9. spotifywebapipython/docs/spotifywebapiPython/sautils.html +2 -2
  10. spotifywebapipython/docs/spotifywebapiPython/spotifyapierror.html +2 -2
  11. spotifywebapipython/docs/spotifywebapiPython/spotifyapimessage.html +2 -2
  12. spotifywebapipython/docs/spotifywebapiPython/spotifyauthtoken.html +2 -2
  13. spotifywebapipython/docs/spotifywebapiPython/spotifyclient.html +200 -2
  14. spotifywebapipython/docs/spotifywebapiPython/spotifydiscovery.html +45 -2
  15. spotifywebapipython/docs/spotifywebapiPython/spotifywebapiauthenticationerror.html +2 -2
  16. spotifywebapipython/docs/spotifywebapiPython/spotifywebapierror.html +2 -2
  17. spotifywebapipython/models/__init__.py +14 -0
  18. spotifywebapipython/models/playlist.py +4 -1
  19. spotifywebapipython/models/playlistsimplified.py +4 -1
  20. spotifywebapipython/models/playlisttracksummary.py +3 -1
  21. spotifywebapipython/models/searchresponse.py +1 -1
  22. spotifywebapipython/models/zeroconfblobbuilder.py +144 -0
  23. spotifywebapipython/models/zeroconfdiscoveryresult.py +451 -0
  24. spotifywebapipython/models/zeroconfgetinfo.py +359 -0
  25. spotifywebapipython/models/zeroconfgetinfoalias.py +96 -0
  26. spotifywebapipython/models/zeroconfgetinfodrmmediaformat.py +90 -0
  27. spotifywebapipython/models/zeroconfproperty.py +93 -0
  28. spotifywebapipython/models/zeroconfresponse.py +108 -0
  29. spotifywebapipython/spotifyclient.py +293 -3
  30. spotifywebapipython/spotifydiscovery.py +98 -11
  31. {spotifywebapiPython-1.0.43.dist-info → spotifywebapiPython-1.0.45.dist-info}/LICENSE +0 -0
  32. {spotifywebapiPython-1.0.43.dist-info → spotifywebapiPython-1.0.45.dist-info}/WHEEL +0 -0
  33. {spotifywebapiPython-1.0.43.dist-info → spotifywebapiPython-1.0.45.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,451 @@
1
+ # external package imports.
2
+ from zeroconf import ServiceInfo
3
+
4
+ # our package imports.
5
+ from ..sautils import export
6
+ from .zeroconfproperty import ZeroconfProperty
7
+
8
+ @export
9
+ class ZeroconfDiscoveryResult:
10
+ """
11
+ Zeroconf Discovery Result object.
12
+
13
+ Information about the Zeroconf entry for a SpotifyConnect device as found by Zeroconf (mDNS).
14
+ """
15
+
16
+ def __init__(self) -> 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._DeviceName:str = None
26
+ self._Domain:str = '.'
27
+ self._HostIpv4Address:str = None
28
+ self._HostIpPort:int = None
29
+ self._HostTTL:int = None
30
+ self._Key:str = None
31
+ self._Name:str = None
32
+ self._OtherTTL:int = None
33
+ self._Priority:int = None
34
+ self._Properties:list = []
35
+ self._Server:str = None
36
+ self._ServerKey:str = None
37
+ self._ServiceInfo:ServiceInfo = None
38
+ self._ServiceType:str = None
39
+ self._Weight:int = None
40
+
41
+ # Spotify Connect specific properties:
42
+ self._SpotifyConnectCPath:str = None
43
+ self._SpotifyConnectVersion:str = None
44
+ self._SpotifyConnectIsInDeviceList:bool = False
45
+
46
+
47
+ def __repr__(self) -> str:
48
+ return self.ToString()
49
+
50
+
51
+ def __str__(self) -> str:
52
+ return self.ToString()
53
+
54
+
55
+ @property
56
+ def DeviceName(self) -> str:
57
+ """
58
+ Device name (e.g. "Bose-ST10-1").
59
+ """
60
+ return self._DeviceName
61
+
62
+ @DeviceName.setter
63
+ def DeviceName(self, value:str):
64
+ """
65
+ Sets the DeviceName property value.
66
+ """
67
+ if isinstance(value, str):
68
+ self._DeviceName = value
69
+
70
+
71
+ @property
72
+ def Domain(self) -> str:
73
+ """
74
+ Domain on which the service is located, which should match the one passed in during the query (e.g. "local.").
75
+ """
76
+ return self._Domain
77
+
78
+ @Domain.setter
79
+ def Domain(self, value:str):
80
+ """
81
+ Sets the Domain property value.
82
+ """
83
+ if isinstance(value, str):
84
+ self._Domain = value
85
+
86
+
87
+ @property
88
+ def HostIpv4Address(self) -> str:
89
+ """
90
+ IPV4 address (as a string) at which the host can be reached (e.g. "192.168.1.81").
91
+ """
92
+ return self._HostIpv4Address
93
+
94
+ @HostIpv4Address.setter
95
+ def HostIpv4Address(self, value:str):
96
+ """
97
+ Sets the HostIpv4Address property value.
98
+ """
99
+ if isinstance(value, str):
100
+ self._HostIpv4Address = value
101
+
102
+
103
+ @property
104
+ def HostIpPort(self) -> int:
105
+ """
106
+ Port number (as an integer) for the service on the host (e.g. 8080).
107
+ """
108
+ return self._HostIpPort
109
+
110
+ @HostIpPort.setter
111
+ def HostIpPort(self, value:int):
112
+ """
113
+ Sets the HostIpPort property value.
114
+ """
115
+ if isinstance(value, int):
116
+ self._HostIpPort = value
117
+
118
+
119
+ @property
120
+ def HostTTL(self) -> int:
121
+ """
122
+ Host Time-To-Live value (as an integer) for the service on the host (e.g. 1200).
123
+ """
124
+ return self._HostTTL
125
+
126
+ @HostTTL.setter
127
+ def HostTTL(self, value:int):
128
+ """
129
+ Sets the HostTTL property value.
130
+ """
131
+ if isinstance(value, int):
132
+ self._HostTTL = value
133
+
134
+
135
+ @property
136
+ def Key(self) -> str:
137
+ """
138
+ Service key (e.g. "bose-st10-2._spotify-connect._tcp.local.").
139
+ """
140
+ return self._Key
141
+
142
+ @Key.setter
143
+ def Key(self, value:str):
144
+ """
145
+ Sets the Key property value.
146
+ """
147
+ if isinstance(value, str):
148
+ self._Key = value
149
+
150
+
151
+ @property
152
+ def Name(self) -> str:
153
+ """
154
+ Service name (e.g. "Bose-ST10-2._spotify-connect._tcp.local.").
155
+ """
156
+ return self._Name
157
+
158
+ @Name.setter
159
+ def Name(self, value:str):
160
+ """
161
+ Sets the Name property value.
162
+ """
163
+ if isinstance(value, str):
164
+ self._Name = value
165
+
166
+
167
+ @property
168
+ def Priority(self) -> int:
169
+ """
170
+ Priority value (as an integer) for the service on the host (e.g. 0).
171
+ """
172
+ return self._Priority
173
+
174
+ @Priority.setter
175
+ def Priority(self, value:int):
176
+ """
177
+ Sets the Priority property value.
178
+ """
179
+ if isinstance(value, int):
180
+ self._Priority = value
181
+
182
+
183
+ @property
184
+ def OtherTTL(self) -> int:
185
+ """
186
+ Other Time-To-Live value (as an integer) for the service on the host (e.g. 5400).
187
+ """
188
+ return self._OtherTTL
189
+
190
+ @OtherTTL.setter
191
+ def OtherTTL(self, value:int):
192
+ """
193
+ Sets the OtherTTL property value.
194
+ """
195
+ if isinstance(value, int):
196
+ self._OtherTTL = value
197
+
198
+
199
+ @property
200
+ def Properties(self) -> list[ZeroconfProperty]:
201
+ """
202
+ Discovered properties.
203
+ """
204
+ return self._Properties
205
+
206
+
207
+ @property
208
+ def Server(self) -> str:
209
+ """
210
+ Server name (e.g. "Bose-SM2-341513fbeeae.local.").
211
+ """
212
+ return self._Server
213
+
214
+ @Server.setter
215
+ def Server(self, value:str):
216
+ """
217
+ Sets the Server property value.
218
+ """
219
+ if isinstance(value, str):
220
+ self._Server = value
221
+
222
+
223
+ @property
224
+ def ServerKey(self) -> str:
225
+ """
226
+ Server key (e.g. "bose-sm2-341513fbeeae.local.").
227
+ """
228
+ return self._ServerKey
229
+
230
+ @ServerKey.setter
231
+ def ServerKey(self, value:str):
232
+ """
233
+ Sets the ServerKey property value.
234
+ """
235
+ if isinstance(value, str):
236
+ self._ServerKey = value
237
+
238
+
239
+ @property
240
+ def ServiceInfo(self) -> ServiceInfo:
241
+ """
242
+ Zeroconf Service info object.
243
+ """
244
+ return self._ServiceInfo
245
+
246
+ @ServiceInfo.setter
247
+ def ServiceInfo(self, value:ServiceInfo):
248
+ """
249
+ Sets the ServiceInfo property value.
250
+ """
251
+ if isinstance(value, ServiceInfo):
252
+ self._ServiceInfo = value
253
+
254
+
255
+ @property
256
+ def ServiceType(self) -> str:
257
+ """
258
+ Service type, which should match the one passed in during the query name (e.g. "_spotify-connect._tcp.").
259
+ """
260
+ return self._ServiceType
261
+
262
+ @ServiceType.setter
263
+ def ServiceType(self, value:str):
264
+ """
265
+ Sets the ServiceType property value.
266
+ """
267
+ if isinstance(value, str):
268
+ self._ServiceType = value
269
+
270
+
271
+ @property
272
+ def Weight(self) -> int:
273
+ """
274
+ Weight value (as an integer) for the service on the host (e.g. 0).
275
+ """
276
+ return self._Weight
277
+
278
+ @Weight.setter
279
+ def Weight(self, value:int):
280
+ """
281
+ Sets the Weight property value.
282
+ """
283
+ if isinstance(value, int):
284
+ self._Weight = value
285
+
286
+ # *****************************************************************************
287
+ # The following are Spotify Connect specific properties.
288
+ # *****************************************************************************
289
+
290
+ @property
291
+ def SpotifyConnectCPath(self) -> str:
292
+ """
293
+ Spotify Connect CPath property value (e.g. "/zc").
294
+ """
295
+ return self._SpotifyConnectCPath
296
+
297
+ @SpotifyConnectCPath.setter
298
+ def SpotifyConnectCPath(self, value:str):
299
+ """
300
+ Sets the SpotifyConnectCPath property value.
301
+ """
302
+ if isinstance(value, str):
303
+ self._SpotifyConnectCPath = value
304
+
305
+
306
+ @property
307
+ def SpotifyConnectIsInDeviceList(self) -> bool:
308
+ """
309
+ Spotify Connect SpotifyConnectIsInDeviceList property value (e.g. "/zc").
310
+ """
311
+ return self._SpotifyConnectIsInDeviceList
312
+
313
+ @SpotifyConnectIsInDeviceList.setter
314
+ def SpotifyConnectIsInDeviceList(self, value:bool):
315
+ """
316
+ Sets the SpotifyConnectIsInDeviceList property value.
317
+ """
318
+ if isinstance(value, bool):
319
+ self._SpotifyConnectIsInDeviceList = value
320
+
321
+
322
+ @property
323
+ def SpotifyConnectVersion(self) -> str:
324
+ """
325
+ Spotify Connect Version property value (e.g. "1.0").
326
+
327
+ """
328
+ return self._SpotifyConnectVersion
329
+
330
+ @SpotifyConnectVersion.setter
331
+ def SpotifyConnectVersion(self, value:str):
332
+ """
333
+ Sets the SpotifyConnectVersion property value.
334
+ """
335
+ if isinstance(value, str):
336
+ self._SpotifyConnectVersion = value
337
+
338
+
339
+ @property
340
+ def ZeroconfApiEndpointAddUser(self) -> str:
341
+ """
342
+ Zeroconf API endpoint to add a user to a Spotify Connect device (e.g. "http://192.168.1.81:8200/zc?action=addUser&version=2.10.0").
343
+ """
344
+ return self.GetEndpointUrl('addUser')
345
+
346
+
347
+ @property
348
+ def ZeroconfApiEndpointGetInformation(self) -> str:
349
+ """
350
+ Zeroconf API endpoint to retrieve device information for a Spotify Connect device (e.g. "http://192.168.1.81:8200/zc?action=getInfo&version=2.10.0").
351
+ """
352
+ return self.GetEndpointUrl('getInfo')
353
+
354
+
355
+ @property
356
+ def ZeroconfApiEndpointResetUsers(self) -> str:
357
+ """
358
+ Zeroconf API endpoint to reset users (e.g. Logoff) currently active on a Spotify Connect device (e.g. "http://192.168.1.81:8200/zc?action=resetUsers&version=2.10.0").
359
+ """
360
+ return self.GetEndpointUrl('resetUsers')
361
+
362
+
363
+ def GetEndpointUrl(self, action:str) -> str:
364
+ """
365
+ Gets a Spotify Zeroconf API endpoint url for the specified action key.
366
+
367
+ Args:
368
+ action (str):
369
+ Spotify Zeroconf endpoint action to formulate (e.g. 'getInfo', 'addUser', 'resetUsers', etc).
370
+
371
+ Returns:
372
+ A string containing the endpoint url for the specified action key.
373
+ """
374
+ return "http://{ip}:{port}{cpath}?action={action}&version={version}".format(
375
+ ip=self.HostIpv4Address,
376
+ port=self.HostIpPort,
377
+ cpath=self.SpotifyConnectCPath,
378
+ action=action,
379
+ version=self.SpotifyConnectVersion
380
+ )
381
+
382
+
383
+ def ToDictionary(self) -> dict:
384
+ """
385
+ Returns a dictionary representation of the class.
386
+ """
387
+ result:dict = \
388
+ {
389
+ 'DeviceName': self._DeviceName,
390
+ 'Domain': self._Domain,
391
+ 'HostIpv4Address': self._HostIpv4Address,
392
+ 'HostIpPort': self._HostIpPort,
393
+ 'HostTTL': self._HostTTL,
394
+ 'Key': self._Key,
395
+ 'Name': self._Name,
396
+ 'Priority': self._Priority,
397
+ 'OtherTTL': self._OtherTTL,
398
+ 'Server': self._Server,
399
+ 'ServerKey': self._ServerKey,
400
+ 'ServiceType': self._ServiceType,
401
+ 'Weight': self._Weight,
402
+ 'Properties': [ item.ToDictionary() for item in self._Properties ],
403
+ 'SpotifyConnectCPath': self._SpotifyConnectCPath,
404
+ 'SpotifyConnectIsInDeviceList': self._SpotifyConnectIsInDeviceList,
405
+ 'SpotifyConnectVersion': self._SpotifyConnectVersion,
406
+ 'ZeroconfApiEndpointAddUser': self.ZeroconfApiEndpointAddUser,
407
+ 'ZeroconfApiEndpointGetInformation': self.ZeroconfApiEndpointGetInformation,
408
+ 'ZeroconfApiEndpointResetUsers': self.ZeroconfApiEndpointResetUsers,
409
+ }
410
+ return result
411
+
412
+
413
+ def ToString(self, includeTitle:bool=True) -> str:
414
+ """
415
+ Returns a displayable string representation of the class.
416
+
417
+ Args:
418
+ includeTitle (str):
419
+ True to include the class name title prefix.
420
+ """
421
+ msg:str = ''
422
+ if includeTitle:
423
+ msg = 'ZeroconfDiscoveryResult:'
424
+
425
+ # get zeroconf api endpoint properties, as they are dynamically generated.
426
+ zeroconfApiEndpointAddUser:str = self.ZeroconfApiEndpointAddUser
427
+ zeroconfApiEndpointGetInformation:str = self.ZeroconfApiEndpointGetInformation
428
+ zeroconfApiEndpointResetUsers:str = self.ZeroconfApiEndpointResetUsers
429
+
430
+ # build result.
431
+ if self._DeviceName is not None: msg = '%s\n DeviceName="%s"' % (msg, str(self._DeviceName))
432
+ if self._Domain is not None: msg = '%s\n Domain="%s"' % (msg, str(self._Domain))
433
+ if self._HostIpv4Address is not None: msg = '%s\n HostIpv4Address="%s"' % (msg, str(self._HostIpv4Address))
434
+ if self._HostIpPort is not None: msg = '%s\n HostIpPort="%s"' % (msg, str(self._HostIpPort))
435
+ if self._HostTTL is not None: msg = '%s\n HostTTL="%s"' % (msg, str(self._HostTTL))
436
+ if self._Key is not None: msg = '%s\n Key="%s"' % (msg, str(self._Key))
437
+ if self._Name is not None: msg = '%s\n Name="%s"' % (msg, str(self._Name))
438
+ if self._Priority is not None: msg = '%s\n Priority="%s"' % (msg, str(self._Priority))
439
+ if self._OtherTTL is not None: msg = '%s\n OtherTTL="%s"' % (msg, str(self._OtherTTL))
440
+ if self._Server is not None: msg = '%s\n Server="%s"' % (msg, str(self._Server))
441
+ if self._ServerKey is not None: msg = '%s\n ServerKey="%s"' % (msg, str(self._ServerKey))
442
+ if self._ServiceType is not None: msg = '%s\n ServiceType="%s"' % (msg, str(self._ServiceType))
443
+ if self._Weight is not None: msg = '%s\n Weight="%s"' % (msg, str(self._Weight))
444
+ if self._Properties is not None: msg = '%s\n Properties Count=%s' % (msg, str(len(self._Properties)))
445
+ if self._SpotifyConnectCPath is not None: msg = '%s\n SpotifyConnectCPath="%s"' % (msg, str(self._SpotifyConnectCPath))
446
+ if self._SpotifyConnectIsInDeviceList is not None: msg = '%s\n SpotifyConnectIsInDeviceList="%s"' % (msg, str(self._SpotifyConnectIsInDeviceList))
447
+ if self._SpotifyConnectVersion is not None: msg = '%s\n SpotifyConnectVersion="%s"' % (msg, str(self._SpotifyConnectVersion))
448
+ if zeroconfApiEndpointAddUser is not None: msg = '%s\n ZeroconfApiEndpointAddUser="%s"' % (msg, zeroconfApiEndpointAddUser)
449
+ if zeroconfApiEndpointGetInformation is not None: msg = '%s\n ZeroconfApiEndpointGetInformation="%s"' % (msg, zeroconfApiEndpointGetInformation)
450
+ if zeroconfApiEndpointResetUsers is not None: msg = '%s\n ZeroconfApiEndpointResetUsers="%s"' % (msg, zeroconfApiEndpointResetUsers)
451
+ return msg