spotifywebapiPython 1.0.90__py3-none-any.whl → 1.0.92__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.

@@ -622,123 +622,6 @@ class SpotifyClient:
622
622
  msg.ResponseData = responseData
623
623
 
624
624
 
625
- def _GetPlayerNowPlayingAlbumUri(self) -> str:
626
- """
627
- Returns the album uri value of the currently playing media if something is
628
- playing; otherwise, null is returned.
629
- """
630
- result:str = None
631
-
632
- # get nowplaying status.
633
- _logsi.LogVerbose("Querying NowPlaying status of Spotify player")
634
- nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying()
635
-
636
- # is a track playing? if so, return the album uri value.
637
- if nowPlaying is not None:
638
- _logsi.LogVerbose("NowPlaying data: %s" % str(nowPlaying))
639
- if nowPlaying.CurrentlyPlayingType in ['track']:
640
- trackItem:Track = nowPlaying.Item
641
- if (trackItem is not None) and (trackItem.Album is not None):
642
- result = trackItem.Album.Uri
643
-
644
- return result
645
-
646
-
647
- def _GetPlayerNowPlayingArtistUri(self) -> str:
648
- """
649
- Returns the artist uri value of the currently playing media if something is
650
- playing; otherwise, null is returned.
651
- """
652
- result:str = None
653
-
654
- # get nowplaying status.
655
- _logsi.LogVerbose("Querying NowPlaying status of Spotify player")
656
- nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying()
657
-
658
- # is a track playing? if so, return the artist uri value.
659
- if nowPlaying is not None:
660
- _logsi.LogVerbose("NowPlaying data: %s" % str(nowPlaying))
661
- if nowPlaying.CurrentlyPlayingType in ['track']:
662
- trackItem:Track = nowPlaying.Item
663
- if (trackItem is not None) and (len(trackItem.Artists) > 0):
664
- result = trackItem.Artists[0].Uri
665
-
666
- return result
667
-
668
-
669
- def _GetPlayerNowPlayingAudiobookUri(self) -> str:
670
- """
671
- Returns the audiobook uri value of the currently playing media if something is
672
- playing; otherwise, null is returned.
673
- """
674
- result:str = None
675
-
676
- # get nowplaying status.
677
- _logsi.LogVerbose("Querying NowPlaying status of Spotify player")
678
- nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes='episode')
679
-
680
- # is an chapter playing? if so, return the parent show uri value.
681
- if nowPlaying is not None:
682
- _logsi.LogVerbose("NowPlaying data: %s" % str(nowPlaying))
683
- if nowPlaying.CurrentlyPlayingType in ['episode']:
684
- playingItem:Chapter = nowPlaying.Item
685
- if (playingItem is not None):
686
- chapter:Chapter = self.GetChapter(playingItem.Id)
687
- result = chapter.Audiobook.Uri
688
- else:
689
- raise SpotifyApiError("Currently playing item is not a Audiobook Chapter", logsi=_logsi)
690
-
691
- return result
692
-
693
-
694
- def _GetPlayerNowPlayingShowUri(self) -> str:
695
- """
696
- Returns the show uri value of the currently playing media 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='episode')
704
-
705
- # is an episode playing? if so, return the parent show uri value.
706
- if nowPlaying is not None:
707
- _logsi.LogVerbose("NowPlaying data: %s" % str(nowPlaying))
708
- if nowPlaying.CurrentlyPlayingType in ['episode']:
709
- playingItem:Episode = nowPlaying.Item
710
- if (playingItem is not None):
711
- episode:Episode = self.GetEpisode(playingItem.Id)
712
- result = episode.Show.Uri
713
- else:
714
- raise SpotifyApiError("Currently playing item is not a Show Episode", logsi=_logsi)
715
-
716
- return result
717
-
718
-
719
- def _GetPlayerNowPlayingUri(
720
- self,
721
- additionalTypes:str=None,
722
- ) -> str:
723
- """
724
- Returns the uri value of the currently playing media type if something is
725
- playing; otherwise, null is returned.
726
- """
727
- result:str = None
728
-
729
- # get nowplaying status.
730
- _logsi.LogVerbose("Querying NowPlaying status of Spotify player")
731
- nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes=additionalTypes)
732
-
733
- # is anything playing? if so, return the uri value.
734
- if nowPlaying is not None:
735
- _logsi.LogVerbose("NowPlaying data: %s" % str(nowPlaying))
736
- if nowPlaying.Item is not None:
737
- result = nowPlaying.Item.Uri
738
-
739
- return result
740
-
741
-
742
625
  def _ValidateMarket(self,
743
626
  market:str,
744
627
  ) -> str:
@@ -1107,6 +990,7 @@ class SpotifyClient:
1107
990
  # no results to process - this is pass or fail.
1108
991
  return
1109
992
 
993
+ except SpotifyApiError: raise # pass handled exceptions on thru
1110
994
  except SpotifyWebApiError: raise # pass handled exceptions on thru
1111
995
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
1112
996
  except Exception as ex:
@@ -1179,7 +1063,7 @@ class SpotifyClient:
1179
1063
 
1180
1064
  # if uris not specified, then return currently playing uri value.
1181
1065
  if (uris is None) or (len(uris.strip()) == 0):
1182
- uris = self._GetPlayerNowPlayingUri()
1066
+ uris = self.GetPlayerNowPlayingUri(None)
1183
1067
  if uris is None:
1184
1068
  raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'uris'), logsi=_logsi)
1185
1069
 
@@ -1338,6 +1222,7 @@ class SpotifyClient:
1338
1222
  # no results to process - this is pass or fail.
1339
1223
  return
1340
1224
 
1225
+ except SpotifyApiError: raise # pass handled exceptions on thru
1341
1226
  except SpotifyWebApiError: raise # pass handled exceptions on thru
1342
1227
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
1343
1228
  except Exception as ex:
@@ -1399,7 +1284,7 @@ class SpotifyClient:
1399
1284
 
1400
1285
  # if ids not specified, then return currently playing album id value.
1401
1286
  if (ids is None) or (len(ids.strip()) == 0):
1402
- uri = self._GetPlayerNowPlayingAlbumUri()
1287
+ uri = self.GetPlayerNowPlayingAlbumUri()
1403
1288
  if uri is not None:
1404
1289
  ids = SpotifyClient.GetIdFromUri(uri)
1405
1290
  else:
@@ -1497,7 +1382,7 @@ class SpotifyClient:
1497
1382
 
1498
1383
  # if ids not specified, then return currently playing artist id value.
1499
1384
  if (ids is None) or (len(ids.strip()) == 0):
1500
- uri = self._GetPlayerNowPlayingArtistUri()
1385
+ uri = self.GetPlayerNowPlayingArtistUri()
1501
1386
  if uri is not None:
1502
1387
  ids = SpotifyClient.GetIdFromUri(uri)
1503
1388
  else:
@@ -1593,7 +1478,7 @@ class SpotifyClient:
1593
1478
 
1594
1479
  # if ids not specified, then return currently playing id value.
1595
1480
  if (ids is None) or (len(ids.strip()) == 0):
1596
- uri = self._GetPlayerNowPlayingAudiobookUri()
1481
+ uri = self.GetPlayerNowPlayingAudiobookUri()
1597
1482
  if uri is not None:
1598
1483
  ids = SpotifyClient.GetIdFromUri(uri)
1599
1484
  else:
@@ -1688,7 +1573,7 @@ class SpotifyClient:
1688
1573
 
1689
1574
  # if ids not specified, then return currently playing id value.
1690
1575
  if (ids is None) or (len(ids.strip()) == 0):
1691
- uri = self._GetPlayerNowPlayingUri('episode')
1576
+ uri = self.GetPlayerNowPlayingUri('episode')
1692
1577
  if uri is not None:
1693
1578
  ids = SpotifyClient.GetIdFromUri(uri)
1694
1579
  else:
@@ -1870,7 +1755,7 @@ class SpotifyClient:
1870
1755
 
1871
1756
  # if ids not specified, then return currently playing id value.
1872
1757
  if (ids is None) or (len(ids.strip()) == 0):
1873
- uri = self._GetPlayerNowPlayingShowUri()
1758
+ uri = self.GetPlayerNowPlayingShowUri()
1874
1759
  if uri is not None:
1875
1760
  ids = SpotifyClient.GetIdFromUri(uri)
1876
1761
  else:
@@ -1965,7 +1850,7 @@ class SpotifyClient:
1965
1850
 
1966
1851
  # if ids not specified, then return currently playing id value.
1967
1852
  if (ids is None) or (len(ids.strip()) == 0):
1968
- uri = self._GetPlayerNowPlayingUri()
1853
+ uri = self.GetPlayerNowPlayingUri('track')
1969
1854
  if uri is not None:
1970
1855
  ids = SpotifyClient.GetIdFromUri(uri)
1971
1856
  else:
@@ -2188,6 +2073,7 @@ class SpotifyClient:
2188
2073
  _logsi.LogString(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
2189
2074
  return result
2190
2075
 
2076
+ except SpotifyApiError: raise # pass handled exceptions on thru
2191
2077
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2192
2078
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2193
2079
  except Exception as ex:
@@ -2325,6 +2211,7 @@ class SpotifyClient:
2325
2211
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
2326
2212
  return result
2327
2213
 
2214
+ except SpotifyApiError: raise # pass handled exceptions on thru
2328
2215
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2329
2216
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2330
2217
  except Exception as ex:
@@ -2338,9 +2225,10 @@ class SpotifyClient:
2338
2225
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
2339
2226
 
2340
2227
 
2341
- def FollowArtists(self,
2342
- ids:str=None,
2343
- ) -> None:
2228
+ def FollowArtists(
2229
+ self,
2230
+ ids:str=None,
2231
+ ) -> None:
2344
2232
  """
2345
2233
  Add the current user as a follower of one or more artists.
2346
2234
 
@@ -2381,7 +2269,7 @@ class SpotifyClient:
2381
2269
 
2382
2270
  # if ids not specified, then return currently playing artist id value.
2383
2271
  if (ids is None) or (len(ids.strip()) == 0):
2384
- uri = self._GetPlayerNowPlayingArtistUri()
2272
+ uri = self.GetPlayerNowPlayingArtistUri()
2385
2273
  if uri is not None:
2386
2274
  ids = SpotifyClient.GetIdFromUri(uri)
2387
2275
  else:
@@ -2409,6 +2297,7 @@ class SpotifyClient:
2409
2297
  # no results to process - this is pass or fail.
2410
2298
  return
2411
2299
 
2300
+ except SpotifyApiError: raise # pass handled exceptions on thru
2412
2301
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2413
2302
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2414
2303
  except Exception as ex:
@@ -2422,10 +2311,11 @@ class SpotifyClient:
2422
2311
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
2423
2312
 
2424
2313
 
