spotifywebapiPython 1.0.66__py3-none-any.whl → 1.0.68__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.66.dist-info → spotifywebapiPython-1.0.68.dist-info}/METADATA +1 -1
- {spotifywebapiPython-1.0.66.dist-info → spotifywebapiPython-1.0.68.dist-info}/RECORD +21 -21
- spotifywebapipython/const.py +1 -1
- spotifywebapipython/docs/__init__.html +17 -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 +2 -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 +5 -4
- spotifywebapipython/docs/spotifywebapiPython/spotifydiscovery.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifywebapiauthenticationerror.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifywebapierror.html +2 -2
- spotifywebapipython/spotifyclient.py +15 -8
- spotifywebapipython/zeroconfapi/zeroconfconnect.py +42 -28
- {spotifywebapiPython-1.0.66.dist-info → spotifywebapiPython-1.0.68.dist-info}/LICENSE +0 -0
- {spotifywebapiPython-1.0.66.dist-info → spotifywebapiPython-1.0.68.dist-info}/WHEEL +0 -0
- {spotifywebapiPython-1.0.66.dist-info → spotifywebapiPython-1.0.68.dist-info}/top_level.txt +0 -0
|
@@ -46,7 +46,7 @@ class ZeroconfConnect:
|
|
|
46
46
|
hostIpAddress:str,
|
|
47
47
|
hostIpPort:int,
|
|
48
48
|
cpath:str,
|
|
49
|
-
version:str=
|
|
49
|
+
version:str=None,
|
|
50
50
|
useSSL:bool=False
|
|
51
51
|
) -> None:
|
|
52
52
|
"""
|
|
@@ -63,15 +63,13 @@ class ZeroconfConnect:
|
|
|
63
63
|
Spotify Connect Zeroconf API CPath property value (e.g. "/zc").
|
|
64
64
|
version (str):
|
|
65
65
|
Spotify Connect Zeroconf API version number that the device supports (e.g. "2.10.0").
|
|
66
|
-
Default is
|
|
66
|
+
Default is null.
|
|
67
67
|
useSSL (bool):
|
|
68
68
|
True if the host device utilizes HTTPS Secure Sockets Layer (SSL) support;
|
|
69
69
|
otherwise, False to utilize HTTP.
|
|
70
70
|
Default is False (HTTP).
|
|
71
71
|
"""
|
|
72
72
|
# validations.
|
|
73
|
-
if (version is None):
|
|
74
|
-
version = '1.0'
|
|
75
73
|
if (useSSL is None) or (not isinstance(useSSL,bool)):
|
|
76
74
|
useSSL = False
|
|
77
75
|
|
|
@@ -89,7 +87,7 @@ class ZeroconfConnect:
|
|
|
89
87
|
@property
|
|
90
88
|
def CPath(self) -> str:
|
|
91
89
|
"""
|
|
92
|
-
|
|
90
|
+
Path that points to the ZeroConf implementation on the server (e.g. "/zc").
|
|
93
91
|
"""
|
|
94
92
|
return self._CPath
|
|
95
93
|
|
|
@@ -241,21 +239,21 @@ class ZeroconfConnect:
|
|
|
241
239
|
# InvalidArguments 303 400 ERROR-INVALID-ARGUMENTS All Incorrect or insufficient arguments supplied for requested action
|
|
242
240
|
# SpotifyError 402 200 ERROR-SPOTIFY-ERROR All A Spotify API call returned an error not covered by other error messages
|
|
243
241
|
|
|
244
|
-
# process results.
|
|
245
|
-
result = ZeroconfResponse(root=responseData)
|
|
242
|
+
# # process results.
|
|
243
|
+
# result = ZeroconfResponse(root=responseData)
|
|
246
244
|
|
|
247
|
-
# if result is ok, then just return the response data.
|
|
248
|
-
if (result.Status == 101) \
|
|
249
|
-
or (result.StatusString == 'OK') \
|
|
250
|
-
or (result.StatusString == 'ERROR-OK'):
|
|
251
|
-
|
|
245
|
+
# # if result is ok, then just return the response data.
|
|
246
|
+
# if (result.Status == 101) \
|
|
247
|
+
# or (result.StatusString == 'OK') \
|
|
248
|
+
# or (result.StatusString == 'ERROR-OK'):
|
|
249
|
+
# return responseData
|
|
252
250
|
|
|
253
|
-
# was an error status string returned?
|
|
254
|
-
# if so, then we will raise an exception.
|
|
255
|
-
if (result.StatusString.startswith('ERROR-')):
|
|
256
|
-
|
|
251
|
+
# # was an error status string returned?
|
|
252
|
+
# # if so, then we will raise an exception.
|
|
253
|
+
# if (result.StatusString.startswith('ERROR-')):
|
|
254
|
+
# raise SpotifyZeroconfApiError(result.Status, result.ToString(), methodName, result.StatusString, _logsi)
|
|
257
255
|
|
|
258
|
-
#
|
|
256
|
+
# let the calling function process the returned status.
|
|
259
257
|
return responseData
|
|
260
258
|
|
|
261
259
|
|
|
@@ -304,7 +302,7 @@ class ZeroconfConnect:
|
|
|
304
302
|
response. This public key is then used to submit another `addUser` request to connect to the device with the
|
|
305
303
|
newly returned public key. When this happens, a `ZeroconfResponse` object is returned with the result of
|
|
306
304
|
the final `addUser` request. If only one `addUser` request is processed, then a `ZeroconfGetInfo` object is
|
|
307
|
-
returned with the result of the `addUser` request. Note that `ZeroconfGetInfo
|
|
305
|
+
returned with the result of the `addUser` request. Note that `ZeroconfGetInfo` inherits from `ZeroconfResponse`,
|
|
308
306
|
so you can always treat the result of this method as a `ZeroconfResponse` object.
|
|
309
307
|
|
|
310
308
|
The login (on the device) is performed asynchronously, so the return result only indicates whether the library
|
|
@@ -354,6 +352,11 @@ class ZeroconfConnect:
|
|
|
354
352
|
# get the current device id from the device via Spotify ZeroConf API `getInfo` endpoint.
|
|
355
353
|
info:ZeroconfGetInfo = self.GetInformation()
|
|
356
354
|
|
|
355
|
+
# if the public key value is "INVALID" then issue a disconnect to reset the user context.
|
|
356
|
+
if (info.PublicKey == 'SU5WQUxJRA=='): # base64 encoded "INVALID"
|
|
357
|
+
_logsi.LogVerbose("Spotify Connect publicKey value is 'INVALID' for Device id '%s'; calling Disconnect to reset the user context" % (info.DeviceId))
|
|
358
|
+
self.Disconnect(ignoreStatusResult=True)
|
|
359
|
+
|
|
357
360
|
# execute the Spotify Zeroconf API addUser request.
|
|
358
361
|
responseData:dict = self._ConnectAddUser(
|
|
359
362
|
info,
|
|
@@ -371,11 +374,11 @@ class ZeroconfConnect:
|
|
|
371
374
|
# when this happens, the initial request will return a 203 status (ERROR-INVALID-PUBLICKEY), and
|
|
372
375
|
# return a valid public key in the response. we can then take this public key and try the
|
|
373
376
|
# `addUser` request again.
|
|
374
|
-
if (result.Status == 203) and (result.
|
|
377
|
+
if (result.Status == 203) and (result.StatusString == "ERROR-INVALID-PUBLICKEY"):
|
|
375
378
|
|
|
376
379
|
# trace.
|
|
377
380
|
_logsi.LogObject(SILevel.Verbose, '%s result (%s)' % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
|
|
378
|
-
_logsi.LogVerbose("Spotify Connect addUser request returned an ERROR-INVALID-PUBLICKEY response for Device id '%s'; addUser will be retried with the returned
|
|
381
|
+
_logsi.LogVerbose("Spotify Connect addUser request returned an ERROR-INVALID-PUBLICKEY response for Device id '%s'; addUser will be retried with the returned publicKey" % (info.DeviceId))
|
|
379
382
|
|
|
380
383
|
# give the device a little time to wake up.
|
|
381
384
|
WAKEUP_DELAY:float = 0.25
|
|
@@ -455,12 +458,13 @@ class ZeroconfConnect:
|
|
|
455
458
|
# set request parameters.
|
|
456
459
|
reqData={
|
|
457
460
|
'action': 'addUser',
|
|
458
|
-
'
|
|
461
|
+
'version': self._Version or '',
|
|
459
462
|
'userName': credentials.username.decode('ascii'), # user name (e.g. "youremail@mail.com")
|
|
460
463
|
'clientKey': int_to_b64str(builder.dh_keys.public_key),
|
|
461
464
|
'blob': blob,
|
|
462
465
|
'tokenType': 'default', # NOTE - not the same as info.TokenType!
|
|
463
|
-
|
|
466
|
+
# not sure if this is required or not, so commenting out for now.
|
|
467
|
+
#'loginId': loginId or '', # canonical login id (e.g. "31l77fd87g8h9j00k89f07jf87ge")
|
|
464
468
|
}
|
|
465
469
|
_logsi.LogDictionary(SILevel.Verbose, "ZeroconfConnect http request: '%s' (data)" % (endpoint), reqData)
|
|
466
470
|
|
|
@@ -479,7 +483,8 @@ class ZeroconfConnect:
|
|
|
479
483
|
|
|
480
484
|
def Disconnect(
|
|
481
485
|
self,
|
|
482
|
-
delay:float=0.50
|
|
486
|
+
delay:float=0.50,
|
|
487
|
+
ignoreStatusResult:bool=False
|
|
483
488
|
) -> ZeroconfResponse:
|
|
484
489
|
"""
|
|
485
490
|
Calls the `resetUsers` Spotify Zeroconf API endpoint to issue a call to SpConnectionLogout.
|
|
@@ -490,6 +495,11 @@ class ZeroconfConnect:
|
|
|
490
495
|
This delay will give the spotify zeroconf api time to process the change before
|
|
491
496
|
another command is issued.
|
|
492
497
|
Default is 0.50; value range is 0 - 10.
|
|
498
|
+
ignoreStatusResult (bool):
|
|
499
|
+
True to ignore processing of result status code;
|
|
500
|
+
otherwise, False to check the result status code for errors and raise an
|
|
501
|
+
exception if needed.
|
|
502
|
+
Default is
|
|
493
503
|
|
|
494
504
|
Returns:
|
|
495
505
|
A `ZeroconfResponse` object that indicates success or failure (see notes below).
|
|
@@ -523,6 +533,7 @@ class ZeroconfConnect:
|
|
|
523
533
|
apiMethodParms.AppendKeyValue("Version", self._Version)
|
|
524
534
|
apiMethodParms.AppendKeyValue("Uri", self._Uri)
|
|
525
535
|
apiMethodParms.AppendKeyValue("delay", delay)
|
|
536
|
+
apiMethodParms.AppendKeyValue("ignoreStatusResult", ignoreStatusResult)
|
|
526
537
|
_logsi.LogMethodParmList(SILevel.Verbose, "Disconnecting device from Spotify Connect (ip=%s)" % self._HostIpAddress, apiMethodParms)
|
|
527
538
|
|
|
528
539
|
# validations.
|
|
@@ -530,6 +541,8 @@ class ZeroconfConnect:
|
|
|
530
541
|
|
|
531
542
|
# set request endpoint.
|
|
532
543
|
endpoint:str = self.GetEndpoint('resetUsers')
|
|
544
|
+
if ignoreStatusResult is None:
|
|
545
|
+
ignoreStatusResult = False
|
|
533
546
|
|
|
534
547
|
# set request headers.
|
|
535
548
|
reqHeaders:dict = {
|
|
@@ -541,7 +554,7 @@ class ZeroconfConnect:
|
|
|
541
554
|
# set request parameters.
|
|
542
555
|
reqData={
|
|
543
556
|
'action': 'resetUsers',
|
|
544
|
-
'
|
|
557
|
+
'version': self._Version or '',
|
|
545
558
|
}
|
|
546
559
|
_logsi.LogDictionary(SILevel.Verbose, "ZeroconfConnect http request: '%s' (data)" % (endpoint), reqData)
|
|
547
560
|
|
|
@@ -563,8 +576,9 @@ class ZeroconfConnect:
|
|
|
563
576
|
_logsi.LogObject(SILevel.Verbose, '%s result (%s)' % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
|
|
564
577
|
|
|
565
578
|
# if result status is not ok, then raise an exception.
|
|
566
|
-
if (
|
|
567
|
-
|
|
579
|
+
if (not ignoreStatusResult):
|
|
580
|
+
if (result.Status != 101):
|
|
581
|
+
raise SpotifyZeroconfApiError(result.Status, result.ToString(), apiMethodName, result.StatusString, _logsi)
|
|
568
582
|
|
|
569
583
|
# give spotify zeroconf api time to process the change.
|
|
570
584
|
if delay > 0:
|
|
@@ -627,7 +641,7 @@ class ZeroconfConnect:
|
|
|
627
641
|
return "{uri}?action={action}&version={version}".format(
|
|
628
642
|
uri=self._Uri,
|
|
629
643
|
action=action,
|
|
630
|
-
version=self._Version,
|
|
644
|
+
version=self._Version or '',
|
|
631
645
|
)
|
|
632
646
|
|
|
633
647
|
|
|
@@ -679,7 +693,7 @@ class ZeroconfConnect:
|
|
|
679
693
|
# set request parameters.
|
|
680
694
|
reqParams={
|
|
681
695
|
'action': 'getInfo',
|
|
682
|
-
'
|
|
696
|
+
'version': self._Version or '',
|
|
683
697
|
}
|
|
684
698
|
_logsi.LogDictionary(SILevel.Verbose, "ZeroconfConnect http request: '%s' (params)" % (endpoint), reqParams)
|
|
685
699
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|