spotifywebapiPython 1.0.84__py3-none-any.whl → 1.0.86__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 (22) hide show
  1. {spotifywebapiPython-1.0.84.dist-info → spotifywebapiPython-1.0.86.dist-info}/METADATA +1 -1
  2. {spotifywebapiPython-1.0.84.dist-info → spotifywebapiPython-1.0.86.dist-info}/RECORD +22 -22
  3. spotifywebapipython/const.py +6 -1
  4. spotifywebapipython/docs/__init__.html +19 -2
  5. spotifywebapipython/docs/index.html +2 -2
  6. spotifywebapipython/docs/search.js +1 -1
  7. spotifywebapipython/docs/spotifywebapiPython/const.html +20 -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 +128 -42
  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/oauthcli/authclient.py +22 -5
  18. spotifywebapipython/spotifyclient.py +196 -27
  19. spotifywebapipython/zeroconfapi/zeroconfconnect.py +20 -1
  20. {spotifywebapiPython-1.0.84.dist-info → spotifywebapiPython-1.0.86.dist-info}/LICENSE +0 -0
  21. {spotifywebapiPython-1.0.84.dist-info → spotifywebapiPython-1.0.86.dist-info}/WHEEL +0 -0
  22. {spotifywebapiPython-1.0.84.dist-info → spotifywebapiPython-1.0.86.dist-info}/top_level.txt +0 -0