2425
- def FollowPlaylist(self,
2426
- playlistId:str,
2427
- public:bool=True
2428
- ) -> None:
2314
+ def FollowPlaylist(
2315
+ self,
2316
+ playlistId:str=None,
2317
+ public:bool=True
2318
+ ) -> None:
2429
2319
  """
2430
2320
  Add the current user as a follower of a playlist.
2431
2321
 
@@ -2435,6 +2325,7 @@ class SpotifyClient:
2435
2325
  playlistId (str):
2436
2326
  The Spotify ID of the playlist.
2437
2327
  Example: `3cEYpjA9oz9GiPac4AsH4n`
2328
+ If null, the currently playing playlist uri id value is used.
2438
2329
  public (bool):
2439
2330
  If true the playlist will be included in user's public playlists, if false it
2440
2331
  will remain private.
@@ -2465,6 +2356,14 @@ class SpotifyClient:
2465
2356
  apiMethodParms.AppendKeyValue("public", public)
2466
2357
  _logsi.LogMethodParmList(SILevel.Verbose, "Add the current user as a follower of a playlist", apiMethodParms)
2467
2358
 
2359
+ # if playlistId not specified, then return currently playing playlist id value.
2360
+ if (playlistId is None) or (len(playlistId.strip()) == 0):
2361
+ uri = self.GetPlayerNowPlayingPlaylistUri()
2362
+ if uri is not None:
2363
+ playlistId = SpotifyClient.GetIdFromUri(uri)
2364
+ else:
2365
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'playlistId'), logsi=_logsi)
2366
+
2468
2367
  # build spotify web api request parameters.
2469
2368
  reqData:dict = {}
2470
2369
  if public is not None:
@@ -2480,6 +2379,7 @@ class SpotifyClient:
2480
2379
  # no results to process - this is pass or fail.
2481
2380
  return
2482
2381
 
2382
+ except SpotifyApiError: raise # pass handled exceptions on thru
2483
2383
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2484
2384
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2485
2385
  except Exception as ex:
@@ -2555,6 +2455,7 @@ class SpotifyClient:
2555
2455
  # no results to process - this is pass or fail.
2556
2456
  return
2557
2457
 
2458
+ except SpotifyApiError: raise # pass handled exceptions on thru
2558
2459
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2559
2460
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2560
2461
  except Exception as ex:
@@ -2568,10 +2469,11 @@ class SpotifyClient:
2568
2469
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
2569
2470
 
2570
2471
 
2571
- def GetAlbum(self,
2572
- albumId:str,
2573
- market:str=None,
2574
- ) -> Album:
2472
+ def GetAlbum(
2473
+ self,
2474
+ albumId:str=None,
2475
+ market:str=None,
2476
+ ) -> Album:
2575
2477
  """
2576
2478
  Get Spotify catalog information for a single album.
2577
2479
 
@@ -2579,6 +2481,8 @@ class SpotifyClient:
2579
2481
  albumId (str):
2580
2482
  The Spotify ID of the album.
2581
2483
  Example: `6vc9OTcyd3hyzabCmsdnwE`
2484
+ If null, the currently playing album uri id value is used; a Spotify Free or Premium account
2485
+ is required to correctly read the currently playing context.
2582
2486
  market (str):
2583
2487
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
2584
2488
  is available in that market will be returned. If a valid user access token is specified
@@ -2602,6 +2506,10 @@ class SpotifyClient:
2602
2506
  <summary>Sample Code</summary>
2603
2507
  ```python
2604
2508
  .. include:: ../docs/include/samplecode/SpotifyClient/GetAlbum.py
2509
+ ```
2510
+ <summary>Sample Code - NowPlaying</summary>
2511
+ ```python
2512
+ .. include:: ../docs/include/samplecode/SpotifyClient/GetAlbum_NowPlaying.py
2605
2513
  ```
2606
2514
  </details>
2607
2515
  """
@@ -2620,6 +2528,14 @@ class SpotifyClient:
2620
2528
  # ensure market was either supplied or implied; default if neither.
2621
2529
  market = self._ValidateMarket(market)
2622
2530
 
2531
+ # if albumId not specified, then return currently playing album id value.
2532
+ if (albumId is None) or (len(albumId.strip()) == 0):
2533
+ uri = self.GetPlayerNowPlayingAlbumUri()
2534
+ if uri is not None:
2535
+ albumId = SpotifyClient.GetIdFromUri(uri)
2536
+ else:
2537
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'albumId'), logsi=_logsi)
2538
+
2623
2539
  # build spotify web api request parameters.
2624
2540
  urlParms:dict = {}
2625
2541
  if market is not None:
@@ -2638,6 +2554,7 @@ class SpotifyClient:
2638
2554
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
2639
2555
  return result
2640
2556
 
2557
+ except SpotifyApiError: raise # pass handled exceptions on thru
2641
2558
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2642
2559
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2643
2560
  except Exception as ex:
@@ -2804,6 +2721,7 @@ class SpotifyClient:
2804
2721
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
2805
2722
  return result
2806
2723
 
2724
+ except SpotifyApiError: raise # pass handled exceptions on thru
2807
2725
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2808
2726
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2809
2727
  except Exception as ex:
@@ -2965,6 +2883,7 @@ class SpotifyClient:
2965
2883
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
2966
2884
  return result
2967
2885
 
2886
+ except SpotifyApiError: raise # pass handled exceptions on thru
2968
2887
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2969
2888
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2970
2889
  except Exception as ex:
@@ -3055,6 +2974,7 @@ class SpotifyClient:
3055
2974
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Album]'), result)
3056
2975
  return result
3057
2976
 
2977
+ except SpotifyApiError: raise # pass handled exceptions on thru
3058
2978
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3059
2979
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3060
2980
  except Exception as ex:
@@ -3068,13 +2988,14 @@ class SpotifyClient:
3068
2988
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
3069
2989
 
3070
2990
 
3071
- def GetAlbumTracks(self,
3072
- albumId:str,
3073
- limit:int=20,
3074
- offset:int=0,
3075
- market:str=None,
3076
- limitTotal:int=None
3077
- ) -> TrackPageSimplified:
2991
+ def GetAlbumTracks(
2992
+ self,
2993
+ albumId:str=None,
2994
+ limit:int=20,
2995
+ offset:int=0,
2996
+ market:str=None,
2997
+ limitTotal:int=None
2998
+ ) -> TrackPageSimplified:
3078
2999
  """
3079
3000
  Get Spotify catalog information about an album's tracks.
3080
3001
 
@@ -3084,6 +3005,8 @@ class SpotifyClient:
3084
3005
  albumId (str):
3085
3006
  The Spotify ID of the album.
3086
3007
  Example: `6vc9OTcyd3hyzabCmsdnwE`
3008
+ If null, the currently playing album uri id value is used; a Spotify Free or Premium account
3009
+ is required to correctly read the currently playing context.
3087
3010
  limit (int):
3088
3011
  The maximum number of items to return in a page of items when manual paging is used.
3089
3012
  Default: 20, Range: 1 to 50.
@@ -3162,6 +3085,14 @@ class SpotifyClient:
3162
3085
  # ensure market was either supplied or implied; default if neither.
3163
3086
  market = self._ValidateMarket(market)
3164
3087
 
3088
+ # if albumId not specified, then return currently playing album id value.
3089
+ if (albumId is None) or (len(albumId.strip()) == 0):
3090
+ uri = self.GetPlayerNowPlayingAlbumUri()
3091
+ if uri is not None:
3092
+ albumId = SpotifyClient.GetIdFromUri(uri)
3093
+ else:
3094
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'albumId'), logsi=_logsi)
3095
+
3165
3096
  # build spotify web api request parameters.
3166
3097
  urlParms:dict = \
3167
3098
  {
@@ -3216,6 +3147,7 @@ class SpotifyClient:
3216
3147
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
3217
3148
  return result
3218
3149
 
3150
+ except SpotifyApiError: raise # pass handled exceptions on thru
3219
3151
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3220
3152
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3221
3153
  except Exception as ex:
@@ -3229,9 +3161,10 @@ class SpotifyClient:
3229
3161
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
3230
3162
 
3231
3163
 
3232
- def GetArtist(self,
3233
- artistId:str,
3234
- ) -> Artist:
3164
+ def GetArtist(
3165
+ self,
3166
+ artistId:str=None,
3167
+ ) -> Artist:
3235
3168
  """
3236
3169
  Get Spotify catalog information for a single artist identified by their unique Spotify ID.
3237
3170
 
@@ -3239,6 +3172,8 @@ class SpotifyClient:
3239
3172
  artistId (str):
3240
3173
  The Spotify ID of the artist.
3241
3174
  Example: `6APm8EjxOHSYM5B4i3vT3q`
3175
+ If null, the currently playing artist uri id value is used; a Spotify Free or Premium account
3176
+ is required to correctly read the currently playing context.
3242
3177
 
3243
3178
  Returns:
3244
3179
  An `Artist` object that contains the artist details.
@@ -3254,6 +3189,10 @@ class SpotifyClient:
3254
3189
  <summary>Sample Code</summary>
3255
3190
  ```python
3256
3191
  .. include:: ../docs/include/samplecode/SpotifyClient/GetArtist.py
3192
+ ```
3193
+ <summary>Sample Code - NowPlaying</summary>
3194
+ ```python
3195
+ .. include:: ../docs/include/samplecode/SpotifyClient/GetArtist_NowPlaying.py
3257
3196
  ```
3258
3197
  </details>
3259
3198
  """
@@ -3268,6 +3207,14 @@ class SpotifyClient:
3268
3207
  apiMethodParms.AppendKeyValue("artistId", artistId)
3269
3208
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for a single artist", apiMethodParms)
3270
3209
 
3210
+ # if artistId not specified, then return currently playing artist id value.
3211
+ if (artistId is None) or (len(artistId.strip()) == 0):
3212
+ uri = self.GetPlayerNowPlayingArtistUri()
3213
+ if uri is not None:
3214
+ artistId = SpotifyClient.GetIdFromUri(uri)
3215
+ else:
3216
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'artistId'), logsi=_logsi)
3217
+
3271
3218
  # execute spotify web api request.
3272
3219
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/artists/{id}'.format(id=artistId))
3273
3220
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -3280,6 +3227,7 @@ class SpotifyClient:
3280
3227
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
3281
3228
  return result
3282
3229
 
3230
+ except SpotifyApiError: raise # pass handled exceptions on thru
3283
3231
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3284
3232
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3285
3233
  except Exception as ex:
@@ -3295,7 +3243,7 @@ class SpotifyClient:
3295
3243
 
