spotifywebapiPython 1.0.122__py3-none-any.whl → 1.0.123__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 (21) hide show
  1. {spotifywebapiPython-1.0.122.dist-info → spotifywebapiPython-1.0.123.dist-info}/METADATA +1 -1
  2. {spotifywebapiPython-1.0.122.dist-info → spotifywebapiPython-1.0.123.dist-info}/RECORD +21 -21
  3. spotifywebapipython/const.py +1 -1
  4. spotifywebapipython/docs/__init__.html +9 -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 +6 -5
  14. spotifywebapipython/docs/spotifywebapipython/spotifydiscovery.html +2 -2
  15. spotifywebapipython/docs/spotifywebapipython/spotifywebapiauthenticationerror.html +2 -2
  16. spotifywebapipython/docs/spotifywebapipython/spotifywebapierror.html +2 -2
  17. spotifywebapipython/spotifyclient.py +111 -16
  18. spotifywebapipython/zeroconfapi/zeroconfresponse.py +1 -1
  19. {spotifywebapiPython-1.0.122.dist-info → spotifywebapiPython-1.0.123.dist-info}/LICENSE +0 -0
  20. {spotifywebapiPython-1.0.122.dist-info → spotifywebapiPython-1.0.123.dist-info}/WHEEL +0 -0
  21. {spotifywebapiPython-1.0.122.dist-info → spotifywebapiPython-1.0.123.dist-info}/top_level.txt +0 -0
@@ -2333,7 +2333,13 @@ class SpotifyClient:
2333
2333
  apiMethodParms.AppendKeyValue("collaborative", collaborative)
2334
2334
  apiMethodParms.AppendKeyValue("imagePath", imagePath)
2335
2335
  _logsi.LogMethodParmList(SILevel.Verbose, "Create an empty playlist for a user", apiMethodParms)
2336
-
2336
+
2337
+ # validations.
2338
+ if (public is None):
2339
+ public = True
2340
+ if (collaborative is None):
2341
+ collaborative = False
2342
+
2337
2343
  # if userId is not supplied, then use profile value.
2338
2344
  if userId is None or len(userId.strip()) == 0:
2339
2345
  userId = self.UserProfile.Id
@@ -2489,7 +2495,7 @@ class SpotifyClient:
2489
2495
  public (bool):
2490
2496
  If true the playlist will be included in user's public playlists, if false it
2491
2497
  will remain private.
2492
- Default = True.
2498
+ Default is True.
2493
2499
 
2494
2500
  Raises:
2495
2501
  SpotifyWebApiError:
@@ -2515,6 +2521,10 @@ class SpotifyClient:
2515
2521
  apiMethodParms.AppendKeyValue("playlistId", playlistId)
2516
2522
  apiMethodParms.AppendKeyValue("public", public)
2517
2523
  _logsi.LogMethodParmList(SILevel.Verbose, "Add the current user as a follower of a playlist", apiMethodParms)
2524
+
2525
+ # validations.
2526
+ if (public is None):
2527
+ public = True
2518
2528
 
2519
2529
  # if playlistId not specified, then return currently playing playlist id value.
2520
2530
  if (playlistId is None) or (len(playlistId.strip()) == 0):
@@ -4996,6 +5006,10 @@ class SpotifyClient:
4996
5006
  apiMethodParms.AppendKeyValue("locale", locale)
4997
5007
  _logsi.LogMethodParmList(SILevel.Verbose, "Get a single category used to tag items in Spotify", apiMethodParms)
4998
5008
 
5009
+ # validations.
5010
+ if (refresh is None):
5011
+ refresh = True
5012
+
4999
5013
  # can we use a cached value?
5000
5014
  cacheKey:str = "GetBrowseCategorys"
5001
5015
  if (not refresh) and (cacheKey in self._ConfigurationCache):
@@ -5287,6 +5301,10 @@ class SpotifyClient:
5287
5301
  apiMethodParms.AppendKeyValue("refresh", refresh)
