spotifywebapiPython 1.0.91__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,137 +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
- Args:
728
- additionalTypes (str):
729
- An item type that your client supports besides the default track type.
730
- Valid types are: `track` and `episode`.
731
- Specify `episode` to get podcast track information.
732
- """
733
- result:str = None
734
-
735
- # get nowplaying status.
736
- _logsi.LogVerbose("Querying NowPlaying status of Spotify player")
737
- nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes=additionalTypes)
738
-
739
- # is anything playing? if so, return the uri value.
740
- if nowPlaying is not None:
741
- _logsi.LogVerbose("NowPlaying data: %s" % str(nowPlaying))
742
- if nowPlaying.Item is not None:
743
- if additionalTypes is None:
744
- # if not validating uri type then just return the uri.
745
- result = nowPlaying.Item.Uri
746
- elif nowPlaying.CurrentlyPlayingType == additionalTypes:
747
- # if validating uri type then return uri if nowplaying types matches desired type.
748
- result = nowPlaying.Item.Uri
749
- else:
750
- # otherwise nowplaying type is not the desired type!
751
- raise SpotifyApiError("Currently playing item is not a %s" % additionalTypes, logsi=_logsi)
752
-
753
- return result
754
-
755
-
756
625
  def _ValidateMarket(self,
757
626
  market:str,
758
627
  ) -> str:
@@ -1121,6 +990,7 @@ class SpotifyClient:
1121
990
  # no results to process - this is pass or fail.
1122
991
  return
1123
992
 
993
+ except SpotifyApiError: raise # pass handled exceptions on thru
1124
994
  except SpotifyWebApiError: raise # pass handled exceptions on thru
1125
995
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
1126
996
  except Exception as ex:
@@ -1193,7 +1063,7 @@ class SpotifyClient:
1193
1063
 
1194
1064
  # if uris not specified, then return currently playing uri value.
1195
1065
  if (uris is None) or (len(uris.strip()) == 0):
1196
- uris = self._GetPlayerNowPlayingUri()
1066
+ uris = self.GetPlayerNowPlayingUri(None)
1197
1067
  if uris is None:
1198
1068
  raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'uris'), logsi=_logsi)
1199
1069
 
@@ -1352,6 +1222,7 @@ class SpotifyClient:
1352
1222
  # no results to process - this is pass or fail.
1353
1223
  return
1354
1224
 
1225
+ except SpotifyApiError: raise # pass handled exceptions on thru
1355
1226
  except SpotifyWebApiError: raise # pass handled exceptions on thru
1356
1227
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
1357
1228
  except Exception as ex:
@@ -1413,7 +1284,7 @@ class SpotifyClient:
1413
1284
 
1414
1285
  # if ids not specified, then return currently playing album id value.
1415
1286
  if (ids is None) or (len(ids.strip()) == 0):
1416
- uri = self._GetPlayerNowPlayingAlbumUri()
1287
+ uri = self.GetPlayerNowPlayingAlbumUri()
1417
1288
  if uri is not None:
1418
1289
  ids = SpotifyClient.GetIdFromUri(uri)
1419
1290
  else:
@@ -1511,7 +1382,7 @@ class SpotifyClient:
1511
1382
 
1512
1383
  # if ids not specified, then return currently playing artist id value.
1513
1384
  if (ids is None) or (len(ids.strip()) == 0):
1514
- uri = self._GetPlayerNowPlayingArtistUri()
1385
+ uri = self.GetPlayerNowPlayingArtistUri()
1515
1386
  if uri is not None:
1516
1387
  ids = SpotifyClient.GetIdFromUri(uri)
1517
1388
  else:
@@ -1607,7 +1478,7 @@ class SpotifyClient:
1607
1478
 
1608
1479
  # if ids not specified, then return currently playing id value.
1609
1480
  if (ids is None) or (len(ids.strip()) == 0):
1610
- uri = self._GetPlayerNowPlayingAudiobookUri()
1481
+ uri = self.GetPlayerNowPlayingAudiobookUri()
1611
1482
  if uri is not None:
1612
1483
  ids = SpotifyClient.GetIdFromUri(uri)
1613
1484
  else:
@@ -1702,7 +1573,7 @@ class SpotifyClient:
1702
1573
 
1703
1574
  # if ids not specified, then return currently playing id value.
1704
1575
  if (ids is None) or (len(ids.strip()) == 0):
1705
- uri = self._GetPlayerNowPlayingUri('episode')
1576
+ uri = self.GetPlayerNowPlayingUri('episode')
1706
1577
  if uri is not None:
1707
1578
  ids = SpotifyClient.GetIdFromUri(uri)
1708
1579
  else:
@@ -1884,7 +1755,7 @@ class SpotifyClient:
1884
1755
 
1885
1756
  # if ids not specified, then return currently playing id value.
1886
1757
  if (ids is None) or (len(ids.strip()) == 0):
1887
- uri = self._GetPlayerNowPlayingShowUri()
1758
+ uri = self.GetPlayerNowPlayingShowUri()
1888
1759
  if uri is not None:
1889
1760
  ids = SpotifyClient.GetIdFromUri(uri)
1890
1761
  else:
@@ -1979,7 +1850,7 @@ class SpotifyClient:
1979
1850
 
1980
1851
  # if ids not specified, then return currently playing id value.
1981
1852
  if (ids is None) or (len(ids.strip()) == 0):
1982
- uri = self._GetPlayerNowPlayingUri('track')
1853
+ uri = self.GetPlayerNowPlayingUri('track')
1983
1854
  if uri is not None:
1984
1855
  ids = SpotifyClient.GetIdFromUri(uri)
1985
1856
  else:
@@ -2202,6 +2073,7 @@ class SpotifyClient:
2202
2073
  _logsi.LogString(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
2203
2074
  return result
2204
2075
 
2076
+ except SpotifyApiError: raise # pass handled exceptions on thru
2205
2077
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2206
2078
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2207
2079
  except Exception as ex:
@@ -2339,6 +2211,7 @@ class SpotifyClient:
2339
2211
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
2340
2212
  return result
2341
2213
 
2214
+ except SpotifyApiError: raise # pass handled exceptions on thru
2342
2215
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2343
2216
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2344
2217
  except Exception as ex:
@@ -2352,9 +2225,10 @@ class SpotifyClient:
2352
2225
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
2353
2226
 
2354
2227
 
2355
- def FollowArtists(self,
2356
- ids:str=None,
2357
- ) -> None:
2228
+ def FollowArtists(
2229
+ self,
2230
+ ids:str=None,
2231
+ ) -> None:
2358
2232
  """
2359
2233
  Add the current user as a follower of one or more artists.
2360
2234
 
@@ -2395,7 +2269,7 @@ class SpotifyClient:
2395
2269
 
2396
2270
  # if ids not specified, then return currently playing artist id value.
2397
2271
  if (ids is None) or (len(ids.strip()) == 0):
2398
- uri = self._GetPlayerNowPlayingArtistUri()
2272
+ uri = self.GetPlayerNowPlayingArtistUri()
2399
2273
  if uri is not None:
2400
2274
  ids = SpotifyClient.GetIdFromUri(uri)
2401
2275
  else:
@@ -2423,6 +2297,7 @@ class SpotifyClient:
2423
2297
  # no results to process - this is pass or fail.
2424
2298
  return
2425
2299
 
2300
+ except SpotifyApiError: raise # pass handled exceptions on thru
2426
2301
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2427
2302
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2428
2303
  except Exception as ex:
@@ -2436,10 +2311,11 @@ class SpotifyClient:
2436
2311
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
2437
2312
 
2438
2313
 