3296
3244
  def GetArtistAlbums(
3297
3245
  self,
3298
- artistId:str,
3246
+ artistId:str=None,
3299
3247
  include_groups:str='album',
3300
3248
  limit:int=20,
3301
3249
  offset:int=0,
@@ -3310,6 +3258,8 @@ class SpotifyClient:
3310
3258
  artistId (str):
3311
3259
  The Spotify ID of the artist.
3312
3260
  Example: `6APm8EjxOHSYM5B4i3vT3q`
3261
+ If null, the currently playing artist uri id value is used; a Spotify Free or Premium account
3262
+ is required to correctly read the currently playing context.
3313
3263
  include_groups (str):
3314
3264
  A comma-separated list of keywords that will be used to filter the response.
3315
3265
  If not supplied, all album types will be returned.
@@ -3399,6 +3349,14 @@ class SpotifyClient:
3399
3349
  # ensure market was either supplied or implied; default if neither.
3400
3350
  market = self._ValidateMarket(market)
3401
3351
 
3352
+ # if artistId not specified, then return currently playing artist id value.
3353
+ if (artistId is None) or (len(artistId.strip()) == 0):
3354
+ uri = self.GetPlayerNowPlayingArtistUri()
3355
+ if uri is not None:
3356
+ artistId = SpotifyClient.GetIdFromUri(uri)
3357
+ else:
3358
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'artistId'), logsi=_logsi)
3359
+
3402
3360
  # build spotify web api request parameters.
3403
3361
  urlParms:dict = \
3404
3362
  {
@@ -3456,6 +3414,7 @@ class SpotifyClient:
3456
3414
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
3457
3415
  return result
3458
3416
 
3417
+ except SpotifyApiError: raise # pass handled exceptions on thru
3459
3418
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3460
3419
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3461
3420
  except Exception as ex:
@@ -3469,9 +3428,10 @@ class SpotifyClient:
3469
3428
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
3470
3429
 
3471
3430
 
3472
- def GetArtistInfo(self,
3473
- artistId:str,
3474
- ) -> ArtistInfo:
3431
+ def GetArtistInfo(
3432
+ self,
3433
+ artistId:str=None,
3434
+ ) -> ArtistInfo:
3475
3435
  """
3476
3436
  Get artist about information from the Spotify Artist Biography page for the
3477
3437
  specified Spotify artist ID.
@@ -3480,6 +3440,8 @@ class SpotifyClient:
3480
3440
  artistId (str):
3481
3441
  The Spotify ID of the artist.
3482
3442
  Example: `6APm8EjxOHSYM5B4i3vT3q`
3443
+ If null, the currently playing artist uri id value is used; a Spotify Free or Premium account
3444
+ is required to correctly read the currently playing context.
3483
3445
 
3484
3446
  Returns:
3485
3447
  An `ArtistInfo` object that contains the artist info details.
@@ -3511,6 +3473,14 @@ class SpotifyClient:
3511
3473
  apiMethodParms.AppendKeyValue("artistId", artistId)
3512
3474
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for a single artist", apiMethodParms)
3513
3475
 
3476
+ # if artistId not specified, then return currently playing artist id value.
3477
+ if (artistId is None) or (len(artistId.strip()) == 0):
3478
+ uri = self.GetPlayerNowPlayingArtistUri()
3479
+ if uri is not None:
3480
+ artistId = SpotifyClient.GetIdFromUri(uri)
3481
+ else:
3482
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'artistId'), logsi=_logsi)
3483
+
3514
3484
  # execute spotify web api request.
3515
3485
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/artists/{id}'.format(id=artistId))
3516
3486
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -3677,6 +3647,7 @@ class SpotifyClient:
3677
3647
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
3678
3648
  return result
3679
3649
 
3650
+ except SpotifyApiError: raise # pass handled exceptions on thru
3680
3651
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3681
3652
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3682
3653
  except Exception as ex:
@@ -3717,9 +3688,10 @@ class SpotifyClient:
3717
3688
  return result
3718
3689
 
3719
3690
 
3720
- def GetArtistRelatedArtists(self,
3721
- artistId:str,
3722
- ) -> list[Artist]:
3691
+ def GetArtistRelatedArtists(
3692
+ self,
3693
+ artistId:str=None,
3694
+ ) -> list[Artist]:
3723
3695
  """
3724
3696
  Get Spotify catalog information about artists similar to a given artist.
3725
3697
  Similarity is based on analysis of the Spotify community's listening history.
@@ -3728,6 +3700,8 @@ class SpotifyClient:
3728
3700
  artistId (str):
3729
3701
  The Spotify ID of the artist.
3730
3702
  Example: `6APm8EjxOHSYM5B4i3vT3q`
3703
+ If null, the currently playing artist uri id value is used; a Spotify Free or Premium account
3704
+ is required to correctly read the currently playing context.
3731
3705
 
3732
3706
  Returns:
3733
3707
  A list of `Artist` objects that contain the artist details.
@@ -3757,6 +3731,14 @@ class SpotifyClient:
3757
3731
  apiMethodParms.AppendKeyValue("artistId", artistId)
3758
3732
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information about artists similar to a given artist", apiMethodParms)
3759
3733
 
3734
+ # if artistId not specified, then return currently playing artist id value.
3735
+ if (artistId is None) or (len(artistId.strip()) == 0):
3736
+ uri = self.GetPlayerNowPlayingArtistUri()
3737
+ if uri is not None:
3738
+ artistId = SpotifyClient.GetIdFromUri(uri)
3739
+ else:
3740
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'artistId'), logsi=_logsi)
3741
+
3760
3742
  # execute spotify web api request.
3761
3743
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/artists/{id}/related-artists'.format(id=artistId))
3762
3744
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -3772,6 +3754,7 @@ class SpotifyClient:
3772
3754
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Artist]'), result)
3773
3755
  return result
3774
3756
 
3757
+ except SpotifyApiError: raise # pass handled exceptions on thru
3775
3758
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3776
3759
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3777
3760
  except Exception as ex:
@@ -3847,6 +3830,7 @@ class SpotifyClient:
3847
3830
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Artist]'), result)
3848
3831
  return result
3849
3832
 
3833
+ except SpotifyApiError: raise # pass handled exceptions on thru
3850
3834
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3851
3835
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3852
3836
  except Exception as ex:
@@ -4005,6 +3989,7 @@ class SpotifyClient:
4005
3989
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4006
3990
  return result
4007
3991
 
3992
+ except SpotifyApiError: raise # pass handled exceptions on thru
4008
3993
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4009
3994
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4010
3995
  except Exception as ex:
@@ -4018,10 +4003,11 @@ class SpotifyClient:
4018
4003
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
4019
4004
 
4020
4005
 
4021
- def GetArtistTopTracks(self,
4022
- artistId:str,
4023
- market:str,
4024
- ) -> list[Track]:
4006
+ def GetArtistTopTracks(
4007
+ self,
4008
+ artistId:str=None,
4009
+ market:str=None,
4010
+ ) -> list[Track]:
4025
4011
  """
4026
4012
  Get Spotify catalog information about an artist's top tracks by country.
4027
4013
 
@@ -4029,6 +4015,8 @@ class SpotifyClient:
4029
4015
  artistId (str):
4030
4016
  The Spotify ID of the artist.
4031
4017
  Example: `6APm8EjxOHSYM5B4i3vT3q`
4018
+ If null, the currently playing artist uri id value is used; a Spotify Free or Premium account
4019
+ is required to correctly read the currently playing context.
4032
4020
  market (str):
4033
4021
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
4034
4022
  is available in that market will be returned. If a valid user access token is specified
@@ -4070,6 +4058,14 @@ class SpotifyClient:
4070
4058
  # ensure market was either supplied or implied; default if neither.
4071
4059
  market = self._ValidateMarket(market)
4072
4060
 
4061
+ # if artistId not specified, then return currently playing artist id value.
4062
+ if (artistId is None) or (len(artistId.strip()) == 0):
4063
+ uri = self.GetPlayerNowPlayingArtistUri()
4064
+ if uri is not None:
4065
+ artistId = SpotifyClient.GetIdFromUri(uri)
4066
+ else:
4067
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'artistId'), logsi=_logsi)
4068
+
4073
4069
  # build spotify web api request parameters.
4074
4070
  urlParms:dict = {}
4075
4071
  if market is not None:
@@ -4091,6 +4087,7 @@ class SpotifyClient:
4091
4087
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Track]'), result)
4092
4088
  return result
4093
4089
 
4090
+ except SpotifyApiError: raise # pass handled exceptions on thru
4094
4091
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4095
4092
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4096
4093
  except Exception as ex:
@@ -4104,10 +4101,11 @@ class SpotifyClient:
4104
4101
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
4105
4102
 
4106
4103
 
4107
- def GetAudiobook(self,
4108
- audiobookId:str,
4109
- market:str=None,
4110
- ) -> Audiobook:
4104
+ def GetAudiobook(
4105
+ self,
4106
+ audiobookId:str=None,
4107
+ market:str=None,
4108
+ ) -> Audiobook:
4111
4109
  """
4112
4110
  Get Spotify catalog information for a single audiobook.
4113
4111
 
@@ -4117,6 +4115,8 @@ class SpotifyClient:
4117
4115
  audiobookId (str):
4118
4116
  The Spotify ID for the audiobook.
4119
4117
  Example: `74aydHJKgYz3AIq3jjBSv1`
4118
+ If null, the currently playing audiobook uri id value is used; a Spotify Free or Premium account
4119
+ is required to correctly read the currently playing context.
4120
4120
  market (str):
4121
4121
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
4122
4122
  is available in that market will be returned. If a valid user access token is specified
@@ -4145,6 +4145,10 @@ class SpotifyClient:
4145
4145
  <summary>Sample Code</summary>
4146
4146
  ```python
4147
4147
  .. include:: ../docs/include/samplecode/SpotifyClient/GetAudiobook.py
4148
+ ```
4149
+ <summary>Sample Code - NowPlaying</summary>
4150
+ ```python
4151
+ .. include:: ../docs/include/samplecode/SpotifyClient/GetAudiobook_NowPlaying.py
4148
4152
  ```
4149
4153
  </details>
4150
4154
  """
@@ -4163,6 +4167,14 @@ class SpotifyClient:
4163
4167
  # ensure market was either supplied or implied; default if neither.
4164
4168
  market = self._ValidateMarket(market)
4165
4169
 
4170
+ # if audiobookId not specified, then return currently playing audiobook id value.
4171
+ if (audiobookId is None) or (len(audiobookId.strip()) == 0):
4172
+ uri = self.GetPlayerNowPlayingAudiobookUri()
4173
+ if uri is not None:
4174
+ audiobookId = SpotifyClient.GetIdFromUri(uri)
4175
+ else:
4176
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'audiobookId'), logsi=_logsi)
4177
+
4166
4178
  # build spotify web api request parameters.
4167
4179
  urlParms:dict = {}
4168
4180
  if market is not None:
@@ -4181,6 +4193,7 @@ class SpotifyClient:
4181
4193
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4182
4194
  return result
4183
4195
 
4196
+ except SpotifyApiError: raise # pass handled exceptions on thru
4184
4197
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4185
4198
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4186
4199
  except Exception as ex:
@@ -4194,13 +4207,14 @@ class SpotifyClient:
4194
4207
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
4195
4208
 
4196
4209
 
4197
- def GetAudiobookChapters(self,
4198
- audiobookId:str,
4199
- limit:int=20,
4200
- offset:int=0,
4201
- market:str=None,
4202
- limitTotal:int=None
4203
- ) -> ChapterPageSimplified:
4210
+ def GetAudiobookChapters(
4211
+ self,
4212
+ audiobookId:str=None,
4213
+ limit:int=20,
4214
+ offset:int=0,
4215
+ market:str=None,
4216
+ limitTotal:int=None
4217
+ ) -> ChapterPageSimplified:
4204
4218
  """