5288
5302
  _logsi.LogMethodParmList(SILevel.Verbose, "Get a sorted list of ALL browse categories", apiMethodParms)
5289
5303
 
5304
+ # validations.
5305
+ if (refresh is None):
5306
+ refresh = True
5307
+
5290
5308
  # can we use the cached value?
5291
5309
  if (not refresh) and (apiMethodName in self._ConfigurationCache):
5292
5310
 
@@ -5584,6 +5602,10 @@ class SpotifyClient:
5584
5602
  apiMethodParms.AppendKeyValue("ignoreResponseErrors", ignoreResponseErrors)
5585
5603
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for a single audiobook chapter", apiMethodParms)
5586
5604
 
5605
+ # validations.
5606
+ if (ignoreResponseErrors is None):
5607
+ ignoreResponseErrors = False
5608
+
5587
5609
  # ensure market was either supplied or implied; default if neither.
5588
5610
  market = self._ValidateMarket(market)
5589
5611
 
@@ -6337,6 +6359,10 @@ class SpotifyClient:
6337
6359
  # api endpoint no longer supported by Spotify as of 2024/11/27.
6338
6360
  raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT % apiMethodName)
6339
6361
 
6362
+ # validations.
6363
+ if (refresh is None):
6364
+ refresh = True
6365
+
6340
6366
  # can we use the cached value?
6341
6367
  if (not refresh) and (apiMethodName in self._ConfigurationCache):
6342
6368
 
@@ -6456,6 +6482,10 @@ class SpotifyClient:
6456
6482
  _logsi.EnterMethod(SILevel.Debug, apiMethodName)
6457
6483
  _logsi.LogVerbose("Get a sorted list of available markets (country codes)")
6458
6484
 
6485
+ # validations.
6486
+ if (refresh is None):
6487
+ refresh = True
6488
+
6459
6489
  # can we use the cached value?
6460
6490
  if (not refresh) and (apiMethodName in self._ConfigurationCache):
6461
6491
 
@@ -6596,6 +6626,8 @@ class SpotifyClient:
6596
6626
  _logsi.LogMethodParmList(SILevel.Verbose, "Get user's available Spotify Connect player device", apiMethodParms)
6597
6627
 
6598
6628
  # validations.
6629
+ if (refresh is None):
6630
+ refresh = True
6599
6631
  if deviceId is None:
6600
6632
  return None
6601
6633
  deviceId = deviceId.lower() # prepare for compare
@@ -6873,6 +6905,10 @@ class SpotifyClient:
6873
6905
  apiMethodParms.AppendKeyValue("refresh", refresh)
6874
6906
  _logsi.LogMethodParmList(SILevel.Verbose, "Checking Spotify Connect Player device for name", apiMethodParms)
6875
6907
 
6908
+ # validations.
6909
+ if (refresh is None):
6910
+ refresh = False
6911
+
6876
6912
  # if nothing specified then just use it as-is.
6877
6913
  if (value is None) or (len(value.strip()) == 0):
6878
6914
  _logsi.LogVerbose("Device ID not specified; active device will be used")
@@ -6982,6 +7018,8 @@ class SpotifyClient:
6982
7018
  _logsi.LogMethodParmList(SILevel.Verbose, "Get user's available Spotify Connect player devices", apiMethodParms)
6983
7019
 
6984
7020
  # validations.
7021
+ if (refresh is None):
7022
+ refresh = True
6985
7023
  if sortResult is None:
6986
7024
  sortResult = True
6987
7025
 