2439
- def FollowPlaylist(self,
2440
- playlistId:str,
2441
- public:bool=True
2442
- ) -> None:
2314
+ def FollowPlaylist(
2315
+ self,
2316
+ playlistId:str=None,
2317
+ public:bool=True
2318
+ ) -> None:
2443
2319
  """
2444
2320
  Add the current user as a follower of a playlist.
2445
2321
 
@@ -2449,6 +2325,7 @@ class SpotifyClient:
2449
2325
  playlistId (str):
2450
2326
  The Spotify ID of the playlist.
2451
2327
  Example: `3cEYpjA9oz9GiPac4AsH4n`
2328
+ If null, the currently playing playlist uri id value is used.
2452
2329
  public (bool):
2453
2330
  If true the playlist will be included in user's public playlists, if false it
2454
2331
  will remain private.
@@ -2479,6 +2356,14 @@ class SpotifyClient:
2479
2356
  apiMethodParms.AppendKeyValue("public", public)
2480
2357
  _logsi.LogMethodParmList(SILevel.Verbose, "Add the current user as a follower of a playlist", apiMethodParms)
2481
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
+
2482
2367
  # build spotify web api request parameters.
2483
2368
  reqData:dict = {}
2484
2369
  if public is not None:
@@ -2494,6 +2379,7 @@ class SpotifyClient:
2494
2379
  # no results to process - this is pass or fail.
2495
2380
  return
2496
2381
 
2382
+ except SpotifyApiError: raise # pass handled exceptions on thru
2497
2383
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2498
2384
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2499
2385
  except Exception as ex:
@@ -2569,6 +2455,7 @@ class SpotifyClient:
2569
2455
  # no results to process - this is pass or fail.
2570
2456
  return
2571
2457
 
2458
+ except SpotifyApiError: raise # pass handled exceptions on thru
2572
2459
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2573
2460
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2574
2461
  except Exception as ex:
@@ -2582,10 +2469,11 @@ class SpotifyClient:
2582
2469
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
2583
2470
 
2584
2471
 
2585
- def GetAlbum(self,
2586
- albumId:str,
2587
- market:str=None,
2588
- ) -> Album:
2472
+ def GetAlbum(
2473
+ self,
2474
+ albumId:str=None,
2475
+ market:str=None,
2476
+ ) -> Album:
2589
2477
  """
2590
2478
  Get Spotify catalog information for a single album.
2591
2479
 
@@ -2593,6 +2481,8 @@ class SpotifyClient:
2593
2481
  albumId (str):
2594
2482
  The Spotify ID of the album.
2595
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.
2596
2486
  market (str):
2597
2487
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
2598
2488
  is available in that market will be returned. If a valid user access token is specified
@@ -2616,6 +2506,10 @@ class SpotifyClient:
2616
2506
  <summary>Sample Code</summary>
2617
2507
  ```python
2618
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
2619
2513
  ```
2620
2514
  </details>
2621
2515
  """
@@ -2634,6 +2528,14 @@ class SpotifyClient:
2634
2528
  # ensure market was either supplied or implied; default if neither.
2635
2529
  market = self._ValidateMarket(market)
2636
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
+
2637
2539
  # build spotify web api request parameters.
2638
2540
  urlParms:dict = {}
2639
2541
  if market is not None:
@@ -2652,6 +2554,7 @@ class SpotifyClient:
2652
2554
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
2653
2555
  return result
2654
2556
 
2557
+ except SpotifyApiError: raise # pass handled exceptions on thru
2655
2558
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2656
2559
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2657
2560
  except Exception as ex:
@@ -2818,6 +2721,7 @@ class SpotifyClient:
2818
2721
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
2819
2722
  return result
2820
2723
 
2724
+ except SpotifyApiError: raise # pass handled exceptions on thru
2821
2725
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2822
2726
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2823
2727
  except Exception as ex:
@@ -2979,6 +2883,7 @@ class SpotifyClient:
2979
2883
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
2980
2884
  return result
2981
2885
 
2886
+ except SpotifyApiError: raise # pass handled exceptions on thru
2982
2887
  except SpotifyWebApiError: raise # pass handled exceptions on thru
2983
2888
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
2984
2889
  except Exception as ex:
@@ -3069,6 +2974,7 @@ class SpotifyClient:
3069
2974
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Album]'), result)
3070
2975
  return result
3071
2976
 
2977
+ except SpotifyApiError: raise # pass handled exceptions on thru
3072
2978
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3073
2979
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3074
2980
  except Exception as ex:
@@ -3082,13 +2988,14 @@ class SpotifyClient:
3082
2988
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
3083
2989
 
3084
2990
 
3085
- def GetAlbumTracks(self,
3086
- albumId:str,
3087
- limit:int=20,
3088
- offset:int=0,
3089
- market:str=None,
3090
- limitTotal:int=None
3091
- ) -> 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:
3092
2999
  """
3093
3000
  Get Spotify catalog information about an album's tracks.
3094
3001
 
@@ -3098,6 +3005,8 @@ class SpotifyClient:
3098
3005
  albumId (str):
3099
3006
  The Spotify ID of the album.
3100
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.
3101
3010
  limit (int):
3102
3011
  The maximum number of items to return in a page of items when manual paging is used.
3103
3012
  Default: 20, Range: 1 to 50.
@@ -3176,6 +3085,14 @@ class SpotifyClient:
3176
3085
  # ensure market was either supplied or implied; default if neither.
3177
3086
  market = self._ValidateMarket(market)
3178
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
+
3179
3096
  # build spotify web api request parameters.
3180
3097
  urlParms:dict = \