@@ -32,6 +32,7 @@ from .const import (
32
32
  SPOTIFY_DESKTOP_APP_CLIENT_ID,
33
33
  SPOTIFY_DEFAULT_MARKET,
34
34
  SPOTIFY_WEBAPI_URL_BASE,
35
+ SPOTIFYWEBAPIPYTHON_TOKEN_CACHE_FILE,
35
36
  TRACE_METHOD_RESULT,
36
37
  TRACE_METHOD_RESULT_TYPE,
37
38
  TRACE_METHOD_RESULT_TYPE_CACHED,
@@ -77,6 +78,7 @@ class SpotifyClient:
77
78
  def __init__(self,
78
79
  manager:PoolManager=None,
79
80
  tokenStorageDir:str=None,
81
+ tokenStorageFile:str=None,
80
82
  tokenUpdater:Callable=None,
81
83
  zeroconfClient:Zeroconf=None,
82
84
  spotifyConnectUsername:str=None,
@@ -91,9 +93,12 @@ class SpotifyClient:
91
93
  manager (urllib3.PoolManager):
92
94
  The manager for HTTP requests to the device.
93
95
  tokenStorageDir (str):
94
- The directory path that will contain the `tokens.json` file.
96
+ The directory path that will contain the authorization Token Cache file.
95
97
  A null value will default to the platform specific storage location:
96
98
  Example for Windows OS = `C:\ProgramData\SpotifyWebApiPython`
99
+ tokenStorageFile (str):
100
+ The filename and extension of the authorization Token Cache file.
101
+ Default is `SpotifyWebApiPython_tokens.json`.
97
102
  tokenUpdater (Callable):
98
103
  A method to call when a token needs to be refreshed by an external provider.
99
104
  The defined method is called with no parameters, and should return a token dictionary.
@@ -143,6 +148,11 @@ class SpotifyClient:
143
148
  if (spotifyConnectPassword is None) or (not isinstance(spotifyConnectPassword,str)):
144
149
  raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % ("__init__", 'spotifyConnectPassword'), logsi=_logsi)
145
150
 
151
+ # verify token storage filename was specified.
152
+ if tokenStorageFile is None:
153
+ tokenStorageFile = SPOTIFYWEBAPIPYTHON_TOKEN_CACHE_FILE
154
+
155
+ # initialize storage.
146
156
  self._AuthToken:SpotifyAuthToken = None
147
157
  self._AuthClient:AuthClient = None
148
158
  self._ConfigurationCache:dict = {}
@@ -152,6 +162,7 @@ class SpotifyClient:
152
162
  self._SpotifyConnectLoginId:str = spotifyConnectLoginId
153
163
  self._SpotifyConnectDiscoveryTimeout:float = float(spotifyConnectDiscoveryTimeout)
154
164
  self._TokenStorageDir:str = tokenStorageDir
165
+ self._TokenStorageFile:str = tokenStorageFile
155
166
  self._TokenUpdater:Callable = tokenUpdater
156
167
  self._UserProfile:UserProfile = None
157
168
  self._ZeroconfClient = zeroconfClient
@@ -294,6 +305,14 @@ class SpotifyClient:
294
305
  return self._TokenStorageDir
295
306
 
296
307
 
308
+ @property
309
+ def TokenStorageFile(self) -> str:
310
+ """
311
+ The filename and extension of the authorization token cache file.
312
+ """
313
+ return self._TokenStorageFile
314
+
315
+
297
316
  @property
298
317
  def UserProfile(self) -> UserProfile:
299
318
  """
@@ -619,16 +638,69 @@ class SpotifyClient:
619
638
  return result
620
639
 
621
640
 
622
- def _GetPlayerNowPlayingUri(self) -> str:
641
+ def _GetPlayerNowPlayingAudiobookUri(self) -> str:
623
642
  """
624
- Returns the uri value of the currently playing media if something is
643
+ Returns the audiobook uri value of the currently playing media if something is
625
644
  playing; otherwise, null is returned.
626
645
  """
627
646
  result:str = None
628
647
 
629
648
  # get nowplaying status.
630
649
  _logsi.LogVerbose("Querying NowPlaying status of Spotify player")
631
- nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying()
650
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes='episode')
651
+
652
+ # is an chapter playing? if so, return the parent show uri value.
653
+ if nowPlaying is not None:
654
+ _logsi.LogVerbose("NowPlaying data: %s" % str(nowPlaying))
655
+ if nowPlaying.CurrentlyPlayingType in ['episode']:
656
+ playingItem:Chapter = nowPlaying.Item
657
+ if (playingItem is not None):
658
+ chapter:Chapter = self.GetChapter(playingItem.Id)
659
+ result = chapter.Audiobook.Uri
660
+ else:
661
+ raise SpotifyApiError("Currently playing item is not a Audiobook Chapter", logsi=_logsi)
662
+
663
+ return result
664
+
665
+
666
+ def _GetPlayerNowPlayingShowUri(self) -> str:
667
+ """
668
+ Returns the show uri value of the currently playing media if something is
669
+ playing; otherwise, null is returned.
670
+ """
671
+ result:str = None
672
+
673
+ # get nowplaying status.
674
+ _logsi.LogVerbose("Querying NowPlaying status of Spotify player")
675
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes='episode')
676
+
677
+ # is an episode playing? if so, return the parent show uri value.
678
+ if nowPlaying is not None:
679
+ _logsi.LogVerbose("NowPlaying data: %s" % str(nowPlaying))
680
+ if nowPlaying.CurrentlyPlayingType in ['episode']:
681
+ playingItem:Episode = nowPlaying.Item
682
+ if (playingItem is not None):
683
+ episode:Episode = self.GetEpisode(playingItem.Id)
684
+ result = episode.Show.Uri
685
+ else:
686
+ raise SpotifyApiError("Currently playing item is not a Show Episode", logsi=_logsi)
687
+
688
+ return result
689
+
690
+
691
+ def _GetPlayerNowPlayingUri(
692
+ self,
693
+ additionalTypes:str=None,
694
+ ) -> str:
695
+ """
696
+ Returns the uri value of the currently playing media type if something is
697
+ playing; otherwise, null is returned.
698
+ """
699
+ result:str = None
700
+
701
+ # get nowplaying status.
702
+ _logsi.LogVerbose("Querying NowPlaying status of Spotify player")
703
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes=additionalTypes)
632
704
 
633
705
  # is anything playing? if so, return the uri value.
634
706
  if nowPlaying is not None:
@@ -2496,6 +2568,7 @@ class SpotifyClient:
2496
2568
  limit (int):
2497
2569
  The maximum number of items to return in a page of items when manual paging is used.
2498
2570
  Default: 20, Range: 1 to 50.
2571
+ See the `limitTotal` argument for automatic paging option.
2499
2572
  offset (int):
2500
2573
  The page index offset of the first item to return.
2501
2574
  Use with limit to get the next set of items.
@@ -2660,6 +2733,7 @@ class SpotifyClient:
2660
2733
  limit (int):
2661
2734
  The maximum number of items to return in a page of items when manual paging is used.
2662
2735
  Default: 20, Range: 1 to 50.
2736
+ See the `limitTotal` argument for automatic paging option.
2663
2737
  offset (int):
2664
2738
  The page index offset of the first item to return.
2665
2739
  Use with limit to get the next set of items.
@@ -2913,6 +2987,7 @@ class SpotifyClient:
2913
2987
  limit (int):
2914
2988
  The maximum number of items to return in a page of items when manual paging is used.
2915
2989
  Default: 20, Range: 1 to 50.
2990
+ See the `limitTotal` argument for automatic paging option.
2916
2991
  offset (int):
2917
2992
  The index of the first item to return; use with limit to get the next set of items.
2918
2993
  Default: 0 (the first item).
@@ -3143,6 +3218,7 @@ class SpotifyClient:
3143
3218
  limit (int):
3144
3219
  The maximum number of items to return in a page of items when manual paging is used.
3145
3220
  Default: 20, Range: 1 to 50.
3221
+ See the `limitTotal` argument for automatic paging option.
3146
3222
  offset (int):
3147
3223
  The index of the first item to return; use with limit to get the next set of items.
3148
3224
  Default: 0 (the first item).
@@ -3702,6 +3778,7 @@ class SpotifyClient:
3702
3778
  limit (int):
3703
3779
  The maximum number of items to return in a page of items when manual paging is used.
3704
3780
  Default: 20, Range: 1 to 50.
3781
+ See the `limitTotal` argument for automatic paging option.
3705
3782
  limitTotal (int):
3706
3783
  The maximum number of items to return for the request.
3707
3784
  If specified, this argument overrides the limit and offset argument values
@@ -4036,6 +4113,7 @@ class SpotifyClient:
4036
4113
  limit (int):
4037
4114
  The maximum number of items to return in a page of items when manual paging is used.
4038
4115
  Default: 20, Range: 1 to 50.
4116
+ See the `limitTotal` argument for automatic paging option.
4039
4117
  offset (int):
4040
4118
  The index of the first item to return; use with limit to get the next set of items.
4041
4119
  Default: 0 (the first item).
@@ -4193,6 +4271,7 @@ class SpotifyClient:
4193
4271
  limit (int):
4194
4272
  The maximum number of items to return in a page of items when manual paging is used.
4195
4273
  Default: 20, Range: 1 to 50.
4274
+ See the `limitTotal` argument for automatic paging option.
4196
4275
  offset (int):
4197
4276
  The page index offset of the first item to return.
4198
4277
  Use with limit to get the next set of items.
@@ -4556,6 +4635,7 @@ class SpotifyClient:
4556
4635
  limit (int):
4557
4636
  The maximum number of items to return in a page of items when manual paging is used.
4558
4637
  Default: 20, Range: 1 to 50.
4638
+ See the `limitTotal` argument for automatic paging option.
4559
4639
  offset (int):
4560
4640
  The page index offset of the first item to return.
4561
4641
  Use with limit to get the next set of items.
@@ -4831,6 +4911,7 @@ class SpotifyClient:
4831
4911
  limit (int):
4832
4912
  The maximum number of items to return in a page of items when manual paging is used.
4833
4913
  Default: 20, Range: 1 to 50.
4914
+ See the `limitTotal` argument for automatic paging option.
4834
4915
  offset (int):
4835
4916
  The page index offset of the first item to return.
4836
4917
  Use with limit to get the next set of items.
@@ -5283,6 +5364,7 @@ class SpotifyClient:
5283
5364
  limit (int):
5284
5365
  The maximum number of items to return in a page of items when manual paging is used.
5285
5366
  Default: 20, Range: 1 to 50.
5367
+ See the `limitTotal` argument for automatic paging option.
5286
5368
  offset (int):
5287
5369
  The page index offset of the first item to return.
5288
5370
  Use with limit to get the next set of items.
@@ -5529,6 +5611,7 @@ class SpotifyClient:
5529
5611
  limit (int):
5530
5612
  The maximum number of items to return in a page of items when manual paging is used.
5531
5613
  Default: 20, Range: 1 to 50.
5614
+ See the `limitTotal` argument for automatic paging option.
5532
5615
  offset (int):
5533
5616
  The page index offset of the first item to return.
5534
5617
  Use with limit to get the next set of items.
@@ -6128,7 +6211,8 @@ class SpotifyClient:
6128
6211
  discoverResult.HostIpPort,
6129
6212
  discoverResult.SpotifyConnectCPath,
6130
6213
  useSSL=False,
6131
- tokenStorageDir=self.TokenStorageDir)
6214
+ tokenStorageDir=self.TokenStorageDir,
6215
+ tokenStorageFile=self.TokenStorageFile)
6132
6216
 
6133
6217
  # if a different user context has control of the device then we need to disconnect
6134
6218
  # the current user context before connecting a different user.
@@ -6649,6 +6733,7 @@ class SpotifyClient:
6649
6733
  limit (int):
6650
6734
  The maximum number of items to return in a page of items when manual paging is used.
6651
6735
  Default: 20, Range: 1 to 50.
6736
+ See the `limitTotal` argument for automatic paging option.
6652
6737
  after (int):
6653
6738
  Returns all items after (but not including) this cursor position, which is
6654
6739
  a Unix timestamp in milliseconds.
@@ -7037,6 +7122,7 @@ class SpotifyClient:
7037
7122
  limit (int):
7038
7123
  The maximum number of items to return in a page of items when manual paging is used.
7039
7124
  Default: 50, Range: 1 to 50.
7125
+ See the `limitTotal` argument for automatic paging option.
7040
7126
  offset (int):
7041
7127
  The page index offset of the first item to return.
7042
7128
  Use with limit to get the next set of items.
@@ -7221,6 +7307,7 @@ class SpotifyClient:
7221
7307
  limit (int):
7222
7308
  The maximum number of items to return in a page of items when manual paging is used.
7223
7309
  Default: 20, Range: 1 to 50.
7310
+ See the `limitTotal` argument for automatic paging option.
7224
7311
  offset (int):
7225
7312
  The page index offset of the first item to return.
7226
7313
  Use with limit to get the next set of items.
@@ -7375,6 +7462,7 @@ class SpotifyClient:
7375
7462
  limit (int):
7376
7463
  The maximum number of items to return in a page of items when manual paging is used.
7377
7464
  Default: 20, Range: 1 to 50.
7465
+ See the `limitTotal` argument for automatic paging option.
7378
7466
  offset (int):
7379
7467
  The page index offset of the first item to return.
7380
7468
  Use with limit to get the next set of items.
@@ -7618,6 +7706,7 @@ class SpotifyClient:
7618
7706
  limit (int):
7619
7707
  The maximum number of items to return in a page of items when manual paging is used.
7620
7708
  Default: 20, Range: 1 to 50.
7709
+ See the `limitTotal` argument for automatic paging option.
7621
7710
  offset (int):
7622
7711
  The index of the first item to return; use with limit to get the next set of items.
7623
7712
  Default: 0 (the first item).
@@ -7775,6 +7864,7 @@ class SpotifyClient:
7775
7864
  limit (int):
7776
7865
  The maximum number of items to return in a page of items when manual paging is used.
7777
7866
  Default: 20, Range: 1 to 50.
7867
+ See the `limitTotal` argument for automatic paging option.
7778
7868
  offset (int):
7779
7869
  The page index offset of the first item to return.
7780
7870
  Use with limit to get the next set of items.
@@ -8182,7 +8272,8 @@ class SpotifyClient:
8182
8272
  discoverResult.HostIpPort,
8183
8273
  discoverResult.SpotifyConnectCPath,
8184
8274
  useSSL=False,
8185
- tokenStorageDir=self.TokenStorageDir)
8275
+ tokenStorageDir=self.TokenStorageDir,
8276
+ tokenStorageFile=self.TokenStorageFile)
8186
8277
 
8187
8278
  # if we did not refresh the device list, then query the device for real-time status; just in
8188
8279
  # case the device was disconnected after the last cache refresh. note that we only do this
@@ -8200,9 +8291,10 @@ class SpotifyClient:
8200
8291
  # check if the Spotify Desktop Application Client oauth2 token is defined.
8201
8292
  hasToken:bool = AuthClient.HasTokenForKey(
8202
8293
  clientId=SPOTIFY_DESKTOP_APP_CLIENT_ID,
8203
- tokenStorageDir=self.TokenStorageDir,
8204
8294
  tokenProviderId='SpotifyWebApiAuthCodePkce',
8205
8295
  tokenProfileId=self._SpotifyConnectLoginId,
8296
+ tokenStorageDir=self.TokenStorageDir,
8297
+ tokenStorageFile=self.TokenStorageFile,
8206
8298
  )
8207
8299
 
8208
8300
  if not hasToken:
@@ -8431,7 +8523,8 @@ class SpotifyClient:
8431
8523
  discoverResult.HostIpPort,
8432
8524
  discoverResult.SpotifyConnectCPath,
8433
8525
  useSSL=False,
8434
- tokenStorageDir=self.TokenStorageDir)
8526
+ tokenStorageDir=self.TokenStorageDir,
8527
+ tokenStorageFile=self.TokenStorageFile)
8435
8528
  info = zconn.GetInformation()
8436
8529
 
8437
8530
  except Exception as ex:
@@ -8446,7 +8539,8 @@ class SpotifyClient:
8446
8539
  discoverResult.HostIpPort,
8447
8540
  discoverResult.SpotifyConnectCPath,
8448
8541
  useSSL=False,
8449
- tokenStorageDir=self.TokenStorageDir)
8542
+ tokenStorageDir=self.TokenStorageDir,
8543
+ tokenStorageFile=self.TokenStorageFile)
8450
8544
  info = zconn.GetInformation()
8451
8545
 
8452
8546
  # update HostIpAddress in discovery result so it knows to use the alias
@@ -8687,6 +8781,7 @@ class SpotifyClient:
8687
8781
  limit (int):
8688
8782
  The maximum number of items to return in a page of items when manual paging is used.
8689
8783
  Default: 20, Range: 1 to 50.
8784
+ See the `limitTotal` argument for automatic paging option.
8690
8785
  offset (int):
8691
8786
  The page index offset of the first item to return.
8692
8787
  Use with limit to get the next set of items.
@@ -9613,6 +9708,7 @@ class SpotifyClient:
9613
9708
  limit (int):
9614
9709
  The maximum number of items to return in a page of items when manual paging is used.
9615
9710
  Default: 20, Range: 1 to 50.
9711
+ See the `limitTotal` argument for automatic paging option.
9616
9712
  offset (int):
9617
9713
  The page index offset of the first item to return.
9618
9714
  Use with limit to get the next set of items.
@@ -9774,6 +9870,7 @@ class SpotifyClient:
9774
9870
  limit (int):
9775
9871
  The maximum number of items to return in a page of items when manual paging is used.
9776
9872
  Default: 20, Range: 1 to 50.
9873
+ See the `limitTotal` argument for automatic paging option.
9777
9874
  offset (int):
9778
9875
  The page index offset of the first item to return.
9779
9876
  Use with limit to get the next set of items.
@@ -11554,9 +11651,10 @@ class SpotifyClient:
11554
11651
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
11555
11652
 
11556
11653
 
11557
- def RemoveAudiobookFavorites(self,
11558
- ids:str
11559
- ) -> None:
11654
+ def RemoveAudiobookFavorites(
11655
+ self,
11656
+ ids:str=None,
11657
+ ) -> None:
11560
11658
  """
11561
11659
  Remove one or more audiobooks from the current user's 'Your Library'.
11562
11660
 
@@ -11567,6 +11665,7 @@ class SpotifyClient:
11567
11665
  A comma-separated list of the Spotify IDs for the audiobooks.
11568
11666
  Maximum: 50 IDs.
11569
11667
  Example: `3PFyizE2tGCSRLusl2Qizf,7iHfbu1YPACw6oZPAFJtqe`
11668
+ If null, the currently playing track album uri id value is used.
11570
11669
 
11571
11670
  Raises:
11572
11671
  SpotifyWebApiError:
@@ -11598,6 +11697,14 @@ class SpotifyClient:
11598
11697
  apiMethodParms.AppendKeyValue("ids", ids)
11599
11698
  _logsi.LogMethodParmList(SILevel.Verbose, "Remove audiobook(s) from user favorites", apiMethodParms)
11600
11699
 
11700
+ # if ids not specified, then return currently playing id value.
11701
+ if (ids is None) or (len(ids.strip()) == 0):
11702
+ uri = self._GetPlayerNowPlayingAudiobookUri()
11703
+ if uri is not None:
11704
+ ids = SpotifyClient.GetIdFromUri(uri)
11705
+ else:
11706
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
11707
+
11601
11708
  # build a list of all item id's.
11602
11709
  # remove any leading / trailing spaces in case user put a space between the items.
11603
11710
  arrIds:list[str] = ids.split(',')
@@ -11633,9 +11740,10 @@ class SpotifyClient:
11633
11740
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
11634
11741
 
11635
11742
 
11636
- def RemoveEpisodeFavorites(self,
11637
- ids:str
11638
- ) -> None:
11743
+ def RemoveEpisodeFavorites(
11744
+ self,
11745
+ ids:str=None,
11746
+ ) -> None:
11639
11747
  """
11640
11748
  Remove one or more episodes from the current user's 'Your Library'.
11641
11749
 
@@ -11646,6 +11754,7 @@ class SpotifyClient:
11646
11754
  A comma-separated list of the Spotify IDs for the episodes.
11647
11755
  Maximum: 50 IDs.
11648
11756
  Example: `6kAsbP8pxwaU2kPibKTuHE,4rOoJ6Egrf8K2IrywzwOMk`
11757
+ If null, the currently playing context uri id value is used.
11649
11758
 
11650
11759
  Raises:
11651
11760
  SpotifyWebApiError:
@@ -11677,6 +11786,14 @@ class SpotifyClient:
11677
11786
  apiMethodParms.AppendKeyValue("ids", ids)
11678
11787
  _logsi.LogMethodParmList(SILevel.Verbose, "Remove episode(s) from user favorites", apiMethodParms)
11679
11788
 
11789
+ # if ids not specified, then return currently playing id value.
11790
+ if (ids is None) or (len(ids.strip()) == 0):
11791
+ uri = self._GetPlayerNowPlayingUri('episode')
11792
+ if uri is not None:
11793
+ ids = SpotifyClient.GetIdFromUri(uri)
11794
+ else:
11795
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
11796
+
11680
11797
  # build a list of all item id's.
11681
11798
  # remove any leading / trailing spaces in case user put a space between the items.
11682
11799
  arrIds:list[str] = ids.split(',')
@@ -11891,9 +12008,10 @@ class SpotifyClient:
11891
12008
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
11892
12009
 
11893
12010
 
11894
- def RemoveShowFavorites(self,
11895
- ids:str
11896
- ) -> None:
12011
+ def RemoveShowFavorites(
12012
+ self,
12013
+ ids:str=None,
12014
+ ) -> None:
11897
12015
  """
11898
12016
  Remove one or more shows from the current user's 'Your Library'.
11899
12017
 
@@ -11904,6 +12022,7 @@ class SpotifyClient:
11904
12022
  A comma-separated list of the Spotify IDs for the shows.
11905
12023
  Maximum: 50 IDs.
11906
12024
  Example: `6kAsbP8pxwaU2kPibKTuHE,4rOoJ6Egrf8K2IrywzwOMk`
12025
+ If null, the currently playing context uri id value is used.
11907
12026
 
11908
12027
  Raises:
11909
12028
  SpotifyWebApiError:
@@ -11935,6 +12054,14 @@ class SpotifyClient:
11935
12054
  apiMethodParms.AppendKeyValue("ids", ids)
11936
12055
  _logsi.LogMethodParmList(SILevel.Verbose, "Remove show(s) from user favorites", apiMethodParms)
11937
12056
 
12057
+ # if ids not specified, then return currently playing id value.
12058
+ if (ids is None) or (len(ids.strip()) == 0):
12059
+ uri = self._GetPlayerNowPlayingShowUri()
12060
+ if uri is not None:
12061
+ ids = SpotifyClient.GetIdFromUri(uri)
12062
+ else:
12063
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
12064
+
11938
12065
  # build a list of all item id's.
11939
12066
  # remove any leading / trailing spaces in case user put a space between the items.
11940
12067
  arrIds:list[str] = ids.split(',')
@@ -12348,9 +12475,10 @@ class SpotifyClient:
12348
12475
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
12349
12476
 
12350
12477
 
12351
- def SaveAudiobookFavorites(self,
12352
- ids:str
12353
- ) -> None:
12478
+ def SaveAudiobookFavorites(
12479
+ self,
12480
+ ids:str=None,
12481
+ ) -> None:
12354
12482
  """
12355
12483
  Save one or more audiobooks to the current user's 'Your Library'.
12356
12484
 
@@ -12392,6 +12520,14 @@ class SpotifyClient:
12392
12520
  apiMethodParms.AppendKeyValue("ids", ids)
12393
12521
  _logsi.LogMethodParmList(SILevel.Verbose, "Save audiobook(s) to user favorites", apiMethodParms)
12394
12522
 
12523
+ # if ids not specified, then return currently playing id value.
12524
+ if (ids is None) or (len(ids.strip()) == 0):
12525
+ uri = self._GetPlayerNowPlayingAudiobookUri()
12526
+ if uri is not None:
12527
+ ids = SpotifyClient.GetIdFromUri(uri)
12528
+ else:
12529
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
12530
+
12395
12531
  # build a list of all item id's.
12396
12532
  # remove any leading / trailing spaces in case user put a space between the items.
12397
12533
  arrIds:list[str] = ids.split(',')
@@ -12427,9 +12563,10 @@ class SpotifyClient:
12427
12563
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
12428
12564
 
12429
12565
 
12430
- def SaveEpisodeFavorites(self,
12431
- ids:str
12432
- ) -> None:
12566
+ def SaveEpisodeFavorites(
12567
+ self,
12568
+ ids:str=None,
12569
+ ) -> None:
12433
12570
  """
12434
12571
  Save one or more episodes to the current user's 'Your Library'.
12435
12572
 
@@ -12440,6 +12577,7 @@ class SpotifyClient:
12440
12577
  A comma-separated list of the Spotify IDs for the episodes.
12441
12578
  Maximum: 50 IDs.
12442
12579
  Example: `6kAsbP8pxwaU2kPibKTuHE,4rOoJ6Egrf8K2IrywzwOMk`
12580
+ If null, the currently playing context uri id value is used.
12443
12581
 
12444
12582
  Raises:
12445
12583
  SpotifyWebApiError:
@@ -12471,6 +12609,14 @@ class SpotifyClient:
12471
12609
  apiMethodParms.AppendKeyValue("ids", ids)
12472
12610
  _logsi.LogMethodParmList(SILevel.Verbose, "Save episode(s) to user favorites", apiMethodParms)
12473
12611
 
12612
+ # if ids not specified, then return currently playing id value.
12613
+ if (ids is None) or (len(ids.strip()) == 0):
12614
+ uri = self._GetPlayerNowPlayingUri('episode')
12615
+ if uri is not None:
12616
+ ids = SpotifyClient.GetIdFromUri(uri)
12617
+ else:
12618
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
12619
+
12474
12620
  # build a list of all item id's.
12475
12621
  # remove any leading / trailing spaces in case user put a space between the items.
12476
12622
  arrIds:list[str] = ids.split(',')
@@ -12506,9 +12652,10 @@ class SpotifyClient:
12506
12652
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
12507
12653
 
12508
12654
 
12509
- def SaveShowFavorites(self,
12510
- ids:str
12511
- ) -> None:
12655
+ def SaveShowFavorites(
12656
+ self,
12657
+ ids:str=None,
12658
+ ) -> None:
12512
12659
  """
12513
12660
  Save one or more shows to the current user's 'Your Library'.
12514
12661
 
@@ -12519,6 +12666,7 @@ class SpotifyClient:
12519
12666
  A comma-separated list of the Spotify IDs for the shows.
12520
12667
  Maximum: 50 IDs.
12521
12668
  Example: `6kAsbP8pxwaU2kPibKTuHE,4rOoJ6Egrf8K2IrywzwOMk`
12669
+ If null, the currently playing context uri id value is used.
12522
12670
 
12523
12671
  Raises:
12524
12672
  SpotifyWebApiError:
@@ -12550,6 +12698,14 @@ class SpotifyClient:
12550
12698
  apiMethodParms.AppendKeyValue("ids", ids)
12551
12699
  _logsi.LogMethodParmList(SILevel.Verbose, "Save show(s) to user favorites", apiMethodParms)
12552
12700
 
12701
+ # if ids not specified, then return currently playing id value.
12702
+ if (ids is None) or (len(ids.strip()) == 0):
12703
+ uri = self._GetPlayerNowPlayingShowUri()
12704
+ if uri is not None:
12705
+ ids = SpotifyClient.GetIdFromUri(uri)
12706
+ else:
12707
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
12708
+
12553
12709
  # build a list of all item id's.
12554
12710
  # remove any leading / trailing spaces in case user put a space between the items.
12555
12711
  arrIds:list[str] = ids.split(',')
@@ -12709,6 +12865,7 @@ class SpotifyClient:
12709
12865
  # limit (int):
12710
12866
  # The maximum number of items to return in a page of items.
12711
12867
  # Default: 20, Range: 1 to 50.
12868
+ # See the `limitTotal` argument for automatic paging option.
12712
12869
  # offset (int):
12713
12870
  # The page index offset of the first item to return.
12714
12871
  # Use with limit to get the next set of items.
@@ -12878,6 +13035,7 @@ class SpotifyClient:
12878
13035
  limit (int):
12879
13036
  The maximum number of items to return in a page of items when manual paging is used.
12880
13037
  Default: 20, Range: 1 to 50.
13038
+ See the `limitTotal` argument for automatic paging option.
12881
13039
  offset (int):
12882
13040
  The page index offset of the first item to return.
12883
13041
  Use with limit to get the next set of items.
@@ -13068,6 +13226,7 @@ class SpotifyClient:
13068
13226
  limit (int):
13069
13227
  The maximum number of items to return in a page of items when manual paging is used.
13070
13228
  Default: 20, Range: 1 to 50.
13229
+ See the `limitTotal` argument for automatic paging option.
13071
13230
  offset (int):
13072
13231
  The page index offset of the first item to return.
13073
13232
  Use with limit to get the next set of items.
@@ -13258,6 +13417,7 @@ class SpotifyClient:
13258
13417
  limit (int):
13259
13418
  The maximum number of items to return in a page of items when manual paging is used.
13260
13419
  Default: 20, Range: 1 to 50.
13420
+ See the `limitTotal` argument for automatic paging option.
13261
13421
  offset (int):
13262
13422
  The page index offset of the first item to return.
13263
13423
  Use with limit to get the next set of items.
@@ -13450,6 +13610,7 @@ class SpotifyClient:
13450
13610
  limit (int):
13451
13611
  The maximum number of items to return in a page of items when manual paging is used.
13452
13612
  Default: 20, Range: 1 to 50.
13613
+ See the `limitTotal` argument for automatic paging option.
13453
13614
  offset (int):
13454
13615
  The page index offset of the first item to return.
13455
13616
  Use with limit to get the next set of items.
@@ -13640,6 +13801,7 @@ class SpotifyClient:
13640
13801
  limit (int):
13641
13802
  The maximum number of items to return in a page of items when manual paging is used.
13642
13803
  Default: 20, Range: 1 to 50.
13804
+ See the `limitTotal` argument for automatic paging option.
13643
13805
  offset (int):
13644
13806
  The page index offset of the first item to return.
13645
13807
  Use with limit to get the next set of items.
@@ -13830,6 +13992,7 @@ class SpotifyClient:
13830
13992
  limit (int):
13831
13993
  The maximum number of items to return in a page of items when manual paging is used.
13832
13994
  Default: 20, Range: 1 to 50.
13995
+ See the `limitTotal` argument for automatic paging option.
13833
13996
  offset (int):
13834
13997
  The page index offset of the first item to return.
13835
13998
  Use with limit to get the next set of items.
@@ -14020,6 +14183,7 @@ class SpotifyClient:
14020
14183
  limit (int):
14021
14184
  The maximum number of items to return in a page of items when manual paging is used.
14022
14185
  Default: 20, Range: 1 to 50.
14186
+ See the `limitTotal` argument for automatic paging option.
14023
14187
  offset (int):
14024
14188
  The page index offset of the first item to return.
14025
14189
  Use with limit to get the next set of items.
@@ -14298,6 +14462,7 @@ class SpotifyClient:
14298
14462
  clientSecret=clientSecret,
14299
14463
  oauth2Client=WebApplicationClient(client_id=clientId), # required for grant_type = authorization_code
14300
14464
  tokenStorageDir=self._TokenStorageDir,
14465
+ tokenStorageFile=self._TokenStorageFile,
14301
14466
  tokenProviderId='SpotifyWebApiAuthCode',
14302
14467
  tokenProfileId=tokenProfileId,
14303
14468
  tokenUpdater=self._TokenUpdater
@@ -14480,6 +14645,7 @@ class SpotifyClient:
14480
14645
  clientSecret=None, # client_secret not used for authorization code with pkce type
14481
14646
  oauth2Client=WebApplicationClient(client_id=clientId), # required for grant_type = authorization_code
14482
14647
  tokenStorageDir=self._TokenStorageDir,
14648
+ tokenStorageFile=self._TokenStorageFile,
14483
14649
  tokenProviderId='SpotifyWebApiAuthCodePkce',
14484
14650
  tokenProfileId=tokenProfileId,
14485
14651
  tokenUpdater=self._TokenUpdater
@@ -14597,6 +14763,7 @@ class SpotifyClient:
14597
14763
  clientSecret=clientSecret,
14598
14764
  oauth2Client=BackendApplicationClient(client_id=clientId), # required for grant_type = client_credentials
14599
14765
  tokenStorageDir=self._TokenStorageDir,
14766
+ tokenStorageFile=self._TokenStorageFile,
14600
14767
  tokenProviderId='SpotifyWebApiClientCredentials',
14601
14768
  tokenProfileId=tokenProfileId,
14602
14769
  tokenUpdater=self._TokenUpdater
@@ -14695,6 +14862,7 @@ class SpotifyClient:
14695
14862
  scope=token.get('scope'),
14696
14863
  clientId=clientId,
14697
14864
  tokenStorageDir=self._TokenStorageDir,
14865
+ tokenStorageFile=self._TokenStorageFile,
14698
14866
  tokenProviderId='SpotifyWebApiOAuth2Token',
14699
14867
  tokenProfileId=tokenProfileId,
14700
14868
  tokenUpdater=self._TokenUpdater
@@ -14754,6 +14922,7 @@ class SpotifyClient:
14754
14922
  msg:str = 'SpotifyClient:'
14755
14923
  msg = "%s\n ConfigurationCache key count=%d" % (msg, len(self._ConfigurationCache))
14756
14924
  msg = "%s\n TokenStorageDir='%s'" % (msg, self._TokenStorageDir)
14925
+ msg = "%s\n TokenStorageFile='%s'" % (msg, self._TokenStorageFile)
14757
14926
  if self._UserProfile is not None:
14758
14927
  msg = "%s\n User DisplayName='%s' (%s)" % (msg, self._UserProfile.DisplayName, self._UserProfile.Id)
14759
14928
  return msg