@@ -7220,6 +7258,10 @@ class SpotifyClient:
7220
7258
  """
7221
7259
  result:str = None
7222
7260
 
7261
+ # validations.
7262
+ if (ignoreResponseErrors is None):
7263
+ ignoreResponseErrors = False
7264
+
7223
7265
  # get nowplaying status.
7224
7266
  nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(market, additionalTypes='episode')
7225
7267
 
@@ -9046,7 +9088,8 @@ class SpotifyClient:
9046
9088
  Default is 5; value range is 0 - 10.
9047
9089
  refreshDeviceList (bool):
9048
9090
  True to refresh the Spotify Connect device list; otherwise, False to use the
9049
- Spotify Connect device list cache.
9091
+ Spotify Connect device list cache.
9092
+ Default is False.
9050
9093
  activateDevice (bool):
9051
9094
  True to activate the device if necessary; otherwise, False.
9052
9095
  Default is True.
@@ -9098,6 +9141,8 @@ class SpotifyClient:
9098
9141
  apiMethodParms:SIMethodParmListContext = None
9099
9142
  deviceResultId:str = None
9100
9143
  deviceResult:SpotifyConnectDevice = None
9144
+
9145
+ DELAY_DISCONNECT:float = 0.350
9101
9146
 
9102
9147
  try:
9103
9148
 
@@ -9126,6 +9171,10 @@ class SpotifyClient:
9126
9171
  verifyTimeout = validateDelay(verifyTimeout, 5, 10)
9127
9172
  if (not isinstance(verifyUserContext, bool)):
9128
9173
  verifyUserContext = True
9174
+ if (activateDevice is None):
9175
+ activateDevice = True
9176
+ if (refreshDeviceList is None):
9177
+ refreshDeviceList = False
9129
9178
 
9130
9179
  # determine if the device value specified is a name (e.g. "Bose-ST10-1") or
9131
9180
  # an id (e.g. "30fbc80e35598f3c242f2120413c943dfd9715fe", "48b677ca-ef9b-516f-b702-93bf2e8c67ba").
@@ -9139,6 +9188,12 @@ class SpotifyClient:
9139
9188
 
9140
9189
  # get all available Spotify Connect devices on the network.
9141
9190
  scDevices:SpotifyConnectDevices = self.GetSpotifyConnectDevices(refresh=refreshDeviceList)
9191
+
9192
+ # if we refreshed the device list, then give the device(s) a little time to disconnect so that
9193
+ # a new connection can be established (if required).
9194
+ if (refreshDeviceList):
9195
+ _logsi.LogVerbose(TRACE_MSG_DELAY_DEVICE % DELAY_DISCONNECT)
9196
+ time.sleep(DELAY_DISCONNECT)
9142
9197
 
9143
9198
  # process all discovered devices.
9144
9199
  for scDevice in scDevices:
@@ -9239,7 +9294,17 @@ class SpotifyClient:
9239
9294
  if (not activateDevice):
9240
9295
  _logsi.LogVerbose("Activation not requested for Spotify Connect device: '%s'" % (deviceResult.Title))
9241
9296
  break
9242
-
9297
+
9298
+ # does the device need to be activated?
9299
+ # check for the device in the available device list.
9300
+ # if we find it, then there is no need to activate it and we are done.
9301
+ # note - if another user is controlling the device, then it will not be in the active device list
9302
+ # for the current user!
9303
+ device:Device = self.GetPlayerDevice(deviceResultId, refresh=True)
9304
+ if device is not None:
9305
+ _logsi.LogVerbose("Spotify Connect device '%s' is already in the available device list; no need to re-activate" % (deviceResult.Title))
9306
+ break
9307
+
9243
9308
  zcfResult:ZeroconfResponse
9244
9309
 
9245
9310
  # disconnect the device.
@@ -9255,7 +9320,8 @@ class SpotifyClient:
9255
9320
  # some devices only support a single connection on the spotify connect
9256
9321
  # zeroconf webserver, so we have to give it a little time to process the
9257
9322
  # disconnect command before we try to call the Connect method.
9258
- time.sleep(0.350)
9323
+ _logsi.LogVerbose(TRACE_MSG_DELAY_DEVICE % DELAY_DISCONNECT)
9324
+ time.sleep(DELAY_DISCONNECT)
9259
9325
 
9260
9326
  # connect the device to OUR Spotify Connect user context.
9261
9327
  # note that the result here only indicates that the connect was submitted - NOT that it was successful!
@@ -9396,6 +9462,8 @@ class SpotifyClient:
9396
9462
  _logsi.LogMethodParmList(SILevel.Verbose, "Get available Spotify Connect devices", apiMethodParms)
9397
9463
 
9398
9464
  # validations.
9465
+ if refresh is None:
9466
+ refresh = True
9399
9467
  if sortResult is None:
9400
9468
  sortResult = True
9401
9469
 
@@ -10571,6 +10639,10 @@ class SpotifyClient:
10571
10639
  apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
10572
10640
  _logsi.LogMethodParmList(SILevel.Verbose, "Get profile information about the current user", apiMethodParms)
10573
10641
 
10642
+ # validations.
10643
+ if (refresh is None):
10644
+ refresh = True
10645
+
10574
10646
  # can we use the cached value?
10575
10647
  if (not refresh) and (apiMethodName in self._ConfigurationCache):
10576
10648
 
@@ -11328,12 +11400,13 @@ class SpotifyClient:
11328
11400
 
11329
11401
  # validations.
11330
11402
  delay = validateDelay(delay, 0.50, 10)
11403
+ if (resolveDeviceId is None):
11404
+ resolveDeviceId = True
11331
11405
 
11332
11406
  # has the device id been resolved?
11333
11407
  if (resolveDeviceId):
11334
11408
 
11335
- # no - ensure the specified device id / name is active and available, and
11336
- # the user context is set correctly.
11409
+ # no - ensure the specified device id / name is active and available.
11337
11410
  scDevice = self.GetSpotifyConnectDevice(
11338
11411
  deviceId,
11339
11412
  refreshDeviceList=False,
@@ -11457,6 +11530,10 @@ class SpotifyClient:
11457
11530
 
11458
11531
  # validations.
11459
11532
  delay = validateDelay(delay, 0.50, 10)
11533
+ if (shuffle is None):
11534
+ shuffle = True
11535
+ if (resolveDeviceId is None):
11536
+ resolveDeviceId = True
11460
11537
 
11461
11538
  # get current users favorite tracks.
11462
11539
  tracks:TrackPageSaved = self.GetTrackFavorites(limitTotal=limitTotal)
@@ -11473,8 +11550,7 @@ class SpotifyClient:
11473
11550
  # has the device id been resolved?
11474
11551
  if (resolveDeviceId):
11475
11552
 
11476
- # no - ensure the specified device id / name is active and available, and
11477
- # the user context is set correctly.
11553
+ # no - ensure the specified device id / name is active and available.
11478
11554
  scDevice = self.GetSpotifyConnectDevice(
11479
11555
  deviceId,
11480
11556
  refreshDeviceList=False,
@@ -11586,6 +11662,8 @@ class SpotifyClient:
11586
11662
 
11587
11663
  # validations.
11588
11664
  delay = validateDelay(delay, 0.50, 10)
11665
+ if (resolveDeviceId is None):
11666
+ resolveDeviceId = True
11589
11667
 
11590
11668
  # build a list of all item uri's.
11591
11669
  # remove any leading / trailing spaces in case user put a space between the items.
@@ -11600,8 +11678,7 @@ class SpotifyClient:
11600
11678
  # has the device id been resolved?
11601
11679
  if (resolveDeviceId):
11602
11680
 
11603
- # no - ensure the specified device id / name is active and available, and
11604
- # the user context is set correctly.
11681
+ # no - ensure the specified device id / name is active and available.
11605
11682
  scDevice = self.GetSpotifyConnectDevice(
11606
11683
  deviceId,
11607
11684
  refreshDeviceList=False,
@@ -12335,7 +12412,7 @@ class SpotifyClient:
12335
12412
  The shuffle mode to set:
12336
12413
  - `True` - Shuffle user's playback.
12337
12414
  - `False` - Do not shuffle user's playback.
12338
- Default: `False`
12415
+ Default is False
12339
12416
  deviceId (str):
12340
12417
  The id or name of the device this command is targeting.
12341
12418
  If not supplied, the user's currently active device is the target.
@@ -12600,9 +12677,14 @@ class SpotifyClient:
12600
12677
 
12601
12678
  # validations.
12602
12679
  delay = validateDelay(delay, 0.50, 10)
12603
-
12604
- # ensure the specified device id / name is active and available, and
12605
- # the user context is set correctly.
12680
+ if (play is None):
12681
+ play = True
12682
+ if (refreshDeviceList is None):
12683
+ refreshDeviceList = True
12684
+ if (forceActivateDevice is None):
12685
+ forceActivateDevice = True
12686
+
12687
+ # ensure the specified device id / name is active and available.
12606
12688
  scDevice = self.GetSpotifyConnectDevice(
12607
12689
  deviceId,
12608
12690
  refreshDeviceList=refreshDeviceList,
@@ -12627,7 +12709,7 @@ class SpotifyClient:
12627
12709
  {
12628
12710
  'device_ids': [deviceId]
12629
12711
  }
12630
- if play is not None:
12712
+ if (play is not None):
12631
12713
  reqData['play'] = play
12632
12714
 
12633
12715
  # execute spotify web api request.
@@ -12640,6 +12722,13 @@ class SpotifyClient:
12640
12722
  if delay > 0:
12641
12723
  _logsi.LogVerbose(TRACE_MSG_DELAY_DEVICE % delay)
12642
12724
  time.sleep(delay)
12725
+
12726
+ # if forceActivateDevice=True, then we need to resume play manually if play=True
12727
+ # was specified; this is due to the device losing its current status since it
12728
+ # was being forcefully activated (e.g. disconnected and reconnected).
12729
+ if (forceActivateDevice) and (play):
12730
+ _logsi.LogVerbose('Resuming play on device that was forcefully activated')
12731
+ self.PlayerMediaResume()
12643
12732
 
12644
12733
  # process results.
12645
12734
  # no results to process - this is pass or fail.
@@ -12721,6 +12810,8 @@ class SpotifyClient:
12721
12810
 
12722
12811
  # validations.
12723
12812
  delay = validateDelay(delay, 0.50, 10)
12813
+ if (play is None):
12814
+ play = False
12724
12815
 
12725
12816
  # get current Spotify Connect player state.
12726
12817
  result = self.GetPlayerPlaybackState()
@@ -15684,6 +15775,8 @@ class SpotifyClient:
15684
15775
  if scope is not None:
15685
15776
  if (not isinstance(scope, list)) and (not isinstance(scope, str)):
15686
15777
  raise SpotifyApiError(SAAppMessages.ARGUMENT_TYPE_ERROR % (apiMethodName, 'scope', 'list', type(scope).__name__), logsi=_logsi)
15778
+ if (forceAuthorize is None):
15779
+ forceAuthorize = False
15687
15780
 
15688
15781
  # create oauth provider for spotify authentication code with pkce.
15689
15782
  self._AuthClient:AuthClient = AuthClient(
@@ -15867,6 +15960,8 @@ class SpotifyClient:
15867
15960
  if scope is not None:
15868
15961
  if (not isinstance(scope, list)) and (not isinstance(scope, str)):
15869
15962
  raise SpotifyApiError(SAAppMessages.ARGUMENT_TYPE_ERROR % (apiMethodName, 'scope', 'list', type(scope).__name__), logsi=_logsi)
15963
+ if (forceAuthorize is None):
15964
+ forceAuthorize = False
15870
15965
 
15871
15966
  # create oauth provider for spotify authentication code with pkce.
15872
15967
  self._AuthClient:AuthClient = AuthClient(
@@ -49,7 +49,7 @@ class ZeroconfResponse:
49
49
  @property
50
50
  def ResponseSource(self) -> str:
51
51
  """
52
- Response source string (e.g. "").
52
+ Response source string (e.g. "", "eSDK", etc).
53
53
  """
54
54
  return self._ResponseSource
55
55