spotifywebapiPython 1.0.52__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.52.dist-info → spotifywebapiPython-1.0.53.dist-info}/METADATA +1 -1
- {spotifywebapiPython-1.0.52.dist-info → spotifywebapiPython-1.0.53.dist-info}/RECORD +22 -22
- spotifywebapipython/const.py +1 -1
- spotifywebapipython/docs/__init__.html +9 -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 +19 -6
- spotifywebapipython/docs/spotifywebapiPython/spotifydiscovery.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifywebapiauthenticationerror.html +2 -2
- spotifywebapipython/docs/spotifywebapiPython/spotifywebapierror.html +2 -2
- spotifywebapipython/sautils.py +31 -0
- spotifywebapipython/spotifyclient.py +40 -54
- spotifywebapipython/zeroconfapi/zeroconfconnect.py +46 -10
- {spotifywebapiPython-1.0.52.dist-info → spotifywebapiPython-1.0.53.dist-info}/LICENSE +0 -0
- {spotifywebapiPython-1.0.52.dist-info → spotifywebapiPython-1.0.53.dist-info}/WHEEL +0 -0
- {spotifywebapiPython-1.0.52.dist-info → spotifywebapiPython-1.0.53.dist-info}/top_level.txt +0 -0
|
@@ -15,7 +15,7 @@ from zeroconf import Zeroconf
|
|
|
15
15
|
from .oauthcli import AuthClient
|
|
16
16
|
from .models import *
|
|
17
17
|
from .models import UserProfile as UserProfileCurrentUser
|
|
18
|
-
from .sautils import export, GetUnixTimestampMSFromUtcNow, _xmlGetInnerText
|
|
18
|
+
from .sautils import export, GetUnixTimestampMSFromUtcNow, _xmlGetInnerText, validateDelay
|
|
19
19
|
from .saappmessages import SAAppMessages
|
|
20
20
|
from .spotifyapierror import SpotifyApiError
|
|
21
21
|
from .spotifyapimessage import SpotifyApiMessage
|
|
@@ -631,32 +631,6 @@ class SpotifyClient:
|
|
|
631
631
|
return result
|
|
632
632
|
|
|
633
633
|
|
|
634
|
-
def _ValidateDelay(self, delay:float, default:float=0.5, maxDelay:float=10) -> float:
|
|
635
|
-
"""
|
|
636
|
-
Validates a delay value.
|
|
637
|
-
|
|
638
|
-
Args:
|
|
639
|
-
delay (int):
|
|
640
|
-
The delay value to validate.
|
|
641
|
-
default (int):
|
|
642
|
-
The default delay value to set if the user-input delay is not valid.
|
|
643
|
-
maxDelay (int):
|
|
644
|
-
The maximum delay value allowed.
|
|
645
|
-
Default is 10.
|
|
646
|
-
"""
|
|
647
|
-
if (isinstance(delay,int)):
|
|
648
|
-
delay = float(delay)
|
|
649
|
-
|
|
650
|
-
if (not isinstance(delay,float)) or (delay < 0):
|
|
651
|
-
result = default
|
|
652
|
-
elif (delay > maxDelay):
|
|
653
|
-
result = maxDelay
|
|
654
|
-
else:
|
|
655
|
-
result = delay
|
|
656
|
-
|
|
657
|
-
return result
|
|
658
|
-
|
|
659
|
-
|
|
660
634
|
def _ValidateMarket(self,
|
|
661
635
|
market:str,
|
|
662
636
|
) -> str:
|
|
@@ -5945,10 +5919,10 @@ class SpotifyClient:
|
|
|
5945
5919
|
def PlayerActivateDevices(
|
|
5946
5920
|
self,
|
|
5947
5921
|
verifyUserContext:bool=False,
|
|
5948
|
-
delay:float=0.
|
|
5922
|
+
delay:float=0.25
|
|
5949
5923
|
) -> str:
|
|
5950
5924
|
"""
|
|
5951
|
-
Activates all Spotify Connect player devices, and (optionally) switches the active user
|
|
5925
|
+
Activates all static Spotify Connect player devices, and (optionally) switches the active user
|
|
5952
5926
|
context to the current user context.
|
|
5953
5927
|
|
|
5954
5928
|
Args:
|
|
@@ -5961,7 +5935,7 @@ class SpotifyClient:
|
|
|
5961
5935
|
Time delay (in seconds) to wait AFTER issuing the final Connect command (if necessary).
|
|
5962
5936
|
This delay will give the spotify web api time to process the device list change before
|
|
5963
5937
|
another command is issued.
|
|
5964
|
-
Default is 0.
|
|
5938
|
+
Default is 0.25; value range is 0 - 10.
|
|
5965
5939
|
|
|
5966
5940
|
Returns:
|
|
5967
5941
|
A string that contains status text.
|
|
@@ -5985,6 +5959,10 @@ class SpotifyClient:
|
|
|
5985
5959
|
The user context switch is bypassed if the `verifyUserContext` argument is False. If the user context
|
|
5986
5960
|
is to be switched, then a Disconnect will be issued if a user context is active on the device followed
|
|
5987
5961
|
by a Connect to the user context specified on the class constructor.
|
|
5962
|
+
|
|
5963
|
+
Dynamic Spotify Connect devices are not processed by this method, as they are temporary devices and are
|
|
5964
|
+
already active and in the device list. These devices are not found in Zeroconf discovery process, and only
|
|
5965
|
+
exist in the player device list. These are usually Spotify Connect web or mobile players with temporary device id's.
|
|
5988
5966
|
|
|
5989
5967
|
<details>
|
|
5990
5968
|
<summary>Sample Code</summary>
|
|
@@ -6012,7 +5990,7 @@ class SpotifyClient:
|
|
|
6012
5990
|
raise SpotifyZeroconfApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'SpotifyConnectUsername'), logsi=_logsi)
|
|
6013
5991
|
|
|
6014
5992
|
# validations.
|
|
6015
|
-
delay =
|
|
5993
|
+
delay = validateDelay(delay, 0.25, 10)
|
|
6016
5994
|
if (not isinstance(verifyUserContext, bool)):
|
|
6017
5995
|
verifyUserContext = False
|
|
6018
5996
|
|
|
@@ -6072,23 +6050,18 @@ class SpotifyClient:
|
|
|
6072
6050
|
# the current user context before connecting a different user.
|
|
6073
6051
|
if (info.HasActiveUser):
|
|
6074
6052
|
_logsi.LogVerbose("Spotify Connect user context '%s' is being disconnected for Device id '%s'" % (deviceActiveUser, deviceIdResult))
|
|
6075
|
-
zcfResult = zconn.Disconnect()
|
|
6053
|
+
zcfResult = zconn.Disconnect(delay)
|
|
6076
6054
|
status = status + 'disconnected from user context "%s";' % deviceActiveUser
|
|
6077
|
-
|
|
6055
|
+
|
|
6078
6056
|
# connect the device to OUR Spotify Connect user context.
|
|
6079
6057
|
# note that the result here only indicates that the connect was submitted - NOT that it was successful!
|
|
6080
6058
|
_logsi.LogVerbose("Spotify Connect user context '%s' is being connected for Device id '%s'" % (self._SpotifyConnectUsername, deviceIdResult))
|
|
6081
|
-
zcfResult = zconn.Connect(self._SpotifyConnectUsername, self._SpotifyConnectPassword)
|
|
6059
|
+
zcfResult = zconn.Connect(self._SpotifyConnectUsername, self._SpotifyConnectPassword, delay)
|
|
6082
6060
|
status = status + 'connected to user context "%s"' % self._SpotifyConnectUsername
|
|
6083
6061
|
|
|
6084
6062
|
# trace.
|
|
6085
6063
|
_logsi.LogVerbose("Spotify Connect user context switch from '%s' to '%s' was requested for Device id '%s'" % (deviceActiveUser, self._SpotifyConnectUsername, deviceIdResult))
|
|
6086
6064
|
|
|
6087
|
-
# give spotify web api time to process the change and add the device to the device list.
|
|
6088
|
-
if delay > 0:
|
|
6089
|
-
_logsi.LogVerbose(TRACE_MSG_DELAY_DEVICE % delay)
|
|
6090
|
-
time.sleep(delay)
|
|
6091
|
-
|
|
6092
6065
|
# append device status to results.
|
|
6093
6066
|
result = "%s%s\n" % (result, MSG_RESULT % (info.RemoteName, info.DeviceId, info.ActiveUser, status))
|
|
6094
6067
|
|
|
@@ -6243,6 +6216,11 @@ class SpotifyClient:
|
|
|
6243
6216
|
SpotifApiError:
|
|
6244
6217
|
If the method fails for any other reason.
|
|
6245
6218
|
|
|
6219
|
+
Note that this method will only return the devices for which the current user
|
|
6220
|
+
context has control of, or other available devices that do not have an active
|
|
6221
|
+
user context assigned. Use the `GetSpotifyConnectDevices` method to retrieve
|
|
6222
|
+
a complete list of devices that are available to all users.
|
|
6223
|
+
|
|
6246
6224
|
The `ConfigurationCache` is updated with the results of this method. Use the
|
|
6247
6225
|
`refresh` argument (with False value) to retrieve the cached value and avoid
|
|
6248
6226
|
the spotify web api request. This results in better performance.
|
|
@@ -9422,7 +9400,7 @@ class SpotifyClient:
|
|
|
9422
9400
|
_logsi.LogMethodParmList(SILevel.Verbose, "Spotify Connect device pause playback", apiMethodParms)
|
|
9423
9401
|
|
|
9424
9402
|
# validations.
|
|
9425
|
-
delay =
|
|
9403
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
9426
9404
|
|
|
9427
9405
|
# check for device name; convert to an id if a name was supplied.
|
|
9428
9406
|
deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -9555,7 +9533,7 @@ class SpotifyClient:
|
|
|
9555
9533
|
_logsi.LogMethodParmList(SILevel.Verbose, "Spotify Connect device play context", apiMethodParms)
|
|
9556
9534
|
|
|
9557
9535
|
# validations.
|
|
9558
|
-
delay =
|
|
9536
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
9559
9537
|
|
|
9560
9538
|
# check for device name; convert to an id if a name was supplied.
|
|
9561
9539
|
#deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -9663,7 +9641,7 @@ class SpotifyClient:
|
|
|
9663
9641
|
_logsi.LogMethodParmList(SILevel.Verbose, "Spotify Connect device play track favorites", apiMethodParms)
|
|
9664
9642
|
|
|
9665
9643
|
# validations.
|
|
9666
|
-
delay =
|
|
9644
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
9667
9645
|
|
|
9668
9646
|
# get current users favorite tracks.
|
|
9669
9647
|
tracks:TrackPageSaved = self.GetTrackFavorites(limitTotal=200)
|
|
@@ -9774,7 +9752,7 @@ class SpotifyClient:
|
|
|
9774
9752
|
_logsi.LogMethodParmList(SILevel.Verbose, "Spotify Connect device play tracks", apiMethodParms)
|
|
9775
9753
|
|
|
9776
9754
|
# validations.
|
|
9777
|
-
delay =
|
|
9755
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
9778
9756
|
|
|
9779
9757
|
# build a list of all item uri's.
|
|
9780
9758
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
@@ -9885,7 +9863,7 @@ class SpotifyClient:
|
|
|
9885
9863
|
_logsi.LogMethodParmList(SILevel.Verbose, "Spotify Connect device resume playback", apiMethodParms)
|
|
9886
9864
|
|
|
9887
9865
|
# validations.
|
|
9888
|
-
delay =
|
|
9866
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
9889
9867
|
|
|
9890
9868
|
# check for device name; convert to an id if a name was supplied.
|
|
9891
9869
|
deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -9982,7 +9960,7 @@ class SpotifyClient:
|
|
|
9982
9960
|
_logsi.LogMethodParmList(SILevel.Verbose, "Spotify Connect device seek position", apiMethodParms)
|
|
9983
9961
|
|
|
9984
9962
|
# validations.
|
|
9985
|
-
delay =
|
|
9963
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
9986
9964
|
|
|
9987
9965
|
# check for device name; convert to an id if a name was supplied.
|
|
9988
9966
|
deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -10074,7 +10052,7 @@ class SpotifyClient:
|
|
|
10074
10052
|
_logsi.LogMethodParmList(SILevel.Verbose, "Spotify Connect device skip next", apiMethodParms)
|
|
10075
10053
|
|
|
10076
10054
|
# validations.
|
|
10077
|
-
delay =
|
|
10055
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
10078
10056
|
|
|
10079
10057
|
# check for device name; convert to an id if a name was supplied.
|
|
10080
10058
|
deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -10163,7 +10141,7 @@ class SpotifyClient:
|
|
|
10163
10141
|
_logsi.LogMethodParmList(SILevel.Verbose, "Spotify Connect device skip previous", apiMethodParms)
|
|
10164
10142
|
|
|
10165
10143
|
# validations.
|
|
10166
|
-
delay =
|
|
10144
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
10167
10145
|
|
|
10168
10146
|
# check for device name; convert to an id if a name was supplied.
|
|
10169
10147
|
deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -10206,6 +10184,7 @@ class SpotifyClient:
|
|
|
10206
10184
|
deviceValue:str,
|
|
10207
10185
|
verifyUserContext:bool=True,
|
|
10208
10186
|
verifyTimeout:float=5.0,
|
|
10187
|
+
delay:float=0.25
|
|
10209
10188
|
) -> str:
|
|
10210
10189
|
"""
|
|
10211
10190
|
Resolves a Spotify Connect device identifier from a specified device id, name, alias id,
|
|
@@ -10225,6 +10204,11 @@ class SpotifyClient:
|
|
|
10225
10204
|
Connect device list. This value is only used if a Connect command has to be
|
|
10226
10205
|
issued to activate the device.
|
|
10227
10206
|
Default is 5; value range is 0 - 10.
|
|
10207
|
+
delay (float):
|
|
10208
|
+
Time delay (in seconds) to wait AFTER issuing any command to the device.
|
|
10209
|
+
This delay will give the spotify zeroconf api time to process the change before
|
|
10210
|
+
another command is issued.
|
|
10211
|
+
Default is 0.25; value range is 0 - 10.
|
|
10228
10212
|
|
|
10229
10213
|
Returns:
|
|
10230
10214
|
A device Id for the deviceValue if one could be resolved;
|
|
@@ -10273,6 +10257,7 @@ class SpotifyClient:
|
|
|
10273
10257
|
apiMethodParms.AppendKeyValue("deviceValue", deviceValue)
|
|
10274
10258
|
apiMethodParms.AppendKeyValue("verifyUserContext", verifyUserContext)
|
|
10275
10259
|
apiMethodParms.AppendKeyValue("verifyTimeout", verifyTimeout)
|
|
10260
|
+
apiMethodParms.AppendKeyValue("delay", delay)
|
|
10276
10261
|
_logsi.LogMethodParmList(SILevel.Verbose, "Resolving Spotify Connect Player Device Id", apiMethodParms)
|
|
10277
10262
|
|
|
10278
10263
|
# if device value not specified then we are done.
|
|
@@ -10281,7 +10266,8 @@ class SpotifyClient:
|
|
|
10281
10266
|
return None
|
|
10282
10267
|
|
|
10283
10268
|
# validations.
|
|
10284
|
-
|
|
10269
|
+
delay = validateDelay(delay, 0.25, 10)
|
|
10270
|
+
verifyTimeout = validateDelay(verifyTimeout, 5, 10)
|
|
10285
10271
|
if (not isinstance(verifyUserContext, bool)):
|
|
10286
10272
|
verifyUserContext = True
|
|
10287
10273
|
|
|
@@ -10376,7 +10362,7 @@ class SpotifyClient:
|
|
|
10376
10362
|
# the current user context before connecting a different user.
|
|
10377
10363
|
if (info.HasActiveUser):
|
|
10378
10364
|
_logsi.LogVerbose("Spotify Connect user context '%s' is being disconnected for Device id '%s'" % (deviceActiveUser, deviceIdResult))
|
|
10379
|
-
zcfResult = zconn.Disconnect()
|
|
10365
|
+
zcfResult = zconn.Disconnect(delay)
|
|
10380
10366
|
|
|
10381
10367
|
# connect the device to OUR Spotify Connect user context.
|
|
10382
10368
|
# note that the result here only indicates that the connect was submitted - NOT that it was successful!
|
|
@@ -10490,7 +10476,7 @@ class SpotifyClient:
|
|
|
10490
10476
|
_logsi.LogMethodParmList(SILevel.Verbose, "Set Spotify Connect device set repeat mode", apiMethodParms)
|
|
10491
10477
|
|
|
10492
10478
|
# validations.
|
|
10493
|
-
delay =
|
|
10479
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
10494
10480
|
|
|
10495
10481
|
# check for device name; convert to an id if a name was supplied.
|
|
10496
10482
|
deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -10589,7 +10575,7 @@ class SpotifyClient:
|
|
|
10589
10575
|
_logsi.LogMethodParmList(SILevel.Verbose, "Set Spotify Connect device set shuffle mode", apiMethodParms)
|
|
10590
10576
|
|
|
10591
10577
|
# validations.
|
|
10592
|
-
delay =
|
|
10578
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
10593
10579
|
|
|
10594
10580
|
# check for device name; convert to an id if a name was supplied.
|
|
10595
10581
|
deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -10687,7 +10673,7 @@ class SpotifyClient:
|
|
|
10687
10673
|
_logsi.LogMethodParmList(SILevel.Verbose, "Set Spotify Connect device set volume level", apiMethodParms)
|
|
10688
10674
|
|
|
10689
10675
|
# validations.
|
|
10690
|
-
delay =
|
|
10676
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
10691
10677
|
|
|
10692
10678
|
# check for device name; convert to an id if a name was supplied.
|
|
10693
10679
|
deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -10785,7 +10771,7 @@ class SpotifyClient:
|
|
|
10785
10771
|
_logsi.LogMethodParmList(SILevel.Verbose, "Transfer playback to a new Spotify Connect device", apiMethodParms)
|
|
10786
10772
|
|
|
10787
10773
|
# validations.
|
|
10788
|
-
delay =
|
|
10774
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
10789
10775
|
|
|
10790
10776
|
# check for device name; convert to an id if a name was supplied.
|
|
10791
10777
|
#deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
@@ -10891,7 +10877,7 @@ class SpotifyClient:
|
|
|
10891
10877
|
_logsi.LogMethodParmList(SILevel.Verbose, "Checks if a Spotify Connect device is active, and activate one if not", apiMethodParms)
|
|
10892
10878
|
|
|
10893
10879
|
# validations.
|
|
10894
|
-
delay =
|
|
10880
|
+
delay = validateDelay(delay, 0.50, 10)
|
|
10895
10881
|
|
|
10896
10882
|
# get current Spotify Connect player state.
|
|
10897
10883
|
result = self.GetPlayerPlaybackState()
|
|
@@ -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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|