4205
4219
  Get Spotify catalog information about an audiobook's chapters.
4206
4220
 
@@ -4210,6 +4224,8 @@ class SpotifyClient:
4210
4224
  audiobookId (str):
4211
4225
  The Spotify ID for the audiobook.
4212
4226
  Example: `74aydHJKgYz3AIq3jjBSv1`
4227
+ If null, the currently playing audiobook uri id value is used; a Spotify Free or Premium account
4228
+ is required to correctly read the currently playing context.
4213
4229
  limit (int):
4214
4230
  The maximum number of items to return in a page of items when manual paging is used.
4215
4231
  Default: 20, Range: 1 to 50.
@@ -4288,6 +4304,14 @@ class SpotifyClient:
4288
4304
  # ensure market was either supplied or implied; default if neither.
4289
4305
  market = self._ValidateMarket(market)
4290
4306
 
4307
+ # if audiobookId not specified, then return currently playing audiobook id value.
4308
+ if (audiobookId is None) or (len(audiobookId.strip()) == 0):
4309
+ uri = self.GetPlayerNowPlayingAudiobookUri()
4310
+ if uri is not None:
4311
+ audiobookId = SpotifyClient.GetIdFromUri(uri)
4312
+ else:
4313
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'audiobookId'), logsi=_logsi)
4314
+
4291
4315
  # build spotify web api request parameters.
4292
4316
  urlParms:dict = \
4293
4317
  {
@@ -4342,6 +4366,7 @@ class SpotifyClient:
4342
4366
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4343
4367
  return result
4344
4368
 
4369
+ except SpotifyApiError: raise # pass handled exceptions on thru
4345
4370
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4346
4371
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4347
4372
  except Exception as ex:
@@ -4493,6 +4518,7 @@ class SpotifyClient:
4493
4518
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4494
4519
  return result
4495
4520
 
4521
+ except SpotifyApiError: raise # pass handled exceptions on thru
4496
4522
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4497
4523
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4498
4524
  except Exception as ex:
@@ -4588,6 +4614,7 @@ class SpotifyClient:
4588
4614
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[AudiobookSimplified]'), result)
4589
4615
  return result
4590
4616
 
4617
+ except SpotifyApiError: raise # pass handled exceptions on thru
4591
4618
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4592
4619
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4593
4620
  except Exception as ex:
@@ -4706,6 +4733,7 @@ class SpotifyClient:
4706
4733
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result, excludeNonPublic=True)
4707
4734
  return result
4708
4735
 
4736
+ except SpotifyApiError: raise # pass handled exceptions on thru
4709
4737
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4710
4738
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4711
4739
  except Exception as ex:
@@ -4880,6 +4908,7 @@ class SpotifyClient:
4880
4908
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4881
4909
  return result
4882
4910
 
4911
+ except SpotifyApiError: raise # pass handled exceptions on thru
4883
4912
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4884
4913
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4885
4914
  except Exception as ex:
@@ -4979,6 +5008,7 @@ class SpotifyClient:
4979
5008
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result)
4980
5009
  return result
4981
5010
 
5011
+ except SpotifyApiError: raise # pass handled exceptions on thru
4982
5012
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4983
5013
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4984
5014
  except Exception as ex:
@@ -5160,6 +5190,7 @@ class SpotifyClient:
5160
5190
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5161
5191
  return result, resultMessage
5162
5192
 
5193
+ except SpotifyApiError: raise # pass handled exceptions on thru
5163
5194
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5164
5195
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5165
5196
  except Exception as ex:
@@ -5250,6 +5281,7 @@ class SpotifyClient:
5250
5281
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5251
5282
  return result
5252
5283
 
5284
+ except SpotifyApiError: raise # pass handled exceptions on thru
5253
5285
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5254
5286
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5255
5287
  except Exception as ex:
@@ -5345,6 +5377,7 @@ class SpotifyClient:
5345
5377
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Chapter]'), result)
5346
5378
  return result
5347
5379
 
5380
+ except SpotifyApiError: raise # pass handled exceptions on thru
5348
5381
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5349
5382
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5350
5383
  except Exception as ex:
@@ -5358,10 +5391,11 @@ class SpotifyClient:
5358
5391
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
5359
5392
 
5360
5393
 
