spotifywebapiPython 1.0.51__py3-none-any.whl → 1.0.53__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.
- {spotifywebapiPython-1.0.51.dist-info → spotifywebapiPython-1.0.53.dist-info}/METADATA +1 -1
- {spotifywebapiPython-1.0.51.dist-info → spotifywebapiPython-1.0.53.dist-info}/RECORD +26 -26
- spotifywebapipython/const.py +1 -1
- spotifywebapipython/docs/__init__.html +15 -2
- spotifywebapipython/docs/index.html +2 -2
- spotifywebapipython/docs/search.js +1 -1
- spotifywebapipython/docs/spotifywebapiPython/const.html +3 -3
- spotifywebapipython/docs/spotifywebapiPython/saappmessages.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/sautils.html +29 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifyapierror.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifyapimessage.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifyauthtoken.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifyclient.html +31 -7
- spotifywebapipython/docs/spotifywebapiPython/spotifydiscovery.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifywebapiauthenticationerror.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifywebapierror.html +2 -2
- spotifywebapipython/models/spotifyconnectdevices.py +103 -0
- spotifywebapipython/models/zeroconfdiscoveryresult.py +13 -0
- spotifywebapipython/sautils.py +31 -0
- spotifywebapipython/spotifyclient.py +105 -92
- spotifywebapipython/zeroconfapi/zeroconfconnect.py +46 -10
- spotifywebapipython/zeroconfapi/zeroconfgetinfo.py +32 -0
- spotifywebapipython/zeroconfapi/zeroconfresponse.py +24 -0
- {spotifywebapiPython-1.0.51.dist-info → spotifywebapiPython-1.0.53.dist-info}/LICENSE +0 -0
- {spotifywebapiPython-1.0.51.dist-info → spotifywebapiPython-1.0.53.dist-info}/WHEEL +0 -0
- {spotifywebapiPython-1.0.51.dist-info → spotifywebapiPython-1.0.53.dist-info}/top_level.txt +0 -0
|
@@ -12,8 +12,11 @@ from .spotifyzeroconfapierror import SpotifyZeroconfApiError
|
|
|
12
12
|
from .zeroconfresponse import ZeroconfResponse
|
|
13
13
|
from .zeroconfgetinfo import ZeroconfGetInfo
|
|
14
14
|
from ..saappmessages import SAAppMessages
|
|
15
|
-
from ..sautils import export
|
|
15
|
+
from ..sautils import export, validateDelay
|
|
16
16
|
from ..spotifyapierror import SpotifyApiError
|
|
17
|
+
from ..const import (
|
|
18
|
+
TRACE_MSG_DELAY_DEVICE,
|
|
19
|
+
)
|
|
17
20
|
|
|
18
21
|
# get smartinspect logger reference; create a new session for this module name.
|
|
19
22
|
from smartinspectpython.siauto import SIAuto, SILevel, SISession, SIMethodParmListContext, SISourceId
|
|
@@ -261,10 +264,12 @@ class ZeroconfConnect:
|
|
|
261
264
|
return responseData
|
|
262
265
|
|
|
263
266
|
|
|
264
|
-
def Connect(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
267
|
+
def Connect(
|
|
268
|
+
self,
|
|
269
|
+
username:str,
|
|
270
|
+
password:str,
|
|
271
|
+
delay:float=0.50
|
|
272
|
+
) -> ZeroconfResponse:
|
|
268
273
|
"""
|
|
269
274
|
Calls the `addUser` Spotify Zeroconf API endpoint to issue a call to SpConnectionLoginBlob. If successful,
|
|
270
275
|
the associated device id is added to the Spotify Connect active device list for the specified user account.
|
|
@@ -277,6 +282,11 @@ class ZeroconfConnect:
|
|
|
277
282
|
on the manufacturer device.
|
|
278
283
|
password (str):
|
|
279
284
|
Spotify Connect user password to login with.
|
|
285
|
+
delay (float):
|
|
286
|
+
Time delay (in seconds) to wait AFTER issuing the command to the device.
|
|
287
|
+
This delay will give the spotify zeroconf api time to process the change before
|
|
288
|
+
another command is issued.
|
|
289
|
+
Default is 0.50; value range is 0 - 10.
|
|
280
290
|
|
|
281
291
|
Returns:
|
|
282
292
|
A `ZeroconfResponse` object that indicates success or failure (see notes below).
|
|
@@ -321,6 +331,7 @@ class ZeroconfConnect:
|
|
|
321
331
|
apiMethodParms.AppendKeyValue("Version", self._Version)
|
|
322
332
|
apiMethodParms.AppendKeyValue("Uri", self._Uri)
|
|
323
333
|
apiMethodParms.AppendKeyValue("username", username)
|
|
334
|
+
apiMethodParms.AppendKeyValue("delay", delay)
|
|
324
335
|
_logsi.LogMethodParmList(SILevel.Verbose, "Connecting device to Spotify Connect using specified Username and Password", apiMethodParms)
|
|
325
336
|
|
|
326
337
|
# validations.
|
|
@@ -328,6 +339,7 @@ class ZeroconfConnect:
|
|
|
328
339
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'username'), logsi=_logsi)
|
|
329
340
|
if (password is None) or (not isinstance(password,str)):
|
|
330
341
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'password'), logsi=_logsi)
|
|
342
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
331
343
|
|
|
332
344
|
# get the current device id from the device via Spotify ZeroConf API `getInfo` endpoint.
|
|
333
345
|
info:ZeroconfGetInfo = self.GetInformation()
|
|
@@ -361,6 +373,13 @@ class ZeroconfConnect:
|
|
|
361
373
|
|
|
362
374
|
# trace.
|
|
363
375
|
_logsi.LogObject(SILevel.Verbose, '%s result - type="%s"' % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
|
|
376
|
+
|
|
377
|
+
# give spotify zeroconf api time to process the change.
|
|
378
|
+
if delay > 0:
|
|
379
|
+
_logsi.LogVerbose(TRACE_MSG_DELAY_DEVICE % delay)
|
|
380
|
+
time.sleep(delay)
|
|
381
|
+
|
|
382
|
+
# return result to caller.
|
|
364
383
|
return result
|
|
365
384
|
|
|
366
385
|
except SpotifyZeroconfApiError: raise # pass handled exceptions on thru
|
|
@@ -380,10 +399,20 @@ class ZeroconfConnect:
|
|
|
380
399
|
_logsi.LeaveMethod(SILevel.Debug, apiMethodName)
|
|
381
400
|
|
|
382
401
|
|
|
383
|
-
def Disconnect(
|
|
402
|
+
def Disconnect(
|
|
403
|
+
self,
|
|
404
|
+
delay:float=0.50
|
|
405
|
+
) -> ZeroconfResponse:
|
|
384
406
|
"""
|
|
385
407
|
Calls the `resetUsers` Spotify Zeroconf API endpoint to issue a call to SpConnectionLogout.
|
|
386
408
|
|
|
409
|
+
Args:
|
|
410
|
+
delay (float):
|
|
411
|
+
Time delay (in seconds) to wait AFTER issuing the command to the device.
|
|
412
|
+
This delay will give the spotify zeroconf api time to process the change before
|
|
413
|
+
another command is issued.
|
|
414
|
+
Default is 0.50; value range is 0 - 10.
|
|
415
|
+
|
|
387
416
|
Returns:
|
|
388
417
|
A `ZeroconfResponse` object that indicates success or failure (see notes below).
|
|
389
418
|
|
|
@@ -415,8 +444,12 @@ class ZeroconfConnect:
|
|
|
415
444
|
apiMethodParms.AppendKeyValue("CPath", self._CPath)
|
|
416
445
|
apiMethodParms.AppendKeyValue("Version", self._Version)
|
|
417
446
|
apiMethodParms.AppendKeyValue("Uri", self._Uri)
|
|
447
|
+
apiMethodParms.AppendKeyValue("delay", delay)
|
|
418
448
|
_logsi.LogMethodParmList(SILevel.Verbose, "Disconnecting device from Spotify Connect", apiMethodParms)
|
|
419
449
|
|
|
450
|
+
# validations.
|
|
451
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
452
|
+
|
|
420
453
|
# execute spotify zeroconf api request.
|
|
421
454
|
response = requests.post(
|
|
422
455
|
self._Uri,
|
|
@@ -436,12 +469,15 @@ class ZeroconfConnect:
|
|
|
436
469
|
# process results.
|
|
437
470
|
result = ZeroconfResponse(root=responseData)
|
|
438
471
|
|
|
439
|
-
# just in case user tries to issue a connect immediately after this, give the device
|
|
440
|
-
# a little time to reset the connection so the subsequent connect does not fail.
|
|
441
|
-
time.sleep(0.5)
|
|
442
|
-
|
|
443
472
|
# trace.
|
|
444
473
|
_logsi.LogObject(SILevel.Verbose, '%s result - type="%s"' % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
|
|
474
|
+
|
|
475
|
+
# give spotify zeroconf api time to process the change.
|
|
476
|
+
if delay > 0:
|
|
477
|
+
_logsi.LogVerbose(TRACE_MSG_DELAY_DEVICE % delay)
|
|
478
|
+
time.sleep(delay)
|
|
479
|
+
|
|
480
|
+
# return result to caller.
|
|
445
481
|
return result
|
|
446
482
|
|
|
447
483
|
except SpotifyZeroconfApiError: raise # pass handled exceptions on thru
|
|
@@ -109,6 +109,14 @@ class ZeroconfGetInfo(ZeroconfResponse):
|
|
|
109
109
|
This value will be an empty string if there is no user logged into the device.
|
|
110
110
|
"""
|
|
111
111
|
return self._ActiveUser
|
|
112
|
+
|
|
113
|
+
@ActiveUser.setter
|
|
114
|
+
def ActiveUser(self, value:str):
|
|
115
|
+
"""
|
|
116
|
+
Sets the ActiveUser property value.
|
|
117
|
+
"""
|
|
118
|
+
if isinstance(value, str):
|
|
119
|
+
self._ActiveUser = value
|
|
112
120
|
|
|
113
121
|
|
|
114
122
|
@property
|
|
@@ -158,6 +166,14 @@ class ZeroconfGetInfo(ZeroconfResponse):
|
|
|
158
166
|
Unique device ID used for ZeroConf logins (e.g. "30fbc80e35598f3c242f2120413c943dfd9715fe").
|
|
159
167
|
"""
|
|
160
168
|
return self._DeviceId
|
|
169
|
+
|
|
170
|
+
@DeviceId.setter
|
|
171
|
+
def DeviceId(self, value:str):
|
|
172
|
+
"""
|
|
173
|
+
Sets the DeviceId property value.
|
|
174
|
+
"""
|
|
175
|
+
if isinstance(value, str):
|
|
176
|
+
self._DeviceId = value
|
|
161
177
|
|
|
162
178
|
|
|
163
179
|
@property
|
|
@@ -182,6 +198,14 @@ class ZeroconfGetInfo(ZeroconfResponse):
|
|
|
182
198
|
- kSpDeviceTypeChromebook Chromebook.
|
|
183
199
|
"""
|
|
184
200
|
return self._DeviceType
|
|
201
|
+
|
|
202
|
+
@DeviceType.setter
|
|
203
|
+
def DeviceType(self, value:str):
|
|
204
|
+
"""
|
|
205
|
+
Sets the DeviceType property value.
|
|
206
|
+
"""
|
|
207
|
+
if isinstance(value, str):
|
|
208
|
+
self._DeviceType = value
|
|
185
209
|
|
|
186
210
|
|
|
187
211
|
@property
|
|
@@ -253,6 +277,14 @@ class ZeroconfGetInfo(ZeroconfResponse):
|
|
|
253
277
|
Please refer to the `Aliases` property for more information.
|
|
254
278
|
"""
|
|
255
279
|
return self._RemoteName
|
|
280
|
+
|
|
281
|
+
@RemoteName.setter
|
|
282
|
+
def RemoteName(self, value:str):
|
|
283
|
+
"""
|
|
284
|
+
Sets the RemoteName property value.
|
|
285
|
+
"""
|
|
286
|
+
if isinstance(value, str):
|
|
287
|
+
self._RemoteName = value
|
|
256
288
|
|
|
257
289
|
|
|
258
290
|
@property
|
|
@@ -57,6 +57,14 @@ class ZeroconfResponse:
|
|
|
57
57
|
The last error code returned by a Spotify API call or the SpCallbackError() callback (e.g. 0, -119, etc).
|
|
58
58
|
"""
|
|
59
59
|
return self._SpotifyError
|
|
60
|
+
|
|
61
|
+
@SpotifyError.setter
|
|
62
|
+
def SpotifyError(self, value:int):
|
|
63
|
+
"""
|
|
64
|
+
Sets the SpotifyError property value.
|
|
65
|
+
"""
|
|
66
|
+
if isinstance(value, int):
|
|
67
|
+
self._SpotifyError = value
|
|
60
68
|
|
|
61
69
|
|
|
62
70
|
@property
|
|
@@ -65,6 +73,14 @@ class ZeroconfResponse:
|
|
|
65
73
|
A code indicating the result of the operation (e.g. 101, 402, etc).
|
|
66
74
|
"""
|
|
67
75
|
return self._Status
|
|
76
|
+
|
|
77
|
+
@Status.setter
|
|
78
|
+
def Status(self, value:int):
|
|
79
|
+
"""
|
|
80
|
+
Sets the Status property value.
|
|
81
|
+
"""
|
|
82
|
+
if isinstance(value, int):
|
|
83
|
+
self._Status = value
|
|
68
84
|
|
|
69
85
|
|
|
70
86
|
@property
|
|
@@ -73,6 +89,14 @@ class ZeroconfResponse:
|
|
|
73
89
|
The string describing the status code (e.g. "OK", "ERROR-SPOTIFY-ERROR", etc).
|
|
74
90
|
"""
|
|
75
91
|
return self._StatusString
|
|
92
|
+
|
|
93
|
+
@StatusString.setter
|
|
94
|
+
def StatusString(self, value:str):
|
|
95
|
+
"""
|
|
96
|
+
Sets the StatusString property value.
|
|
97
|
+
"""
|
|
98
|
+
if isinstance(value, str):
|
|
99
|
+
self._StatusString = value
|
|
76
100
|
|
|
77
101
|
|
|
78
102
|
def ToDictionary(self) -> dict:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|