3181
3098
  {
@@ -3230,6 +3147,7 @@ class SpotifyClient:
3230
3147
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
3231
3148
  return result
3232
3149
 
3150
+ except SpotifyApiError: raise # pass handled exceptions on thru
3233
3151
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3234
3152
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3235
3153
  except Exception as ex:
@@ -3243,9 +3161,10 @@ class SpotifyClient:
3243
3161
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
3244
3162
 
3245
3163
 
3246
- def GetArtist(self,
3247
- artistId:str,
3248
- ) -> Artist:
3164
+ def GetArtist(
3165
+ self,
3166
+ artistId:str=None,
3167
+ ) -> Artist:
3249
3168
  """
3250
3169
  Get Spotify catalog information for a single artist identified by their unique Spotify ID.
3251
3170
 
@@ -3253,6 +3172,8 @@ class SpotifyClient:
3253
3172
  artistId (str):
3254
3173
  The Spotify ID of the artist.
3255
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.
3256
3177
 
3257
3178
  Returns:
3258
3179
  An `Artist` object that contains the artist details.
@@ -3268,6 +3189,10 @@ class SpotifyClient:
3268
3189
  <summary>Sample Code</summary>
3269
3190
  ```python
3270
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
3271
3196
  ```
3272
3197
  </details>
3273
3198
  """
@@ -3282,6 +3207,14 @@ class SpotifyClient:
3282
3207
  apiMethodParms.AppendKeyValue("artistId", artistId)
3283
3208
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for a single artist", apiMethodParms)
3284
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
+
3285
3218
  # execute spotify web api request.
3286
3219
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/artists/{id}'.format(id=artistId))
3287
3220
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -3294,6 +3227,7 @@ class SpotifyClient:
3294
3227
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
3295
3228
  return result
3296
3229
 
3230
+ except SpotifyApiError: raise # pass handled exceptions on thru
3297
3231
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3298
3232
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3299
3233
  except Exception as ex:
@@ -3309,7 +3243,7 @@ class SpotifyClient:
3309
3243
 
3310
3244
  def GetArtistAlbums(
3311
3245
  self,
3312
- artistId:str,
3246
+ artistId:str=None,
3313
3247
  include_groups:str='album',
3314
3248
  limit:int=20,
3315
3249
  offset:int=0,
@@ -3324,6 +3258,8 @@ class SpotifyClient:
3324
3258
  artistId (str):
3325
3259
  The Spotify ID of the artist.
3326
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.
3327
3263
  include_groups (str):
3328
3264
  A comma-separated list of keywords that will be used to filter the response.
3329
3265
  If not supplied, all album types will be returned.
@@ -3413,6 +3349,14 @@ class SpotifyClient:
3413
3349
  # ensure market was either supplied or implied; default if neither.
3414
3350
  market = self._ValidateMarket(market)
3415
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
+
3416
3360
  # build spotify web api request parameters.
3417
3361
  urlParms:dict = \
3418
3362
  {
@@ -3470,6 +3414,7 @@ class SpotifyClient:
3470
3414
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
3471
3415
  return result
3472
3416
 
3417
+ except SpotifyApiError: raise # pass handled exceptions on thru
3473
3418
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3474
3419
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3475
3420
  except Exception as ex:
@@ -3483,9 +3428,10 @@ class SpotifyClient:
3483
3428
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
3484
3429
 
3485
3430
 
3486
- def GetArtistInfo(self,
3487
- artistId:str,
3488
- ) -> ArtistInfo:
3431
+ def GetArtistInfo(
3432
+ self,
3433
+ artistId:str=None,
3434
+ ) -> ArtistInfo:
3489
3435
  """
3490
3436
  Get artist about information from the Spotify Artist Biography page for the
3491
3437
  specified Spotify artist ID.
@@ -3494,6 +3440,8 @@ class SpotifyClient:
3494
3440
  artistId (str):
3495
3441
  The Spotify ID of the artist.
3496
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.
3497
3445
 
3498
3446
  Returns:
3499
3447
  An `ArtistInfo` object that contains the artist info details.
@@ -3525,6 +3473,14 @@ class SpotifyClient:
3525
3473
  apiMethodParms.AppendKeyValue("artistId", artistId)
3526
3474
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for a single artist", apiMethodParms)
3527
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
+
3528
3484
  # execute spotify web api request.
3529
3485
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/artists/{id}'.format(id=artistId))
3530
3486
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -3691,6 +3647,7 @@ class SpotifyClient:
3691
3647
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
3692
3648
  return result
3693
3649
 
3650
+ except SpotifyApiError: raise # pass handled exceptions on thru
3694
3651
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3695
3652
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3696
3653
  except Exception as ex:
@@ -3731,9 +3688,10 @@ class SpotifyClient:
3731
3688
  return result
3732
3689
 
3733
3690
 
3734
- def GetArtistRelatedArtists(self,
3735
- artistId:str,
3736
- ) -> list[Artist]:
3691
+ def GetArtistRelatedArtists(
3692
+ self,
3693
+ artistId:str=None,
3694
+ ) -> list[Artist]:
3737
3695
  """
3738
3696
  Get Spotify catalog information about artists similar to a given artist.
3739
3697
  Similarity is based on analysis of the Spotify community's listening history.
@@ -3742,6 +3700,8 @@ class SpotifyClient:
3742
3700
  artistId (str):
3743
3701
  The Spotify ID of the artist.
3744
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.
3745
3705
 
3746
3706
  Returns:
3747
3707
  A list of `Artist` objects that contain the artist details.
@@ -3771,6 +3731,14 @@ class SpotifyClient:
3771
3731
  apiMethodParms.AppendKeyValue("artistId", artistId)
3772
3732
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information about artists similar to a given artist", apiMethodParms)
3773
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
+
3774
3742
  # execute spotify web api request.
3775
3743
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/artists/{id}/related-artists'.format(id=artistId))
3776
3744
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -3786,6 +3754,7 @@ class SpotifyClient:
3786
3754
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Artist]'), result)
3787
3755
  return result
3788
3756
 
3757
+ except SpotifyApiError: raise # pass handled exceptions on thru
3789
3758
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3790
3759
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3791
3760
  except Exception as ex:
@@ -3861,6 +3830,7 @@ class SpotifyClient:
3861
3830
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Artist]'), result)
3862
3831
  return result
3863
3832
 
3833
+ except SpotifyApiError: raise # pass handled exceptions on thru
3864
3834
  except SpotifyWebApiError: raise # pass handled exceptions on thru
3865
3835
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
3866
3836
  except Exception as ex:
@@ -4019,6 +3989,7 @@ class SpotifyClient:
4019
3989
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4020
3990
  return result
4021
3991
 
3992
+ except SpotifyApiError: raise # pass handled exceptions on thru
4022
3993
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4023
3994
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4024
3995
  except Exception as ex:
@@ -4032,10 +4003,11 @@ class SpotifyClient:
4032
4003
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
4033
4004
 
4034
4005
 
4035
- def GetArtistTopTracks(self,
4036
- artistId:str,
4037
- market:str,
4038
- ) -> list[Track]:
4006
+ def GetArtistTopTracks(
4007
+ self,
4008
+ artistId:str=None,
4009
+ market:str=None,
4010
+ ) -> list[Track]:
4039
4011
  """
4040
4012
  Get Spotify catalog information about an artist's top tracks by country.
4041
4013
 
@@ -4043,6 +4015,8 @@ class SpotifyClient:
4043
4015
  artistId (str):
4044
4016
  The Spotify ID of the artist.
4045
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.
4046
4020
  market (str):
4047
4021
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
4048
4022
  is available in that market will be returned. If a valid user access token is specified
@@ -4084,6 +4058,14 @@ class SpotifyClient:
4084
4058
  # ensure market was either supplied or implied; default if neither.
4085
4059
  market = self._ValidateMarket(market)
4086
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
+
4087
4069
  # build spotify web api request parameters.
4088
4070
  urlParms:dict = {}
4089
4071
  if market is not None:
@@ -4105,6 +4087,7 @@ class SpotifyClient:
4105
4087
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Track]'), result)
4106
4088
  return result
4107
4089
 
4090
+ except SpotifyApiError: raise # pass handled exceptions on thru
4108
4091
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4109
4092
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4110
4093
  except Exception as ex:
@@ -4118,10 +4101,11 @@ class SpotifyClient:
4118
4101
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
4119
4102
 
4120
4103
 
4121
- def GetAudiobook(self,
4122
- audiobookId:str,
4123
- market:str=None,
4124
- ) -> Audiobook:
4104
+ def GetAudiobook(
4105
+ self,
4106
+ audiobookId:str=None,
4107
+ market:str=None,
4108
+ ) -> Audiobook:
4125
4109
  """
4126
4110
  Get Spotify catalog information for a single audiobook.
4127
4111
 
@@ -4131,6 +4115,8 @@ class SpotifyClient:
4131
4115
  audiobookId (str):
4132
4116
  The Spotify ID for the audiobook.
4133
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.
4134
4120
  market (str):
4135
4121
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
4136
4122
  is available in that market will be returned. If a valid user access token is specified
@@ -4159,6 +4145,10 @@ class SpotifyClient:
4159
4145
  <summary>Sample Code</summary>
4160
4146
  ```python
4161
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
4162
4152
  ```
4163
4153
  </details>
4164
4154
  """
@@ -4177,6 +4167,14 @@ class SpotifyClient:
4177
4167
  # ensure market was either supplied or implied; default if neither.
4178
4168
  market = self._ValidateMarket(market)
4179
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
+
4180
4178
  # build spotify web api request parameters.
4181
4179
  urlParms:dict = {}
4182
4180
  if market is not None:
@@ -4195,6 +4193,7 @@ class SpotifyClient:
4195
4193
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4196
4194
  return result
4197
4195
 
4196
+ except SpotifyApiError: raise # pass handled exceptions on thru
4198
4197
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4199
4198
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4200
4199
  except Exception as ex:
@@ -4208,13 +4207,14 @@ class SpotifyClient:
4208
4207
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
4209
4208
 
4210
4209
 
4211
- def GetAudiobookChapters(self,
4212
- audiobookId:str,
4213
- limit:int=20,
4214
- offset:int=0,
4215
- market:str=None,
4216
- limitTotal:int=None
4217
- ) -> 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:
4218
4218
  """
4219
4219
  Get Spotify catalog information about an audiobook's chapters.
4220
4220
 
@@ -4224,6 +4224,8 @@ class SpotifyClient:
4224
4224
  audiobookId (str):
4225
4225
  The Spotify ID for the audiobook.
4226
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.
4227
4229
  limit (int):
4228
4230
  The maximum number of items to return in a page of items when manual paging is used.
4229
4231
  Default: 20, Range: 1 to 50.
@@ -4302,6 +4304,14 @@ class SpotifyClient:
4302
4304
  # ensure market was either supplied or implied; default if neither.
4303
4305
  market = self._ValidateMarket(market)
4304
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
+
4305
4315
  # build spotify web api request parameters.
4306
4316
  urlParms:dict = \
4307
4317
  {
@@ -4356,6 +4366,7 @@ class SpotifyClient:
4356
4366
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4357
4367
  return result
4358
4368
 
4369
+ except SpotifyApiError: raise # pass handled exceptions on thru
4359
4370
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4360
4371
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4361
4372
  except Exception as ex:
@@ -4507,6 +4518,7 @@ class SpotifyClient:
4507
4518
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4508
4519
  return result
4509
4520
 
4521
+ except SpotifyApiError: raise # pass handled exceptions on thru
4510
4522
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4511
4523
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4512
4524
  except Exception as ex:
@@ -4602,6 +4614,7 @@ class SpotifyClient:
4602
4614
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[AudiobookSimplified]'), result)
4603
4615
  return result
4604
4616
 
4617
+ except SpotifyApiError: raise # pass handled exceptions on thru
4605
4618
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4606
4619
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4607
4620
  except Exception as ex:
@@ -4720,6 +4733,7 @@ class SpotifyClient:
4720
4733
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result, excludeNonPublic=True)
4721
4734
  return result
4722
4735
 
4736
+ except SpotifyApiError: raise # pass handled exceptions on thru
4723
4737
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4724
4738
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4725
4739
  except Exception as ex:
@@ -4894,6 +4908,7 @@ class SpotifyClient:
4894
4908
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
4895
4909
  return result
4896
4910
 
4911
+ except SpotifyApiError: raise # pass handled exceptions on thru
4897
4912
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4898
4913
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4899
4914
  except Exception as ex:
@@ -4993,6 +5008,7 @@ class SpotifyClient:
4993
5008
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result)
4994
5009
  return result
4995
5010
 
5011
+ except SpotifyApiError: raise # pass handled exceptions on thru
4996
5012
  except SpotifyWebApiError: raise # pass handled exceptions on thru
4997
5013
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
4998
5014
  except Exception as ex:
@@ -5174,6 +5190,7 @@ class SpotifyClient:
5174
5190
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5175
5191
  return result, resultMessage
5176
5192
 
5193
+ except SpotifyApiError: raise # pass handled exceptions on thru
5177
5194
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5178
5195
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5179
5196
  except Exception as ex:
@@ -5264,6 +5281,7 @@ class SpotifyClient:
5264
5281
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5265
5282
  return result
5266
5283
 
5284
+ except SpotifyApiError: raise # pass handled exceptions on thru
5267
5285
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5268
5286
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5269
5287
  except Exception as ex:
@@ -5359,6 +5377,7 @@ class SpotifyClient:
5359
5377
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Chapter]'), result)
5360
5378
  return result
5361
5379
 
5380
+ except SpotifyApiError: raise # pass handled exceptions on thru
5362
5381
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5363
5382
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5364
5383
  except Exception as ex:
@@ -5372,10 +5391,11 @@ class SpotifyClient:
5372
5391
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
5373
5392
 
5374
5393
 
5375
- def GetEpisode(self,
5376
- episodeId:str,
5377
- market:str=None,
5378
- ) -> Episode:
5394
+ def GetEpisode(
5395
+ self,
5396
+ episodeId:str=None,
5397
+ market:str=None,
5398
+ ) -> Episode:
5379
5399
  """
5380
5400
  Get Spotify catalog information for a single episode identified by its unique Spotify ID.
5381
5401
 
@@ -5385,6 +5405,8 @@ class SpotifyClient:
5385
5405
  episodeId (str):
5386
5406
  The Spotify ID for the episode.
5387
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.
5388
5410
  market (str):
5389
5411
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
5390
5412
  is available in that market will be returned. If a valid user access token is specified
@@ -5431,6 +5453,14 @@ class SpotifyClient:
5431
5453
  # ensure market was either supplied or implied; default if neither.
5432
5454
  market = self._ValidateMarket(market)
5433
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
+
5434
5464
  # build spotify web api request parameters.
5435
5465
  urlParms:dict = {}
5436
5466
  if market is not None:
@@ -5449,6 +5479,7 @@ class SpotifyClient:
5449
5479
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5450
5480
  return result
5451
5481
 
5482
+ except SpotifyApiError: raise # pass handled exceptions on thru
5452
5483
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5453
5484
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5454
5485
  except Exception as ex:
@@ -5600,6 +5631,7 @@ class SpotifyClient:
5600
5631
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5601
5632
  return result
5602
5633
 
5634
+ except SpotifyApiError: raise # pass handled exceptions on thru
5603
5635
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5604
5636
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5605
5637
  except Exception as ex:
@@ -5695,6 +5727,7 @@ class SpotifyClient:
5695
5727
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Episode]'), result)
5696
5728
  return result
5697
5729
 
5730
+ except SpotifyApiError: raise # pass handled exceptions on thru
5698
5731
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5699
5732
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5700
5733
  except Exception as ex:
@@ -5885,6 +5918,7 @@ class SpotifyClient:
5885
5918
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
5886
5919
  return result, resultMessage
5887
5920
 
5921
+ except SpotifyApiError: raise # pass handled exceptions on thru
5888
5922
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5889
5923
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5890
5924
  except Exception as ex:
@@ -5965,6 +5999,7 @@ class SpotifyClient:
5965
5999
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result)
5966
6000
  return result
5967
6001
 
6002
+ except SpotifyApiError: raise # pass handled exceptions on thru
5968
6003
  except SpotifyWebApiError: raise # pass handled exceptions on thru
5969
6004
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
5970
6005
  except Exception as ex:
@@ -6083,6 +6118,7 @@ class SpotifyClient:
6083
6118
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result)
6084
6119
  return result
6085
6120
 
6121
+ except SpotifyApiError: raise # pass handled exceptions on thru
6086
6122
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6087
6123
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6088
6124
  except Exception as ex:
@@ -6133,6 +6169,7 @@ class SpotifyClient:
6133
6169
  # subsequent calls to the Spotify Web API player endpoints.
6134
6170
  return None
6135
6171
 
6172
+ except SpotifyApiError: raise # pass handled exceptions on thru
6136
6173
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6137
6174
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6138
6175
  except Exception as ex:
@@ -6222,6 +6259,7 @@ class SpotifyClient:
6222
6259
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'Device'), result, excludeNonPublic=True)
6223
6260
  return result
6224
6261
 
6262
+ except SpotifyApiError: raise # pass handled exceptions on thru
6225
6263
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6226
6264
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6227
6265
  except Exception as ex:
@@ -6513,6 +6551,7 @@ class SpotifyClient:
6513
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)
6514
6552
  return value
6515
6553
 
6554
+ except SpotifyApiError: raise # pass handled exceptions on thru
6516
6555
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6517
6556
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6518
6557
  except Exception as ex:
@@ -6616,6 +6655,7 @@ class SpotifyClient:
6616
6655
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, 'list[Device]', cacheDesc), result)
6617
6656
  return result
6618
6657
 
6658
+ except SpotifyApiError: raise # pass handled exceptions on thru
6619
6659
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6620
6660
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6621
6661
  except Exception as ex:
@@ -6682,11 +6722,16 @@ class SpotifyClient:
6682
6722
  # trace.
6683
6723
  apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
6684
6724
  apiMethodParms.AppendKeyValue("market", market)
6725
+ apiMethodParms.AppendKeyValue("additionalTypes", additionalTypes)
6685
6726
  _logsi.LogMethodParmList(SILevel.Verbose, "Get the object currently being played on the user's Spotify account", apiMethodParms)
6686
6727
 
6687
6728
  # ensure market was either supplied or implied; default if neither.
6688
6729
  market = self._ValidateMarket(market)
6689
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
+
6690
6735
  # build spotify web api request parameters.
6691
6736
  urlParms:dict = {}
6692
6737
  if market is not None:
@@ -6707,6 +6752,7 @@ class SpotifyClient:
6707
6752
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
6708
6753
  return result
6709
6754
 
6755
+ except SpotifyApiError: raise # pass handled exceptions on thru
6710
6756
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6711
6757
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6712
6758
  except Exception as ex:
@@ -6720,6 +6766,188 @@ class SpotifyClient:
6720
6766
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
6721
6767
 
6722
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
+
6723
6951
  def GetPlayerPlaybackState(self,
6724
6952
  market:str=None,
6725
6953
  additionalTypes:str=None
@@ -6811,6 +7039,7 @@ class SpotifyClient:
6811
7039
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
6812
7040
  return result
6813
7041
 
7042
+ except SpotifyApiError: raise # pass handled exceptions on thru
6814
7043
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6815
7044
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6816
7045
  except Exception as ex:
@@ -6868,6 +7097,7 @@ class SpotifyClient:
6868
7097
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
6869
7098
  return result
6870
7099
 
7100
+ except SpotifyApiError: raise # pass handled exceptions on thru
6871
7101
  except SpotifyWebApiError: raise # pass handled exceptions on thru
6872
7102
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
6873
7103
  except Exception as ex:
@@ -7052,6 +7282,7 @@ class SpotifyClient:
7052
7282
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7053
7283
  return result
7054
7284
 
7285
+ except SpotifyApiError: raise # pass handled exceptions on thru
7055
7286
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7056
7287
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7057
7288
  except Exception as ex:
@@ -7065,12 +7296,13 @@ class SpotifyClient:
7065
7296
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
7066
7297
 
7067
7298
 
7068
- def GetPlaylist(self,
7069
- playlistId:str,
7070
- market:str=None,
7071
- fields:str=None,
7072
- additionalTypes:str=None
7073
- ) -> Playlist:
7299
+ def GetPlaylist(
7300
+ self,
7301
+ playlistId:str=None,
7302
+ market:str=None,
7303
+ fields:str=None,
7304
+ additionalTypes:str=None
7305
+ ) -> Playlist:
7074
7306
  """
7075
7307
  Get a playlist owned by a Spotify user.
7076
7308
 
@@ -7078,6 +7310,7 @@ class SpotifyClient:
7078
7310
  playlistId (str):
7079
7311
  The Spotify ID of the playlist.
7080
7312
  Example: `5v5ETK9WFXAnGQ3MRubKuE`
7313
+ If null, the currently playing playlist uri id value is used.
7081
7314
  market (str):
7082
7315
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
7083
7316
  is available in that market will be returned. If a valid user access token is specified
@@ -7121,6 +7354,10 @@ class SpotifyClient:
7121
7354
  <summary>Sample Code</summary>
7122
7355
  ```python
7123
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
7124
7361
  ```
7125
7362
  </details>
7126
7363
  """
@@ -7141,6 +7378,14 @@ class SpotifyClient:
7141
7378
  # ensure market was either supplied or implied; default if neither.
7142
7379
  market = self._ValidateMarket(market)
7143
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
+
7144
7389
  # was the Spotify DJ playlist specified?
7145
7390
  # the DJ is not fully integrated with the playlist API, so the GET request will fail.
7146
7391
  # we will manually build a basic playlist object to return for the playlist.
@@ -7184,6 +7429,7 @@ class SpotifyClient:
7184
7429
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7185
7430
  return result
7186
7431
 
7432
+ except SpotifyApiError: raise # pass handled exceptions on thru
7187
7433
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7188
7434
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7189
7435
  except Exception as ex:
@@ -7252,6 +7498,7 @@ class SpotifyClient:
7252
7498
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7253
7499
  return result
7254
7500
 
7501
+ except SpotifyApiError: raise # pass handled exceptions on thru
7255
7502
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7256
7503
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7257
7504
  except Exception as ex:
@@ -7265,15 +7512,16 @@ class SpotifyClient:
7265
7512
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
7266
7513
 
7267
7514
 
7268
- def GetPlaylistItems(self,
7269
- playlistId:str,
7270
- limit:int=50,
7271
- offset:int=0,
7272
- market:str=None,
7273
- fields:str=None,
7274
- additionalTypes:str=None,
7275
- limitTotal:int=None
7276
- ) -> 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:
7277
7525
  """
7278
7526
  Get full details of the items of a playlist owned by a Spotify user.
7279
7527
 
@@ -7283,6 +7531,7 @@ class SpotifyClient:
7283
7531
  playlistId (str):
7284
7532
  The Spotify ID of the playlist.
7285
7533
  Example: `5v5ETK9WFXAnGQ3MRubKuE`
7534
+ If null, the currently playing playlist uri id value is used.
7286
7535
  limit (int):
7287
7536
  The maximum number of items to return in a page of items when manual paging is used.
7288
7537
  Default: 50, Range: 1 to 50.
@@ -7384,6 +7633,14 @@ class SpotifyClient:
7384
7633
  # ensure market was either supplied or implied; default if neither.
7385
7634
  market = self._ValidateMarket(market)
7386
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
+
7387
7644
  # build spotify web api request parameters.
7388
7645
  urlParms:dict = \
7389
7646
  {
@@ -7442,6 +7699,7 @@ class SpotifyClient:
7442
7699
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7443
7700
  return result
7444
7701
 
7702
+ except SpotifyApiError: raise # pass handled exceptions on thru
7445
7703
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7446
7704
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7447
7705
  except Exception as ex:
@@ -7593,6 +7851,7 @@ class SpotifyClient:
7593
7851
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7594
7852
  return result
7595
7853
 
7854
+ except SpotifyApiError: raise # pass handled exceptions on thru
7596
7855
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7597
7856
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7598
7857
  except Exception as ex:
@@ -7750,6 +8009,7 @@ class SpotifyClient:
7750
8009
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7751
8010
  return result
7752
8011
 
8012
+ except SpotifyApiError: raise # pass handled exceptions on thru
7753
8013
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7754
8014
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7755
8015
  except Exception as ex:
@@ -7763,10 +8023,11 @@ class SpotifyClient:
7763
8023
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
7764
8024
 
7765
8025
 
7766
- def GetShow(self,
7767
- showId:str,
7768
- market:str=None,
7769
- ) -> Show:
8026
+ def GetShow(
8027
+ self,
8028
+ showId:str=None,
8029
+ market:str=None,
8030
+ ) -> Show:
7770
8031
  """
7771
8032
  Get Spotify catalog information for a single show identified by its unique Spotify ID.
7772
8033
 
@@ -7774,6 +8035,8 @@ class SpotifyClient:
7774
8035
  showId (str):
7775
8036
  The Spotify ID for the show.
7776
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.
7777
8040
  market (str):
7778
8041
  An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
7779
8042
  is available in that market will be returned. If a valid user access token is specified
@@ -7802,6 +8065,10 @@ class SpotifyClient:
7802
8065
  <summary>Sample Code</summary>
7803
8066
  ```python
7804
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
7805
8072
  ```
7806
8073
  </details>
7807
8074
  """
@@ -7820,6 +8087,14 @@ class SpotifyClient:
7820
8087
  # ensure market was either supplied or implied; default if neither.
7821
8088
  market = self._ValidateMarket(market)
7822
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
+
7823
8098
  # build spotify web api request parameters.
7824
8099
  urlParms:dict = {}
7825
8100
  if market is not None:
@@ -7838,6 +8113,7 @@ class SpotifyClient:
7838
8113
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
7839
8114
  return result
7840
8115
 
8116
+ except SpotifyApiError: raise # pass handled exceptions on thru
7841
8117
  except SpotifyWebApiError: raise # pass handled exceptions on thru
7842
8118
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
7843
8119
  except Exception as ex:
@@ -7851,13 +8127,14 @@ class SpotifyClient:
7851
8127
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
7852
8128
 
7853
8129
 
7854
- def GetShowEpisodes(self,
7855
- showId:str,
7856
- limit:int=20,
7857
- offset:int=0,
7858
- market:str=None,
7859
- limitTotal:int=None
7860
- ) -> 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:
7861
8138
  """
7862
8139
  Get Spotify catalog information about a show's episodes.
7863
8140
 
@@ -7867,6 +8144,8 @@ class SpotifyClient:
7867
8144
  showId (str):
7868
8145
  The Spotify ID for the show.
7869
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.
7870
8149
  limit (int):
7871
8150
  The maximum number of items to return in a page of items when manual paging is used.
7872
8151
  Default: 20, Range: 1 to 50.
@@ -7945,6 +8224,14 @@ class SpotifyClient:
7945
8224
  # ensure market was either supplied or implied; default if neither.
7946
8225
  market = self._ValidateMarket(market)
7947
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
+
7948
8235
  # build spotify web api request parameters.
7949
8236
  urlParms:dict = \
7950
8237
  {
@@ -7999,6 +8286,7 @@ class SpotifyClient:
7999
8286
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
8000
8287
  return result
8001
8288
 
8289
+ except SpotifyApiError: raise # pass handled exceptions on thru
8002
8290
  except SpotifyWebApiError: raise # pass handled exceptions on thru
8003
8291
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
8004
8292
  except Exception as ex:
@@ -8150,6 +8438,7 @@ class SpotifyClient:
8150
8438
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
8151
8439
  return result
8152
8440
 
8441
+ except SpotifyApiError: raise # pass handled exceptions on thru
8153
8442
  except SpotifyWebApiError: raise # pass handled exceptions on thru
8154
8443
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
8155
8444
  except Exception as ex:
@@ -8245,6 +8534,7 @@ class SpotifyClient:
8245
8534
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[ShowSimplified]'), result)
8246
8535
  return result
8247
8536
 
8537
+ except SpotifyApiError: raise # pass handled exceptions on thru
8248
8538
  except SpotifyWebApiError: raise # pass handled exceptions on thru
8249
8539
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
8250
8540
  except Exception as ex:
@@ -8800,9 +9090,10 @@ class SpotifyClient:
8800
9090
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
8801
9091
 
8802
9092
 
8803
- def GetTrack(self,
8804
- trackId:str,
8805
- ) -> Track:
9093
+ def GetTrack(
9094
+ self,
9095
+ trackId:str=None,
9096
+ ) -> Track:
8806
9097
  """
8807
9098
  Get Spotify catalog information for a single track identified by its unique Spotify ID.
8808
9099
 
@@ -8810,6 +9101,8 @@ class SpotifyClient:
8810
9101
  trackId (str):
8811
9102
  The Spotify ID of the track.
8812
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.
8813
9106
 
8814
9107
  Returns:
8815
9108
  A `Track` object that contains the track details.
@@ -8825,6 +9118,10 @@ class SpotifyClient:
8825
9118
  <summary>Sample Code</summary>
8826
9119
  ```python
8827
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
8828
9125
  ```
8829
9126
  </details>
8830
9127
  """
@@ -8839,6 +9136,14 @@ class SpotifyClient:
8839
9136
  apiMethodParms.AppendKeyValue("trackId", trackId)
8840
9137
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for a single track", apiMethodParms)
8841
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
+
8842
9147
  # execute spotify web api request.
8843
9148
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/tracks/{id}'.format(id=trackId))
8844
9149
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -8851,6 +9156,7 @@ class SpotifyClient:
8851
9156
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
8852
9157
  return result
8853
9158
 
9159
+ except SpotifyApiError: raise # pass handled exceptions on thru
8854
9160
  except SpotifyWebApiError: raise # pass handled exceptions on thru
8855
9161
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
8856
9162
  except Exception as ex:
@@ -8864,9 +9170,10 @@ class SpotifyClient:
8864
9170
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
8865
9171
 
8866
9172
 
8867
- def GetTrackAudioFeatures(self,
8868
- trackId:str,
8869
- ) -> AudioFeatures:
9173
+ def GetTrackAudioFeatures(
9174
+ self,
9175
+ trackId:str=None,
9176
+ ) -> AudioFeatures:
8870
9177
  """
8871
9178
  Get audio feature information for a single track identified by its unique Spotify ID.
8872
9179
 
@@ -8874,6 +9181,8 @@ class SpotifyClient:
8874
9181
  trackId (str):
8875
9182
  The Spotify ID of the track.
8876
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.
8877
9186
 
8878
9187
  Returns:
8879
9188
  An `AudioFeatures` object that contains the audio feature details.
@@ -8903,6 +9212,14 @@ class SpotifyClient:
8903
9212
  apiMethodParms.AppendKeyValue("trackId", trackId)
8904
9213
  _logsi.LogMethodParmList(SILevel.Verbose, "Get audio feature information for a single track", apiMethodParms)
8905
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
+
8906
9223
  # execute spotify web api request.
8907
9224
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/audio-features/{id}'.format(id=trackId))
8908
9225
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -8915,6 +9232,7 @@ class SpotifyClient:
8915
9232
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
8916
9233
  return result
8917
9234
 
9235
+ except SpotifyApiError: raise # pass handled exceptions on thru
8918
9236
  except SpotifyWebApiError: raise # pass handled exceptions on thru
8919
9237
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
8920
9238
  except Exception as ex:
@@ -9081,6 +9399,7 @@ class SpotifyClient:
9081
9399
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
9082
9400
  return result
9083
9401
 
9402
+ except SpotifyApiError: raise # pass handled exceptions on thru
9084
9403
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9085
9404
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9086
9405
  except Exception as ex:
@@ -9171,6 +9490,7 @@ class SpotifyClient:
9171
9490
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Track]'), result)
9172
9491
  return result
9173
9492
 
9493
+ except SpotifyApiError: raise # pass handled exceptions on thru
9174
9494
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9175
9495
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9176
9496
  except Exception as ex:
@@ -9246,6 +9566,7 @@ class SpotifyClient:
9246
9566
  _logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[AudioFeatures]'), result)
9247
9567
  return result
9248
9568
 
9569
+ except SpotifyApiError: raise # pass handled exceptions on thru
9249
9570
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9250
9571
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9251
9572
  except Exception as ex:
@@ -9648,6 +9969,7 @@ class SpotifyClient:
9648
9969
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
9649
9970
  return result
9650
9971
 
9972
+ except SpotifyApiError: raise # pass handled exceptions on thru
9651
9973
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9652
9974
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9653
9975
  except Exception as ex:
@@ -9772,6 +10094,7 @@ class SpotifyClient:
9772
10094
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE_CACHED % (apiMethodName, type(result).__name__, cacheDesc), result, excludeNonPublic=True)
9773
10095
  return result
9774
10096
 
10097
+ except SpotifyApiError: raise # pass handled exceptions on thru
9775
10098
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9776
10099
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9777
10100
  except Exception as ex:
@@ -9836,6 +10159,7 @@ class SpotifyClient:
9836
10159
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
9837
10160
  return result
9838
10161
 
10162
+ except SpotifyApiError: raise # pass handled exceptions on thru
9839
10163
  except SpotifyWebApiError: raise # pass handled exceptions on thru
9840
10164
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
9841
10165
  except Exception as ex:
@@ -9998,6 +10322,7 @@ class SpotifyClient:
9998
10322
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
9999
10323
  return result
10000
10324
 
10325
+ except SpotifyApiError: raise # pass handled exceptions on thru
10001
10326
  except SpotifyWebApiError: raise # pass handled exceptions on thru
10002
10327
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
10003
10328
  except Exception as ex:
@@ -10160,6 +10485,7 @@ class SpotifyClient:
10160
10485
  _logsi.LogObject(SILevel.Verbose, (TRACE_METHOD_RESULT_TYPE + result.PagingInfo) % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
10161
10486
  return result
10162
10487
 
10488
+ except SpotifyApiError: raise # pass handled exceptions on thru
10163
10489
  except SpotifyWebApiError: raise # pass handled exceptions on thru
10164
10490
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
10165
10491
  except Exception as ex:
@@ -10812,6 +11138,7 @@ class SpotifyClient:
10812
11138
  # no results to process - this is pass or fail.
10813
11139
  return
10814
11140
 
11141
+ except SpotifyApiError: raise # pass handled exceptions on thru
10815
11142
  except SpotifyWebApiError: raise # pass handled exceptions on thru
10816
11143
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
10817
11144
  except Exception as ex:
@@ -10916,6 +11243,7 @@ class SpotifyClient:
10916
11243
  # no results to process - this is pass or fail.
10917
11244
  return
10918
11245
 
11246
+ except SpotifyApiError: raise # pass handled exceptions on thru
10919
11247
  except SpotifyWebApiError: raise # pass handled exceptions on thru
10920
11248
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
10921
11249
  except Exception as ex:
@@ -11009,6 +11337,7 @@ class SpotifyClient:
11009
11337
  # no results to process - this is pass or fail.
11010
11338
  return
11011
11339
 
11340
+ except SpotifyApiError: raise # pass handled exceptions on thru
11012
11341
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11013
11342
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11014
11343
  except Exception as ex:
@@ -11102,6 +11431,7 @@ class SpotifyClient:
11102
11431
  # no results to process - this is pass or fail.
11103
11432
  return
11104
11433
 
11434
+ except SpotifyApiError: raise # pass handled exceptions on thru
11105
11435
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11106
11436
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11107
11437
  except Exception as ex:
@@ -11320,6 +11650,7 @@ class SpotifyClient:
11320
11650
  # no results to process - this is pass or fail.
11321
11651
  return
11322
11652
 
11653
+ except SpotifyApiError: raise # pass handled exceptions on thru
11323
11654
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11324
11655
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11325
11656
  except Exception as ex:
@@ -11423,6 +11754,7 @@ class SpotifyClient:
11423
11754
  # no results to process - this is pass or fail.
11424
11755
  return
11425
11756
 
11757
+ except SpotifyApiError: raise # pass handled exceptions on thru
11426
11758
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11427
11759
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11428
11760
  except Exception as ex:
@@ -11525,6 +11857,7 @@ class SpotifyClient:
11525
11857
  # no results to process - this is pass or fail.
11526
11858
  return
11527
11859
 
11860
+ except SpotifyApiError: raise # pass handled exceptions on thru
11528
11861
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11529
11862
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11530
11863
  except Exception as ex:
@@ -11746,6 +12079,7 @@ class SpotifyClient:
11746
12079
  _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
11747
12080
  return result
11748
12081
 
12082
+ except SpotifyApiError: raise # pass handled exceptions on thru
11749
12083
  except SpotifyWebApiError: raise # pass handled exceptions on thru
11750
12084
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
11751
12085
  except Exception as ex:
@@ -11806,7 +12140,7 @@ class SpotifyClient:
11806
12140
 
11807
12141
  # if ids not specified, then return currently playing album id value.
11808
12142
  if (ids is None) or (len(ids.strip()) == 0):
11809
- uri = self._GetPlayerNowPlayingAlbumUri()
12143
+ uri = self.GetPlayerNowPlayingAlbumUri()
11810
12144
  if uri is not None:
11811
12145
  ids = SpotifyClient.GetIdFromUri(uri)
11812
12146
  else:
@@ -11896,7 +12230,7 @@ class SpotifyClient:
11896
12230
 
11897
12231
  # if ids not specified, then return currently playing id value.
11898
12232
  if (ids is None) or (len(ids.strip()) == 0):
11899
- uri = self._GetPlayerNowPlayingAudiobookUri()
12233
+ uri = self.GetPlayerNowPlayingAudiobookUri()
11900
12234
  if uri is not None:
11901
12235
  ids = SpotifyClient.GetIdFromUri(uri)
11902
12236
  else:
@@ -11986,7 +12320,7 @@ class SpotifyClient:
11986
12320
 
11987
12321
  # if ids not specified, then return currently playing id value.
11988
12322
  if (ids is None) or (len(ids.strip()) == 0):
11989
- uri = self._GetPlayerNowPlayingUri('episode')
12323
+ uri = self.GetPlayerNowPlayingUri('episode')
11990
12324
  if uri is not None:
11991
12325
  ids = SpotifyClient.GetIdFromUri(uri)
11992
12326
  else:
@@ -12157,7 +12491,7 @@ class SpotifyClient:
12157
12491
 
12158
12492
  # if uris not specified, then return currently playing uri value.
12159
12493
  if (uris is None) or (len(uris.strip()) == 0):
12160
- uris = self._GetPlayerNowPlayingUri()
12494
+ uris = self.GetPlayerNowPlayingUri(None)
12161
12495
  if uris is None:
12162
12496
  raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'uris'), logsi=_logsi)
12163
12497
 
@@ -12255,7 +12589,7 @@ class SpotifyClient:
12255
12589
 
12256
12590
  # if ids not specified, then return currently playing id value.
12257
12591
  if (ids is None) or (len(ids.strip()) == 0):
12258
- uri = self._GetPlayerNowPlayingShowUri()
12592
+ uri = self.GetPlayerNowPlayingShowUri()
12259
12593
  if uri is not None:
12260
12594
  ids = SpotifyClient.GetIdFromUri(uri)
12261
12595
  else:
@@ -12344,7 +12678,7 @@ class SpotifyClient:
12344
12678
 
12345
12679
  # if ids not specified, then return currently playing id value.
12346
12680
  if (ids is None) or (len(ids.strip()) == 0):
12347
- uri = self._GetPlayerNowPlayingUri('track')
12681
+ uri = self.GetPlayerNowPlayingUri('track')
12348
12682
  if uri is not None:
12349
12683
  ids = SpotifyClient.GetIdFromUri(uri)
12350
12684
  else:
@@ -12485,6 +12819,7 @@ class SpotifyClient:
12485
12819
  _logsi.LogString(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
12486
12820
  return result
12487
12821
 
12822
+ except SpotifyApiError: raise # pass handled exceptions on thru
12488
12823
  except SpotifyWebApiError: raise # pass handled exceptions on thru
12489
12824
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
12490
12825
  except Exception as ex:
@@ -12574,6 +12909,7 @@ class SpotifyClient:
12574
12909
  _logsi.LogString(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
12575
12910
  return result
12576
12911
 
12912
+ except SpotifyApiError: raise # pass handled exceptions on thru
12577
12913
  except SpotifyWebApiError: raise # pass handled exceptions on thru
12578
12914
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
12579
12915
  except Exception as ex:
@@ -12634,7 +12970,7 @@ class SpotifyClient:
12634
12970
 
12635
12971
  # if ids not specified, then return currently playing album id value.
12636
12972
  if (ids is None) or (len(ids.strip()) == 0):
12637
- uri = self._GetPlayerNowPlayingAlbumUri()
12973
+ uri = self.GetPlayerNowPlayingAlbumUri()
12638
12974
  if uri is not None:
12639
12975
  ids = SpotifyClient.GetIdFromUri(uri)
12640
12976
  else:
@@ -12724,7 +13060,7 @@ class SpotifyClient:
12724
13060
 
12725
13061
  # if ids not specified, then return currently playing id value.
12726
13062
  if (ids is None) or (len(ids.strip()) == 0):
12727
- uri = self._GetPlayerNowPlayingAudiobookUri()
13063
+ uri = self.GetPlayerNowPlayingAudiobookUri()
12728
13064
  if uri is not None:
12729
13065
  ids = SpotifyClient.GetIdFromUri(uri)
12730
13066
  else:
@@ -12814,7 +13150,7 @@ class SpotifyClient:
12814
13150
 
12815
13151
  # if ids not specified, then return currently playing id value.
12816
13152
  if (ids is None) or (len(ids.strip()) == 0):
12817
- uri = self._GetPlayerNowPlayingUri('episode')
13153
+ uri = self.GetPlayerNowPlayingUri('episode')
12818
13154
  if uri is not None:
12819
13155
  ids = SpotifyClient.GetIdFromUri(uri)
12820
13156
  else:
@@ -12904,7 +13240,7 @@ class SpotifyClient:
12904
13240
 
12905
13241
  # if ids not specified, then return currently playing id value.
12906
13242
  if (ids is None) or (len(ids.strip()) == 0):
12907
- uri = self._GetPlayerNowPlayingShowUri()
13243
+ uri = self.GetPlayerNowPlayingShowUri()
12908
13244
  if uri is not None:
12909
13245
  ids = SpotifyClient.GetIdFromUri(uri)
12910
13246
  else:
@@ -12993,7 +13329,7 @@ class SpotifyClient:
12993
13329
 
12994
13330
  # if ids not specified, then return currently playing id value.
12995
13331
  if (ids is None) or (len(ids.strip()) == 0):
12996
- uri = self._GetPlayerNowPlayingUri('track')
13332
+ uri = self.GetPlayerNowPlayingUri('track')
12997
13333
  if uri is not None:
12998
13334
  ids = SpotifyClient.GetIdFromUri(uri)
12999
13335
  else:
@@ -13199,6 +13535,7 @@ class SpotifyClient:
13199
13535
  # _logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
13200
13536
  # return result
13201
13537
 
13538
+ # except SpotifyApiError: raise # pass handled exceptions on thru
13202
13539
  # except SpotifyWebApiError: raise # pass handled exceptions on thru
13203
13540
  # except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13204
13541
  # except Exception as ex:
@@ -13390,6 +13727,7 @@ class SpotifyClient:
13390
13727
  response.Albums = result
13391
13728
  return response
13392
13729
 
13730
+ except SpotifyApiError: raise # pass handled exceptions on thru
13393
13731
  except SpotifyWebApiError: raise # pass handled exceptions on thru
13394
13732
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13395
13733
  except Exception as ex:
@@ -13581,6 +13919,7 @@ class SpotifyClient:
13581
13919
  response.Artists = result
13582
13920
  return response
13583
13921
 
13922
+ except SpotifyApiError: raise # pass handled exceptions on thru
13584
13923
  except SpotifyWebApiError: raise # pass handled exceptions on thru
13585
13924
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13586
13925
  except Exception as ex:
@@ -13774,6 +14113,7 @@ class SpotifyClient:
13774
14113
  response.Audiobooks = result
13775
14114
  return response
13776
14115
 
14116
+ except SpotifyApiError: raise # pass handled exceptions on thru
13777
14117
  except SpotifyWebApiError: raise # pass handled exceptions on thru
13778
14118
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13779
14119
  except Exception as ex:
@@ -13965,6 +14305,7 @@ class SpotifyClient:
13965
14305
  response.Episodes = result
13966
14306
  return response
13967
14307
 
14308
+ except SpotifyApiError: raise # pass handled exceptions on thru
13968
14309
  except SpotifyWebApiError: raise # pass handled exceptions on thru
13969
14310
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
13970
14311
  except Exception as ex:
@@ -14156,6 +14497,7 @@ class SpotifyClient:
14156
14497
  response.Playlists = result
14157
14498
  return response
14158
14499
 
14500
+ except SpotifyApiError: raise # pass handled exceptions on thru
14159
14501
  except SpotifyWebApiError: raise # pass handled exceptions on thru
14160
14502
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
14161
14503
  except Exception as ex:
@@ -14347,6 +14689,7 @@ class SpotifyClient:
14347
14689
  response.Shows = result
14348
14690
  return response
14349
14691
 
14692
+ except SpotifyApiError: raise # pass handled exceptions on thru
14350
14693
  except SpotifyWebApiError: raise # pass handled exceptions on thru
14351
14694
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
14352
14695
  except Exception as ex:
@@ -14538,6 +14881,7 @@ class SpotifyClient:
14538
14881
  response.Tracks = result
14539
14882
  return response
14540
14883
 
14884
+ except SpotifyApiError: raise # pass handled exceptions on thru
14541
14885
  except SpotifyWebApiError: raise # pass handled exceptions on thru
14542
14886
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
14543
14887
  except Exception as ex:
@@ -14999,6 +15343,7 @@ class SpotifyClient:
14999
15343
  # trace.
15000
15344
  _logsi.LogObject(SILevel.Verbose, TRACE_MSG_USERPROFILE % (self._UserProfile.DisplayName, self._UserProfile.EMail), self._UserProfile, excludeNonPublic=True)
15001
15345
 
15346
+ except SpotifyApiError: raise # pass handled exceptions on thru
15002
15347
  except SpotifyWebApiError: raise # pass handled exceptions on thru
15003
15348
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
15004
15349
  except Exception as ex:
@@ -15133,9 +15478,10 @@ class SpotifyClient:
15133
15478
  return msg
15134
15479
 
15135
15480
 
15136
- def UnfollowArtists(self,
15137
- ids:str=None,
15138
- ) -> None:
15481
+ def UnfollowArtists(
15482
+ self,
15483
+ ids:str=None,
15484
+ ) -> None:
15139
15485
  """
15140
15486
  Remove the current user as a follower of one or more artists.
15141
15487
 
@@ -15176,7 +15522,7 @@ class SpotifyClient:
15176
15522
 
15177
15523
  # if ids not specified, then return currently playing artist id value.
15178
15524
  if (ids is None) or (len(ids.strip()) == 0):
15179
- uri = self._GetPlayerNowPlayingArtistUri()
15525
+ uri = self.GetPlayerNowPlayingArtistUri()
15180
15526
  if uri is not None:
15181
15527
  ids = SpotifyClient.GetIdFromUri(uri)
15182
15528
  else:
@@ -15204,6 +15550,7 @@ class SpotifyClient:
15204
15550
  # no results to process - this is pass or fail.
15205
15551
  return
15206
15552
 
15553
+ except SpotifyApiError: raise # pass handled exceptions on thru
15207
15554
  except SpotifyWebApiError: raise # pass handled exceptions on thru
15208
15555
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
15209
15556
  except Exception as ex:
@@ -15217,9 +15564,10 @@ class SpotifyClient:
15217
15564
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
15218
15565
 
15219
15566
 
15220
- def UnfollowPlaylist(self,
15221
- playlistId:str,
15222
- ) -> None:
15567
+ def UnfollowPlaylist(
15568
+ self,
15569
+ playlistId:str=None,
15570
+ ) -> None:
15223
15571
  """
15224
15572
  Remove the current user as a follower of a playlist.
15225
15573
 
@@ -15229,6 +15577,7 @@ class SpotifyClient:
15229
15577
  playlistId (str):
15230
15578
  The Spotify ID of the playlist.
15231
15579
  Example: `3cEYpjA9oz9GiPac4AsH4n`
15580
+ If null, the currently playing playlist uri id value is used.
15232
15581
 
15233
15582
  Raises:
15234
15583
  SpotifyWebApiError:
@@ -15254,6 +15603,14 @@ class SpotifyClient:
15254
15603
  apiMethodParms.AppendKeyValue("playlistId", playlistId)
15255
15604
  _logsi.LogMethodParmList(SILevel.Verbose, "Remove the current user as a follower of a playlist", apiMethodParms)
15256
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
+
15257
15614
  # execute spotify web api request.
15258
15615
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{playlist_id}/followers'.format(playlist_id=playlistId))
15259
15616
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
@@ -15263,6 +15620,7 @@ class SpotifyClient:
15263
15620
  # no results to process - this is pass or fail.
15264
15621
  return
15265
15622
 
15623
+ except SpotifyApiError: raise # pass handled exceptions on thru
15266
15624
  except SpotifyWebApiError: raise # pass handled exceptions on thru
15267
15625
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
15268
15626
  except Exception as ex:
@@ -15338,6 +15696,7 @@ class SpotifyClient:
15338
15696
  # no results to process - this is pass or fail.
15339
15697
  return
15340
15698
 
15699
+ except SpotifyApiError: raise # pass handled exceptions on thru
15341
15700
  except SpotifyWebApiError: raise # pass handled exceptions on thru
15342
15701
  except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
15343
15702
  except Exception as ex: