spotifywebapiPython 1.0.260__py3-none-any.whl → 1.0.261__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.
- spotifywebapipython/__init__.py +2 -0
- spotifywebapipython/const.py +1 -1
- spotifywebapipython/docs/__init__.html +16 -2
- spotifywebapipython/docs/index.html +8 -2
- spotifywebapipython/docs/search.js +1 -1
- spotifywebapipython/docs/spotifywebapipython/const.html +3 -3
- spotifywebapipython/docs/spotifywebapipython/saappmessages.html +26 -8
- spotifywebapipython/docs/spotifywebapipython/sautils.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifyapierror.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifyapimessage.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifyauthtoken.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifyclient.html +494 -82
- spotifywebapipython/docs/spotifywebapipython/spotifydiscovery.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifymediatypes.html +441 -0
- spotifywebapipython/docs/spotifywebapipython/spotifytypeprefixes.html +458 -0
- spotifywebapipython/docs/spotifywebapipython/spotifywebapiauthenticationerror.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifywebapierror.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifywebplayertoken.html +2 -2
- spotifywebapipython/saappmessages.py +6 -1
- spotifywebapipython/spotifyclient.py +1004 -341
- spotifywebapipython/spotifymediatypes.py +10 -10
- spotifywebapipython/spotifytypeprefixes.py +65 -0
- {spotifywebapipython-1.0.260.dist-info → spotifywebapipython-1.0.261.dist-info}/METADATA +1 -1
- {spotifywebapipython-1.0.260.dist-info → spotifywebapipython-1.0.261.dist-info}/RECORD +27 -24
- {spotifywebapipython-1.0.260.dist-info → spotifywebapipython-1.0.261.dist-info}/LICENSE +0 -0
- {spotifywebapipython-1.0.260.dist-info → spotifywebapipython-1.0.261.dist-info}/WHEEL +0 -0
- {spotifywebapipython-1.0.260.dist-info → spotifywebapipython-1.0.261.dist-info}/top_level.txt +0 -0
|
@@ -31,6 +31,7 @@ from .spotifyapierror import SpotifyApiError
|
|
|
31
31
|
from .spotifyapimessage import SpotifyApiMessage
|
|
32
32
|
from .spotifyauthtoken import SpotifyAuthToken
|
|
33
33
|
from .spotifymediatypes import SpotifyMediaTypes
|
|
34
|
+
from .spotifytypeprefixes import SpotifyTypePrefixes
|
|
34
35
|
from .spotifywebapiauthenticationerror import SpotifyWebApiAuthenticationError
|
|
35
36
|
from .spotifywebapierror import SpotifyWebApiError
|
|
36
37
|
from .spotifywebplayertoken import SpotifyWebPlayerToken
|
|
@@ -1692,7 +1693,7 @@ class SpotifyClient:
|
|
|
1692
1693
|
break
|
|
1693
1694
|
|
|
1694
1695
|
# execute spotify web api request.
|
|
1695
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{
|
|
1696
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}/images'.format(id=playlistId))
|
|
1696
1697
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
1697
1698
|
msg.RequestHeaders['Content-Type'] = 'image/jpeg'
|
|
1698
1699
|
msg.RequestData = base64.b64encode(fData.getvalue()).decode('utf-8')
|
|
@@ -1755,6 +1756,10 @@ class SpotifyClient:
|
|
|
1755
1756
|
SpotifyApiError:
|
|
1756
1757
|
If the method fails for any other reason.
|
|
1757
1758
|
|
|
1759
|
+
All specified items are added to the playlist, even if any of the items already exist
|
|
1760
|
+
in the playlist. You must check for duplicates prior to adding items if you want to
|
|
1761
|
+
prevent duplicate items in the list.
|
|
1762
|
+
|
|
1758
1763
|
<details>
|
|
1759
1764
|
<summary>Sample Code</summary>
|
|
1760
1765
|
```python
|
|
@@ -1796,7 +1801,7 @@ class SpotifyClient:
|
|
|
1796
1801
|
reqData['position'] = position
|
|
1797
1802
|
|
|
1798
1803
|
# execute spotify web api request.
|
|
1799
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{
|
|
1804
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}/items'.format(id=playlistId))
|
|
1800
1805
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
1801
1806
|
msg.RequestJson = reqData
|
|
1802
1807
|
self.MakeRequest('POST', msg)
|
|
@@ -1921,7 +1926,7 @@ class SpotifyClient:
|
|
|
1921
1926
|
raise ValueError('no details were provided to change.')
|
|
1922
1927
|
|
|
1923
1928
|
# execute spotify web api request.
|
|
1924
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{
|
|
1929
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}'.format(id=playlistId))
|
|
1925
1930
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
1926
1931
|
msg.RequestJson = reqData
|
|
1927
1932
|
self.MakeRequest('PUT', msg)
|
|
@@ -1963,8 +1968,8 @@ class SpotifyClient:
|
|
|
1963
1968
|
|
|
1964
1969
|
Args:
|
|
1965
1970
|
ids (str):
|
|
1966
|
-
A comma-separated list of the Spotify
|
|
1967
|
-
Maximum:
|
|
1971
|
+
A comma-separated list of the Spotify ID's (or URI's) for the albums.
|
|
1972
|
+
Maximum: 40 IDs.
|
|
1968
1973
|
Example: `6vc9OTcyd3hyzabCmsdnwE,2noRn2Aes5aoNVsU6iWThc`
|
|
1969
1974
|
If null, the currently playing album uri id value is used.
|
|
1970
1975
|
|
|
@@ -1997,6 +2002,10 @@ class SpotifyClient:
|
|
|
1997
2002
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
1998
2003
|
_logsi.LogMethodParmList(SILevel.Verbose, "Check if one or more albums are saved in a user's favorites", apiMethodParms)
|
|
1999
2004
|
|
|
2005
|
+
# remove any leading / trailing spaces.
|
|
2006
|
+
if ids is not None:
|
|
2007
|
+
ids = ids.replace(' ','')
|
|
2008
|
+
|
|
2000
2009
|
# if ids not specified, then return currently playing album id value.
|
|
2001
2010
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
2002
2011
|
uri = self.GetPlayerNowPlayingAlbumUri()
|
|
@@ -2005,25 +2014,29 @@ class SpotifyClient:
|
|
|
2005
2014
|
else:
|
|
2006
2015
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
2007
2016
|
|
|
2017
|
+
# build a list of all item uri's from id values.
|
|
2018
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
2019
|
+
arrUris:list[str] = ids.split(',')
|
|
2020
|
+
for idx in range(0, len(arrUris)):
|
|
2021
|
+
if (arrUris[idx].find(":") == -1):
|
|
2022
|
+
arrUris[idx] = SpotifyTypePrefixes.ALBUM.value + arrUris[idx].strip()
|
|
2023
|
+
|
|
2008
2024
|
# build spotify web api request parameters.
|
|
2009
2025
|
urlParms:dict = \
|
|
2010
2026
|
{
|
|
2011
|
-
'
|
|
2027
|
+
'uris': ",".join(arrUris)
|
|
2012
2028
|
}
|
|
2013
2029
|
|
|
2014
2030
|
# execute spotify web api request.
|
|
2015
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
2031
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library/contains')
|
|
2016
2032
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2017
2033
|
msg.UrlParameters = urlParms
|
|
2018
2034
|
self.MakeRequest('GET', msg)
|
|
2019
2035
|
|
|
2020
|
-
# build list of all input album id's.
|
|
2021
|
-
arrIds:list[str] = ids.split(',')
|
|
2022
|
-
|
|
2023
2036
|
# process results.
|
|
2024
2037
|
flags:list[bool] = msg.ResponseData
|
|
2025
2038
|
flagPtr:int = 0
|
|
2026
|
-
for strId in
|
|
2039
|
+
for strId in arrUris:
|
|
2027
2040
|
if strId not in result:
|
|
2028
2041
|
result[strId] = flags[flagPtr]
|
|
2029
2042
|
flagPtr = flagPtr + 1
|
|
@@ -2058,7 +2071,7 @@ class SpotifyClient:
|
|
|
2058
2071
|
Args:
|
|
2059
2072
|
ids (str):
|
|
2060
2073
|
A comma-separated list of Spotify artist ID's to check.
|
|
2061
|
-
Maximum:
|
|
2074
|
+
Maximum: 40 ID's.
|
|
2062
2075
|
Example: `2CIMQHirSU0MQqyYHq0eOx,1IQ2e1buppatiN1bxUVkrk`
|
|
2063
2076
|
If null, the currently playing artist uri id value is used.
|
|
2064
2077
|
|
|
@@ -2091,7 +2104,7 @@ class SpotifyClient:
|
|
|
2091
2104
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
2092
2105
|
_logsi.LogMethodParmList(SILevel.Verbose, "Check if user is following one or more artists", apiMethodParms)
|
|
2093
2106
|
|
|
2094
|
-
# remove any leading / trailing spaces
|
|
2107
|
+
# remove any leading / trailing spaces.
|
|
2095
2108
|
if ids is not None:
|
|
2096
2109
|
ids = ids.replace(' ','')
|
|
2097
2110
|
|
|
@@ -2103,30 +2116,33 @@ class SpotifyClient:
|
|
|
2103
2116
|
else:
|
|
2104
2117
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
2105
2118
|
|
|
2119
|
+
# build a list of all item uri's from id values.
|
|
2120
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
2121
|
+
arrUris:list[str] = ids.split(',')
|
|
2122
|
+
for idx in range(0, len(arrUris)):
|
|
2123
|
+
if (arrUris[idx].find(":") == -1):
|
|
2124
|
+
arrUris[idx] = SpotifyTypePrefixes.ARTIST.value + arrUris[idx].strip()
|
|
2125
|
+
|
|
2106
2126
|
# build spotify web api request parameters.
|
|
2107
2127
|
urlParms:dict = \
|
|
2108
2128
|
{
|
|
2109
|
-
'
|
|
2110
|
-
'ids': ids
|
|
2129
|
+
'uris': ",".join(arrUris)
|
|
2111
2130
|
}
|
|
2112
2131
|
|
|
2113
2132
|
# execute spotify web api request.
|
|
2114
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
2133
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library/contains')
|
|
2115
2134
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2116
2135
|
msg.UrlParameters = urlParms
|
|
2117
2136
|
self.MakeRequest('GET', msg)
|
|
2118
2137
|
|
|
2119
|
-
#
|
|
2120
|
-
arrIds:list[str] = ids.split(',')
|
|
2121
|
-
|
|
2122
|
-
# process results.
|
|
2138
|
+
# process results.
|
|
2123
2139
|
flags:list[bool] = msg.ResponseData
|
|
2124
2140
|
flagPtr:int = 0
|
|
2125
|
-
for strId in
|
|
2141
|
+
for strId in arrUris:
|
|
2126
2142
|
if strId not in result:
|
|
2127
2143
|
result[strId] = flags[flagPtr]
|
|
2128
2144
|
flagPtr = flagPtr + 1
|
|
2129
|
-
|
|
2145
|
+
|
|
2130
2146
|
# trace.
|
|
2131
2147
|
_logsi.LogDictionary(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
|
|
2132
2148
|
return result
|
|
@@ -2157,8 +2173,8 @@ class SpotifyClient:
|
|
|
2157
2173
|
|
|
2158
2174
|
Args:
|
|
2159
2175
|
ids (str):
|
|
2160
|
-
A comma-separated list of the Spotify
|
|
2161
|
-
Maximum:
|
|
2176
|
+
A comma-separated list of the Spotify ID's (or URI's) for the audiobooks.
|
|
2177
|
+
Maximum: 40 IDs.
|
|
2162
2178
|
Example: `74aydHJKgYz3AIq3jjBSv1,4nfQ1hBJWjD0Jq9sK3YRW8,3PFyizE2tGCSRLusl2Qizf`
|
|
2163
2179
|
If null, the currently playing audiobook uri id value is used.
|
|
2164
2180
|
|
|
@@ -2191,6 +2207,10 @@ class SpotifyClient:
|
|
|
2191
2207
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
2192
2208
|
_logsi.LogMethodParmList(SILevel.Verbose, "Check if one or more audiobooks are saved in a user's favorites", apiMethodParms)
|
|
2193
2209
|
|
|
2210
|
+
# remove any leading / trailing spaces.
|
|
2211
|
+
if ids is not None:
|
|
2212
|
+
ids = ids.replace(' ','')
|
|
2213
|
+
|
|
2194
2214
|
# if ids not specified, then return currently playing id value.
|
|
2195
2215
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
2196
2216
|
uri = self.GetPlayerNowPlayingAudiobookUri()
|
|
@@ -2199,25 +2219,29 @@ class SpotifyClient:
|
|
|
2199
2219
|
else:
|
|
2200
2220
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
2201
2221
|
|
|
2222
|
+
# build a list of all item uri's from id values.
|
|
2223
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
2224
|
+
arrUris:list[str] = ids.split(',')
|
|
2225
|
+
for idx in range(0, len(arrUris)):
|
|
2226
|
+
if (arrUris[idx].find(":") == -1):
|
|
2227
|
+
arrUris[idx] = SpotifyTypePrefixes.SHOW.value + arrUris[idx].strip() # spotify web api considers audiobook a "show"!
|
|
2228
|
+
|
|
2202
2229
|
# build spotify web api request parameters.
|
|
2203
2230
|
urlParms:dict = \
|
|
2204
2231
|
{
|
|
2205
|
-
'
|
|
2232
|
+
'uris': ",".join(arrUris)
|
|
2206
2233
|
}
|
|
2207
2234
|
|
|
2208
2235
|
# execute spotify web api request.
|
|
2209
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
2236
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library/contains')
|
|
2210
2237
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2211
2238
|
msg.UrlParameters = urlParms
|
|
2212
2239
|
self.MakeRequest('GET', msg)
|
|
2213
2240
|
|
|
2214
|
-
# build list of all input album id's.
|
|
2215
|
-
arrIds:list[str] = ids.split(',')
|
|
2216
|
-
|
|
2217
2241
|
# process results.
|
|
2218
2242
|
flags:list[bool] = msg.ResponseData
|
|
2219
2243
|
flagPtr:int = 0
|
|
2220
|
-
for strId in
|
|
2244
|
+
for strId in arrUris:
|
|
2221
2245
|
if strId not in result:
|
|
2222
2246
|
result[strId] = flags[flagPtr]
|
|
2223
2247
|
flagPtr = flagPtr + 1
|
|
@@ -2252,8 +2276,8 @@ class SpotifyClient:
|
|
|
2252
2276
|
|
|
2253
2277
|
Args:
|
|
2254
2278
|
ids (str):
|
|
2255
|
-
A comma-separated list of the Spotify
|
|
2256
|
-
Maximum:
|
|
2279
|
+
A comma-separated list of the Spotify ID's (or URI's) for the episodes.
|
|
2280
|
+
Maximum: 40 IDs.
|
|
2257
2281
|
Example: `1kWUud3vY5ij5r62zxpTRy,2takcwOaAZWiXQijPHIx7B`
|
|
2258
2282
|
If null, the currently playing episode uri id value is used.
|
|
2259
2283
|
|
|
@@ -2286,6 +2310,10 @@ class SpotifyClient:
|
|
|
2286
2310
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
2287
2311
|
_logsi.LogMethodParmList(SILevel.Verbose, "Check if one or more episodes are saved in a user's favorites", apiMethodParms)
|
|
2288
2312
|
|
|
2313
|
+
# remove any leading / trailing spaces.
|
|
2314
|
+
if ids is not None:
|
|
2315
|
+
ids = ids.replace(' ','')
|
|
2316
|
+
|
|
2289
2317
|
# if ids not specified, then return currently playing id value.
|
|
2290
2318
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
2291
2319
|
uri = self.GetPlayerNowPlayingUri(SpotifyMediaTypes.EPISODE.value)
|
|
@@ -2294,25 +2322,29 @@ class SpotifyClient:
|
|
|
2294
2322
|
else:
|
|
2295
2323
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
2296
2324
|
|
|
2325
|
+
# build a list of all item uri's from id values.
|
|
2326
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
2327
|
+
arrUris:list[str] = ids.split(',')
|
|
2328
|
+
for idx in range(0, len(arrUris)):
|
|
2329
|
+
if (arrUris[idx].find(":") == -1):
|
|
2330
|
+
arrUris[idx] = SpotifyTypePrefixes.EPISODE.value + arrUris[idx].strip()
|
|
2331
|
+
|
|
2297
2332
|
# build spotify web api request parameters.
|
|
2298
2333
|
urlParms:dict = \
|
|
2299
2334
|
{
|
|
2300
|
-
'
|
|
2335
|
+
'uris': ",".join(arrUris)
|
|
2301
2336
|
}
|
|
2302
2337
|
|
|
2303
2338
|
# execute spotify web api request.
|
|
2304
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
2339
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library/contains')
|
|
2305
2340
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2306
2341
|
msg.UrlParameters = urlParms
|
|
2307
2342
|
self.MakeRequest('GET', msg)
|
|
2308
2343
|
|
|
2309
|
-
# build list of all input album id's.
|
|
2310
|
-
arrIds:list[str] = ids.split(',')
|
|
2311
|
-
|
|
2312
2344
|
# process results.
|
|
2313
2345
|
flags:list[bool] = msg.ResponseData
|
|
2314
2346
|
flagPtr:int = 0
|
|
2315
|
-
for strId in
|
|
2347
|
+
for strId in arrUris:
|
|
2316
2348
|
if strId not in result:
|
|
2317
2349
|
result[strId] = flags[flagPtr]
|
|
2318
2350
|
flagPtr = flagPtr + 1
|
|
@@ -2337,7 +2369,7 @@ class SpotifyClient:
|
|
|
2337
2369
|
|
|
2338
2370
|
def CheckPlaylistFollowers(
|
|
2339
2371
|
self,
|
|
2340
|
-
playlistId:str,
|
|
2372
|
+
playlistId:str=None,
|
|
2341
2373
|
userIds:str=None,
|
|
2342
2374
|
) -> dict:
|
|
2343
2375
|
"""
|
|
@@ -2345,13 +2377,12 @@ class SpotifyClient:
|
|
|
2345
2377
|
|
|
2346
2378
|
Args:
|
|
2347
2379
|
playlistId (str):
|
|
2348
|
-
|
|
2380
|
+
A comma-separated list of Spotify playlist IDs.
|
|
2381
|
+
A maximum of 40 IDs can be sent in one request.
|
|
2349
2382
|
Example: `3cEYpjA9oz9GiPac4AsH4n`
|
|
2383
|
+
If null, the currently playing playlist uri id value is used.
|
|
2350
2384
|
userIds (str):
|
|
2351
|
-
DEPRECATED -
|
|
2352
|
-
A comma-separated list of Spotify User ID's to check.
|
|
2353
|
-
Maximum: 5 ID's.
|
|
2354
|
-
Example: `1kWUud3vY5ij5r62zxpTRy,2takcwOaAZWiXQijPHIx7B`
|
|
2385
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
2355
2386
|
|
|
2356
2387
|
Returns:
|
|
2357
2388
|
Array of boolean, containing a single boolean status that indicates
|
|
@@ -2367,7 +2398,6 @@ class SpotifyClient:
|
|
|
2367
2398
|
As of (at least) 2024/10/07, Spotify has deprecated the userId's argument;
|
|
2368
2399
|
only current user can be tested. Any other id's specified on this argument will
|
|
2369
2400
|
generate a `400 Bad Request` error.
|
|
2370
|
-
|
|
2371
2401
|
|
|
2372
2402
|
<details>
|
|
2373
2403
|
<summary>Sample Code</summary>
|
|
@@ -2388,29 +2418,37 @@ class SpotifyClient:
|
|
|
2388
2418
|
apiMethodParms.AppendKeyValue("userIds (DEPRECATED)", userIds)
|
|
2389
2419
|
_logsi.LogMethodParmList(SILevel.Verbose, "Check to see if users are following a playlist", apiMethodParms)
|
|
2390
2420
|
|
|
2391
|
-
#
|
|
2392
|
-
if (
|
|
2393
|
-
|
|
2421
|
+
# if playlistId not specified, then return currently playing playlist id value.
|
|
2422
|
+
if (playlistId is None) or (len(playlistId.strip()) == 0):
|
|
2423
|
+
uri = self.GetPlayerNowPlayingPlaylistUri()
|
|
2424
|
+
if uri is not None:
|
|
2425
|
+
playlistId = SpotifyClient.GetIdFromUri(uri)
|
|
2426
|
+
else:
|
|
2427
|
+
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'playlistId'), logsi=_logsi)
|
|
2428
|
+
|
|
2429
|
+
# build a list of all item uri's from id values.
|
|
2430
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
2431
|
+
arrUris:list[str] = playlistId.split(',')
|
|
2432
|
+
for idx in range(0, len(arrUris)):
|
|
2433
|
+
if (arrUris[idx].find(":") == -1):
|
|
2434
|
+
arrUris[idx] = SpotifyTypePrefixes.PLAYLIST.value + arrUris[idx].strip()
|
|
2394
2435
|
|
|
2395
2436
|
# build spotify web api request parameters.
|
|
2396
2437
|
urlParms:dict = \
|
|
2397
2438
|
{
|
|
2398
|
-
'
|
|
2439
|
+
'uris': ",".join(arrUris)
|
|
2399
2440
|
}
|
|
2400
2441
|
|
|
2401
2442
|
# execute spotify web api request.
|
|
2402
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/
|
|
2443
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library/contains')
|
|
2403
2444
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2404
2445
|
msg.UrlParameters = urlParms
|
|
2405
2446
|
self.MakeRequest('GET', msg)
|
|
2406
2447
|
|
|
2407
|
-
# build list of all input id's.
|
|
2408
|
-
arrIds:list[str] = userIds.split(',')
|
|
2409
|
-
|
|
2410
2448
|
# process results.
|
|
2411
2449
|
flags:list[bool] = msg.ResponseData
|
|
2412
2450
|
flagPtr:int = 0
|
|
2413
|
-
for strId in
|
|
2451
|
+
for strId in arrUris:
|
|
2414
2452
|
if strId not in result:
|
|
2415
2453
|
result[strId] = flags[flagPtr]
|
|
2416
2454
|
flagPtr = flagPtr + 1
|
|
@@ -2445,8 +2483,8 @@ class SpotifyClient:
|
|
|
2445
2483
|
|
|
2446
2484
|
Args:
|
|
2447
2485
|
ids (str):
|
|
2448
|
-
A comma-separated list of the Spotify
|
|
2449
|
-
Maximum:
|
|
2486
|
+
A comma-separated list of the Spotify ID's (or URI's) for the shows.
|
|
2487
|
+
Maximum: 40 IDs.
|
|
2450
2488
|
Example: `1kWUud3vY5ij5r62zxpTRy,2takcwOaAZWiXQijPHIx7B`
|
|
2451
2489
|
If null, the currently playing show uri id value is used.
|
|
2452
2490
|
|
|
@@ -2479,6 +2517,10 @@ class SpotifyClient:
|
|
|
2479
2517
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
2480
2518
|
_logsi.LogMethodParmList(SILevel.Verbose, "Check if one or more shows are saved in a user's favorites", apiMethodParms)
|
|
2481
2519
|
|
|
2520
|
+
# remove any leading / trailing spaces.
|
|
2521
|
+
if ids is not None:
|
|
2522
|
+
ids = ids.replace(' ','')
|
|
2523
|
+
|
|
2482
2524
|
# if ids not specified, then return currently playing id value.
|
|
2483
2525
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
2484
2526
|
uri = self.GetPlayerNowPlayingShowUri()
|
|
@@ -2487,25 +2529,29 @@ class SpotifyClient:
|
|
|
2487
2529
|
else:
|
|
2488
2530
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
2489
2531
|
|
|
2532
|
+
# build a list of all item uri's from id values.
|
|
2533
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
2534
|
+
arrUris:list[str] = ids.split(',')
|
|
2535
|
+
for idx in range(0, len(arrUris)):
|
|
2536
|
+
if (arrUris[idx].find(":") == -1):
|
|
2537
|
+
arrUris[idx] = SpotifyTypePrefixes.SHOW.value + arrUris[idx].strip()
|
|
2538
|
+
|
|
2490
2539
|
# build spotify web api request parameters.
|
|
2491
2540
|
urlParms:dict = \
|
|
2492
2541
|
{
|
|
2493
|
-
'
|
|
2542
|
+
'uris': ",".join(arrUris)
|
|
2494
2543
|
}
|
|
2495
2544
|
|
|
2496
2545
|
# execute spotify web api request.
|
|
2497
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
2546
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library/contains')
|
|
2498
2547
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2499
2548
|
msg.UrlParameters = urlParms
|
|
2500
2549
|
self.MakeRequest('GET', msg)
|
|
2501
2550
|
|
|
2502
|
-
# build list of all input album id's.
|
|
2503
|
-
arrIds:list[str] = ids.split(',')
|
|
2504
|
-
|
|
2505
2551
|
# process results.
|
|
2506
2552
|
flags:list[bool] = msg.ResponseData
|
|
2507
2553
|
flagPtr:int = 0
|
|
2508
|
-
for strId in
|
|
2554
|
+
for strId in arrUris:
|
|
2509
2555
|
if strId not in result:
|
|
2510
2556
|
result[strId] = flags[flagPtr]
|
|
2511
2557
|
flagPtr = flagPtr + 1
|
|
@@ -2540,8 +2586,8 @@ class SpotifyClient:
|
|
|
2540
2586
|
|
|
2541
2587
|
Args:
|
|
2542
2588
|
ids (str):
|
|
2543
|
-
A comma-separated list of the Spotify
|
|
2544
|
-
Maximum:
|
|
2589
|
+
A comma-separated list of the Spotify ID's (or URI's) for the tracks.
|
|
2590
|
+
Maximum: 40 IDs.
|
|
2545
2591
|
Example: `1kWUud3vY5ij5r62zxpTRy,2takcwOaAZWiXQijPHIx7B`
|
|
2546
2592
|
If null, the currently playing track uri id value is used.
|
|
2547
2593
|
|
|
@@ -2574,6 +2620,10 @@ class SpotifyClient:
|
|
|
2574
2620
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
2575
2621
|
_logsi.LogMethodParmList(SILevel.Verbose, "Check if one or more tracks are saved in a user's favorites", apiMethodParms)
|
|
2576
2622
|
|
|
2623
|
+
# remove any leading / trailing spaces.
|
|
2624
|
+
if ids is not None:
|
|
2625
|
+
ids = ids.replace(' ','')
|
|
2626
|
+
|
|
2577
2627
|
# if ids not specified, then return currently playing id value.
|
|
2578
2628
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
2579
2629
|
uri = self.GetPlayerNowPlayingUri(SpotifyMediaTypes.TRACK.value)
|
|
@@ -2582,25 +2632,122 @@ class SpotifyClient:
|
|
|
2582
2632
|
else:
|
|
2583
2633
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
2584
2634
|
|
|
2635
|
+
# build a list of all item uri's from id values.
|
|
2636
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
2637
|
+
arrUris:list[str] = ids.split(',')
|
|
2638
|
+
for idx in range(0, len(arrUris)):
|
|
2639
|
+
if (arrUris[idx].find(":") == -1):
|
|
2640
|
+
arrUris[idx] = SpotifyTypePrefixes.TRACK.value + arrUris[idx].strip()
|
|
2641
|
+
|
|
2585
2642
|
# build spotify web api request parameters.
|
|
2586
2643
|
urlParms:dict = \
|
|
2587
2644
|
{
|
|
2588
|
-
'
|
|
2645
|
+
'uris': ",".join(arrUris)
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2648
|
+
# execute spotify web api request.
|
|
2649
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library/contains')
|
|
2650
|
+
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2651
|
+
msg.UrlParameters = urlParms
|
|
2652
|
+
self.MakeRequest('GET', msg)
|
|
2653
|
+
|
|
2654
|
+
# process results.
|
|
2655
|
+
flags:list[bool] = msg.ResponseData
|
|
2656
|
+
flagPtr:int = 0
|
|
2657
|
+
for strId in arrUris:
|
|
2658
|
+
if strId not in result:
|
|
2659
|
+
result[strId] = flags[flagPtr]
|
|
2660
|
+
flagPtr = flagPtr + 1
|
|
2661
|
+
|
|
2662
|
+
# trace.
|
|
2663
|
+
_logsi.LogDictionary(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
|
|
2664
|
+
return result
|
|
2665
|
+
|
|
2666
|
+
except SpotifyApiError: raise # pass handled exceptions on thru
|
|
2667
|
+
except SpotifyWebApiError: raise # pass handled exceptions on thru
|
|
2668
|
+
except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
|
|
2669
|
+
except Exception as ex:
|
|
2670
|
+
|
|
2671
|
+
# format unhandled exception.
|
|
2672
|
+
raise SpotifyApiError(SAAppMessages.UNHANDLED_EXCEPTION.format(apiMethodName, str(ex)), ex, logsi=_logsi)
|
|
2673
|
+
|
|
2674
|
+
finally:
|
|
2675
|
+
|
|
2676
|
+
# trace.
|
|
2677
|
+
_logsi.LeaveMethod(SILevel.Debug, apiMethodName)
|
|
2678
|
+
|
|
2679
|
+
|
|
2680
|
+
def CheckUserFavorites(
|
|
2681
|
+
self,
|
|
2682
|
+
uris:str=None,
|
|
2683
|
+
) -> dict:
|
|
2684
|
+
"""
|
|
2685
|
+
Check if one or more items are already saved in the current user's library.
|
|
2686
|
+
Accepts Spotify URIs for tracks, albums, episodes, shows, audiobooks, artists, users, and playlists.
|
|
2687
|
+
|
|
2688
|
+
This method requires the `user-library-read`, `user-follow-read`, and `playlist-read-private` scopes.
|
|
2689
|
+
|
|
2690
|
+
Args:
|
|
2691
|
+
uris (str):
|
|
2692
|
+
A comma-separated list of the Spotify URIs for the items.
|
|
2693
|
+
Maximum: 40 URIs.
|
|
2694
|
+
Example: `spotify:artist:6APm8EjxOHSYM5B4i3vT3q,spotify:album:6vc9OTcyd3hyzabCmsdnwE,spotify:track:1kWUud3vY5ij5r62zxpTRy`
|
|
2695
|
+
If null, the currently playing item uri value is used.
|
|
2696
|
+
|
|
2697
|
+
Returns:
|
|
2698
|
+
A dictionary of the uris, along with a boolean status for each that indicates
|
|
2699
|
+
if the item is saved (True) in the users 'Your Library' or not (False).
|
|
2700
|
+
|
|
2701
|
+
Raises:
|
|
2702
|
+
SpotifyWebApiError:
|
|
2703
|
+
If the Spotify Web API request was for a non-authorization service
|
|
2704
|
+
and the response contains error information.
|
|
2705
|
+
SpotifyApiError:
|
|
2706
|
+
If the method fails for any other reason.
|
|
2707
|
+
|
|
2708
|
+
<details>
|
|
2709
|
+
<summary>Sample Code</summary>
|
|
2710
|
+
```python
|
|
2711
|
+
.. include:: ../docs/include/samplecode/SpotifyClient/CheckUserFavorites.py
|
|
2712
|
+
```
|
|
2713
|
+
</details>
|
|
2714
|
+
"""
|
|
2715
|
+
apiMethodName:str = 'CheckUserFavorites'
|
|
2716
|
+
apiMethodParms:SIMethodParmListContext = None
|
|
2717
|
+
result:dict = {}
|
|
2718
|
+
|
|
2719
|
+
try:
|
|
2720
|
+
|
|
2721
|
+
# trace.
|
|
2722
|
+
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
2723
|
+
apiMethodParms.AppendKeyValue("uris", uris)
|
|
2724
|
+
_logsi.LogMethodParmList(SILevel.Verbose, "Check if one or more items are saved in a user's favorites", apiMethodParms)
|
|
2725
|
+
|
|
2726
|
+
# if uris not specified, then return currently playing item uri value.
|
|
2727
|
+
if (uris is None) or (len(uris.strip()) == 0):
|
|
2728
|
+
uris = self.GetPlayerNowPlayingUri(SpotifyMediaTypes.EPISODE.value, False)
|
|
2729
|
+
if uris is None:
|
|
2730
|
+
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'uris'), logsi=_logsi)
|
|
2731
|
+
|
|
2732
|
+
# build spotify web api request parameters.
|
|
2733
|
+
urlParms:dict = \
|
|
2734
|
+
{
|
|
2735
|
+
'uris': uris
|
|
2589
2736
|
}
|
|
2590
2737
|
|
|
2591
2738
|
# execute spotify web api request.
|
|
2592
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
2739
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library/contains')
|
|
2593
2740
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2594
2741
|
msg.UrlParameters = urlParms
|
|
2595
2742
|
self.MakeRequest('GET', msg)
|
|
2596
2743
|
|
|
2597
|
-
# build list of all input
|
|
2598
|
-
|
|
2744
|
+
# build list of all input item uri's.
|
|
2745
|
+
arrUris:list[str] = uris.split(',')
|
|
2599
2746
|
|
|
2600
2747
|
# process results.
|
|
2601
2748
|
flags:list[bool] = msg.ResponseData
|
|
2602
2749
|
flagPtr:int = 0
|
|
2603
|
-
for strId in
|
|
2750
|
+
for strId in arrUris:
|
|
2604
2751
|
if strId not in result:
|
|
2605
2752
|
result[strId] = flags[flagPtr]
|
|
2606
2753
|
flagPtr = flagPtr + 1
|
|
@@ -2667,30 +2814,37 @@ class SpotifyClient:
|
|
|
2667
2814
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
2668
2815
|
_logsi.LogMethodParmList(SILevel.Verbose, "Check if user is following one or more users", apiMethodParms)
|
|
2669
2816
|
|
|
2670
|
-
# remove any leading / trailing spaces
|
|
2817
|
+
# remove any leading / trailing spaces.
|
|
2671
2818
|
if ids is not None:
|
|
2672
2819
|
ids = ids.replace(' ','')
|
|
2673
2820
|
|
|
2821
|
+
# if ids not specified, then it's an error!
|
|
2822
|
+
if (ids is None) or (len(ids.strip()) == 0):
|
|
2823
|
+
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
2824
|
+
|
|
2825
|
+
# build a list of all item uri's from id values.
|
|
2826
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
2827
|
+
arrUris:list[str] = ids.split(',')
|
|
2828
|
+
for idx in range(0, len(arrUris)):
|
|
2829
|
+
if (arrUris[idx].find(":") == -1):
|
|
2830
|
+
arrUris[idx] = SpotifyTypePrefixes.USER.value + arrUris[idx].strip()
|
|
2831
|
+
|
|
2674
2832
|
# build spotify web api request parameters.
|
|
2675
2833
|
urlParms:dict = \
|
|
2676
2834
|
{
|
|
2677
|
-
'
|
|
2678
|
-
'ids': ids
|
|
2835
|
+
'uris': ",".join(arrUris)
|
|
2679
2836
|
}
|
|
2680
2837
|
|
|
2681
2838
|
# execute spotify web api request.
|
|
2682
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
2839
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library/contains')
|
|
2683
2840
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2684
2841
|
msg.UrlParameters = urlParms
|
|
2685
2842
|
self.MakeRequest('GET', msg)
|
|
2686
2843
|
|
|
2687
|
-
# build list of all input id's.
|
|
2688
|
-
arrIds:list[str] = ids.split(',')
|
|
2689
|
-
|
|
2690
2844
|
# process results.
|
|
2691
2845
|
flags:list[bool] = msg.ResponseData
|
|
2692
2846
|
flagPtr:int = 0
|
|
2693
|
-
for strId in
|
|
2847
|
+
for strId in arrUris:
|
|
2694
2848
|
if strId not in result:
|
|
2695
2849
|
result[strId] = flags[flagPtr]
|
|
2696
2850
|
flagPtr = flagPtr + 1
|
|
@@ -2789,7 +2943,7 @@ class SpotifyClient:
|
|
|
2789
2943
|
}
|
|
2790
2944
|
|
|
2791
2945
|
# execute spotify web api request.
|
|
2792
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{
|
|
2946
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}/items'.format(id=playlistId))
|
|
2793
2947
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2794
2948
|
msg.RequestJson = reqData
|
|
2795
2949
|
self.MakeRequest('PUT', msg)
|
|
@@ -2817,7 +2971,7 @@ class SpotifyClient:
|
|
|
2817
2971
|
|
|
2818
2972
|
def CreatePlaylist(
|
|
2819
2973
|
self,
|
|
2820
|
-
userId:str,
|
|
2974
|
+
userId:str=None,
|
|
2821
2975
|
name:str=None,
|
|
2822
2976
|
description:str=None,
|
|
2823
2977
|
public:bool=True,
|
|
@@ -2825,15 +2979,14 @@ class SpotifyClient:
|
|
|
2825
2979
|
imagePath:str=None
|
|
2826
2980
|
) -> Playlist:
|
|
2827
2981
|
"""
|
|
2828
|
-
Create an empty playlist for
|
|
2982
|
+
Create an empty playlist for the current Spotify user.
|
|
2829
2983
|
|
|
2830
2984
|
This method requires the `playlist-modify-public` and `playlist-modify-private` scope.
|
|
2831
|
-
|
|
2985
|
+
|
|
2832
2986
|
Args:
|
|
2833
2987
|
|
|
2834
2988
|
userId (str):
|
|
2835
|
-
|
|
2836
|
-
Example: `32k99y2kg5lnn3mxhtmd2bpdkjfu`
|
|
2989
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
2837
2990
|
name (str):
|
|
2838
2991
|
The name for the new playlist, for example "My Playlist".
|
|
2839
2992
|
This name does not need to be unique; a user may have several playlists with
|
|
@@ -2895,7 +3048,7 @@ class SpotifyClient:
|
|
|
2895
3048
|
|
|
2896
3049
|
# trace.
|
|
2897
3050
|
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
2898
|
-
apiMethodParms.AppendKeyValue("userId", userId)
|
|
3051
|
+
apiMethodParms.AppendKeyValue("userId (DEPRECATED)", userId)
|
|
2899
3052
|
apiMethodParms.AppendKeyValue("name", name)
|
|
2900
3053
|
apiMethodParms.AppendKeyValue("description", description)
|
|
2901
3054
|
apiMethodParms.AppendKeyValue("public", public)
|
|
@@ -2909,10 +3062,6 @@ class SpotifyClient:
|
|
|
2909
3062
|
if (collaborative is None):
|
|
2910
3063
|
collaborative = False
|
|
2911
3064
|
|
|
2912
|
-
# if userId is not supplied, then use profile value.
|
|
2913
|
-
if userId is None or len(userId.strip()) == 0:
|
|
2914
|
-
userId = self.UserProfile.Id
|
|
2915
|
-
|
|
2916
3065
|
# if collaborative is True, then force public to false as Spotify requires it.
|
|
2917
3066
|
if collaborative:
|
|
2918
3067
|
public = False
|
|
@@ -2920,14 +3069,14 @@ class SpotifyClient:
|
|
|
2920
3069
|
# build spotify web api request parameters.
|
|
2921
3070
|
reqData:dict = \
|
|
2922
3071
|
{
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
3072
|
+
"name": "%s" % name,
|
|
3073
|
+
"description": "%s" % description,
|
|
3074
|
+
"public": public,
|
|
3075
|
+
"collaborative": collaborative
|
|
2927
3076
|
}
|
|
2928
|
-
|
|
3077
|
+
|
|
2929
3078
|
# execute spotify web api request.
|
|
2930
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/
|
|
3079
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/playlists')
|
|
2931
3080
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
2932
3081
|
msg.RequestJson = reqData
|
|
2933
3082
|
self.MakeRequest('POST', msg)
|
|
@@ -2972,7 +3121,7 @@ class SpotifyClient:
|
|
|
2972
3121
|
Args:
|
|
2973
3122
|
ids (str):
|
|
2974
3123
|
A comma-separated list of the Spotify artist IDs.
|
|
2975
|
-
A maximum of
|
|
3124
|
+
A maximum of 40 IDs can be sent in one request.
|
|
2976
3125
|
Example: `2CIMQHirSU0MQqyYHq0eOx,1IQ2e1buppatiN1bxUVkrk`
|
|
2977
3126
|
If null, the currently playing track artist uri id value is used.
|
|
2978
3127
|
|
|
@@ -3002,6 +3151,10 @@ class SpotifyClient:
|
|
|
3002
3151
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
3003
3152
|
_logsi.LogMethodParmList(SILevel.Verbose, "Add the current user as a follower of one or more artists", apiMethodParms)
|
|
3004
3153
|
|
|
3154
|
+
# remove any leading / trailing spaces.
|
|
3155
|
+
if ids is not None:
|
|
3156
|
+
ids = ids.replace(' ','')
|
|
3157
|
+
|
|
3005
3158
|
# if ids not specified, then return currently playing artist id value.
|
|
3006
3159
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
3007
3160
|
uri = self.GetPlayerNowPlayingArtistUri()
|
|
@@ -3010,24 +3163,25 @@ class SpotifyClient:
|
|
|
3010
3163
|
else:
|
|
3011
3164
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
3012
3165
|
|
|
3013
|
-
# build a list of all item
|
|
3166
|
+
# build a list of all item uri's from id values.
|
|
3014
3167
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
3015
|
-
|
|
3016
|
-
for idx in range(0, len(
|
|
3017
|
-
|
|
3168
|
+
arrUris:list[str] = ids.split(',')
|
|
3169
|
+
for idx in range(0, len(arrUris)):
|
|
3170
|
+
if (arrUris[idx].find(":") == -1):
|
|
3171
|
+
arrUris[idx] = SpotifyTypePrefixes.ARTIST.value + arrUris[idx].strip()
|
|
3018
3172
|
|
|
3019
3173
|
# build spotify web api request parameters.
|
|
3020
|
-
|
|
3174
|
+
urlParms:dict = \
|
|
3021
3175
|
{
|
|
3022
|
-
'
|
|
3176
|
+
'uris': ",".join(arrUris)
|
|
3023
3177
|
}
|
|
3024
3178
|
|
|
3025
3179
|
# execute spotify web api request.
|
|
3026
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
3180
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
3027
3181
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
3028
|
-
msg.
|
|
3182
|
+
msg.UrlParameters = urlParms
|
|
3029
3183
|
self.MakeRequest('PUT', msg)
|
|
3030
|
-
|
|
3184
|
+
|
|
3031
3185
|
# process results.
|
|
3032
3186
|
# no results to process - this is pass or fail.
|
|
3033
3187
|
return
|
|
@@ -3058,13 +3212,12 @@ class SpotifyClient:
|
|
|
3058
3212
|
|
|
3059
3213
|
Args:
|
|
3060
3214
|
playlistId (str):
|
|
3061
|
-
|
|
3215
|
+
A comma-separated list of Spotify playlist IDs.
|
|
3216
|
+
A maximum of 40 IDs can be sent in one request.
|
|
3062
3217
|
Example: `3cEYpjA9oz9GiPac4AsH4n`
|
|
3063
3218
|
If null, the currently playing playlist uri id value is used.
|
|
3064
3219
|
public (bool):
|
|
3065
|
-
|
|
3066
|
-
will remain private.
|
|
3067
|
-
Default is True.
|
|
3220
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
3068
3221
|
|
|
3069
3222
|
Raises:
|
|
3070
3223
|
SpotifyWebApiError:
|
|
@@ -3088,13 +3241,13 @@ class SpotifyClient:
|
|
|
3088
3241
|
# trace.
|
|
3089
3242
|
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
3090
3243
|
apiMethodParms.AppendKeyValue("playlistId", playlistId)
|
|
3091
|
-
apiMethodParms.AppendKeyValue("public", public)
|
|
3244
|
+
apiMethodParms.AppendKeyValue("public (DEPRECATED)", public)
|
|
3092
3245
|
_logsi.LogMethodParmList(SILevel.Verbose, "Add the current user as a follower of a playlist", apiMethodParms)
|
|
3093
3246
|
|
|
3094
|
-
#
|
|
3095
|
-
if
|
|
3096
|
-
|
|
3097
|
-
|
|
3247
|
+
# remove any leading / trailing spaces.
|
|
3248
|
+
if playlistId is not None:
|
|
3249
|
+
playlistId = playlistId.replace(' ','')
|
|
3250
|
+
|
|
3098
3251
|
# if playlistId not specified, then return currently playing playlist id value.
|
|
3099
3252
|
if (playlistId is None) or (len(playlistId.strip()) == 0):
|
|
3100
3253
|
uri = self.GetPlayerNowPlayingPlaylistUri()
|
|
@@ -3103,17 +3256,25 @@ class SpotifyClient:
|
|
|
3103
3256
|
else:
|
|
3104
3257
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'playlistId'), logsi=_logsi)
|
|
3105
3258
|
|
|
3259
|
+
# build a list of all item uri's from id values.
|
|
3260
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
3261
|
+
arrUris:list[str] = playlistId.split(',')
|
|
3262
|
+
for idx in range(0, len(arrUris)):
|
|
3263
|
+
if (arrUris[idx].find(":") == -1):
|
|
3264
|
+
arrUris[idx] = SpotifyTypePrefixes.PLAYLIST.value + arrUris[idx].strip()
|
|
3265
|
+
|
|
3106
3266
|
# build spotify web api request parameters.
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3267
|
+
urlParms:dict = \
|
|
3268
|
+
{
|
|
3269
|
+
'uris': ",".join(arrUris)
|
|
3270
|
+
}
|
|
3110
3271
|
|
|
3111
3272
|
# execute spotify web api request.
|
|
3112
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/
|
|
3273
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
3113
3274
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
3114
|
-
msg.
|
|
3275
|
+
msg.UrlParameters = urlParms
|
|
3115
3276
|
self.MakeRequest('PUT', msg)
|
|
3116
|
-
|
|
3277
|
+
|
|
3117
3278
|
# process results.
|
|
3118
3279
|
# no results to process - this is pass or fail.
|
|
3119
3280
|
return
|
|
@@ -3144,7 +3305,7 @@ class SpotifyClient:
|
|
|
3144
3305
|
Args:
|
|
3145
3306
|
ids (str):
|
|
3146
3307
|
A comma-separated list of the Spotify user IDs.
|
|
3147
|
-
A maximum of
|
|
3308
|
+
A maximum of 40 IDs can be sent in one request.
|
|
3148
3309
|
Example: `smedjan`
|
|
3149
3310
|
|
|
3150
3311
|
Raises:
|
|
@@ -3173,24 +3334,25 @@ class SpotifyClient:
|
|
|
3173
3334
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
3174
3335
|
_logsi.LogMethodParmList(SILevel.Verbose, "Add the current user as a follower of one or more users", apiMethodParms)
|
|
3175
3336
|
|
|
3176
|
-
# build a list of all item
|
|
3337
|
+
# build a list of all item uri's from id values.
|
|
3177
3338
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
3178
|
-
|
|
3179
|
-
for idx in range(0, len(
|
|
3180
|
-
|
|
3339
|
+
arrUris:list[str] = ids.split(',')
|
|
3340
|
+
for idx in range(0, len(arrUris)):
|
|
3341
|
+
if (arrUris[idx].find(":") == -1):
|
|
3342
|
+
arrUris[idx] = SpotifyTypePrefixes.USER.value + arrUris[idx].strip()
|
|
3181
3343
|
|
|
3182
3344
|
# build spotify web api request parameters.
|
|
3183
|
-
|
|
3345
|
+
urlParms:dict = \
|
|
3184
3346
|
{
|
|
3185
|
-
'
|
|
3347
|
+
'uris': ",".join(arrUris)
|
|
3186
3348
|
}
|
|
3187
3349
|
|
|
3188
3350
|
# execute spotify web api request.
|
|
3189
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
3351
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
3190
3352
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
3191
|
-
msg.
|
|
3353
|
+
msg.UrlParameters = urlParms
|
|
3192
3354
|
self.MakeRequest('PUT', msg)
|
|
3193
|
-
|
|
3355
|
+
|
|
3194
3356
|
# process results.
|
|
3195
3357
|
# no results to process - this is pass or fail.
|
|
3196
3358
|
return
|
|
@@ -3492,6 +3654,14 @@ class SpotifyClient:
|
|
|
3492
3654
|
sortResult:bool=True,
|
|
3493
3655
|
) -> AlbumPageSimplified:
|
|
3494
3656
|
"""
|
|
3657
|
+
<span class="deprecated">
|
|
3658
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
3659
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
3660
|
+
More information about the deprecated functionality can be found on the
|
|
3661
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
3662
|
+
page.
|
|
3663
|
+
</span>
|
|
3664
|
+
|
|
3495
3665
|
Get a list of new album releases featured in Spotify (shown, for example, on a
|
|
3496
3666
|
Spotify player's "Browse" tab).
|
|
3497
3667
|
|
|
@@ -3558,6 +3728,15 @@ class SpotifyClient:
|
|
|
3558
3728
|
apiMethodParms.AppendKeyValue("sortResult", sortResult)
|
|
3559
3729
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get a list of new album releases", apiMethodParms)
|
|
3560
3730
|
|
|
3731
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
3732
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
3733
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
3734
|
+
|
|
3735
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
3736
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
3737
|
+
if (accessTokenHeaderValue is None):
|
|
3738
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
3739
|
+
|
|
3561
3740
|
# validations.
|
|
3562
3741
|
if limit is None:
|
|
3563
3742
|
limit = 20
|
|
@@ -3655,6 +3834,14 @@ class SpotifyClient:
|
|
|
3655
3834
|
market:str=None,
|
|
3656
3835
|
) -> list[Album]:
|
|
3657
3836
|
"""
|
|
3837
|
+
<span class="deprecated">
|
|
3838
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
3839
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
3840
|
+
More information about the deprecated functionality can be found on the
|
|
3841
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
3842
|
+
page.
|
|
3843
|
+
</span>
|
|
3844
|
+
|
|
3658
3845
|
Get Spotify catalog information for multiple albums.
|
|
3659
3846
|
|
|
3660
3847
|
Args:
|
|
@@ -3699,6 +3886,15 @@ class SpotifyClient:
|
|
|
3699
3886
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
3700
3887
|
apiMethodParms.AppendKeyValue("market", market)
|
|
3701
3888
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for multiple albums", apiMethodParms)
|
|
3889
|
+
|
|
3890
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
3891
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
3892
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
3893
|
+
|
|
3894
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
3895
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
3896
|
+
if (accessTokenHeaderValue is None):
|
|
3897
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
3702
3898
|
|
|
3703
3899
|
# ensure we have a market value, in order to return track relinking (e.g. `linked_from`) data.
|
|
3704
3900
|
market = self._ValidateMarket(market, forceReturnValue=True)
|
|
@@ -4585,7 +4781,7 @@ class SpotifyClient:
|
|
|
4585
4781
|
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
4586
4782
|
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2024/11/27.
|
|
4587
4783
|
if (accessTokenHeaderValue is None):
|
|
4588
|
-
raise SpotifyApiError(SAAppMessages.
|
|
4784
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20241127 % apiMethodName)
|
|
4589
4785
|
|
|
4590
4786
|
# validations.
|
|
4591
4787
|
if sortResult is None:
|
|
@@ -4638,6 +4834,14 @@ class SpotifyClient:
|
|
|
4638
4834
|
ids:list[str],
|
|
4639
4835
|
) -> list[Artist]:
|
|
4640
4836
|
"""
|
|
4837
|
+
<span class="deprecated">
|
|
4838
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
4839
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
4840
|
+
More information about the deprecated functionality can be found on the
|
|
4841
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
4842
|
+
page.
|
|
4843
|
+
</span>
|
|
4844
|
+
|
|
4641
4845
|
Get Spotify catalog information for several artists based on their Spotify IDs.
|
|
4642
4846
|
|
|
4643
4847
|
Args:
|
|
@@ -4674,6 +4878,15 @@ class SpotifyClient:
|
|
|
4674
4878
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
4675
4879
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for multiple artists", apiMethodParms)
|
|
4676
4880
|
|
|
4881
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
4882
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
4883
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
4884
|
+
|
|
4885
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
4886
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
4887
|
+
if (accessTokenHeaderValue is None):
|
|
4888
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
4889
|
+
|
|
4677
4890
|
# build spotify web api request parameters.
|
|
4678
4891
|
urlParms:dict = \
|
|
4679
4892
|
{
|
|
@@ -4880,6 +5093,14 @@ class SpotifyClient:
|
|
|
4880
5093
|
sortResult:bool=True,
|
|
4881
5094
|
) -> list[Track]:
|
|
4882
5095
|
"""
|
|
5096
|
+
<span class="deprecated">
|
|
5097
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
5098
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
5099
|
+
More information about the deprecated functionality can be found on the
|
|
5100
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
5101
|
+
page.
|
|
5102
|
+
</span>
|
|
5103
|
+
|
|
4883
5104
|
Get Spotify catalog information about an artist's top tracks by country.
|
|
4884
5105
|
|
|
4885
5106
|
Args:
|
|
@@ -4931,6 +5152,15 @@ class SpotifyClient:
|
|
|
4931
5152
|
apiMethodParms.AppendKeyValue("sortResult", sortResult)
|
|
4932
5153
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information about an artist's top tracks", apiMethodParms)
|
|
4933
5154
|
|
|
5155
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
5156
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
5157
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
5158
|
+
|
|
5159
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
5160
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
5161
|
+
if (accessTokenHeaderValue is None):
|
|
5162
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
5163
|
+
|
|
4934
5164
|
# validations.
|
|
4935
5165
|
if sortResult is None:
|
|
4936
5166
|
sortResult = True
|
|
@@ -5428,6 +5658,14 @@ class SpotifyClient:
|
|
|
5428
5658
|
market:str=None,
|
|
5429
5659
|
) -> list[AudiobookSimplified]:
|
|
5430
5660
|
"""
|
|
5661
|
+
<span class="deprecated">
|
|
5662
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
5663
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
5664
|
+
More information about the deprecated functionality can be found on the
|
|
5665
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
5666
|
+
page.
|
|
5667
|
+
</span>
|
|
5668
|
+
|
|
5431
5669
|
Get Spotify catalog information for several audiobooks based on their Spotify IDs.
|
|
5432
5670
|
|
|
5433
5671
|
Args:
|
|
@@ -5478,6 +5716,15 @@ class SpotifyClient:
|
|
|
5478
5716
|
apiMethodParms.AppendKeyValue("market", market)
|
|
5479
5717
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for multiple audiobooks", apiMethodParms)
|
|
5480
5718
|
|
|
5719
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
5720
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
5721
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
5722
|
+
|
|
5723
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
5724
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
5725
|
+
if (accessTokenHeaderValue is None):
|
|
5726
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
5727
|
+
|
|
5481
5728
|
# ensure market was either supplied or implied; default if neither.
|
|
5482
5729
|
market = self._ValidateMarket(market)
|
|
5483
5730
|
|
|
@@ -5527,6 +5774,14 @@ class SpotifyClient:
|
|
|
5527
5774
|
refresh:bool=True,
|
|
5528
5775
|
) -> Playlist:
|
|
5529
5776
|
"""
|
|
5777
|
+
<span class="deprecated">
|
|
5778
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
5779
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
5780
|
+
More information about the deprecated functionality can be found on the
|
|
5781
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
5782
|
+
page.
|
|
5783
|
+
</span>
|
|
5784
|
+
|
|
5530
5785
|
Get a single category used to tag items in Spotify.
|
|
5531
5786
|
|
|
5532
5787
|
Args:
|
|
@@ -5590,6 +5845,15 @@ class SpotifyClient:
|
|
|
5590
5845
|
apiMethodParms.AppendKeyValue("locale", locale)
|
|
5591
5846
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get a single category used to tag items in Spotify", apiMethodParms)
|
|
5592
5847
|
|
|
5848
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
5849
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
5850
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
5851
|
+
|
|
5852
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
5853
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
5854
|
+
if (accessTokenHeaderValue is None):
|
|
5855
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
5856
|
+
|
|
5593
5857
|
# validations.
|
|
5594
5858
|
if (refresh is None):
|
|
5595
5859
|
refresh = True
|
|
@@ -5653,6 +5917,14 @@ class SpotifyClient:
|
|
|
5653
5917
|
sortResult:bool=True,
|
|
5654
5918
|
) -> CategoryPage:
|
|
5655
5919
|
"""
|
|
5920
|
+
<span class="deprecated">
|
|
5921
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
5922
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
5923
|
+
More information about the deprecated functionality can be found on the
|
|
5924
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
5925
|
+
page.
|
|
5926
|
+
</span>
|
|
5927
|
+
|
|
5656
5928
|
Get categories used to tag items in Spotify.
|
|
5657
5929
|
|
|
5658
5930
|
Args:
|
|
@@ -5729,6 +6001,15 @@ class SpotifyClient:
|
|
|
5729
6001
|
apiMethodParms.AppendKeyValue("sortResult", sortResult)
|
|
5730
6002
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get a page of categories used to tag items in Spotify", apiMethodParms)
|
|
5731
6003
|
|
|
6004
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
6005
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
6006
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
6007
|
+
|
|
6008
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
6009
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
6010
|
+
if (accessTokenHeaderValue is None):
|
|
6011
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
6012
|
+
|
|
5732
6013
|
# validations.
|
|
5733
6014
|
if limit is None:
|
|
5734
6015
|
limit = 20
|
|
@@ -6034,7 +6315,7 @@ class SpotifyClient:
|
|
|
6034
6315
|
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
6035
6316
|
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2024/11/27.
|
|
6036
6317
|
if (accessTokenHeaderValue is None):
|
|
6037
|
-
raise SpotifyApiError(SAAppMessages.
|
|
6318
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20241127 % apiMethodName)
|
|
6038
6319
|
|
|
6039
6320
|
# validations.
|
|
6040
6321
|
if limit is None:
|
|
@@ -6249,6 +6530,14 @@ class SpotifyClient:
|
|
|
6249
6530
|
market:str=None,
|
|
6250
6531
|
) -> list[Chapter]:
|
|
6251
6532
|
"""
|
|
6533
|
+
<span class="deprecated">
|
|
6534
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
6535
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
6536
|
+
More information about the deprecated functionality can be found on the
|
|
6537
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
6538
|
+
page.
|
|
6539
|
+
</span>
|
|
6540
|
+
|
|
6252
6541
|
Get Spotify catalog information for several chapters based on their Spotify IDs.
|
|
6253
6542
|
|
|
6254
6543
|
Args:
|
|
@@ -6299,6 +6588,15 @@ class SpotifyClient:
|
|
|
6299
6588
|
apiMethodParms.AppendKeyValue("market", market)
|
|
6300
6589
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for multiple chapters", apiMethodParms)
|
|
6301
6590
|
|
|
6591
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
6592
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
6593
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
6594
|
+
|
|
6595
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
6596
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
6597
|
+
if (accessTokenHeaderValue is None):
|
|
6598
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
6599
|
+
|
|
6302
6600
|
# ensure market was either supplied or implied; default if neither.
|
|
6303
6601
|
market = self._ValidateMarket(market)
|
|
6304
6602
|
|
|
@@ -6843,6 +7141,14 @@ class SpotifyClient:
|
|
|
6843
7141
|
market:str=None,
|
|
6844
7142
|
) -> list[Episode]:
|
|
6845
7143
|
"""
|
|
7144
|
+
<span class="deprecated">
|
|
7145
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
7146
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
7147
|
+
More information about the deprecated functionality can be found on the
|
|
7148
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
7149
|
+
page.
|
|
7150
|
+
</span>
|
|
7151
|
+
|
|
6846
7152
|
Get Spotify catalog information for several episodes based on their Spotify IDs.
|
|
6847
7153
|
|
|
6848
7154
|
Args:
|
|
@@ -6893,6 +7199,15 @@ class SpotifyClient:
|
|
|
6893
7199
|
apiMethodParms.AppendKeyValue("market", market)
|
|
6894
7200
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for multiple episodes", apiMethodParms)
|
|
6895
7201
|
|
|
7202
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
7203
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
7204
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
7205
|
+
|
|
7206
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
7207
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
7208
|
+
if (accessTokenHeaderValue is None):
|
|
7209
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
7210
|
+
|
|
6896
7211
|
# ensure market was either supplied or implied; default if neither.
|
|
6897
7212
|
market = self._ValidateMarket(market)
|
|
6898
7213
|
|
|
@@ -7048,7 +7363,7 @@ class SpotifyClient:
|
|
|
7048
7363
|
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
7049
7364
|
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2024/11/27.
|
|
7050
7365
|
if (accessTokenHeaderValue is None):
|
|
7051
|
-
raise SpotifyApiError(SAAppMessages.
|
|
7366
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20241127 % apiMethodName)
|
|
7052
7367
|
|
|
7053
7368
|
# validations.
|
|
7054
7369
|
if limit is None:
|
|
@@ -7204,7 +7519,7 @@ class SpotifyClient:
|
|
|
7204
7519
|
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
7205
7520
|
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2024/11/27.
|
|
7206
7521
|
if (accessTokenHeaderValue is None):
|
|
7207
|
-
raise SpotifyApiError(SAAppMessages.
|
|
7522
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20241127 % apiMethodName)
|
|
7208
7523
|
|
|
7209
7524
|
# validations.
|
|
7210
7525
|
if (refresh is None):
|
|
@@ -7562,6 +7877,14 @@ class SpotifyClient:
|
|
|
7562
7877
|
refresh:bool=True
|
|
7563
7878
|
) -> list[str]:
|
|
7564
7879
|
"""
|
|
7880
|
+
<span class="deprecated">
|
|
7881
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
7882
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
7883
|
+
More information about the deprecated functionality can be found on the
|
|
7884
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
7885
|
+
page.
|
|
7886
|
+
</span>
|
|
7887
|
+
|
|
7565
7888
|
Get the list of markets (country codes) where Spotify is available.
|
|
7566
7889
|
|
|
7567
7890
|
Args:
|
|
@@ -7600,6 +7923,15 @@ class SpotifyClient:
|
|
|
7600
7923
|
_logsi.EnterMethod(SILevel.Debug, apiMethodName)
|
|
7601
7924
|
_logsi.LogVerbose("Get a sorted list of available markets (country codes)")
|
|
7602
7925
|
|
|
7926
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
7927
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
7928
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
7929
|
+
|
|
7930
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
7931
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
7932
|
+
if (accessTokenHeaderValue is None):
|
|
7933
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
7934
|
+
|
|
7603
7935
|
# validations.
|
|
7604
7936
|
if (refresh is None):
|
|
7605
7937
|
refresh = True
|
|
@@ -8214,6 +8546,7 @@ class SpotifyClient:
|
|
|
8214
8546
|
def GetPlayerNowPlayingUri(
|
|
8215
8547
|
self,
|
|
8216
8548
|
additionalTypes:str=None,
|
|
8549
|
+
checkSpecificType:bool=True,
|
|
8217
8550
|
) -> str:
|
|
8218
8551
|
"""
|
|
8219
8552
|
Returns the uri value of the currently playing media type if something is
|
|
@@ -8224,6 +8557,9 @@ class SpotifyClient:
|
|
|
8224
8557
|
An item type that your client supports besides the default track type.
|
|
8225
8558
|
Valid types are: `track` and `episode`.
|
|
8226
8559
|
Specify `episode` to get podcast track information.
|
|
8560
|
+
checkSpecificType (bool):
|
|
8561
|
+
If true, the currently playing type MUST match the specified additional type value;
|
|
8562
|
+
otherwise, it will return any uri that is currently playing.
|
|
8227
8563
|
|
|
8228
8564
|
Raises:
|
|
8229
8565
|
SpotifyApiError:
|
|
@@ -8238,7 +8574,7 @@ class SpotifyClient:
|
|
|
8238
8574
|
# is anything playing? if so, return the uri value.
|
|
8239
8575
|
if nowPlaying is not None:
|
|
8240
8576
|
if nowPlaying.Item is not None:
|
|
8241
|
-
if additionalTypes is None:
|
|
8577
|
+
if (additionalTypes is None) or (checkSpecificType == False):
|
|
8242
8578
|
# if not validating uri type then just return the uri.
|
|
8243
8579
|
result = nowPlaying.Item.Uri
|
|
8244
8580
|
elif nowPlaying.CurrentlyPlayingType == additionalTypes:
|
|
@@ -8249,7 +8585,7 @@ class SpotifyClient:
|
|
|
8249
8585
|
raise SpotifyApiError("Currently playing item is not a %s" % additionalTypes, logsi=_logsi)
|
|
8250
8586
|
else:
|
|
8251
8587
|
# otherwise nowplaying item does not contain the desired type!
|
|
8252
|
-
if additionalTypes is None:
|
|
8588
|
+
if (additionalTypes is None) or (checkSpecificType == False):
|
|
8253
8589
|
raise SpotifyApiError("Currently playing item context is not set", logsi=_logsi)
|
|
8254
8590
|
else:
|
|
8255
8591
|
raise SpotifyApiError("Currently playing item context is not a %s item" % additionalTypes, logsi=_logsi)
|
|
@@ -9083,7 +9419,7 @@ class SpotifyClient:
|
|
|
9083
9419
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'playlistId'), logsi=_logsi)
|
|
9084
9420
|
|
|
9085
9421
|
# execute spotify web api request.
|
|
9086
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{
|
|
9422
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}/images'.format(id=playlistId))
|
|
9087
9423
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
9088
9424
|
self.MakeRequest('GET', msg)
|
|
9089
9425
|
|
|
@@ -9281,7 +9617,7 @@ class SpotifyClient:
|
|
|
9281
9617
|
while True:
|
|
9282
9618
|
|
|
9283
9619
|
# execute spotify web api request.
|
|
9284
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}/
|
|
9620
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}/items'.format(id=playlistId))
|
|
9285
9621
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = accessTokenHeaderValue or self.AuthToken.HeaderValue
|
|
9286
9622
|
msg.UrlParameters = urlParms
|
|
9287
9623
|
self.MakeRequest('GET', msg)
|
|
@@ -9515,6 +9851,14 @@ class SpotifyClient:
|
|
|
9515
9851
|
sortResult:bool=True,
|
|
9516
9852
|
) -> PlaylistPageSimplified:
|
|
9517
9853
|
"""
|
|
9854
|
+
<span class="deprecated">
|
|
9855
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
9856
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
9857
|
+
More information about the deprecated functionality can be found on the
|
|
9858
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
9859
|
+
page.
|
|
9860
|
+
</span>
|
|
9861
|
+
|
|
9518
9862
|
Get a list of the playlists owned or followed by a Spotify user.
|
|
9519
9863
|
|
|
9520
9864
|
This method requires the `playlist-read-private` and `playlist-read-collaborative` scope.
|
|
@@ -9580,6 +9924,15 @@ class SpotifyClient:
|
|
|
9580
9924
|
apiMethodParms.AppendKeyValue("sortResult", sortResult)
|
|
9581
9925
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get a list of the playlists owned or followed by a Spotify user", apiMethodParms)
|
|
9582
9926
|
|
|
9927
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
9928
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
9929
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
9930
|
+
|
|
9931
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
9932
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
9933
|
+
if (accessTokenHeaderValue is None):
|
|
9934
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
9935
|
+
|
|
9583
9936
|
# validations.
|
|
9584
9937
|
if limit is None:
|
|
9585
9938
|
limit = 20
|
|
@@ -9609,7 +9962,7 @@ class SpotifyClient:
|
|
|
9609
9962
|
while True:
|
|
9610
9963
|
|
|
9611
9964
|
# execute spotify web api request.
|
|
9612
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/users/{
|
|
9965
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/users/{id}/playlists'.format(id=userId))
|
|
9613
9966
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
9614
9967
|
msg.UrlParameters = urlParms
|
|
9615
9968
|
self.MakeRequest('GET', msg)
|
|
@@ -10139,6 +10492,14 @@ class SpotifyClient:
|
|
|
10139
10492
|
market:str=None,
|
|
10140
10493
|
) -> list[ShowSimplified]:
|
|
10141
10494
|
"""
|
|
10495
|
+
<span class="deprecated">
|
|
10496
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
10497
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
10498
|
+
More information about the deprecated functionality can be found on the
|
|
10499
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
10500
|
+
page.
|
|
10501
|
+
</span>
|
|
10502
|
+
|
|
10142
10503
|
Get Spotify catalog information for several shows based on their Spotify IDs.
|
|
10143
10504
|
|
|
10144
10505
|
Args:
|
|
@@ -10189,6 +10550,15 @@ class SpotifyClient:
|
|
|
10189
10550
|
apiMethodParms.AppendKeyValue("market", market)
|
|
10190
10551
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for multiple shows", apiMethodParms)
|
|
10191
10552
|
|
|
10553
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
10554
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
10555
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
10556
|
+
|
|
10557
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
10558
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
10559
|
+
if (accessTokenHeaderValue is None):
|
|
10560
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
10561
|
+
|
|
10192
10562
|
# ensure market was either supplied or implied; default if neither.
|
|
10193
10563
|
market = self._ValidateMarket(market)
|
|
10194
10564
|
|
|
@@ -10852,7 +11222,7 @@ class SpotifyClient:
|
|
|
10852
11222
|
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
10853
11223
|
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2024/11/27.
|
|
10854
11224
|
if (accessTokenHeaderValue is None):
|
|
10855
|
-
raise SpotifyApiError(SAAppMessages.
|
|
11225
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20241127 % apiMethodName)
|
|
10856
11226
|
|
|
10857
11227
|
# if trackId not specified, then return currently playing track id value.
|
|
10858
11228
|
if (trackId is None) or (len(trackId.strip()) == 0):
|
|
@@ -11121,6 +11491,14 @@ class SpotifyClient:
|
|
|
11121
11491
|
market:str=None,
|
|
11122
11492
|
) -> list[Track]:
|
|
11123
11493
|
"""
|
|
11494
|
+
<span class="deprecated">
|
|
11495
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
11496
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
11497
|
+
More information about the deprecated functionality can be found on the
|
|
11498
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
11499
|
+
page.
|
|
11500
|
+
</span>
|
|
11501
|
+
|
|
11124
11502
|
Get Spotify catalog information for multiple tracks based on their Spotify IDs.
|
|
11125
11503
|
|
|
11126
11504
|
Args:
|
|
@@ -11165,7 +11543,16 @@ class SpotifyClient:
|
|
|
11165
11543
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
11166
11544
|
apiMethodParms.AppendKeyValue("market", market)
|
|
11167
11545
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information for multiple tracks", apiMethodParms)
|
|
11168
|
-
|
|
11546
|
+
|
|
11547
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
11548
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
11549
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
11550
|
+
|
|
11551
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
11552
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
11553
|
+
if (accessTokenHeaderValue is None):
|
|
11554
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
11555
|
+
|
|
11169
11556
|
# ensure we have a market value, in order to return track relinking (e.g. `linked_from`) data.
|
|
11170
11557
|
market = self._ValidateMarket(market, forceReturnValue=True)
|
|
11171
11558
|
|
|
@@ -11261,7 +11648,7 @@ class SpotifyClient:
|
|
|
11261
11648
|
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
11262
11649
|
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2024/11/27.
|
|
11263
11650
|
if (accessTokenHeaderValue is None):
|
|
11264
|
-
raise SpotifyApiError(SAAppMessages.
|
|
11651
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20241127 % apiMethodName)
|
|
11265
11652
|
|
|
11266
11653
|
# execute spotify web api request.
|
|
11267
11654
|
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/audio-features')
|
|
@@ -11569,7 +11956,7 @@ class SpotifyClient:
|
|
|
11569
11956
|
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
11570
11957
|
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2024/11/27.
|
|
11571
11958
|
if (accessTokenHeaderValue is None):
|
|
11572
|
-
raise SpotifyApiError(SAAppMessages.
|
|
11959
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20241127 % apiMethodName)
|
|
11573
11960
|
|
|
11574
11961
|
# ensure market was either supplied or implied; default if neither.
|
|
11575
11962
|
market = self._ValidateMarket(market)
|
|
@@ -11859,6 +12246,14 @@ class SpotifyClient:
|
|
|
11859
12246
|
userId:str,
|
|
11860
12247
|
) -> UserProfileSimplified:
|
|
11861
12248
|
"""
|
|
12249
|
+
<span class="deprecated">
|
|
12250
|
+
DEPRECATED - api endpoint no longer supported by Spotify as of 2026/02/11 for unauthorized Spotify Developer Applications.
|
|
12251
|
+
The api endpoint IS still supported by Spotify for authorized Spotify Developer Applications.
|
|
12252
|
+
More information about the deprecated functionality can be found on the
|
|
12253
|
+
<a href="https://developer.spotify.com/blog/2026-02-06-update-on-developer-access-and-platform-security" target="_blank">Spotify Developer Forum Blog</a>
|
|
12254
|
+
page.
|
|
12255
|
+
</span>
|
|
12256
|
+
|
|
11862
12257
|
Get public profile information about a Spotify user.
|
|
11863
12258
|
|
|
11864
12259
|
Args:
|
|
@@ -11894,8 +12289,17 @@ class SpotifyClient:
|
|
|
11894
12289
|
apiMethodParms.AppendKeyValue("userId", userId)
|
|
11895
12290
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get public profile information about a Spotify user", apiMethodParms)
|
|
11896
12291
|
|
|
12292
|
+
# are spotify web player credentials configured? if so, then we will use them to create
|
|
12293
|
+
# an elevated authorization access token for the Spotify Web API endpoint call.
|
|
12294
|
+
accessTokenHeaderValue:str = self._GetSpotifyWebPlayerTokenHeaderValue()
|
|
12295
|
+
|
|
12296
|
+
# if spotify web player credentials not configured then we are done; the Spotify Web API
|
|
12297
|
+
# endpoint is no longer supported by unauthorized Spotify Developer Applications as of 2026/02/11.
|
|
12298
|
+
if (accessTokenHeaderValue is None):
|
|
12299
|
+
raise SpotifyApiError(SAAppMessages.MSG_SPOTIFY_DEPRECATED_ENDPOINT_20260211 % apiMethodName)
|
|
12300
|
+
|
|
11897
12301
|
# execute spotify web api request.
|
|
11898
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/users/{
|
|
12302
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/users/{id}'.format(id=userId))
|
|
11899
12303
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
11900
12304
|
self.MakeRequest('GET', msg)
|
|
11901
12305
|
|
|
@@ -14537,8 +14941,8 @@ class SpotifyClient:
|
|
|
14537
14941
|
|
|
14538
14942
|
Args:
|
|
14539
14943
|
ids (str):
|
|
14540
|
-
A comma-separated list of the Spotify
|
|
14541
|
-
Maximum:
|
|
14944
|
+
A comma-separated list of the Spotify ID's (or URI's) for the albums.
|
|
14945
|
+
Maximum: 40 IDs.
|
|
14542
14946
|
Example: `6vc9OTcyd3hyzabCmsdnwE,382ObEPsp2rxGrnsizN5TX`
|
|
14543
14947
|
If null, the currently playing track album uri id value is used.
|
|
14544
14948
|
|
|
@@ -14572,6 +14976,10 @@ class SpotifyClient:
|
|
|
14572
14976
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
14573
14977
|
_logsi.LogMethodParmList(SILevel.Verbose, "Remove album(s) from user favorites", apiMethodParms)
|
|
14574
14978
|
|
|
14979
|
+
# remove any leading / trailing spaces.
|
|
14980
|
+
if ids is not None:
|
|
14981
|
+
ids = ids.replace(' ','')
|
|
14982
|
+
|
|
14575
14983
|
# if ids not specified, then return currently playing album id value.
|
|
14576
14984
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
14577
14985
|
uri = self.GetPlayerNowPlayingAlbumUri()
|
|
@@ -14580,24 +14988,25 @@ class SpotifyClient:
|
|
|
14580
14988
|
else:
|
|
14581
14989
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
14582
14990
|
|
|
14583
|
-
# build a list of all item
|
|
14991
|
+
# build a list of all item uri's from id values.
|
|
14584
14992
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
14585
|
-
|
|
14586
|
-
for idx in range(0, len(
|
|
14587
|
-
|
|
14993
|
+
arrUris:list[str] = ids.split(',')
|
|
14994
|
+
for idx in range(0, len(arrUris)):
|
|
14995
|
+
if (arrUris[idx].find(":") == -1):
|
|
14996
|
+
arrUris[idx] = SpotifyTypePrefixes.ALBUM.value + arrUris[idx].strip()
|
|
14588
14997
|
|
|
14589
14998
|
# build spotify web api request parameters.
|
|
14590
|
-
|
|
14999
|
+
urlParms:dict = \
|
|
14591
15000
|
{
|
|
14592
|
-
'
|
|
15001
|
+
'uris': ",".join(arrUris)
|
|
14593
15002
|
}
|
|
14594
15003
|
|
|
14595
15004
|
# execute spotify web api request.
|
|
14596
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
15005
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
14597
15006
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
14598
|
-
msg.
|
|
15007
|
+
msg.UrlParameters = urlParms
|
|
14599
15008
|
self.MakeRequest('DELETE', msg)
|
|
14600
|
-
|
|
15009
|
+
|
|
14601
15010
|
# process results.
|
|
14602
15011
|
# no results to process - this is pass or fail.
|
|
14603
15012
|
return
|
|
@@ -14627,8 +15036,8 @@ class SpotifyClient:
|
|
|
14627
15036
|
|
|
14628
15037
|
Args:
|
|
14629
15038
|
ids (str):
|
|
14630
|
-
A comma-separated list of the Spotify
|
|
14631
|
-
Maximum:
|
|
15039
|
+
A comma-separated list of the Spotify ID's (or URI's) for the audiobooks.
|
|
15040
|
+
Maximum: 40 IDs.
|
|
14632
15041
|
Example: `3PFyizE2tGCSRLusl2Qizf,7iHfbu1YPACw6oZPAFJtqe`
|
|
14633
15042
|
If null, the currently playing audiobook uri id value is used.
|
|
14634
15043
|
|
|
@@ -14662,6 +15071,10 @@ class SpotifyClient:
|
|
|
14662
15071
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
14663
15072
|
_logsi.LogMethodParmList(SILevel.Verbose, "Remove audiobook(s) from user favorites", apiMethodParms)
|
|
14664
15073
|
|
|
15074
|
+
# remove any leading / trailing spaces.
|
|
15075
|
+
if ids is not None:
|
|
15076
|
+
ids = ids.replace(' ','')
|
|
15077
|
+
|
|
14665
15078
|
# if ids not specified, then return currently playing id value.
|
|
14666
15079
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
14667
15080
|
uri = self.GetPlayerNowPlayingAudiobookUri()
|
|
@@ -14670,22 +15083,23 @@ class SpotifyClient:
|
|
|
14670
15083
|
else:
|
|
14671
15084
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
14672
15085
|
|
|
14673
|
-
# build a list of all item
|
|
15086
|
+
# build a list of all item uri's from id values.
|
|
14674
15087
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
14675
|
-
|
|
14676
|
-
for idx in range(0, len(
|
|
14677
|
-
|
|
15088
|
+
arrUris:list[str] = ids.split(',')
|
|
15089
|
+
for idx in range(0, len(arrUris)):
|
|
15090
|
+
if (arrUris[idx].find(":") == -1):
|
|
15091
|
+
arrUris[idx] = SpotifyTypePrefixes.SHOW.value + arrUris[idx].strip() # spotify web api considers audiobook a "show"!
|
|
14678
15092
|
|
|
14679
15093
|
# build spotify web api request parameters.
|
|
14680
|
-
|
|
15094
|
+
urlParms:dict = \
|
|
14681
15095
|
{
|
|
14682
|
-
'
|
|
15096
|
+
'uris': ",".join(arrUris)
|
|
14683
15097
|
}
|
|
14684
15098
|
|
|
14685
15099
|
# execute spotify web api request.
|
|
14686
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
15100
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
14687
15101
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
14688
|
-
msg.
|
|
15102
|
+
msg.UrlParameters = urlParms
|
|
14689
15103
|
self.MakeRequest('DELETE', msg)
|
|
14690
15104
|
|
|
14691
15105
|
# process results.
|
|
@@ -14717,8 +15131,8 @@ class SpotifyClient:
|
|
|
14717
15131
|
|
|
14718
15132
|
Args:
|
|
14719
15133
|
ids (str):
|
|
14720
|
-
A comma-separated list of the Spotify
|
|
14721
|
-
Maximum:
|
|
15134
|
+
A comma-separated list of the Spotify ID's (or URI's) for the episodes.
|
|
15135
|
+
Maximum: 40 IDs.
|
|
14722
15136
|
Example: `6kAsbP8pxwaU2kPibKTuHE,4rOoJ6Egrf8K2IrywzwOMk`
|
|
14723
15137
|
If null, the currently playing episode uri id value is used.
|
|
14724
15138
|
|
|
@@ -14752,6 +15166,10 @@ class SpotifyClient:
|
|
|
14752
15166
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
14753
15167
|
_logsi.LogMethodParmList(SILevel.Verbose, "Remove episode(s) from user favorites", apiMethodParms)
|
|
14754
15168
|
|
|
15169
|
+
# remove any leading / trailing spaces.
|
|
15170
|
+
if ids is not None:
|
|
15171
|
+
ids = ids.replace(' ','')
|
|
15172
|
+
|
|
14755
15173
|
# if ids not specified, then return currently playing id value.
|
|
14756
15174
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
14757
15175
|
uri = self.GetPlayerNowPlayingUri(SpotifyMediaTypes.EPISODE.value)
|
|
@@ -14760,22 +15178,23 @@ class SpotifyClient:
|
|
|
14760
15178
|
else:
|
|
14761
15179
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
14762
15180
|
|
|
14763
|
-
# build a list of all item
|
|
15181
|
+
# build a list of all item uri's from id values.
|
|
14764
15182
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
14765
|
-
|
|
14766
|
-
for idx in range(0, len(
|
|
14767
|
-
|
|
15183
|
+
arrUris:list[str] = ids.split(',')
|
|
15184
|
+
for idx in range(0, len(arrUris)):
|
|
15185
|
+
if (arrUris[idx].find(":") == -1):
|
|
15186
|
+
arrUris[idx] = SpotifyTypePrefixes.EPISODE.value + arrUris[idx].strip()
|
|
14768
15187
|
|
|
14769
15188
|
# build spotify web api request parameters.
|
|
14770
|
-
|
|
15189
|
+
urlParms:dict = \
|
|
14771
15190
|
{
|
|
14772
|
-
'
|
|
15191
|
+
'uris': ",".join(arrUris)
|
|
14773
15192
|
}
|
|
14774
15193
|
|
|
14775
15194
|
# execute spotify web api request.
|
|
14776
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
15195
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
14777
15196
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
14778
|
-
msg.
|
|
15197
|
+
msg.UrlParameters = urlParms
|
|
14779
15198
|
self.MakeRequest('DELETE', msg)
|
|
14780
15199
|
|
|
14781
15200
|
# process results.
|
|
@@ -14903,6 +15322,8 @@ class SpotifyClient:
|
|
|
14903
15322
|
|
|
14904
15323
|
The `snapshotId` argument value will be returned if no items were removed; otherwise, a
|
|
14905
15324
|
new snapshot id value will be returned.
|
|
15325
|
+
|
|
15326
|
+
If the playlist contains duplicate items, then all of the item instances will be removed.
|
|
14906
15327
|
|
|
14907
15328
|
<details>
|
|
14908
15329
|
<summary>Sample Code</summary>
|
|
@@ -14930,37 +15351,132 @@ class SpotifyClient:
|
|
|
14930
15351
|
if uris is None:
|
|
14931
15352
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'uris'), logsi=_logsi)
|
|
14932
15353
|
|
|
14933
|
-
# build a list of all item uri's.
|
|
15354
|
+
# build a list of all item uri's.
|
|
15355
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
15356
|
+
arrUris:list[str] = uris.split(',')
|
|
15357
|
+
for idx in range(0, len(arrUris)):
|
|
15358
|
+
arrUris[idx] = arrUris[idx].strip()
|
|
15359
|
+
|
|
15360
|
+
# build items dictionary.
|
|
15361
|
+
items:list[dict] = []
|
|
15362
|
+
for idx in range(0, len(arrUris)):
|
|
15363
|
+
items.append({'uri': '%s' % arrUris[idx]})
|
|
15364
|
+
|
|
15365
|
+
# build spotify web api request parameters.
|
|
15366
|
+
reqData:dict = \
|
|
15367
|
+
{
|
|
15368
|
+
'items': items
|
|
15369
|
+
}
|
|
15370
|
+
if snapshotId is not None:
|
|
15371
|
+
reqData['snapshot_id'] = snapshotId
|
|
15372
|
+
|
|
15373
|
+
# execute spotify web api request.
|
|
15374
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}/items'.format(id=playlistId))
|
|
15375
|
+
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15376
|
+
msg.RequestJson = reqData
|
|
15377
|
+
self.MakeRequest('DELETE', msg)
|
|
15378
|
+
|
|
15379
|
+
# process results.
|
|
15380
|
+
result = msg.ResponseData.get('snapshot_id','unknown')
|
|
15381
|
+
|
|
15382
|
+
# trace.
|
|
15383
|
+
_logsi.LogString(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
|
|
15384
|
+
return result
|
|
15385
|
+
|
|
15386
|
+
except SpotifyApiError: raise # pass handled exceptions on thru
|
|
15387
|
+
except SpotifyWebApiError: raise # pass handled exceptions on thru
|
|
15388
|
+
except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
|
|
15389
|
+
except Exception as ex:
|
|
15390
|
+
|
|
15391
|
+
# format unhandled exception.
|
|
15392
|
+
raise SpotifyApiError(SAAppMessages.UNHANDLED_EXCEPTION.format(apiMethodName, str(ex)), ex, logsi=_logsi)
|
|
15393
|
+
|
|
15394
|
+
finally:
|
|
15395
|
+
|
|
15396
|
+
# trace.
|
|
15397
|
+
_logsi.LeaveMethod(SILevel.Debug, apiMethodName)
|
|
15398
|
+
|
|
15399
|
+
|
|
15400
|
+
def RemoveShowFavorites(
|
|
15401
|
+
self,
|
|
15402
|
+
ids:str=None,
|
|
15403
|
+
) -> None:
|
|
15404
|
+
"""
|
|
15405
|
+
Remove one or more shows from the current user's 'Your Library'.
|
|
15406
|
+
|
|
15407
|
+
This method requires the `user-library-modify` scope.
|
|
15408
|
+
|
|
15409
|
+
Args:
|
|
15410
|
+
ids (str):
|
|
15411
|
+
A comma-separated list of the Spotify ID's (or URI's) for the shows.
|
|
15412
|
+
Maximum: 40 IDs.
|
|
15413
|
+
Example: `6kAsbP8pxwaU2kPibKTuHE,4rOoJ6Egrf8K2IrywzwOMk`
|
|
15414
|
+
If null, the currently playing show uri id value is used.
|
|
15415
|
+
|
|
15416
|
+
Raises:
|
|
15417
|
+
SpotifyWebApiError:
|
|
15418
|
+
If the Spotify Web API request was for a non-authorization service
|
|
15419
|
+
and the response contains error information.
|
|
15420
|
+
SpotifyApiError:
|
|
15421
|
+
If the method fails for any other reason.
|
|
15422
|
+
|
|
15423
|
+
No error will be raised if a show id in the list does not exist in the
|
|
15424
|
+
user's 'Your Library'.
|
|
15425
|
+
|
|
15426
|
+
An SpotifyWebApiError will be raised if a specified album id does not exist
|
|
15427
|
+
in the Spotify music catalog.
|
|
15428
|
+
|
|
15429
|
+
<details>
|
|
15430
|
+
<summary>Sample Code</summary>
|
|
15431
|
+
```python
|
|
15432
|
+
.. include:: ../docs/include/samplecode/SpotifyClient/RemoveShowFavorites.py
|
|
15433
|
+
```
|
|
15434
|
+
</details>
|
|
15435
|
+
"""
|
|
15436
|
+
apiMethodName:str = 'RemoveShowFavorites'
|
|
15437
|
+
apiMethodParms:SIMethodParmListContext = None
|
|
15438
|
+
|
|
15439
|
+
try:
|
|
15440
|
+
|
|
15441
|
+
# trace.
|
|
15442
|
+
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
15443
|
+
apiMethodParms.AppendKeyValue("ids", ids)
|
|
15444
|
+
_logsi.LogMethodParmList(SILevel.Verbose, "Remove show(s) from user favorites", apiMethodParms)
|
|
15445
|
+
|
|
15446
|
+
# remove any leading / trailing spaces.
|
|
15447
|
+
if ids is not None:
|
|
15448
|
+
ids = ids.replace(' ','')
|
|
15449
|
+
|
|
15450
|
+
# if ids not specified, then return currently playing id value.
|
|
15451
|
+
if (ids is None) or (len(ids.strip()) == 0):
|
|
15452
|
+
uri = self.GetPlayerNowPlayingShowUri()
|
|
15453
|
+
if uri is not None:
|
|
15454
|
+
ids = SpotifyClient.GetIdFromUri(uri)
|
|
15455
|
+
else:
|
|
15456
|
+
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
15457
|
+
|
|
15458
|
+
# build a list of all item uri's from id values.
|
|
14934
15459
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
14935
|
-
arrUris:list[str] =
|
|
14936
|
-
for idx in range(0, len(arrUris)):
|
|
14937
|
-
arrUris[idx] = arrUris[idx].strip()
|
|
14938
|
-
|
|
14939
|
-
# build tracks dictionary.
|
|
14940
|
-
tracks:list[dict] = []
|
|
15460
|
+
arrUris:list[str] = ids.split(',')
|
|
14941
15461
|
for idx in range(0, len(arrUris)):
|
|
14942
|
-
|
|
15462
|
+
if (arrUris[idx].find(":") == -1):
|
|
15463
|
+
arrUris[idx] = SpotifyTypePrefixes.SHOW.value + arrUris[idx].strip()
|
|
14943
15464
|
|
|
14944
15465
|
# build spotify web api request parameters.
|
|
14945
|
-
|
|
15466
|
+
urlParms:dict = \
|
|
14946
15467
|
{
|
|
14947
|
-
'
|
|
15468
|
+
'uris': ",".join(arrUris)
|
|
14948
15469
|
}
|
|
14949
|
-
|
|
14950
|
-
reqData['snapshot_id'] = snapshotId
|
|
14951
|
-
|
|
15470
|
+
|
|
14952
15471
|
# execute spotify web api request.
|
|
14953
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/
|
|
15472
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
14954
15473
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
14955
|
-
msg.
|
|
15474
|
+
msg.UrlParameters = urlParms
|
|
14956
15475
|
self.MakeRequest('DELETE', msg)
|
|
14957
|
-
|
|
15476
|
+
|
|
14958
15477
|
# process results.
|
|
14959
|
-
|
|
14960
|
-
|
|
14961
|
-
# trace.
|
|
14962
|
-
_logsi.LogString(SILevel.Verbose, TRACE_METHOD_RESULT % apiMethodName, result)
|
|
14963
|
-
return result
|
|
15478
|
+
# no results to process - this is pass or fail.
|
|
15479
|
+
return
|
|
14964
15480
|
|
|
14965
15481
|
except SpotifyApiError: raise # pass handled exceptions on thru
|
|
14966
15482
|
except SpotifyWebApiError: raise # pass handled exceptions on thru
|
|
@@ -14976,21 +15492,21 @@ class SpotifyClient:
|
|
|
14976
15492
|
_logsi.LeaveMethod(SILevel.Debug, apiMethodName)
|
|
14977
15493
|
|
|
14978
15494
|
|
|
14979
|
-
def
|
|
15495
|
+
def RemoveTrackFavorites(
|
|
14980
15496
|
self,
|
|
14981
|
-
ids:str=None
|
|
15497
|
+
ids:str=None
|
|
14982
15498
|
) -> None:
|
|
14983
15499
|
"""
|
|
14984
|
-
Remove one or more
|
|
15500
|
+
Remove one or more tracks from the current user's 'Your Library'.
|
|
14985
15501
|
|
|
14986
15502
|
This method requires the `user-library-modify` scope.
|
|
14987
15503
|
|
|
14988
15504
|
Args:
|
|
14989
15505
|
ids (str):
|
|
14990
|
-
A comma-separated list of the Spotify
|
|
14991
|
-
Maximum:
|
|
14992
|
-
Example: `
|
|
14993
|
-
If null, the currently playing
|
|
15506
|
+
A comma-separated list of the Spotify ID's (or URI's) for the tracks.
|
|
15507
|
+
Maximum: 40 IDs.
|
|
15508
|
+
Example: `1kWUud3vY5ij5r62zxpTRy,4eoYKv2kDwJS7gRGh5q6SK`
|
|
15509
|
+
If null, the currently playing track uri id value is used.
|
|
14994
15510
|
|
|
14995
15511
|
Raises:
|
|
14996
15512
|
SpotifyWebApiError:
|
|
@@ -14999,7 +15515,7 @@ class SpotifyClient:
|
|
|
14999
15515
|
SpotifyApiError:
|
|
15000
15516
|
If the method fails for any other reason.
|
|
15001
15517
|
|
|
15002
|
-
No error will be raised if a
|
|
15518
|
+
No error will be raised if a track id in the list does not exist in the
|
|
15003
15519
|
user's 'Your Library'.
|
|
15004
15520
|
|
|
15005
15521
|
An SpotifyWebApiError will be raised if a specified album id does not exist
|
|
@@ -15008,11 +15524,11 @@ class SpotifyClient:
|
|
|
15008
15524
|
<details>
|
|
15009
15525
|
<summary>Sample Code</summary>
|
|
15010
15526
|
```python
|
|
15011
|
-
.. include:: ../docs/include/samplecode/SpotifyClient/
|
|
15527
|
+
.. include:: ../docs/include/samplecode/SpotifyClient/RemoveTrackFavorites.py
|
|
15012
15528
|
```
|
|
15013
15529
|
</details>
|
|
15014
15530
|
"""
|
|
15015
|
-
apiMethodName:str = '
|
|
15531
|
+
apiMethodName:str = 'RemoveTrackFavorites'
|
|
15016
15532
|
apiMethodParms:SIMethodParmListContext = None
|
|
15017
15533
|
|
|
15018
15534
|
try:
|
|
@@ -15020,28 +15536,35 @@ class SpotifyClient:
|
|
|
15020
15536
|
# trace.
|
|
15021
15537
|
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
15022
15538
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
15023
|
-
_logsi.LogMethodParmList(SILevel.Verbose, "Remove
|
|
15539
|
+
_logsi.LogMethodParmList(SILevel.Verbose, "Remove track(s) from user favorites", apiMethodParms)
|
|
15024
15540
|
|
|
15541
|
+
# remove any leading / trailing spaces.
|
|
15542
|
+
if ids is not None:
|
|
15543
|
+
ids = ids.replace(' ','')
|
|
15544
|
+
|
|
15025
15545
|
# if ids not specified, then return currently playing id value.
|
|
15026
15546
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
15027
|
-
uri = self.
|
|
15547
|
+
uri = self.GetPlayerNowPlayingUri(SpotifyMediaTypes.TRACK.value)
|
|
15028
15548
|
if uri is not None:
|
|
15029
15549
|
ids = SpotifyClient.GetIdFromUri(uri)
|
|
15030
15550
|
else:
|
|
15031
15551
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
15032
15552
|
|
|
15553
|
+
# build a list of all item uri's from id values.
|
|
15033
15554
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
15034
|
-
|
|
15035
|
-
|
|
15555
|
+
arrUris:list[str] = ids.split(',')
|
|
15556
|
+
for idx in range(0, len(arrUris)):
|
|
15557
|
+
if (arrUris[idx].find(":") == -1):
|
|
15558
|
+
arrUris[idx] = SpotifyTypePrefixes.TRACK.value + arrUris[idx].strip()
|
|
15036
15559
|
|
|
15037
15560
|
# build spotify web api request parameters.
|
|
15038
15561
|
urlParms:dict = \
|
|
15039
15562
|
{
|
|
15040
|
-
'
|
|
15563
|
+
'uris': ",".join(arrUris)
|
|
15041
15564
|
}
|
|
15042
15565
|
|
|
15043
15566
|
# execute spotify web api request.
|
|
15044
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
15567
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
15045
15568
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15046
15569
|
msg.UrlParameters = urlParms
|
|
15047
15570
|
self.MakeRequest('DELETE', msg)
|
|
@@ -15064,21 +15587,22 @@ class SpotifyClient:
|
|
|
15064
15587
|
_logsi.LeaveMethod(SILevel.Debug, apiMethodName)
|
|
15065
15588
|
|
|
15066
15589
|
|
|
15067
|
-
def
|
|
15590
|
+
def RemoveUserFavorites(
|
|
15068
15591
|
self,
|
|
15069
|
-
|
|
15592
|
+
uris:str=None
|
|
15070
15593
|
) -> None:
|
|
15071
15594
|
"""
|
|
15072
|
-
Remove one or more
|
|
15595
|
+
Remove one or more items from the current user's library.
|
|
15596
|
+
Accepts Spotify URIs for tracks, albums, episodes, shows, audiobooks, users, and playlists.
|
|
15073
15597
|
|
|
15074
|
-
This method requires the `user-library-modify`
|
|
15598
|
+
This method requires the `user-library-modify`, `user-follow-modify`, and `playlist-modify-public` scopes.
|
|
15075
15599
|
|
|
15076
15600
|
Args:
|
|
15077
|
-
|
|
15078
|
-
A comma-separated list of the Spotify
|
|
15079
|
-
Maximum:
|
|
15080
|
-
Example: `1kWUud3vY5ij5r62zxpTRy
|
|
15081
|
-
If null, the currently playing
|
|
15601
|
+
uris (str):
|
|
15602
|
+
A comma-separated list of the Spotify URIs for the items.
|
|
15603
|
+
Maximum: 40 URIs.
|
|
15604
|
+
Example: `spotify:artist:6APm8EjxOHSYM5B4i3vT3q,spotify:album:6vc9OTcyd3hyzabCmsdnwE,spotify:track:1kWUud3vY5ij5r62zxpTRy`
|
|
15605
|
+
If null, the currently playing item uri value is used.
|
|
15082
15606
|
|
|
15083
15607
|
Raises:
|
|
15084
15608
|
SpotifyWebApiError:
|
|
@@ -15087,53 +15611,51 @@ class SpotifyClient:
|
|
|
15087
15611
|
SpotifyApiError:
|
|
15088
15612
|
If the method fails for any other reason.
|
|
15089
15613
|
|
|
15090
|
-
No error will be raised if
|
|
15614
|
+
No error will be raised if an item uri in the list does not exist in the
|
|
15091
15615
|
user's 'Your Library'.
|
|
15092
15616
|
|
|
15093
|
-
An SpotifyWebApiError will be raised if a specified
|
|
15617
|
+
An SpotifyWebApiError will be raised if a specified item uri does not exist
|
|
15094
15618
|
in the Spotify music catalog.
|
|
15095
15619
|
|
|
15096
15620
|
<details>
|
|
15097
15621
|
<summary>Sample Code</summary>
|
|
15098
15622
|
```python
|
|
15099
|
-
.. include:: ../docs/include/samplecode/SpotifyClient/
|
|
15623
|
+
.. include:: ../docs/include/samplecode/SpotifyClient/RemoveUserFavorites.py
|
|
15100
15624
|
```
|
|
15101
15625
|
</details>
|
|
15102
15626
|
"""
|
|
15103
|
-
apiMethodName:str = '
|
|
15627
|
+
apiMethodName:str = 'RemoveUserFavorites'
|
|
15104
15628
|
apiMethodParms:SIMethodParmListContext = None
|
|
15105
15629
|
|
|
15106
15630
|
try:
|
|
15107
15631
|
|
|
15108
15632
|
# trace.
|
|
15109
15633
|
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
15110
|
-
apiMethodParms.AppendKeyValue("
|
|
15111
|
-
_logsi.LogMethodParmList(SILevel.Verbose, "Remove
|
|
15634
|
+
apiMethodParms.AppendKeyValue("uris", uris)
|
|
15635
|
+
_logsi.LogMethodParmList(SILevel.Verbose, "Remove item(s) from user favorites", apiMethodParms)
|
|
15112
15636
|
|
|
15113
|
-
# if
|
|
15114
|
-
if (
|
|
15115
|
-
|
|
15116
|
-
if
|
|
15117
|
-
|
|
15118
|
-
else:
|
|
15119
|
-
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
15637
|
+
# if uris not specified, then return currently playing item uri value.
|
|
15638
|
+
if (uris is None) or (len(uris.strip()) == 0):
|
|
15639
|
+
uris = self.GetPlayerNowPlayingUri(SpotifyMediaTypes.EPISODE.value, False)
|
|
15640
|
+
if uris is None:
|
|
15641
|
+
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'uris'), logsi=_logsi)
|
|
15120
15642
|
|
|
15121
|
-
# build a list of all item
|
|
15643
|
+
# build a list of all item uri's.
|
|
15122
15644
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
15123
|
-
|
|
15124
|
-
for idx in range(0, len(
|
|
15125
|
-
|
|
15645
|
+
arrUris:list[str] = uris.split(',')
|
|
15646
|
+
for idx in range(0, len(arrUris)):
|
|
15647
|
+
arrUris[idx] = arrUris[idx].strip()
|
|
15126
15648
|
|
|
15127
15649
|
# build spotify web api request parameters.
|
|
15128
|
-
|
|
15650
|
+
urlParms:dict = \
|
|
15129
15651
|
{
|
|
15130
|
-
'
|
|
15652
|
+
'uris': ",".join(arrUris)
|
|
15131
15653
|
}
|
|
15132
15654
|
|
|
15133
15655
|
# execute spotify web api request.
|
|
15134
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
15656
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
15135
15657
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15136
|
-
msg.
|
|
15658
|
+
msg.UrlParameters = urlParms
|
|
15137
15659
|
self.MakeRequest('DELETE', msg)
|
|
15138
15660
|
|
|
15139
15661
|
# process results.
|
|
@@ -15250,7 +15772,7 @@ class SpotifyClient:
|
|
|
15250
15772
|
reqData['snapshot_id'] = snapshotId
|
|
15251
15773
|
|
|
15252
15774
|
# execute spotify web api request.
|
|
15253
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{
|
|
15775
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}/items'.format(id=playlistId))
|
|
15254
15776
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15255
15777
|
msg.RequestJson = reqData
|
|
15256
15778
|
self.MakeRequest('PUT', msg)
|
|
@@ -15350,7 +15872,7 @@ class SpotifyClient:
|
|
|
15350
15872
|
}
|
|
15351
15873
|
|
|
15352
15874
|
# execute spotify web api request.
|
|
15353
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{
|
|
15875
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/playlists/{id}/items'.format(id=playlistId))
|
|
15354
15876
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15355
15877
|
msg.RequestJson = reqData
|
|
15356
15878
|
self.MakeRequest('PUT', msg)
|
|
@@ -15387,8 +15909,8 @@ class SpotifyClient:
|
|
|
15387
15909
|
|
|
15388
15910
|
Args:
|
|
15389
15911
|
ids (str):
|
|
15390
|
-
A comma-separated list of the Spotify
|
|
15391
|
-
Maximum:
|
|
15912
|
+
A comma-separated list of the Spotify ID's (or URI's) for the albums.
|
|
15913
|
+
Maximum: 40 IDs.
|
|
15392
15914
|
Example: `6vc9OTcyd3hyzabCmsdnwE,382ObEPsp2rxGrnsizN5TX,2noRn2Aes5aoNVsU6iWThc`
|
|
15393
15915
|
If null, the currently playing track album uri id value is used.
|
|
15394
15916
|
|
|
@@ -15422,6 +15944,10 @@ class SpotifyClient:
|
|
|
15422
15944
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
15423
15945
|
_logsi.LogMethodParmList(SILevel.Verbose, "Save album(s) to user favorites", apiMethodParms)
|
|
15424
15946
|
|
|
15947
|
+
# remove any leading / trailing spaces.
|
|
15948
|
+
if ids is not None:
|
|
15949
|
+
ids = ids.replace(' ','')
|
|
15950
|
+
|
|
15425
15951
|
# if ids not specified, then return currently playing album id value.
|
|
15426
15952
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
15427
15953
|
uri = self.GetPlayerNowPlayingAlbumUri()
|
|
@@ -15430,22 +15956,23 @@ class SpotifyClient:
|
|
|
15430
15956
|
else:
|
|
15431
15957
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
15432
15958
|
|
|
15433
|
-
# build a list of all item
|
|
15959
|
+
# build a list of all item uri's from id values.
|
|
15434
15960
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
15435
|
-
|
|
15436
|
-
for idx in range(0, len(
|
|
15437
|
-
|
|
15438
|
-
|
|
15961
|
+
arrUris:list[str] = ids.split(',')
|
|
15962
|
+
for idx in range(0, len(arrUris)):
|
|
15963
|
+
if (arrUris[idx].find(":") == -1):
|
|
15964
|
+
arrUris[idx] = SpotifyTypePrefixes.ALBUM.value + arrUris[idx].strip()
|
|
15965
|
+
|
|
15439
15966
|
# build spotify web api request parameters.
|
|
15440
|
-
|
|
15967
|
+
urlParms:dict = \
|
|
15441
15968
|
{
|
|
15442
|
-
'
|
|
15969
|
+
'uris': ",".join(arrUris)
|
|
15443
15970
|
}
|
|
15444
15971
|
|
|
15445
15972
|
# execute spotify web api request.
|
|
15446
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
15973
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
15447
15974
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15448
|
-
msg.
|
|
15975
|
+
msg.UrlParameters = urlParms
|
|
15449
15976
|
self.MakeRequest('PUT', msg)
|
|
15450
15977
|
|
|
15451
15978
|
# process results.
|
|
@@ -15477,8 +16004,8 @@ class SpotifyClient:
|
|
|
15477
16004
|
|
|
15478
16005
|
Args:
|
|
15479
16006
|
ids (str):
|
|
15480
|
-
A comma-separated list of the Spotify
|
|
15481
|
-
Maximum:
|
|
16007
|
+
A comma-separated list of the Spotify ID's (or URI's) for the audiobooks.
|
|
16008
|
+
Maximum: 40 IDs.
|
|
15482
16009
|
Example: `3PFyizE2tGCSRLusl2Qizf,7iHfbu1YPACw6oZPAFJtqe`
|
|
15483
16010
|
If null, the currently playing audiobook uri id value is used.
|
|
15484
16011
|
|
|
@@ -15512,6 +16039,10 @@ class SpotifyClient:
|
|
|
15512
16039
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
15513
16040
|
_logsi.LogMethodParmList(SILevel.Verbose, "Save audiobook(s) to user favorites", apiMethodParms)
|
|
15514
16041
|
|
|
16042
|
+
# remove any leading / trailing spaces.
|
|
16043
|
+
if ids is not None:
|
|
16044
|
+
ids = ids.replace(' ','')
|
|
16045
|
+
|
|
15515
16046
|
# if ids not specified, then return currently playing id value.
|
|
15516
16047
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
15517
16048
|
uri = self.GetPlayerNowPlayingAudiobookUri()
|
|
@@ -15520,24 +16051,25 @@ class SpotifyClient:
|
|
|
15520
16051
|
else:
|
|
15521
16052
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
15522
16053
|
|
|
15523
|
-
# build a list of all item
|
|
16054
|
+
# build a list of all item uri's from id values.
|
|
15524
16055
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
15525
|
-
|
|
15526
|
-
for idx in range(0, len(
|
|
15527
|
-
|
|
16056
|
+
arrUris:list[str] = ids.split(',')
|
|
16057
|
+
for idx in range(0, len(arrUris)):
|
|
16058
|
+
if (arrUris[idx].find(":") == -1):
|
|
16059
|
+
arrUris[idx] = SpotifyTypePrefixes.SHOW.value + arrUris[idx].strip() # spotify web api considers audiobook a "show"!
|
|
15528
16060
|
|
|
15529
16061
|
# build spotify web api request parameters.
|
|
15530
|
-
|
|
16062
|
+
urlParms:dict = \
|
|
15531
16063
|
{
|
|
15532
|
-
'
|
|
16064
|
+
'uris': ",".join(arrUris)
|
|
15533
16065
|
}
|
|
15534
16066
|
|
|
15535
16067
|
# execute spotify web api request.
|
|
15536
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
16068
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
15537
16069
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15538
|
-
msg.
|
|
16070
|
+
msg.UrlParameters = urlParms
|
|
15539
16071
|
self.MakeRequest('PUT', msg)
|
|
15540
|
-
|
|
16072
|
+
|
|
15541
16073
|
# process results.
|
|
15542
16074
|
# no results to process - this is pass or fail.
|
|
15543
16075
|
return
|
|
@@ -15567,8 +16099,8 @@ class SpotifyClient:
|
|
|
15567
16099
|
|
|
15568
16100
|
Args:
|
|
15569
16101
|
ids (str):
|
|
15570
|
-
A comma-separated list of the Spotify
|
|
15571
|
-
Maximum:
|
|
16102
|
+
A comma-separated list of the Spotify ID's (or URI's) for the episodes.
|
|
16103
|
+
Maximum: 40 IDs.
|
|
15572
16104
|
Example: `6kAsbP8pxwaU2kPibKTuHE,4rOoJ6Egrf8K2IrywzwOMk`
|
|
15573
16105
|
If null, the currently playing episode uri id value is used.
|
|
15574
16106
|
|
|
@@ -15602,6 +16134,10 @@ class SpotifyClient:
|
|
|
15602
16134
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
15603
16135
|
_logsi.LogMethodParmList(SILevel.Verbose, "Save episode(s) to user favorites", apiMethodParms)
|
|
15604
16136
|
|
|
16137
|
+
# remove any leading / trailing spaces.
|
|
16138
|
+
if ids is not None:
|
|
16139
|
+
ids = ids.replace(' ','')
|
|
16140
|
+
|
|
15605
16141
|
# if ids not specified, then return currently playing id value.
|
|
15606
16142
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
15607
16143
|
uri = self.GetPlayerNowPlayingUri(SpotifyMediaTypes.EPISODE.value)
|
|
@@ -15610,22 +16146,23 @@ class SpotifyClient:
|
|
|
15610
16146
|
else:
|
|
15611
16147
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
15612
16148
|
|
|
15613
|
-
# build a list of all item
|
|
16149
|
+
# build a list of all item uri's from id values.
|
|
15614
16150
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
15615
|
-
|
|
15616
|
-
for idx in range(0, len(
|
|
15617
|
-
|
|
16151
|
+
arrUris:list[str] = ids.split(',')
|
|
16152
|
+
for idx in range(0, len(arrUris)):
|
|
16153
|
+
if (arrUris[idx].find(":") == -1):
|
|
16154
|
+
arrUris[idx] = SpotifyTypePrefixes.EPISODE.value + arrUris[idx].strip()
|
|
15618
16155
|
|
|
15619
16156
|
# build spotify web api request parameters.
|
|
15620
|
-
|
|
16157
|
+
urlParms:dict = \
|
|
15621
16158
|
{
|
|
15622
|
-
'
|
|
16159
|
+
'uris': ",".join(arrUris)
|
|
15623
16160
|
}
|
|
15624
16161
|
|
|
15625
16162
|
# execute spotify web api request.
|
|
15626
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
16163
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
15627
16164
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15628
|
-
msg.
|
|
16165
|
+
msg.UrlParameters = urlParms
|
|
15629
16166
|
self.MakeRequest('PUT', msg)
|
|
15630
16167
|
|
|
15631
16168
|
# process results.
|
|
@@ -15657,8 +16194,8 @@ class SpotifyClient:
|
|
|
15657
16194
|
|
|
15658
16195
|
Args:
|
|
15659
16196
|
ids (str):
|
|
15660
|
-
A comma-separated list of the Spotify
|
|
15661
|
-
Maximum:
|
|
16197
|
+
A comma-separated list of the Spotify ID's (or URI's) for the shows.
|
|
16198
|
+
Maximum: 40 IDs.
|
|
15662
16199
|
Example: `6kAsbP8pxwaU2kPibKTuHE,4rOoJ6Egrf8K2IrywzwOMk`
|
|
15663
16200
|
If null, the currently playing show uri id value is used.
|
|
15664
16201
|
|
|
@@ -15692,6 +16229,10 @@ class SpotifyClient:
|
|
|
15692
16229
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
15693
16230
|
_logsi.LogMethodParmList(SILevel.Verbose, "Save show(s) to user favorites", apiMethodParms)
|
|
15694
16231
|
|
|
16232
|
+
# remove any leading / trailing spaces.
|
|
16233
|
+
if ids is not None:
|
|
16234
|
+
ids = ids.replace(' ','')
|
|
16235
|
+
|
|
15695
16236
|
# if ids not specified, then return currently playing id value.
|
|
15696
16237
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
15697
16238
|
uri = self.GetPlayerNowPlayingShowUri()
|
|
@@ -15700,18 +16241,21 @@ class SpotifyClient:
|
|
|
15700
16241
|
else:
|
|
15701
16242
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
15702
16243
|
|
|
16244
|
+
# build a list of all item uri's from id values.
|
|
15703
16245
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
15704
|
-
|
|
15705
|
-
|
|
16246
|
+
arrUris:list[str] = ids.split(',')
|
|
16247
|
+
for idx in range(0, len(arrUris)):
|
|
16248
|
+
if (arrUris[idx].find(":") == -1):
|
|
16249
|
+
arrUris[idx] = SpotifyTypePrefixes.SHOW.value + arrUris[idx].strip()
|
|
15706
16250
|
|
|
15707
16251
|
# build spotify web api request parameters.
|
|
15708
16252
|
urlParms:dict = \
|
|
15709
16253
|
{
|
|
15710
|
-
'
|
|
16254
|
+
'uris': ",".join(arrUris)
|
|
15711
16255
|
}
|
|
15712
16256
|
|
|
15713
16257
|
# execute spotify web api request.
|
|
15714
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
16258
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
15715
16259
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15716
16260
|
msg.UrlParameters = urlParms
|
|
15717
16261
|
self.MakeRequest('PUT', msg)
|
|
@@ -15745,8 +16289,8 @@ class SpotifyClient:
|
|
|
15745
16289
|
|
|
15746
16290
|
Args:
|
|
15747
16291
|
ids (str):
|
|
15748
|
-
A comma-separated list of the Spotify
|
|
15749
|
-
Maximum:
|
|
16292
|
+
A comma-separated list of the Spotify ID's (or URI's) for the tracks.
|
|
16293
|
+
Maximum: 40 IDs.
|
|
15750
16294
|
Example: `6vc9OTcyd3hyzabCmsdnwE,382ObEPsp2rxGrnsizN5TX,2noRn2Aes5aoNVsU6iWThc`
|
|
15751
16295
|
If null, the currently playing track uri id value is used.
|
|
15752
16296
|
|
|
@@ -15780,6 +16324,10 @@ class SpotifyClient:
|
|
|
15780
16324
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
15781
16325
|
_logsi.LogMethodParmList(SILevel.Verbose, "Save track(s) to user favorites", apiMethodParms)
|
|
15782
16326
|
|
|
16327
|
+
# remove any leading / trailing spaces.
|
|
16328
|
+
if ids is not None:
|
|
16329
|
+
ids = ids.replace(' ','')
|
|
16330
|
+
|
|
15783
16331
|
# if ids not specified, then return currently playing id value.
|
|
15784
16332
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
15785
16333
|
uri = self.GetPlayerNowPlayingUri(SpotifyMediaTypes.TRACK.value)
|
|
@@ -15788,22 +16336,112 @@ class SpotifyClient:
|
|
|
15788
16336
|
else:
|
|
15789
16337
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
15790
16338
|
|
|
15791
|
-
# build a list of all item
|
|
16339
|
+
# build a list of all item uri's from id values.
|
|
15792
16340
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
15793
|
-
|
|
15794
|
-
for idx in range(0, len(
|
|
15795
|
-
|
|
16341
|
+
arrUris:list[str] = ids.split(',')
|
|
16342
|
+
for idx in range(0, len(arrUris)):
|
|
16343
|
+
if (arrUris[idx].find(":") == -1):
|
|
16344
|
+
arrUris[idx] = SpotifyTypePrefixes.TRACK.value + arrUris[idx].strip()
|
|
15796
16345
|
|
|
15797
16346
|
# build spotify web api request parameters.
|
|
15798
|
-
|
|
16347
|
+
urlParms:dict = \
|
|
15799
16348
|
{
|
|
15800
|
-
'
|
|
16349
|
+
'uris': ",".join(arrUris)
|
|
15801
16350
|
}
|
|
15802
16351
|
|
|
15803
16352
|
# execute spotify web api request.
|
|
15804
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
16353
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
15805
16354
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
15806
|
-
msg.
|
|
16355
|
+
msg.UrlParameters = urlParms
|
|
16356
|
+
self.MakeRequest('PUT', msg)
|
|
16357
|
+
|
|
16358
|
+
# process results.
|
|
16359
|
+
# no results to process - this is pass or fail.
|
|
16360
|
+
return
|
|
16361
|
+
|
|
16362
|
+
except SpotifyApiError: raise # pass handled exceptions on thru
|
|
16363
|
+
except SpotifyWebApiError: raise # pass handled exceptions on thru
|
|
16364
|
+
except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
|
|
16365
|
+
except Exception as ex:
|
|
16366
|
+
|
|
16367
|
+
# format unhandled exception.
|
|
16368
|
+
raise SpotifyApiError(SAAppMessages.UNHANDLED_EXCEPTION.format(apiMethodName, str(ex)), ex, logsi=_logsi)
|
|
16369
|
+
|
|
16370
|
+
finally:
|
|
16371
|
+
|
|
16372
|
+
# trace.
|
|
16373
|
+
_logsi.LeaveMethod(SILevel.Debug, apiMethodName)
|
|
16374
|
+
|
|
16375
|
+
|
|
16376
|
+
def SaveUserFavorites(
|
|
16377
|
+
self,
|
|
16378
|
+
uris:str=None
|
|
16379
|
+
) -> None:
|
|
16380
|
+
"""
|
|
16381
|
+
Add one or more items to the current user's library.
|
|
16382
|
+
Accepts Spotify URIs for tracks, albums, episodes, shows, audiobooks, users, and playlists.
|
|
16383
|
+
|
|
16384
|
+
This method requires the `user-library-modify`, `user-follow-modify`, and `playlist-modify-public` scopes.
|
|
16385
|
+
|
|
16386
|
+
Args:
|
|
16387
|
+
uris (str):
|
|
16388
|
+
A comma-separated list of the Spotify URIs for the items.
|
|
16389
|
+
Maximum: 40 URIs.
|
|
16390
|
+
Example: `spotify:artist:6APm8EjxOHSYM5B4i3vT3q,spotify:album:6vc9OTcyd3hyzabCmsdnwE,spotify:track:1kWUud3vY5ij5r62zxpTRy`
|
|
16391
|
+
If null, the currently playing item uri value is used.
|
|
16392
|
+
|
|
16393
|
+
Raises:
|
|
16394
|
+
SpotifyWebApiError:
|
|
16395
|
+
If the Spotify Web API request was for a non-authorization service
|
|
16396
|
+
and the response contains error information.
|
|
16397
|
+
SpotifyApiError:
|
|
16398
|
+
If the method fails for any other reason.
|
|
16399
|
+
|
|
16400
|
+
No error will be raised if an item uri in the list already exists in the
|
|
16401
|
+
user's 'Your Library'.
|
|
16402
|
+
|
|
16403
|
+
An SpotifyWebApiError will be raised if a specified item uri does not exist
|
|
16404
|
+
in the Spotify music catalog.
|
|
16405
|
+
|
|
16406
|
+
<details>
|
|
16407
|
+
<summary>Sample Code</summary>
|
|
16408
|
+
```python
|
|
16409
|
+
.. include:: ../docs/include/samplecode/SpotifyClient/SaveUserFavorites.py
|
|
16410
|
+
```
|
|
16411
|
+
</details>
|
|
16412
|
+
"""
|
|
16413
|
+
apiMethodName:str = 'SaveUserFavorites'
|
|
16414
|
+
apiMethodParms:SIMethodParmListContext = None
|
|
16415
|
+
|
|
16416
|
+
try:
|
|
16417
|
+
|
|
16418
|
+
# trace.
|
|
16419
|
+
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
16420
|
+
apiMethodParms.AppendKeyValue("uris", uris)
|
|
16421
|
+
_logsi.LogMethodParmList(SILevel.Verbose, "Save item(s) to user favorites", apiMethodParms)
|
|
16422
|
+
|
|
16423
|
+
# if uris not specified, then return currently playing item uri value.
|
|
16424
|
+
if (uris is None) or (len(uris.strip()) == 0):
|
|
16425
|
+
uris = self.GetPlayerNowPlayingUri(SpotifyMediaTypes.EPISODE.value, False)
|
|
16426
|
+
if uris is None:
|
|
16427
|
+
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'uris'), logsi=_logsi)
|
|
16428
|
+
|
|
16429
|
+
# build a list of all item uri's.
|
|
16430
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
16431
|
+
arrUris:list[str] = uris.split(',')
|
|
16432
|
+
for idx in range(0, len(arrUris)):
|
|
16433
|
+
arrUris[idx] = arrUris[idx].strip()
|
|
16434
|
+
|
|
16435
|
+
# build spotify web api request parameters.
|
|
16436
|
+
urlParms:dict = \
|
|
16437
|
+
{
|
|
16438
|
+
'uris': ",".join(arrUris)
|
|
16439
|
+
}
|
|
16440
|
+
|
|
16441
|
+
# execute spotify web api request.
|
|
16442
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
16443
|
+
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
16444
|
+
msg.UrlParameters = urlParms
|
|
15807
16445
|
self.MakeRequest('PUT', msg)
|
|
15808
16446
|
|
|
15809
16447
|
# process results.
|
|
@@ -15874,7 +16512,7 @@ class SpotifyClient:
|
|
|
15874
16512
|
The maximum number of items to return for the request, per criteria type.
|
|
15875
16513
|
Paging is automatically used to retrieve all available items up to the
|
|
15876
16514
|
maximum number specified per type.
|
|
15877
|
-
Default:
|
|
16515
|
+
Default: 10
|
|
15878
16516
|
|
|
15879
16517
|
Returns:
|
|
15880
16518
|
A `SearchResponse` object that contains the search results.
|
|
@@ -15921,12 +16559,12 @@ class SpotifyClient:
|
|
|
15921
16559
|
if isinstance(criteriaType, SpotifyMediaTypes):
|
|
15922
16560
|
criteriaType = SpotifyMediaTypes.value
|
|
15923
16561
|
if limitTotal is None:
|
|
15924
|
-
limitTotal =
|
|
16562
|
+
limitTotal = 10
|
|
15925
16563
|
if not isinstance(limitTotal, int):
|
|
15926
|
-
limitTotal =
|
|
16564
|
+
limitTotal = 10
|
|
15927
16565
|
|
|
15928
16566
|
# are we auto-paging? if so, then use max limit.
|
|
15929
|
-
limit:int =
|
|
16567
|
+
limit:int = 10
|
|
15930
16568
|
if limit > limitTotal:
|
|
15931
16569
|
limit = limitTotal
|
|
15932
16570
|
|
|
@@ -15994,7 +16632,7 @@ class SpotifyClient:
|
|
|
15994
16632
|
def SearchAlbums(
|
|
15995
16633
|
self,
|
|
15996
16634
|
criteria:str,
|
|
15997
|
-
limit:int=
|
|
16635
|
+
limit:int=5,
|
|
15998
16636
|
offset:int=0,
|
|
15999
16637
|
market:str=None,
|
|
16000
16638
|
includeExternal:str=None,
|
|
@@ -16188,7 +16826,7 @@ class SpotifyClient:
|
|
|
16188
16826
|
def SearchArtists(
|
|
16189
16827
|
self,
|
|
16190
16828
|
criteria:str,
|
|
16191
|
-
limit:int=
|
|
16829
|
+
limit:int=5,
|
|
16192
16830
|
offset:int=0,
|
|
16193
16831
|
market:str=None,
|
|
16194
16832
|
includeExternal:str=None,
|
|
@@ -16213,7 +16851,7 @@ class SpotifyClient:
|
|
|
16213
16851
|
can be used to return only albums with the lowest 10% popularity.
|
|
16214
16852
|
limit (int):
|
|
16215
16853
|
The maximum number of items to return in a page of items when manual paging is used.
|
|
16216
|
-
Default:
|
|
16854
|
+
Default: 5, Range: 1 to 10.
|
|
16217
16855
|
See the `limitTotal` argument for automatic paging option.
|
|
16218
16856
|
offset (int):
|
|
16219
16857
|
The page index offset of the first item to return.
|
|
@@ -16285,7 +16923,7 @@ class SpotifyClient:
|
|
|
16285
16923
|
|
|
16286
16924
|
# validations.
|
|
16287
16925
|
if limit is None:
|
|
16288
|
-
limit =
|
|
16926
|
+
limit = 5
|
|
16289
16927
|
if offset is None:
|
|
16290
16928
|
offset = 0
|
|
16291
16929
|
if not isinstance(limitTotal, int):
|
|
@@ -16293,7 +16931,7 @@ class SpotifyClient:
|
|
|
16293
16931
|
|
|
16294
16932
|
# are we auto-paging? if so, then use max limit.
|
|
16295
16933
|
if limitTotal > 0:
|
|
16296
|
-
limit =
|
|
16934
|
+
limit = 10
|
|
16297
16935
|
if limit > limitTotal:
|
|
16298
16936
|
limit = limitTotal
|
|
16299
16937
|
result = ArtistPage()
|
|
@@ -16382,7 +17020,7 @@ class SpotifyClient:
|
|
|
16382
17020
|
def SearchAudiobooks(
|
|
16383
17021
|
self,
|
|
16384
17022
|
criteria:str,
|
|
16385
|
-
limit:int=
|
|
17023
|
+
limit:int=5,
|
|
16386
17024
|
offset:int=0,
|
|
16387
17025
|
market:str=None,
|
|
16388
17026
|
includeExternal:str=None,
|
|
@@ -16407,7 +17045,7 @@ class SpotifyClient:
|
|
|
16407
17045
|
can be used to return only albums with the lowest 10% popularity.
|
|
16408
17046
|
limit (int):
|
|
16409
17047
|
The maximum number of items to return in a page of items when manual paging is used.
|
|
16410
|
-
Default:
|
|
17048
|
+
Default: 5, Range: 1 to 10.
|
|
16411
17049
|
See the `limitTotal` argument for automatic paging option.
|
|
16412
17050
|
offset (int):
|
|
16413
17051
|
The page index offset of the first item to return.
|
|
@@ -16481,7 +17119,7 @@ class SpotifyClient:
|
|
|
16481
17119
|
|
|
16482
17120
|
# validations.
|
|
16483
17121
|
if limit is None:
|
|
16484
|
-
limit =
|
|
17122
|
+
limit = 5
|
|
16485
17123
|
if offset is None:
|
|
16486
17124
|
offset = 0
|
|
16487
17125
|
if not isinstance(limitTotal, int):
|
|
@@ -16489,7 +17127,7 @@ class SpotifyClient:
|
|
|
16489
17127
|
|
|
16490
17128
|
# are we auto-paging? if so, then use max limit.
|
|
16491
17129
|
if limitTotal > 0:
|
|
16492
|
-
limit =
|
|
17130
|
+
limit = 10
|
|
16493
17131
|
if limit > limitTotal:
|
|
16494
17132
|
limit = limitTotal
|
|
16495
17133
|
result = AudiobookPageSimplified()
|
|
@@ -16578,7 +17216,7 @@ class SpotifyClient:
|
|
|
16578
17216
|
def SearchEpisodes(
|
|
16579
17217
|
self,
|
|
16580
17218
|
criteria:str,
|
|
16581
|
-
limit:int=
|
|
17219
|
+
limit:int=5,
|
|
16582
17220
|
offset:int=0,
|
|
16583
17221
|
market:str=None,
|
|
16584
17222
|
includeExternal:str=None,
|
|
@@ -16603,7 +17241,7 @@ class SpotifyClient:
|
|
|
16603
17241
|
can be used to return only albums with the lowest 10% popularity.
|
|
16604
17242
|
limit (int):
|
|
16605
17243
|
The maximum number of items to return in a page of items when manual paging is used.
|
|
16606
|
-
Default:
|
|
17244
|
+
Default: 5, Range: 1 to 10.
|
|
16607
17245
|
See the `limitTotal` argument for automatic paging option.
|
|
16608
17246
|
offset (int):
|
|
16609
17247
|
The page index offset of the first item to return.
|
|
@@ -16675,7 +17313,7 @@ class SpotifyClient:
|
|
|
16675
17313
|
|
|
16676
17314
|
# validations.
|
|
16677
17315
|
if limit is None:
|
|
16678
|
-
limit =
|
|
17316
|
+
limit = 5
|
|
16679
17317
|
if offset is None:
|
|
16680
17318
|
offset = 0
|
|
16681
17319
|
if not isinstance(limitTotal, int):
|
|
@@ -16683,7 +17321,7 @@ class SpotifyClient:
|
|
|
16683
17321
|
|
|
16684
17322
|
# are we auto-paging? if so, then use max limit.
|
|
16685
17323
|
if limitTotal > 0:
|
|
16686
|
-
limit =
|
|
17324
|
+
limit = 10
|
|
16687
17325
|
if limit > limitTotal:
|
|
16688
17326
|
limit = limitTotal
|
|
16689
17327
|
result = EpisodePageSimplified()
|
|
@@ -16772,7 +17410,7 @@ class SpotifyClient:
|
|
|
16772
17410
|
def SearchPlaylists(
|
|
16773
17411
|
self,
|
|
16774
17412
|
criteria:str,
|
|
16775
|
-
limit:int=
|
|
17413
|
+
limit:int=5,
|
|
16776
17414
|
offset:int=0,
|
|
16777
17415
|
market:str=None,
|
|
16778
17416
|
includeExternal:str=None,
|
|
@@ -16797,7 +17435,7 @@ class SpotifyClient:
|
|
|
16797
17435
|
can be used to return only albums with the lowest 10% popularity.
|
|
16798
17436
|
limit (int):
|
|
16799
17437
|
The maximum number of items to return in a page of items when manual paging is used.
|
|
16800
|
-
Default:
|
|
17438
|
+
Default: 5, Range: 1 to 10.
|
|
16801
17439
|
See the `limitTotal` argument for automatic paging option.
|
|
16802
17440
|
offset (int):
|
|
16803
17441
|
The page index offset of the first item to return.
|
|
@@ -16869,7 +17507,7 @@ class SpotifyClient:
|
|
|
16869
17507
|
|
|
16870
17508
|
# validations.
|
|
16871
17509
|
if limit is None:
|
|
16872
|
-
limit =
|
|
17510
|
+
limit = 5
|
|
16873
17511
|
if offset is None:
|
|
16874
17512
|
offset = 0
|
|
16875
17513
|
if not isinstance(limitTotal, int):
|
|
@@ -16877,7 +17515,7 @@ class SpotifyClient:
|
|
|
16877
17515
|
|
|
16878
17516
|
# are we auto-paging? if so, then use max limit.
|
|
16879
17517
|
if limitTotal > 0:
|
|
16880
|
-
limit =
|
|
17518
|
+
limit = 10
|
|
16881
17519
|
if limit > limitTotal:
|
|
16882
17520
|
limit = limitTotal
|
|
16883
17521
|
result = PlaylistPageSimplified()
|
|
@@ -16966,7 +17604,7 @@ class SpotifyClient:
|
|
|
16966
17604
|
def SearchShows(
|
|
16967
17605
|
self,
|
|
16968
17606
|
criteria:str,
|
|
16969
|
-
limit:int=
|
|
17607
|
+
limit:int=5,
|
|
16970
17608
|
offset:int=0,
|
|
16971
17609
|
market:str=None,
|
|
16972
17610
|
includeExternal:str=None,
|
|
@@ -16991,7 +17629,7 @@ class SpotifyClient:
|
|
|
16991
17629
|
can be used to return only albums with the lowest 10% popularity.
|
|
16992
17630
|
limit (int):
|
|
16993
17631
|
The maximum number of items to return in a page of items when manual paging is used.
|
|
16994
|
-
Default:
|
|
17632
|
+
Default: 5, Range: 1 to 10.
|
|
16995
17633
|
See the `limitTotal` argument for automatic paging option.
|
|
16996
17634
|
offset (int):
|
|
16997
17635
|
The page index offset of the first item to return.
|
|
@@ -17063,7 +17701,7 @@ class SpotifyClient:
|
|
|
17063
17701
|
|
|
17064
17702
|
# validations.
|
|
17065
17703
|
if limit is None:
|
|
17066
|
-
limit =
|
|
17704
|
+
limit = 5
|
|
17067
17705
|
if offset is None:
|
|
17068
17706
|
offset = 0
|
|
17069
17707
|
if not isinstance(limitTotal, int):
|
|
@@ -17071,7 +17709,7 @@ class SpotifyClient:
|
|
|
17071
17709
|
|
|
17072
17710
|
# are we auto-paging? if so, then use max limit.
|
|
17073
17711
|
if limitTotal > 0:
|
|
17074
|
-
limit =
|
|
17712
|
+
limit = 10
|
|
17075
17713
|
if limit > limitTotal:
|
|
17076
17714
|
limit = limitTotal
|
|
17077
17715
|
result = ShowPageSimplified()
|
|
@@ -17160,7 +17798,7 @@ class SpotifyClient:
|
|
|
17160
17798
|
def SearchTracks(
|
|
17161
17799
|
self,
|
|
17162
17800
|
criteria:str,
|
|
17163
|
-
limit:int=
|
|
17801
|
+
limit:int=5,
|
|
17164
17802
|
offset:int=0,
|
|
17165
17803
|
market:str=None,
|
|
17166
17804
|
includeExternal:str=None,
|
|
@@ -17185,7 +17823,7 @@ class SpotifyClient:
|
|
|
17185
17823
|
can be used to return only albums with the lowest 10% popularity.
|
|
17186
17824
|
limit (int):
|
|
17187
17825
|
The maximum number of items to return in a page of items when manual paging is used.
|
|
17188
|
-
Default:
|
|
17826
|
+
Default: 5, Range: 1 to 10.
|
|
17189
17827
|
See the `limitTotal` argument for automatic paging option.
|
|
17190
17828
|
offset (int):
|
|
17191
17829
|
The page index offset of the first item to return.
|
|
@@ -17257,7 +17895,7 @@ class SpotifyClient:
|
|
|
17257
17895
|
|
|
17258
17896
|
# validations.
|
|
17259
17897
|
if limit is None:
|
|
17260
|
-
limit =
|
|
17898
|
+
limit = 5
|
|
17261
17899
|
if offset is None:
|
|
17262
17900
|
offset = 0
|
|
17263
17901
|
if not isinstance(limitTotal, int):
|
|
@@ -17265,7 +17903,7 @@ class SpotifyClient:
|
|
|
17265
17903
|
|
|
17266
17904
|
# are we auto-paging? if so, then use max limit.
|
|
17267
17905
|
if limitTotal > 0:
|
|
17268
|
-
limit =
|
|
17906
|
+
limit = 10
|
|
17269
17907
|
if limit > limitTotal:
|
|
17270
17908
|
limit = limitTotal
|
|
17271
17909
|
result = TrackPage()
|
|
@@ -17990,7 +18628,7 @@ class SpotifyClient:
|
|
|
17990
18628
|
Args:
|
|
17991
18629
|
ids (str):
|
|
17992
18630
|
A comma-separated list of Spotify artist IDs.
|
|
17993
|
-
A maximum of
|
|
18631
|
+
A maximum of 40 IDs can be sent in one request.
|
|
17994
18632
|
Example: `2CIMQHirSU0MQqyYHq0eOx,1IQ2e1buppatiN1bxUVkrk`
|
|
17995
18633
|
If null, the currently playing track artist uri id value is used.
|
|
17996
18634
|
|
|
@@ -18020,6 +18658,10 @@ class SpotifyClient:
|
|
|
18020
18658
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
18021
18659
|
_logsi.LogMethodParmList(SILevel.Verbose, "Remove the current user as a follower of one or more artists", apiMethodParms)
|
|
18022
18660
|
|
|
18661
|
+
# remove any leading / trailing spaces.
|
|
18662
|
+
if ids is not None:
|
|
18663
|
+
ids = ids.replace(' ','')
|
|
18664
|
+
|
|
18023
18665
|
# if ids not specified, then return currently playing artist id value.
|
|
18024
18666
|
if (ids is None) or (len(ids.strip()) == 0):
|
|
18025
18667
|
uri = self.GetPlayerNowPlayingArtistUri()
|
|
@@ -18028,22 +18670,23 @@ class SpotifyClient:
|
|
|
18028
18670
|
else:
|
|
18029
18671
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'ids'), logsi=_logsi)
|
|
18030
18672
|
|
|
18031
|
-
# build a list of all item
|
|
18673
|
+
# build a list of all item uri's from id values.
|
|
18032
18674
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
18033
|
-
|
|
18034
|
-
for idx in range(0, len(
|
|
18035
|
-
|
|
18675
|
+
arrUris:list[str] = ids.split(',')
|
|
18676
|
+
for idx in range(0, len(arrUris)):
|
|
18677
|
+
if (arrUris[idx].find(":") == -1):
|
|
18678
|
+
arrUris[idx] = SpotifyTypePrefixes.ARTIST.value + arrUris[idx].strip()
|
|
18036
18679
|
|
|
18037
18680
|
# build spotify web api request parameters.
|
|
18038
|
-
|
|
18681
|
+
urlParms:dict = \
|
|
18039
18682
|
{
|
|
18040
|
-
'
|
|
18683
|
+
'uris': ",".join(arrUris)
|
|
18041
18684
|
}
|
|
18042
18685
|
|
|
18043
18686
|
# execute spotify web api request.
|
|
18044
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
18687
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
18045
18688
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
18046
|
-
msg.
|
|
18689
|
+
msg.UrlParameters = urlParms
|
|
18047
18690
|
self.MakeRequest('DELETE', msg)
|
|
18048
18691
|
|
|
18049
18692
|
# process results.
|
|
@@ -18075,7 +18718,8 @@ class SpotifyClient:
|
|
|
18075
18718
|
|
|
18076
18719
|
Args:
|
|
18077
18720
|
playlistId (str):
|
|
18078
|
-
|
|
18721
|
+
A comma-separated list of Spotify playlist IDs.
|
|
18722
|
+
A maximum of 40 IDs can be sent in one request.
|
|
18079
18723
|
Example: `3cEYpjA9oz9GiPac4AsH4n`
|
|
18080
18724
|
If null, the currently playing playlist uri id value is used.
|
|
18081
18725
|
|
|
@@ -18103,6 +18747,10 @@ class SpotifyClient:
|
|
|
18103
18747
|
apiMethodParms.AppendKeyValue("playlistId", playlistId)
|
|
18104
18748
|
_logsi.LogMethodParmList(SILevel.Verbose, "Remove the current user as a follower of a playlist", apiMethodParms)
|
|
18105
18749
|
|
|
18750
|
+
# remove any leading / trailing spaces.
|
|
18751
|
+
if playlistId is not None:
|
|
18752
|
+
playlistId = playlistId.replace(' ','')
|
|
18753
|
+
|
|
18106
18754
|
# if playlistId not specified, then return currently playing playlist id value.
|
|
18107
18755
|
if (playlistId is None) or (len(playlistId.strip()) == 0):
|
|
18108
18756
|
uri = self.GetPlayerNowPlayingPlaylistUri()
|
|
@@ -18111,11 +18759,25 @@ class SpotifyClient:
|
|
|
18111
18759
|
else:
|
|
18112
18760
|
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'playlistId'), logsi=_logsi)
|
|
18113
18761
|
|
|
18762
|
+
# build a list of all item uri's from id values.
|
|
18763
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
18764
|
+
arrUris:list[str] = playlistId.split(',')
|
|
18765
|
+
for idx in range(0, len(arrUris)):
|
|
18766
|
+
if (arrUris[idx].find(":") == -1):
|
|
18767
|
+
arrUris[idx] = SpotifyTypePrefixes.PLAYLIST.value + arrUris[idx].strip()
|
|
18768
|
+
|
|
18769
|
+
# build spotify web api request parameters.
|
|
18770
|
+
urlParms:dict = \
|
|
18771
|
+
{
|
|
18772
|
+
'uris': ",".join(arrUris)
|
|
18773
|
+
}
|
|
18774
|
+
|
|
18114
18775
|
# execute spotify web api request.
|
|
18115
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/
|
|
18776
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
18116
18777
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
18778
|
+
msg.UrlParameters = urlParms
|
|
18117
18779
|
self.MakeRequest('DELETE', msg)
|
|
18118
|
-
|
|
18780
|
+
|
|
18119
18781
|
# process results.
|
|
18120
18782
|
# no results to process - this is pass or fail.
|
|
18121
18783
|
return
|
|
@@ -18146,7 +18808,7 @@ class SpotifyClient:
|
|
|
18146
18808
|
Args:
|
|
18147
18809
|
ids (str):
|
|
18148
18810
|
A comma-separated list of Spotify user IDs.
|
|
18149
|
-
A maximum of
|
|
18811
|
+
A maximum of 40 IDs can be sent in one request.
|
|
18150
18812
|
Example: `smedjan`
|
|
18151
18813
|
|
|
18152
18814
|
Raises:
|
|
@@ -18175,22 +18837,23 @@ class SpotifyClient:
|
|
|
18175
18837
|
apiMethodParms.AppendKeyValue("ids", ids)
|
|
18176
18838
|
_logsi.LogMethodParmList(SILevel.Verbose, "Remove current user as a follower of one or more users", apiMethodParms)
|
|
18177
18839
|
|
|
18178
|
-
# build a list of all item
|
|
18840
|
+
# build a list of all item uri's from id values.
|
|
18179
18841
|
# remove any leading / trailing spaces in case user put a space between the items.
|
|
18180
|
-
|
|
18181
|
-
for idx in range(0, len(
|
|
18182
|
-
|
|
18842
|
+
arrUris:list[str] = ids.split(',')
|
|
18843
|
+
for idx in range(0, len(arrUris)):
|
|
18844
|
+
if (arrUris[idx].find(":") == -1):
|
|
18845
|
+
arrUris[idx] = SpotifyTypePrefixes.USER.value + arrUris[idx].strip()
|
|
18183
18846
|
|
|
18184
18847
|
# build spotify web api request parameters.
|
|
18185
|
-
|
|
18848
|
+
urlParms:dict = \
|
|
18186
18849
|
{
|
|
18187
|
-
'
|
|
18850
|
+
'uris': ",".join(arrUris)
|
|
18188
18851
|
}
|
|
18189
18852
|
|
|
18190
18853
|
# execute spotify web api request.
|
|
18191
|
-
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/
|
|
18854
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/library')
|
|
18192
18855
|
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
18193
|
-
msg.
|
|
18856
|
+
msg.UrlParameters = urlParms
|
|
18194
18857
|
self.MakeRequest('DELETE', msg)
|
|
18195
18858
|
|
|
18196
18859
|
# process results.
|