5361
- def GetEpisode(self,
5362
- episodeId:str,
5363
- market:str=None,
5364
- ) -> Episode:
5394
+ def GetEpisode(
5395
+ self,
5396
+ episodeId:str=None,
5397
+ market:str=None,
5398
+ ) -> Episode:
5365
5399
  """
5366
5400
  Get Spotify catalog information for a single episode identified by its unique Spotify ID.
5367
5401
 
@@ -5371,6 +5405,8 @@ class SpotifyClient:
5371
5405
  episodeId (str):
5372
5406
  The Spotify ID for the episode.
5373
5407
  Example: `512ojhOuo1ktJprKbVcKyQ`
5408
+ If null, the currently playing episode uri id value is used; a Spotify Free or Premium account
5409
+ is required to correctly read the currently playing context.
5374
5410
  market (str):
5375
5411
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
5376
5412
  is available in that market will be returned. If a valid user access token is specified
@@ -5417,6 +5453,14 @@ class SpotifyClient:
5417
5453
  # ensure market was either supplied or implied; default if neither.
5418
5454
  market = self._ValidateMarket(market)
5419
5455
 
5456
+ # if ids not specified, then return currently playing id value.
5457
+ if (episodeId is None) or (len(episodeId.strip()) == 0):
5458
+ uri = self.GetPlayerNowPlayingUri('episode')
5459
+ if uri is not None:
5460
+ episodeId = SpotifyClient.GetIdFromUri(uri)
5461
+ else:
5462
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'episodeId'), logsi=_logsi)
5463
+
5420
5464
  # build spotify web api request parameters.
5421
5465
  urlParms:dict = {}
5422
5466
  if market is not None:
@@ -5435,6 +5479,7 @@ class SpotifyClient:
5435
5479
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5436
5480
  return result
5437
5481
 
5482
+ except SpotifyApiError: raise # pass handled exceptions on thru
5438
5483
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5439
5484
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5440
5485
  except Exception as ex:
@@ -5586,6 +5631,7 @@ class SpotifyClient:
5586
5631
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5587
5632
  return result
5588
5633
 
5634
+ except SpotifyApiError: raise # pass handled exceptions on thru
5589
5635
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5590
5636
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5591
5637
  except Exception as ex:
@@ -5681,6 +5727,7 @@ class SpotifyClient:
5681
5727
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Episode]'), result)
5682
5728
  return result
5683
5729
 
5730
+ except SpotifyApiError: raise # pass handled exceptions on thru
5684
5731
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5685
5732
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5686
5733
  except Exception as ex:
@@ -5871,6 +5918,7 @@ class SpotifyClient:
5871
5918
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5872
5919
  return result, resultMessage
5873
5920
 
5921
+ except SpotifyApiError: raise # pass handled exceptions on thru
5874
5922
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5875
5923
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5876
5924
  except Exception as ex:
@@ -5951,6 +5999,7 @@ class SpotifyClient:
5951
5999
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result)
5952
6000
  return result
5953
6001
 
6002
+ except SpotifyApiError: raise # pass handled exceptions on thru
5954
6003
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5955
6004
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5956
6005
  except Exception as ex:
@@ -6069,6 +6118,7 @@ class SpotifyClient:
6069
6118
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result)
6070
6119
  return result
6071
6120
 
6121
+ except SpotifyApiError: raise # pass handled exceptions on thru
6072
6122
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6073
6123
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6074
6124
  except Exception as ex:
@@ -6119,6 +6169,7 @@ class SpotifyClient:
6119
6169
  # subsequent calls to the Spotify Web API player endpoints.
6120
6170
  return None
6121
6171
 
6172
+ except SpotifyApiError: raise # pass handled exceptions on thru
6122
6173
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6123
6174
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6124
6175
  except Exception as ex:
@@ -6208,6 +6259,7 @@ class SpotifyClient:
6208
6259
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'Device'), result, excludeNonPublic=True)
6209
6260
  return result
6210
6261
 
6262
+ except SpotifyApiError: raise # pass handled exceptions on thru
6211
6263
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6212
6264
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6213
6265
  except Exception as ex:
@@ -6499,6 +6551,7 @@ class SpotifyClient:
6499
6551
  _logsi.LogVerbose("Device name '%s' could not be found in the Spotify Connect Device list; subsequent actions will probably fail using this device name" % value)
6500
6552
  return value
6501
6553
 
6554
+ except SpotifyApiError: raise # pass handled exceptions on thru
6502
6555
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6503
6556
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6504
6557
  except Exception as ex:
@@ -6602,6 +6655,7 @@ class SpotifyClient:
6602
6655
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, 'list[Device]', cacheDesc), result)
6603
6656
  return result
6604
6657
 
6658
+ except SpotifyApiError: raise # pass handled exceptions on thru
6605
6659
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6606
6660
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6607
6661
  except Exception as ex:
@@ -6668,11 +6722,16 @@ class SpotifyClient:
6668
6722
  # trace.
6669
6723
  apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
6670
6724
  apiMethodParms.AppendKeyValue("market", market)
6725
+ apiMethodParms.AppendKeyValue("additionalTypes", additionalTypes)
6671
6726
  _logsi.LogMethodParmList(SILevel.Verbose, "Get the object currently being played on the user's Spotify account", apiMethodParms)
6672
6727
 
6673
6728
  # ensure market was either supplied or implied; default if neither.
6674
6729
  market = self._ValidateMarket(market)
6675
6730
 
6731
+ # a spotify free or premium level membership is required to get the nowplaying info.
6732
+ if (not self.UserProfile.IsProductPremium) and (not self.UserProfile.IsProductFree):
6733
+ raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_ACCOUNT_REQUIRED_FOR_NOWPLAYING, logsi=_logsi)
6734
+
6676
6735
  # build spotify web api request parameters.
6677
6736
  urlParms:dict = {}
6678
6737
  if market is not None:
@@ -6693,6 +6752,7 @@ class SpotifyClient:
6693
6752
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
6694
6753
  return result
6695
6754
 
6755
+ except SpotifyApiError: raise # pass handled exceptions on thru
6696
6756
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6697
6757
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6698
6758
  except Exception as ex:
@@ -6706,6 +6766,188 @@ class SpotifyClient:
6706
6766
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
6707
6767
 
6708
6768
 
6769
+ def GetPlayerNowPlayingAlbumUri(self) -> str:
6770
+ """
6771
+ Returns the album uri value of the currently playing media if something is
6772
+ playing; otherwise, null is returned.
6773
+
6774
+ Raises:
6775
+ SpotifyApiError:
6776
+ If current user does not have a Spotify free or premium level account.
6777
+ If nowplaying context does not contain an album reference.
6778
+ """
6779
+ result:str = None
6780
+
6781
+ # get nowplaying status.
6782
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes='track')
6783
+
6784
+ # is a track playing? if so, return the album uri value.
6785
+ if nowPlaying is not None:
6786
+ if nowPlaying.CurrentlyPlayingType in ['track']:
6787
+ trackItem:Track = nowPlaying.Item
6788
+ if (trackItem is not None) and (trackItem.Album is not None):
6789
+ result = trackItem.Album.Uri
6790
+ else:
6791
+ raise SpotifyApiError("Currently playing item does not contain an Album reference", logsi=_logsi)
6792
+
6793
+ return result
6794
+
6795
+
6796
+ def GetPlayerNowPlayingArtistUri(self) -> str:
6797
+ """
6798
+ Returns the artist uri value of the currently playing media if something is
6799
+ playing; otherwise, null is returned.
6800
+
6801
+ Raises:
6802
+ SpotifyApiError:
6803
+ If current user does not have a Spotify free or premium level account.
6804
+ If nowplaying context does not contain an artist reference.
6805
+ """
6806
+ result:str = None
6807
+
6808
+ # get nowplaying status.
6809
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying()
6810
+
6811
+ # is a track playing? if so, return the artist uri value.
6812
+ if nowPlaying is not None:
6813
+ if nowPlaying.CurrentlyPlayingType in ['track']:
6814
+ trackItem:Track = nowPlaying.Item
6815
+ if (trackItem is not None) and (len(trackItem.Artists) > 0):
6816
+ result = trackItem.Artists[0].Uri
6817
+ else:
6818
+ raise SpotifyApiError("Currently playing item does not contain an Artist reference", logsi=_logsi)
6819
+
6820
+ return result
6821
+
6822
+
6823
+ def GetPlayerNowPlayingAudiobookUri(self) -> str:
6824
+ """
6825
+ Returns the audiobook uri value of the currently playing media if something is
6826
+ playing; otherwise, null is returned.
6827
+
6828
+ Raises:
6829
+ SpotifyApiError:
6830
+ If current user does not have a Spotify free or premium level account.
6831
+ If nowplaying context is not a audiobook chapter.
6832
+ """
6833
+ result:str = None
6834
+
6835
+ # get nowplaying status.
6836
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes='episode')
6837
+
6838
+ # is an chapter playing? if so, return the parent show uri value.
6839
+ if nowPlaying is not None:
6840
+ if nowPlaying.CurrentlyPlayingType in ['episode']:
6841
+ playingItem:Chapter = nowPlaying.Item
6842
+ if (playingItem is not None):
6843
+ chapter:Chapter = self.GetChapter(playingItem.Id)
6844
+ result = chapter.Audiobook.Uri
6845
+ else:
6846
+ raise SpotifyApiError("Currently playing item is not a Audiobook Chapter", logsi=_logsi)
6847
+
6848
+ return result
6849
+
6850
+
6851
+ def GetPlayerNowPlayingPlaylistUri(self) -> str:
6852
+ """
6853
+ Returns the playlist uri value of the currently playing media if something is
6854
+ playing; otherwise, null is returned.
6855
+
6856
+ Raises:
6857
+ SpotifyApiError:
6858
+ If current user does not have a Spotify free or premium level account.
6859
+ If nowplaying context is not a playlist.
6860
+ """
6861
+ result:str = None
6862
+
6863
+ # get nowplaying status.
6864
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying()
6865
+
6866
+ # is a playlist playing? if so, return the uri value.
6867
+ if nowPlaying is not None:
6868
+ context:Context = nowPlaying.Context
6869
+ if (context is not None) and (context.Type == 'playlist'):
6870
+ result = context.Uri
6871
+ else:
6872
+ raise SpotifyApiError("Currently playing context is not a Playlist", logsi=_logsi)
6873
+
6874
+ return result
6875
+
6876
+
6877
+ def GetPlayerNowPlayingShowUri(self) -> str:
6878
+ """
6879
+ Returns the show uri value of the currently playing media if something is
6880
+ playing; otherwise, null is returned.
6881
+
6882
+ Raises:
6883
+ SpotifyApiError:
6884
+ If current user does not have a Spotify free or premium level account.
6885
+ If nowplaying context is not a show episode.
6886
+ """
6887
+ result:str = None
6888
+
6889
+ # get nowplaying status.
6890
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes='episode')
6891
+
6892
+ # is an episode playing? if so, return the parent show uri value.
6893
+ if nowPlaying is not None:
6894
+ if nowPlaying.CurrentlyPlayingType in ['episode']:
6895
+ playingItem:Episode = nowPlaying.Item
6896
+ if (playingItem is not None):
6897
+ episode:Episode = self.GetEpisode(playingItem.Id)
6898
+ result = episode.Show.Uri
6899
+ else:
6900
+ raise SpotifyApiError("Currently playing item is not a Show Episode", logsi=_logsi)
6901
+
6902
+ return result
6903
+
6904
+
6905
+ def GetPlayerNowPlayingUri(
6906
+ self,
6907
+ additionalTypes:str=None,
6908
+ ) -> str:
6909
+ """
6910
+ Returns the uri value of the currently playing media type if something is
6911
+ playing; otherwise, null is returned.
6912
+
6913
+ Args:
6914
+ additionalTypes (str):
6915
+ An item type that your client supports besides the default track type.
6916
+ Valid types are: `track` and `episode`.
6917
+ Specify `episode` to get podcast track information.
6918
+
6919
+ Raises:
6920
+ SpotifyApiError:
6921
+ If current user does not have a Spotify free or premium level account.
6922
+ If nowplaying item is not of the specified `additionalType`.
6923
+ """
6924
+ result:str = None
6925
+
6926
+ # get nowplaying status.
6927
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes=additionalTypes)
6928
+
6929
+ # is anything playing? if so, return the uri value.
6930
+ if nowPlaying is not None:
6931
+ if nowPlaying.Item is not None:
6932
+ if additionalTypes is None:
6933
+ # if not validating uri type then just return the uri.
6934
+ result = nowPlaying.Item.Uri
6935
+ elif nowPlaying.CurrentlyPlayingType == additionalTypes:
6936
+ # if validating uri type then return uri if nowplaying types matches desired type.
6937
+ result = nowPlaying.Item.Uri
6938
+ else:
6939
+ # otherwise nowplaying type is not the desired type!
6940
+ raise SpotifyApiError("Currently playing item is not a %s" % additionalTypes, logsi=_logsi)
6941
+ else:
6942
+ # otherwise nowplaying item does not contain the desired type!
6943
+ if additionalTypes is None:
6944
+ raise SpotifyApiError("Currently playing item context is not set", logsi=_logsi)
6945
+ else:
6946
+ raise SpotifyApiError("Currently playing item context is not a %s item" % additionalTypes, logsi=_logsi)
6947
+
6948
+ return result
6949
+
6950
+
6709
6951
  def GetPlayerPlaybackState(self,
6710
6952
  market:str=None,
6711
6953
  additionalTypes:str=None
@@ -6797,6 +7039,7 @@ class SpotifyClient:
6797
7039
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
6798
7040
  return result
6799
7041
 
7042
+ except SpotifyApiError: raise # pass handled exceptions on thru
6800
7043
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6801
7044
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6802
7045
  except Exception as ex:
@@ -6854,6 +7097,7 @@ class SpotifyClient:
6854
7097
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
6855
7098
  return result
6856
7099
 
7100
+ except SpotifyApiError: raise # pass handled exceptions on thru
6857
7101
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6858
7102
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6859
7103
  except Exception as ex:
@@ -7038,6 +7282,7 @@ class SpotifyClient:
7038
7282
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7039
7283
  return result
7040
7284
 
7285
+ except SpotifyApiError: raise # pass handled exceptions on thru
7041
7286
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7042
7287
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7043
7288
  except Exception as ex:
@@ -7051,12 +7296,13 @@ class SpotifyClient:
7051
7296
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
7052
7297
 
7053
7298
 
7054
- def GetPlaylist(self,
7055
- playlistId:str,
7056
- market:str=None,
7057
- fields:str=None,
7058
- additionalTypes:str=None
7059
- ) -> Playlist:
7299
+ def GetPlaylist(
7300
+ self,
7301
+ playlistId:str=None,
7302
+ market:str=None,
7303
+ fields:str=None,
7304
+ additionalTypes:str=None
7305
+ ) -> Playlist:
7060
7306
  """
7061
7307
  Get a playlist owned by a Spotify user.
7062
7308
 
@@ -7064,6 +7310,7 @@ class SpotifyClient:
7064
7310
  playlistId (str):
7065
7311
  The Spotify ID of the playlist.
7066
7312
  Example: `5v5ETK9WFXAnGQ3MRubKuE`
7313
+ If null, the currently playing playlist uri id value is used.
7067
7314
  market (str):
7068
7315
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
7069
7316
  is available in that market will be returned. If a valid user access token is specified
@@ -7107,6 +7354,10 @@ class SpotifyClient:
7107
7354
  <summary>Sample Code</summary>
7108
7355
  ```python
7109
7356
  .. include:: ../docs/include/samplecode/SpotifyClient/GetPlaylist.py
7357
+ ```
7358
+ <summary>Sample Code - NowPlaying</summary>
7359
+ ```python
7360
+ .. include:: ../docs/include/samplecode/SpotifyClient/GetPlaylist_NowPlaying.py
7110
7361
  ```
7111
7362
  </details>
7112
7363
  """
@@ -7127,6 +7378,14 @@ class SpotifyClient:
7127
7378
  # ensure market was either supplied or implied; default if neither.
7128
7379
  market = self._ValidateMarket(market)
7129
7380
 
7381
+ # if playlistId not specified, then return currently playing playlist id value.
7382
+ if (playlistId is None) or (len(playlistId.strip()) == 0):
7383
+ uri = self.GetPlayerNowPlayingPlaylistUri()
7384
+ if uri is not None:
7385
+ playlistId = SpotifyClient.GetIdFromUri(uri)
7386
+ else:
7387
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'playlistId'), logsi=_logsi)
7388
+
7130
7389
  # was the Spotify DJ playlist specified?
7131
7390
  # the DJ is not fully integrated with the playlist API, so the GET request will fail.
7132
7391
  # we will manually build a basic playlist object to return for the playlist.
@@ -7170,6 +7429,7 @@ class SpotifyClient:
7170
7429
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7171
7430
  return result
7172
7431
 
7432
+ except SpotifyApiError: raise # pass handled exceptions on thru
7173
7433
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7174
7434
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7175
7435
  except Exception as ex:
@@ -7238,6 +7498,7 @@ class SpotifyClient:
7238
7498
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7239
7499
  return result
7240
7500
 
7501
+ except SpotifyApiError: raise # pass handled exceptions on thru
7241
7502
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7242
7503
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7243
7504
  except Exception as ex:
@@ -7251,15 +7512,16 @@ class SpotifyClient:
7251
7512
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
7252
7513
 
7253
7514
 
7254
- def GetPlaylistItems(self,
7255
- playlistId:str,
7256
- limit:int=50,
7257
- offset:int=0,
7258
- market:str=None,
7259
- fields:str=None,
7260
- additionalTypes:str=None,
7261
- limitTotal:int=None
7262
- ) -> PlaylistPage:
7515
+ def GetPlaylistItems(
7516
+ self,
7517
+ playlistId:str=None,
7518
+ limit:int=50,
7519
+ offset:int=0,
7520
+ market:str=None,
7521
+ fields:str=None,
7522
+ additionalTypes:str=None,
7523
+ limitTotal:int=None
7524
+ ) -> PlaylistPage:
7263
7525
  """
7264
7526
  Get full details of the items of a playlist owned by a Spotify user.
7265
7527
 
@@ -7269,6 +7531,7 @@ class SpotifyClient:
7269
7531
  playlistId (str):
7270
7532
  The Spotify ID of the playlist.
7271
7533
  Example: `5v5ETK9WFXAnGQ3MRubKuE`
7534
+ If null, the currently playing playlist uri id value is used.
7272
7535
  limit (int):
7273
7536
  The maximum number of items to return in a page of items when manual paging is used.
7274
7537
  Default: 50, Range: 1 to 50.
@@ -7370,6 +7633,14 @@ class SpotifyClient:
7370
7633
  # ensure market was either supplied or implied; default if neither.
7371
7634
  market = self._ValidateMarket(market)
7372
7635
 
7636
+ # if playlistId not specified, then return currently playing playlist id value.
7637
+ if (playlistId is None) or (len(playlistId.strip()) == 0):
7638
+ uri = self.GetPlayerNowPlayingPlaylistUri()
7639
+ if uri is not None:
7640
+ playlistId = SpotifyClient.GetIdFromUri(uri)
7641
+ else:
7642
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'playlistId'), logsi=_logsi)
7643
+
7373
7644
  # build spotify web api request parameters.
7374
7645
  urlParms:dict = \
7375
7646
  {
@@ -7428,6 +7699,7 @@ class SpotifyClient:
7428
7699
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7429
7700
  return result
7430
7701
 
7702
+ except SpotifyApiError: raise # pass handled exceptions on thru
7431
7703
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7432
7704
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7433
7705
  except Exception as ex:
@@ -7579,6 +7851,7 @@ class SpotifyClient:
7579
7851
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7580
7852
  return result
7581
7853
 
7854
+ except SpotifyApiError: raise # pass handled exceptions on thru
7582
7855
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7583
7856
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7584
7857
  except Exception as ex:
@@ -7736,6 +8009,7 @@ class SpotifyClient:
7736
8009
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7737
8010
  return result
7738
8011
 
8012
+ except SpotifyApiError: raise # pass handled exceptions on thru
7739
8013
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7740
8014
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7741
8015
  except Exception as ex:
@@ -7749,10 +8023,11 @@ class SpotifyClient:
7749
8023
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
7750
8024
 
7751
8025
 
7752
- def GetShow(self,
7753
- showId:str,
7754
- market:str=None,
7755
- ) -> Show:
8026
+ def GetShow(
8027
+ self,
8028
+ showId:str=None,
8029
+ market:str=None,
8030
+ ) -> Show:
7756
8031
  """
7757
8032
  Get Spotify catalog information for a single show identified by its unique Spotify ID.
7758
8033
 
@@ -7760,6 +8035,8 @@ class SpotifyClient:
7760
8035
  showId (str):
7761
8036
  The Spotify ID for the show.
7762
8037
  Example: `5CfCWKI5pZ28U0uOzXkDHe`
8038
+ If null, the currently playing show uri id value is used; a Spotify Free or Premium account
8039
+ is required to correctly read the currently playing context.
7763
8040
  market (str):
7764
8041
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
7765
8042
  is available in that market will be returned. If a valid user access token is specified
@@ -7788,6 +8065,10 @@ class SpotifyClient:
7788
8065
  <summary>Sample Code</summary>
7789
8066
  ```python
7790
8067
  .. include:: ../docs/include/samplecode/SpotifyClient/GetShow.py
8068
+ ```
8069
+ <summary>Sample Code - NowPlaying</summary>
8070
+ ```python
8071
+ .. include:: ../docs/include/samplecode/SpotifyClient/GetShow_NowPlaying.py
7791
8072
  ```
7792
8073
  </details>
7793
8074
  """
@@ -7806,6 +8087,14 @@ class SpotifyClient:
7806
8087
  # ensure market was either supplied or implied; default if neither.
7807
8088
  market = self._ValidateMarket(market)
7808
8089
 
8090
+ # if showId not specified, then return currently playing show id value.
8091
+ if (showId is None) or (len(showId.strip()) == 0):
8092
+ uri = self.GetPlayerNowPlayingShowUri()
8093
+ if uri is not None:
8094
+ showId = SpotifyClient.GetIdFromUri(uri)
8095
+ else:
8096
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'showId'), logsi=_logsi)
8097
+
7809
8098
  # build spotify web api request parameters.
7810
8099
  urlParms:dict = {}
7811
8100
  if market is not None:
@@ -7824,6 +8113,7 @@ class SpotifyClient:
7824
8113
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7825
8114
  return result
7826
8115
 
8116
+ except SpotifyApiError: raise # pass handled exceptions on thru
7827
8117
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7828
8118
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7829
8119
  except Exception as ex:
@@ -7837,13 +8127,14 @@ class SpotifyClient:
7837
8127
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
7838
8128
 
7839
8129
 
7840
- def GetShowEpisodes(self,
7841
- showId:str,
7842
- limit:int=20,
7843
- offset:int=0,
7844
- market:str=None,
7845
- limitTotal:int=None
7846
- ) -> EpisodePageSimplified:
8130
+ def GetShowEpisodes(
8131
+ self,
8132
+ showId:str=None,
8133
+ limit:int=20,
8134
+ offset:int=0,
8135
+ market:str=None,
8136
+ limitTotal:int=None
8137
+ ) -> EpisodePageSimplified:
7847
8138
  """
7848
8139
  Get Spotify catalog information about a show's episodes.
7849
8140
 
@@ -7853,6 +8144,8 @@ class SpotifyClient:
7853
8144
  showId (str):
7854
8145
  The Spotify ID for the show.
7855
8146
  Example: `6kAsbP8pxwaU2kPibKTuHE`
8147
+ If null, the currently playing show uri id value is used; a Spotify Free or Premium account
8148
+ is required to correctly read the currently playing context.
7856
8149
  limit (int):
7857
8150
  The maximum number of items to return in a page of items when manual paging is used.
7858
8151
  Default: 20, Range: 1 to 50.
@@ -7931,6 +8224,14 @@ class SpotifyClient:
7931
8224
  # ensure market was either supplied or implied; default if neither.
7932
8225
  market = self._ValidateMarket(market)
7933
8226
 
8227
+ # if showId not specified, then return currently playing show id value.
8228
+ if (showId is None) or (len(showId.strip()) == 0):
8229
+ uri = self.GetPlayerNowPlayingShowUri()
8230
+ if uri is not None:
8231
+ showId = SpotifyClient.GetIdFromUri(uri)
8232
+ else:
8233
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'showId'), logsi=_logsi)
8234
+
7934
8235
  # build spotify web api request parameters.
7935
8236
  urlParms:dict = \
7936
8237
  {
@@ -7985,6 +8286,7 @@ class SpotifyClient:
7985
8286
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7986
8287
  return result
7987
8288
 
8289
+ except SpotifyApiError: raise # pass handled exceptions on thru
7988
8290
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7989
8291
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7990
8292
  except Exception as ex:
@@ -8136,6 +8438,7 @@ class SpotifyClient:
8136
8438
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
8137
8439
  return result
8138
8440
 
8441
+ except SpotifyApiError: raise # pass handled exceptions on thru
8139
8442
  except SpotifyWebApiError: raise # pass handled exceptions on thru
8140
8443
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
8141
8444
  except Exception as ex:
@@ -8231,6 +8534,7 @@ class SpotifyClient:
8231
8534
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[ShowSimplified]'), result)
8232
8535
  return result
8233
8536
 
8537
+ except SpotifyApiError: raise # pass handled exceptions on thru
8234
8538
  except SpotifyWebApiError: raise # pass handled exceptions on thru
8235
8539
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
8236
8540
  except Exception as ex:
@@ -8786,9 +9090,10 @@ class SpotifyClient:
8786
9090
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
8787
9091
 
8788
9092
 
8789
- def GetTrack(self,
8790
- trackId:str,
8791
- ) -> Track:
9093
+ def GetTrack(
9094
+ self,
9095
+ trackId:str=None,
9096
+ ) -> Track:
8792
9097
  """
8793
9098
  Get Spotify catalog information for a single track identified by its unique Spotify ID.
8794
9099
 
@@ -8796,6 +9101,8 @@ class SpotifyClient:
8796
9101
  trackId (str):
8797
9102
  The Spotify ID of the track.
8798
9103
  Example: `1kWUud3vY5ij5r62zxpTRy`
9104
+ If null, the currently playing track uri id value is used; a Spotify Free or Premium account
9105
+ is required to correctly read the currently playing context.
8799
9106
 
8800
9107
  Returns:
8801
9108
  A `Track` object that contains the track details.
@@ -8811,6 +9118,10 @@ class SpotifyClient:
8811
9118
  <summary>Sample Code</summary>
8812
9119
  ```python
8813
9120
  .. include:: ../docs/include/samplecode/SpotifyClient/GetTrack.py
9121
+ ```
9122
+ <summary>Sample Code - NowPlaying</summary>
9123
+ ```python
9124
+ .. include:: ../docs/include/samplecode/SpotifyClient/GetTrack_NowPlaying.py
8814
9125
  ```
8815
9126
  </details>
8816
9127
  """
@@ -8825,6 +9136,14 @@ class SpotifyClient:
8825
9136
  apiMethodParms.AppendKeyValue("trackId", trackId)
8826
9137
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for a single track", apiMethodParms)
8827
9138
 
9139
+ # if trackId not specified, then return currently playing track id value.
9140
+ if (trackId is None) or (len(trackId.strip()) == 0):
9141
+ uri = self.GetPlayerNowPlayingUri('track')
9142
+ if uri is not None:
9143
+ trackId = SpotifyClient.GetIdFromUri(uri)
9144
+ else:
9145
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'trackId'), logsi=_logsi)
9146
+
8828
9147
  # execute spotify web api request.
8829
9148
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/tracks/{id}'.format(id=trackId))
8830
9149
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -8837,6 +9156,7 @@ class SpotifyClient:
8837
9156
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
8838
9157
  return result
8839
9158
 
9159
+ except SpotifyApiError: raise # pass handled exceptions on thru
8840
9160
  except SpotifyWebApiError: raise # pass handled exceptions on thru
8841
9161
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
8842
9162
  except Exception as ex:
@@ -8850,9 +9170,10 @@ class SpotifyClient:
8850
9170
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
8851
9171
 
8852
9172
 
8853
- def GetTrackAudioFeatures(self,
8854
- trackId:str,
8855
- ) -> AudioFeatures:
9173
+ def GetTrackAudioFeatures(
9174
+ self,
9175
+ trackId:str=None,
9176
+ ) -> AudioFeatures:
8856
9177
  """
8857
9178
  Get audio feature information for a single track identified by its unique Spotify ID.
8858
9179
 
@@ -8860,6 +9181,8 @@ class SpotifyClient:
8860
9181
  trackId (str):
8861
9182
  The Spotify ID of the track.
8862
9183
  Example: `1kWUud3vY5ij5r62zxpTRy`
9184
+ If null, the currently playing track uri id value is used; a Spotify Free or Premium account
9185
+ is required to correctly read the currently playing context.
8863
9186
 
8864
9187
  Returns:
8865
9188
  An `AudioFeatures` object that contains the audio feature details.
@@ -8889,6 +9212,14 @@ class SpotifyClient:
8889
9212
  apiMethodParms.AppendKeyValue("trackId", trackId)
8890
9213
  _logsi.LogMethodParmList(SILevel.Verbose, "Get audio feature information for a single track", apiMethodParms)
8891
9214
 
9215
+ # if trackId not specified, then return currently playing track id value.
9216
+ if (trackId is None) or (len(trackId.strip()) == 0):
9217
+ uri = self.GetPlayerNowPlayingUri('track')
9218
+ if uri is not None:
9219
+ trackId = SpotifyClient.GetIdFromUri(uri)
9220
+ else:
9221
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'trackId'), logsi=_logsi)
9222
+
8892
9223
  # execute spotify web api request.
8893
9224
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/audio-features/{id}'.format(id=trackId))
8894
9225
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -8901,6 +9232,7 @@ class SpotifyClient:
8901
9232
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
8902
9233
  return result
8903
9234
 
9235
+ except SpotifyApiError: raise # pass handled exceptions on thru
8904
9236
  except SpotifyWebApiError: raise # pass handled exceptions on thru
8905
9237
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
8906
9238
  except Exception as ex:
@@ -9067,6 +9399,7 @@ class SpotifyClient:
9067
9399
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
9068
9400
  return result
9069
9401
 
9402
+ except SpotifyApiError: raise # pass handled exceptions on thru
9070
9403
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9071
9404
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9072
9405
  except Exception as ex:
@@ -9157,6 +9490,7 @@ class SpotifyClient:
9157
9490
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Track]'), result)
9158
9491
  return result
9159
9492
 
9493
+ except SpotifyApiError: raise # pass handled exceptions on thru
9160
9494
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9161
9495
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9162
9496
  except Exception as ex:
@@ -9232,6 +9566,7 @@ class SpotifyClient:
9232
9566
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[AudioFeatures]'), result)
9233
9567
  return result
9234
9568
 
9569
+ except SpotifyApiError: raise # pass handled exceptions on thru
9235
9570
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9236
9571
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9237
9572
  except Exception as ex:
@@ -9634,6 +9969,7 @@ class SpotifyClient:
9634
9969
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
9635
9970
  return result
9636
9971
 
9972
+ except SpotifyApiError: raise # pass handled exceptions on thru
9637
9973
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9638
9974
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9639
9975
  except Exception as ex:
@@ -9758,6 +10094,7 @@ class SpotifyClient:
9758
10094
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result, excludeNonPublic=True)
9759
10095
  return result
9760
10096
 
10097
+ except SpotifyApiError: raise # pass handled exceptions on thru
9761
10098
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9762
10099
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9763
10100
  except Exception as ex:
@@ -9822,6 +10159,7 @@ class SpotifyClient:
9822
10159
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
9823
10160
  return result
9824
10161
 
10162
+ except SpotifyApiError: raise # pass handled exceptions on thru
9825
10163
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9826
10164
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9827
10165
  except Exception as ex:
@@ -9984,6 +10322,7 @@ class SpotifyClient:
9984
10322
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
9985
10323
  return result
9986
10324
 
10325
+ except SpotifyApiError: raise # pass handled exceptions on thru
9987
10326
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9988
10327
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9989
10328
  except Exception as ex:
@@ -10146,6 +10485,7 @@ class SpotifyClient:
10146
10485
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
10147
10486
  return result
10148
10487
 
10488
+ except SpotifyApiError: raise # pass handled exceptions on thru
10149
10489
  except SpotifyWebApiError: raise # pass handled exceptions on thru
10150
10490
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
10151
10491
  except Exception as ex:
@@ -10798,6 +11138,7 @@ class SpotifyClient:
10798
11138
  # no results to process - this is pass or fail.
10799
11139
  return
10800
11140
 
11141
+ except SpotifyApiError: raise # pass handled exceptions on thru
10801
11142
  except SpotifyWebApiError: raise # pass handled exceptions on thru
10802
11143
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
10803
11144
  except Exception as ex:
@@ -10902,6 +11243,7 @@ class SpotifyClient:
10902
11243
  # no results to process - this is pass or fail.
10903
11244
  return
10904
11245
 
11246
+ except SpotifyApiError: raise # pass handled exceptions on thru
10905
11247
  except SpotifyWebApiError: raise # pass handled exceptions on thru
10906
11248
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
10907
11249
  except Exception as ex:
@@ -10995,6 +11337,7 @@ class SpotifyClient:
10995
11337
  # no results to process - this is pass or fail.
10996
11338
  return
10997
11339
 
11340
+ except SpotifyApiError: raise # pass handled exceptions on thru
10998
11341
  except SpotifyWebApiError: raise # pass handled exceptions on thru
10999
11342
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11000
11343
  except Exception as ex:
@@ -11088,6 +11431,7 @@ class SpotifyClient:
11088
11431
  # no results to process - this is pass or fail.
11089
11432
  return
11090
11433
 
11434
+ except SpotifyApiError: raise # pass handled exceptions on thru
11091
11435
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11092
11436
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11093
11437
  except Exception as ex:
@@ -11306,6 +11650,7 @@ class SpotifyClient:
11306
11650
  # no results to process - this is pass or fail.
11307
11651
  return
11308
11652
 
11653
+ except SpotifyApiError: raise # pass handled exceptions on thru
11309
11654
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11310
11655
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11311
11656
  except Exception as ex:
@@ -11409,6 +11754,7 @@ class SpotifyClient:
11409
11754
  # no results to process - this is pass or fail.
11410
11755
  return
11411
11756
 
11757
+ except SpotifyApiError: raise # pass handled exceptions on thru
11412
11758
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11413
11759
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11414
11760
  except Exception as ex:
@@ -11511,6 +11857,7 @@ class SpotifyClient:
11511
11857
  # no results to process - this is pass or fail.
11512
11858
  return
11513
11859
 
11860
+ except SpotifyApiError: raise # pass handled exceptions on thru
11514
11861
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11515
11862
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11516
11863
  except Exception as ex:
@@ -11732,6 +12079,7 @@ class SpotifyClient:
11732
12079
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
11733
12080
  return result
11734
12081
 
12082
+ except SpotifyApiError: raise # pass handled exceptions on thru
11735
12083
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11736
12084
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11737
12085
  except Exception as ex:
@@ -11792,7 +12140,7 @@ class SpotifyClient:
11792
12140
 
11793
12141
  # if ids not specified, then return currently playing album id value.
11794
12142
  if (ids is None) or (len(ids.strip()) == 0):
11795
- uri = self._GetPlayerNowPlayingAlbumUri()
12143
+ uri = self.GetPlayerNowPlayingAlbumUri()
11796
12144
  if uri is not None:
11797
12145
  ids = SpotifyClient.GetIdFromUri(uri)
11798
12146
  else:
@@ -11882,7 +12230,7 @@ class SpotifyClient:
11882
12230
 
11883
12231
  # if ids not specified, then return currently playing id value.
11884
12232
  if (ids is None) or (len(ids.strip()) == 0):
11885
- uri = self._GetPlayerNowPlayingAudiobookUri()
12233
+ uri = self.GetPlayerNowPlayingAudiobookUri()
11886
12234
  if uri is not None:
11887
12235
  ids = SpotifyClient.GetIdFromUri(uri)
11888
12236
  else:
@@ -11972,7 +12320,7 @@ class SpotifyClient:
11972
12320
 
11973
12321
  # if ids not specified, then return currently playing id value.
11974
12322
  if (ids is None) or (len(ids.strip()) == 0):
11975
- uri = self._GetPlayerNowPlayingUri('episode')
12323
+ uri = self.GetPlayerNowPlayingUri('episode')
11976
12324
  if uri is not None:
11977
12325
  ids = SpotifyClient.GetIdFromUri(uri)
11978
12326
  else:
@@ -12143,7 +12491,7 @@ class SpotifyClient:
12143
12491
 
12144
12492
  # if uris not specified, then return currently playing uri value.
12145
12493
  if (uris is None) or (len(uris.strip()) == 0):
12146
- uris = self._GetPlayerNowPlayingUri()
12494
+ uris = self.GetPlayerNowPlayingUri(None)
12147
12495
  if uris is None:
12148
12496
  raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'uris'), logsi=_logsi)
12149
12497
 
@@ -12241,7 +12589,7 @@ class SpotifyClient:
12241
12589
 
12242
12590
  # if ids not specified, then return currently playing id value.
12243
12591
  if (ids is None) or (len(ids.strip()) == 0):
12244
- uri = self._GetPlayerNowPlayingShowUri()
12592
+ uri = self.GetPlayerNowPlayingShowUri()
12245
12593
  if uri is not None:
12246
12594
  ids = SpotifyClient.GetIdFromUri(uri)
12247
12595
  else:
@@ -12330,7 +12678,7 @@ class SpotifyClient:
12330
12678
 
12331
12679
  # if ids not specified, then return currently playing id value.
12332
12680
  if (ids is None) or (len(ids.strip()) == 0):
12333
- uri = self._GetPlayerNowPlayingUri()
12681
+ uri = self.GetPlayerNowPlayingUri('track')
12334
12682
  if uri is not None:
12335
12683
  ids = SpotifyClient.GetIdFromUri(uri)
12336
12684
  else:
@@ -12471,6 +12819,7 @@ class SpotifyClient:
12471
12819
  _logsi.LogString(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
12472
12820
  return result
12473
12821
 
12822
+ except SpotifyApiError: raise # pass handled exceptions on thru
12474
12823
  except SpotifyWebApiError: raise # pass handled exceptions on thru
12475
12824
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
12476
12825
  except Exception as ex:
@@ -12560,6 +12909,7 @@ class SpotifyClient:
12560
12909
  _logsi.LogString(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
12561
12910
  return result
12562
12911
 
12912
+ except SpotifyApiError: raise # pass handled exceptions on thru
12563
12913
  except SpotifyWebApiError: raise # pass handled exceptions on thru
12564
12914
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
12565
12915
  except Exception as ex:
@@ -12620,7 +12970,7 @@ class SpotifyClient:
12620
12970
 
12621
12971
  # if ids not specified, then return currently playing album id value.
12622
12972
  if (ids is None) or (len(ids.strip()) == 0):
12623
- uri = self._GetPlayerNowPlayingAlbumUri()
12973
+ uri = self.GetPlayerNowPlayingAlbumUri()
12624
12974
  if uri is not None:
12625
12975
  ids = SpotifyClient.GetIdFromUri(uri)
12626
12976
  else:
@@ -12710,7 +13060,7 @@ class SpotifyClient:
12710
13060
 
12711
13061
  # if ids not specified, then return currently playing id value.
12712
13062
  if (ids is None) or (len(ids.strip()) == 0):
12713
- uri = self._GetPlayerNowPlayingAudiobookUri()
13063
+ uri = self.GetPlayerNowPlayingAudiobookUri()
12714
13064
  if uri is not None:
12715
13065
  ids = SpotifyClient.GetIdFromUri(uri)
12716
13066
  else:
@@ -12800,7 +13150,7 @@ class SpotifyClient:
12800
13150
 
12801
13151
  # if ids not specified, then return currently playing id value.
12802
13152
  if (ids is None) or (len(ids.strip()) == 0):
12803
- uri = self._GetPlayerNowPlayingUri('episode')
13153
+ uri = self.GetPlayerNowPlayingUri('episode')
12804
13154
  if uri is not None:
12805
13155
  ids = SpotifyClient.GetIdFromUri(uri)
12806
13156
  else:
@@ -12890,7 +13240,7 @@ class SpotifyClient:
12890
13240
 
12891
13241
  # if ids not specified, then return currently playing id value.
12892
13242
  if (ids is None) or (len(ids.strip()) == 0):
12893
- uri = self._GetPlayerNowPlayingShowUri()
13243
+ uri = self.GetPlayerNowPlayingShowUri()
12894
13244
  if uri is not None:
12895
13245
  ids = SpotifyClient.GetIdFromUri(uri)
12896
13246
  else:
@@ -12979,7 +13329,7 @@ class SpotifyClient:
12979
13329
 
12980
13330
  # if ids not specified, then return currently playing id value.
12981
13331
  if (ids is None) or (len(ids.strip()) == 0):
12982
- uri = self._GetPlayerNowPlayingUri()
13332
+ uri = self.GetPlayerNowPlayingUri('track')
12983
13333
  if uri is not None:
12984
13334
  ids = SpotifyClient.GetIdFromUri(uri)
12985
13335
  else:
@@ -13185,6 +13535,7 @@ class SpotifyClient:
13185
13535
  # _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
13186
13536
  # return result
13187
13537
 
13538
+ # except SpotifyApiError: raise # pass handled exceptions on thru
13188
13539
  # except SpotifyWebApiError: raise # pass handled exceptions on thru
13189
13540
  # except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13190
13541
  # except Exception as ex:
@@ -13376,6 +13727,7 @@ class SpotifyClient:
13376
13727
  response.Albums = result
13377
13728
  return response
13378
13729
 
13730
+ except SpotifyApiError: raise # pass handled exceptions on thru
13379
13731
  except SpotifyWebApiError: raise # pass handled exceptions on thru
13380
13732
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13381
13733
  except Exception as ex:
@@ -13567,6 +13919,7 @@ class SpotifyClient:
13567
13919
  response.Artists = result
13568
13920
  return response
13569
13921
 
13922
+ except SpotifyApiError: raise # pass handled exceptions on thru
13570
13923
  except SpotifyWebApiError: raise # pass handled exceptions on thru
13571
13924
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13572
13925
  except Exception as ex:
@@ -13760,6 +14113,7 @@ class SpotifyClient:
13760
14113
  response.Audiobooks = result
13761
14114
  return response
13762
14115
 
14116
+ except SpotifyApiError: raise # pass handled exceptions on thru
13763
14117
  except SpotifyWebApiError: raise # pass handled exceptions on thru
13764
14118
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13765
14119
  except Exception as ex:
@@ -13951,6 +14305,7 @@ class SpotifyClient:
13951
14305
  response.Episodes = result
13952
14306
  return response
13953
14307
 
14308
+ except SpotifyApiError: raise # pass handled exceptions on thru
13954
14309
  except SpotifyWebApiError: raise # pass handled exceptions on thru
13955
14310
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13956
14311
  except Exception as ex:
@@ -14142,6 +14497,7 @@ class SpotifyClient:
14142
14497
  response.Playlists = result
14143
14498
  return response
14144
14499
 
14500
+ except SpotifyApiError: raise # pass handled exceptions on thru
14145
14501
  except SpotifyWebApiError: raise # pass handled exceptions on thru
14146
14502
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
14147
14503
  except Exception as ex:
@@ -14333,6 +14689,7 @@ class SpotifyClient:
14333
14689
  response.Shows = result
14334
14690
  return response
14335
14691
 
14692
+ except SpotifyApiError: raise # pass handled exceptions on thru
14336
14693
  except SpotifyWebApiError: raise # pass handled exceptions on thru
14337
14694
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
14338
14695
  except Exception as ex:
@@ -14524,6 +14881,7 @@ class SpotifyClient:
14524
14881
  response.Tracks = result
14525
14882
  return response
14526
14883
 
14884
+ except SpotifyApiError: raise # pass handled exceptions on thru
14527
14885
  except SpotifyWebApiError: raise # pass handled exceptions on thru
14528
14886
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
14529
14887
  except Exception as ex:
@@ -14985,6 +15343,7 @@ class SpotifyClient:
14985
15343
  # trace.
14986
15344
  _logsi.LogObject(SILevel.Verbose, TRACE_MSG_USERPROFILE % (self._UserProfile.DisplayName, self._UserProfile.EMail), self._UserProfile, excludeNonPublic=True)
14987
15345
 
15346
+ except SpotifyApiError: raise # pass handled exceptions on thru
14988
15347
  except SpotifyWebApiError: raise # pass handled exceptions on thru
14989
15348
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
14990
15349
  except Exception as ex:
@@ -15119,9 +15478,10 @@ class SpotifyClient:
15119
15478
  return msg
15120
15479
 
15121
15480
 
15122
- def UnfollowArtists(self,
15123
- ids:str=None,
15124
- ) -> None:
15481
+ def UnfollowArtists(
15482
+ self,
15483
+ ids:str=None,
15484
+ ) -> None:
15125
15485
  """
15126
15486
  Remove the current user as a follower of one or more artists.
15127
15487
 
@@ -15162,7 +15522,7 @@ class SpotifyClient:
15162
15522
 
15163
15523
  # if ids not specified, then return currently playing artist id value.
15164
15524
  if (ids is None) or (len(ids.strip()) == 0):
15165
- uri = self._GetPlayerNowPlayingArtistUri()
15525
+ uri = self.GetPlayerNowPlayingArtistUri()
15166
15526
  if uri is not None:
15167
15527
  ids = SpotifyClient.GetIdFromUri(uri)
15168
15528
  else:
@@ -15190,6 +15550,7 @@ class SpotifyClient:
15190
15550
  # no results to process - this is pass or fail.
15191
15551
  return
15192
15552
 
15553
+ except SpotifyApiError: raise # pass handled exceptions on thru
15193
15554
  except SpotifyWebApiError: raise # pass handled exceptions on thru
15194
15555
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
15195
15556
  except Exception as ex:
@@ -15203,9 +15564,10 @@ class SpotifyClient:
15203
15564
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
15204
15565
 
15205
15566
 
15206
- def UnfollowPlaylist(self,
15207
- playlistId:str,
15208
- ) -> None:
15567
+ def UnfollowPlaylist(
15568
+ self,
15569
+ playlistId:str=None,
15570
+ ) -> None:
15209
15571
  """
15210
15572
  Remove the current user as a follower of a playlist.
15211
15573
 
@@ -15215,6 +15577,7 @@ class SpotifyClient:
15215
15577
  playlistId (str):
15216
15578
  The Spotify ID of the playlist.
15217
15579
  Example: `3cEYpjA9oz9GiPac4AsH4n`
15580
+ If null, the currently playing playlist uri id value is used.
15218
15581
 
15219
15582
  Raises:
15220
15583
  SpotifyWebApiError:
@@ -15240,6 +15603,14 @@ class SpotifyClient:
15240
15603
  apiMethodParms.AppendKeyValue("playlistId", playlistId)
15241
15604
  _logsi.LogMethodParmList(SILevel.Verbose, "Remove the current user as a follower of a playlist", apiMethodParms)
15242
15605
 
15606
+ # if playlistId not specified, then return currently playing playlist id value.
15607
+ if (playlistId is None) or (len(playlistId.strip()) == 0):
15608
+ uri = self.GetPlayerNowPlayingPlaylistUri()
15609
+ if uri is not None:
15610
+ playlistId = SpotifyClient.GetIdFromUri(uri)
15611
+ else:
15612
+ raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'playlistId'), logsi=_logsi)
15613
+
15243
15614
  # execute spotify web api request.
15244
15615
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{playlist_id}/followers'.format(playlist_id=playlistId))
15245
15616
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -15249,6 +15620,7 @@ class SpotifyClient:
15249
15620
  # no results to process - this is pass or fail.
15250
15621
  return
15251
15622
 
15623
+ except SpotifyApiError: raise # pass handled exceptions on thru
15252
15624
  except SpotifyWebApiError: raise # pass handled exceptions on thru
15253
15625
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
15254
15626
  except Exception as ex:
@@ -15324,6 +15696,7 @@ class SpotifyClient:
15324
15696
  # no results to process - this is pass or fail.
15325
15697
  return
15326
15698
 
15699
+ except SpotifyApiError: raise # pass handled exceptions on thru
15327
15700
  except SpotifyWebApiError: raise # pass handled exceptions on thru
15328
15701
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
15329
15702
  except Exception as ex: