spotifywebapiPython 1.0.96__py3-none-any.whl → 1.0.98__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of spotifywebapiPython might be problematic. Click here for more details.

Files changed (23) hide show
  1. {spotifywebapiPython-1.0.96.dist-info → spotifywebapiPython-1.0.98.dist-info}/METADATA +1 -1
  2. {spotifywebapiPython-1.0.96.dist-info → spotifywebapiPython-1.0.98.dist-info}/RECORD +23 -23
  3. spotifywebapipython/const.py +1 -1
  4. spotifywebapipython/docs/__init__.html +14 -2
  5. spotifywebapipython/docs/index.html +2 -2
  6. spotifywebapipython/docs/search.js +1 -1
  7. spotifywebapipython/docs/spotifywebapiPython/const.html +3 -3
  8. spotifywebapipython/docs/spotifywebapiPython/saappmessages.html +2 -2
  9. spotifywebapipython/docs/spotifywebapiPython/sautils.html +2 -2
  10. spotifywebapipython/docs/spotifywebapiPython/spotifyapierror.html +2 -2
  11. spotifywebapipython/docs/spotifywebapiPython/spotifyapimessage.html +19 -2
  12. spotifywebapipython/docs/spotifywebapiPython/spotifyauthtoken.html +2 -2
  13. spotifywebapipython/docs/spotifywebapiPython/spotifyclient.html +134 -4
  14. spotifywebapipython/docs/spotifywebapiPython/spotifydiscovery.html +2 -2
  15. spotifywebapipython/docs/spotifywebapiPython/spotifywebapiauthenticationerror.html +2 -2
  16. spotifywebapipython/docs/spotifywebapiPython/spotifywebapierror.html +2 -2
  17. spotifywebapipython/spotifyapimessage.py +18 -1
  18. spotifywebapipython/spotifyclient.py +123 -6
  19. spotifywebapipython/zeroconfapi/zeroconfgetinfo.py +1 -0
  20. spotifywebapipython/zeroconfapi/zeroconfgetinfoalias.py +1 -1
  21. {spotifywebapiPython-1.0.96.dist-info → spotifywebapiPython-1.0.98.dist-info}/LICENSE +0 -0
  22. {spotifywebapiPython-1.0.96.dist-info → spotifywebapiPython-1.0.98.dist-info}/WHEEL +0 -0
  23. {spotifywebapiPython-1.0.96.dist-info → spotifywebapiPython-1.0.98.dist-info}/top_level.txt +0 -0
@@ -42,6 +42,7 @@ class SpotifyApiMessage:
42
42
  self._RequestHeaders:Mapping[str, str] = requestHeaders
43
43
  self._RequestJson:dict = None
44
44
  self._ResponseData = {}
45
+ self._IgnoreResponseErrors:bool = False
45
46
  self._IsRequestDataEncoded:bool = False
46
47
  self._Uri:str = uri
47
48
  self._UrlParameters:dict = urlParameters
@@ -99,6 +100,22 @@ class SpotifyApiMessage:
99
100
  return self._RequestData is not None
100
101
 
101
102
 
103
+ @property
104
+ def IgnoreResponseErrors(self) -> bool:
105
+ """
106
+ Indicates if request response errors are ignored (True) or not (False, default).
107
+ If not, an exception will be thrown with the error details.
108
+ """
109
+ return self._IgnoreResponseErrors
110
+
111
+ @IgnoreResponseErrors.setter
112
+ def IgnoreResponseErrors(self, value:bool):
113
+ """
114
+ Sets the IgnoreResponseErrors property value.
115
+ """
116
+ self._IgnoreResponseErrors = value
117
+
118
+
102
119
  @property
103
120
  def IsRequestDataEncoded(self) -> bool:
104
121
  """
@@ -109,7 +126,7 @@ class SpotifyApiMessage:
109
126
  @IsRequestDataEncoded.setter
110
127
  def IsRequestDataEncoded(self, value:bool):
111
128
  """
112
- Sets the MethodName property value.
129
+ Sets the IsRequestDataEncoded property value.
113
130
  """
114
131
  self._IsRequestDataEncoded = value
115
132
 
@@ -607,7 +607,8 @@ class SpotifyClient:
607
607
  if errCode is None:
608
608
  errCode = response.status
609
609
 
610
- raise SpotifyWebApiError(errCode, errMessage, msg.MethodName, response.reason, _logsi)
610
+ if (not msg.IgnoreResponseErrors):
611
+ raise SpotifyWebApiError(errCode, errMessage, msg.MethodName, response.reason, _logsi)
611
612
 
612
613
  elif isinstance(errObj, str):
613
614
 
@@ -5216,6 +5217,7 @@ class SpotifyClient:
5216
5217
  def GetChapter(self,
5217
5218
  chapterId:str,
5218
5219
  market:str=None,
5220
+ ignoreResponseErrors:bool=False,
5219
5221
  ) -> Chapter:
5220
5222
  """
5221
5223
  Get Spotify catalog information for a single audiobook chapter identified by its unique Spotify ID.
@@ -5234,6 +5236,9 @@ class SpotifyClient:
5234
5236
  Note: If neither market or user country are provided, the content is considered unavailable for the client.
5235
5237
  Users can view the country that is associated with their account in the account settings.
5236
5238
  Example: `ES`
5239
+ ignoreResponseErrors (bool):
5240
+ True to ignore any request response errors that occur; otherwise, an exception will be thrown
5241
+ if a response error is detected (default).
5237
5242
 
5238
5243
  Returns:
5239
5244
  An `Chapter` object that contain the chapter details.
@@ -5267,6 +5272,7 @@ class SpotifyClient:
5267
5272
  apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
5268
5273
  apiMethodParms.AppendKeyValue("chapterId", chapterId)
5269
5274
  apiMethodParms.AppendKeyValue("market", market)
5275
+ apiMethodParms.AppendKeyValue("ignoreResponseErrors", ignoreResponseErrors)
5270
5276
  _logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for a single audiobook chapter", apiMethodParms)
5271
5277
 
5272
5278
  # ensure market was either supplied or implied; default if neither.
@@ -5281,6 +5287,7 @@ class SpotifyClient:
5281
5287
  msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/chapters/{id}'.format(id=chapterId))
5282
5288
  msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
5283
5289
  msg.UrlParameters = urlParms
5290
+ msg.IgnoreResponseErrors = ignoreResponseErrors
5284
5291
  self.MakeRequest('GET', msg)
5285
5292
 
5286
5293
  # process results.
@@ -6833,11 +6840,28 @@ class SpotifyClient:
6833
6840
  return result
6834
6841
 
6835
6842
 
6836
- def GetPlayerNowPlayingAudiobookUri(self) -> str:
6843
+ def GetPlayerNowPlayingAudiobookUri(
6844
+ self,
6845
+ market:str=None,
6846
+ ignoreResponseErrors:bool=False,
6847
+ ) -> str:
6837
6848
  """
6838
6849
  Returns the audiobook uri value of the currently playing media if something is
6839
6850
  playing; otherwise, null is returned.
6840
6851
 
6852
+ Args:
6853
+ market (str):
6854
+ An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
6855
+ is available in that market will be returned. If a valid user access token is specified
6856
+ in the request header, the country associated with the user account will take priority over
6857
+ this parameter.
6858
+ Note: If neither market or user country are provided, the content is considered unavailable for the client.
6859
+ Users can view the country that is associated with their account in the account settings.
6860
+ Example: `ES`
6861
+ ignoreResponseErrors (bool):
6862
+ True to ignore any request response errors that occur; otherwise, an exception will be thrown
6863
+ if a response error is detected (default).
6864
+
6841
6865
  Raises:
6842
6866
  SpotifyApiError:
6843
6867
  If current user does not have a Spotify free or premium level account.
@@ -6846,17 +6870,19 @@ class SpotifyClient:
6846
6870
  result:str = None
6847
6871
 
6848
6872
  # get nowplaying status.
6849
- nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(additionalTypes='episode')
6873
+ nowPlaying:PlayerPlayState = self.GetPlayerNowPlaying(market, additionalTypes='episode')
6850
6874
 
6851
6875
  # is an chapter playing? if so, return the parent show uri value.
6852
6876
  if nowPlaying is not None:
6853
6877
  if nowPlaying.CurrentlyPlayingType in ['episode']:
6854
6878
  playingItem:Chapter = nowPlaying.Item
6855
6879
  if (playingItem is not None):
6856
- chapter:Chapter = self.GetChapter(playingItem.Id)
6857
- result = chapter.Audiobook.Uri
6880
+ chapter:Chapter = self.GetChapter(playingItem.Id, market, ignoreResponseErrors)
6881
+ if (chapter.Audiobook is not None):
6882
+ result = chapter.Audiobook.Uri
6858
6883
  else:
6859
- raise SpotifyApiError("Currently playing item is not a Audiobook Chapter", logsi=_logsi)
6884
+ if (not ignoreResponseErrors):
6885
+ raise SpotifyApiError("Currently playing item is not a Audiobook Chapter", logsi=_logsi)
6860
6886
 
6861
6887
  return result
6862
6888
 
@@ -10523,6 +10549,97 @@ class SpotifyClient:
10523
10549
  _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
10524
10550
 
10525
10551
 
10552
+ def IsChapterEpisode(
10553
+ self,
10554
+ episodeId:str=None,
10555
+ market:str=None,
10556
+ ) -> bool:
10557
+ """
10558
+ Returns true if the specified episode id is an audiobook chapter; otherwise, false.
10559
+
10560
+ Args:
10561
+ episodeId (str):
10562
+ The Spotify ID to check.
10563
+ Example: `74aydHJKgYz3AIq3jjBSv1`
10564
+ If null, the currently playing uri id value is used; a Spotify Free or Premium account
10565
+ is required to correctly read the currently playing context.
10566
+ market (str):
10567
+ An ISO 3166-1 alpha-2 country code. If a country code is specified, only content that
10568
+ is available in that market will be returned. If a valid user access token is specified
10569
+ in the request header, the country associated with the user account will take priority over
10570
+ this parameter.
10571
+ Note: If neither market or user country are provided, the content is considered unavailable for the client.
10572
+ Users can view the country that is associated with their account in the account settings.
10573
+ Example: `ES`
10574
+
10575
+ Returns:
10576
+ True if the specified id is an audiobook chapter; otherwise, false.
10577
+
10578
+ Raises:
10579
+ SpotifyWebApiError:
10580
+ If the Spotify Web API request was for a non-authorization service
10581
+ and the response contains error information.
10582
+ SpotifApiError:
10583
+ If the method fails for any other reason.
10584
+
10585
+ <details>
10586
+ <summary>Sample Code</summary>
10587
+ ```python
10588
+ .. include:: ../docs/include/samplecode/SpotifyClient/IsChapterEpisode.py
10589
+ ```
10590
+ <summary>Sample Code - NowPlaying</summary>
10591
+ ```python
10592
+ .. include:: ../docs/include/samplecode/SpotifyClient/IsChapterEpisode_NowPlaying.py
10593
+ ```
10594
+ </details>
10595
+ """
10596
+ apiMethodName:str = 'IsChapterEpisode'
10597
+ apiMethodParms:SIMethodParmListContext = None
10598
+ result:bool = False
10599
+
10600
+ try:
10601
+
10602
+ # trace.
10603
+ apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
10604
+ apiMethodParms.AppendKeyValue("episodeId", episodeId)
10605
+ apiMethodParms.AppendKeyValue("market", market)
10606
+ _logsi.LogMethodParmList(SILevel.Verbose, "Check if episode id is an audiobook chapter or not", apiMethodParms)
10607
+
10608
+ # ensure market was either supplied or implied; default if neither.
10609
+ market = self._ValidateMarket(market)
10610
+
10611
+ # if id not specified, then return currently playing id value.
10612
+ # this will issue a GetChapter call to retrieve the actual audiobook id.
10613
+ # the `GetPlayerNowPlayingAudiobookUri` method will fail if it's not a chapter id.
10614
+ if (episodeId is None) or (len(episodeId.strip()) == 0):
10615
+
10616
+ uri = self.GetPlayerNowPlayingAudiobookUri(market, True)
10617
+ result = (uri is not None)
10618
+
10619
+ else:
10620
+
10621
+ # if id was supplied, then call the `GetChapter` method to retrieve chapter information.
10622
+ # the `GetChapter` method will fail if it's not a chapter id.
10623
+ chapter:Chapter = self.GetChapter(episodeId, market, True)
10624
+ result = (chapter.Id is not None)
10625
+
10626
+ return result
10627
+
10628
+ except Exception as ex:
10629
+
10630
+ # at this point we can safely assume it's NOT an audiobook chapter.
10631
+ result = False
10632
+ return result
10633
+
10634
+ finally:
10635
+
10636
+ # trace.
10637
+ _logsi.LogValue(SILevel.Verbose, TRACE_METHOD_RESULT % (apiMethodName), result)
10638
+
10639
+ # trace.
10640
+ _logsi.LeaveMethod(SILevel.Debug, apiMethodName)
10641
+
10642
+
10526
10643
  @staticmethod
10527
10644
  def IsDeviceId(value:str) -> bool:
10528
10645
  """
@@ -78,6 +78,7 @@ class ZeroconfGetInfo(ZeroconfResponse):
78
78
  self._VoiceSupport = root.get('voiceSupport', None)
79
79
 
80
80
  # process all collections and objects.
81
+ #items:list = root.get('aliases', [{ "id":"aliasId","isGroup": False, "name":"aliasName" }]) # simulate an alias value (used for testing).
81
82
  items:list = root.get('aliases',None)
82
83
  if items is not None:
83
84
  for item in items:
@@ -70,7 +70,7 @@ class ZeroconfGetInfoAlias:
70
70
  """
71
71
  Alias name and id value (e.g. '"Bose-ST10-1" (30fbc80e35598f3c242f2120413c943dfd9715fe)').
72
72
  """
73
- return '"%s" (%s)' & (self._Name, self._Id)
73
+ return '"%s" (%s)' % (self._Name, self._Id)
74
74
 
75
75
 
76
76
  def ToDictionary(self) -> dict: