spotifywebapiPython 1.0.112__py3-none-any.whl → 1.0.114__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of spotifywebapiPython might be problematic. Click here for more details.
- {spotifywebapiPython-1.0.112.dist-info → spotifywebapiPython-1.0.114.dist-info}/METADATA +1 -1
- {spotifywebapiPython-1.0.112.dist-info → spotifywebapiPython-1.0.114.dist-info}/RECORD +23 -23
- spotifywebapipython/const.py +1 -1
- spotifywebapipython/docs/__init__.html +17 -2
- spotifywebapipython/docs/index.html +2 -2
- spotifywebapipython/docs/search.js +1 -1
- spotifywebapipython/docs/spotifywebapipython/const.html +3 -3
- spotifywebapipython/docs/spotifywebapipython/saappmessages.html +2 -2
- 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 +73 -8
- spotifywebapipython/docs/spotifywebapipython/spotifydiscovery.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifywebapiauthenticationerror.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifywebapierror.html +2 -2
- spotifywebapipython/models/pageobject.py +28 -0
- spotifywebapipython/models/playerqueueinfo.py +34 -4
- spotifywebapipython/models/trackpage.py +40 -0
- spotifywebapipython/spotifyclient.py +215 -10
- {spotifywebapiPython-1.0.112.dist-info → spotifywebapiPython-1.0.114.dist-info}/LICENSE +0 -0
- {spotifywebapiPython-1.0.112.dist-info → spotifywebapiPython-1.0.114.dist-info}/WHEEL +0 -0
- {spotifywebapiPython-1.0.112.dist-info → spotifywebapiPython-1.0.114.dist-info}/top_level.txt +0 -0
|
@@ -42,15 +42,25 @@ class PlayerQueueInfo:
|
|
|
42
42
|
elif self._CurrentlyPlayingType == 'episode':
|
|
43
43
|
self._CurrentlyPlaying = Episode(root=item)
|
|
44
44
|
|
|
45
|
+
# for some reason, the Spotify Web API will return up to 10 duplicate items
|
|
46
|
+
# with the same information! for example:
|
|
47
|
+
# - if there is only 1 item in the queue, then 10 duplicate items are returned by the Spotify Web API.
|
|
48
|
+
# - if there are 5 items in the queue, then 5 duplicate items are returned by the Spotify Web API.
|
|
49
|
+
# we will check for this scenario, and only return non-duplicate items if so.
|
|
45
50
|
items:list = root.get('queue',None)
|
|
46
51
|
if items is not None:
|
|
47
52
|
for item in items:
|
|
53
|
+
|
|
48
54
|
itemType = item.get('type','unknown')
|
|
49
55
|
if itemType == 'track':
|
|
50
|
-
|
|
56
|
+
track:Track = Track(root=item)
|
|
57
|
+
if (track) and (not self.ContainsUri(track.Uri)):
|
|
58
|
+
self._Queue.append(track)
|
|
51
59
|
elif itemType == 'episode':
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
episode:Episode = Episode(root=item)
|
|
61
|
+
if (episode) and (not self.ContainsUri(episode.Uri)):
|
|
62
|
+
self._Queue.append(episode)
|
|
63
|
+
|
|
54
64
|
|
|
55
65
|
def __repr__(self) -> str:
|
|
56
66
|
return self.ToString()
|
|
@@ -122,6 +132,26 @@ class PlayerQueueInfo:
|
|
|
122
132
|
return result
|
|
123
133
|
|
|
124
134
|
|
|
135
|
+
def ContainsUri(self, uri:str) -> bool:
|
|
136
|
+
"""
|
|
137
|
+
Checks the `Queue` collection to see if an item already exists with the
|
|
138
|
+
specified Uri value.
|
|
139
|
+
|
|
140
|
+
Returns True if the specified Uri value exists in the collection; otherwise, False.
|
|
141
|
+
"""
|
|
142
|
+
result:bool = False
|
|
143
|
+
|
|
144
|
+
if (uri is None):
|
|
145
|
+
return result
|
|
146
|
+
|
|
147
|
+
for item in self._Queue:
|
|
148
|
+
if item.Uri == uri:
|
|
149
|
+
result = True
|
|
150
|
+
break
|
|
151
|
+
|
|
152
|
+
return result
|
|
153
|
+
|
|
154
|
+
|
|
125
155
|
def ToDictionary(self) -> dict:
|
|
126
156
|
"""
|
|
127
157
|
Returns a dictionary representation of the class.
|
|
@@ -132,8 +162,8 @@ class PlayerQueueInfo:
|
|
|
132
162
|
|
|
133
163
|
result:dict = \
|
|
134
164
|
{
|
|
135
|
-
'currently_playing': currentlyPlaying,
|
|
136
165
|
'currently_playing_type': self._CurrentlyPlayingType,
|
|
166
|
+
'currently_playing': currentlyPlaying,
|
|
137
167
|
'queue': [ item.ToDictionary() for item in self._Queue ],
|
|
138
168
|
}
|
|
139
169
|
return result
|
|
@@ -58,6 +58,46 @@ class TrackPage(PageObject):
|
|
|
58
58
|
return self._Items
|
|
59
59
|
|
|
60
60
|
|
|
61
|
+
def GetUris(self, afterUri:str=None) -> str:
|
|
62
|
+
"""
|
|
63
|
+
Gets a comma-delimited list of uri's contained in the underlying `Items` list.
|
|
64
|
+
|
|
65
|
+
args:
|
|
66
|
+
afterUri (str):
|
|
67
|
+
If specified, the process will look for this uri before adding subsequent
|
|
68
|
+
uri's to the returned results. This allows you to skip uri's that have
|
|
69
|
+
recently been played.
|
|
70
|
+
|
|
71
|
+
This is a convenience method so one does not have to loop through the `Items`
|
|
72
|
+
array of PlayHistory objects to get the list of uri's.
|
|
73
|
+
"""
|
|
74
|
+
result:str = ""
|
|
75
|
+
addUri:bool = False
|
|
76
|
+
item:Track
|
|
77
|
+
|
|
78
|
+
# add uri's from the beginning if no `afterUri` argument was passed.
|
|
79
|
+
if (afterUri is None) or (len(afterUri.strip()) == 0):
|
|
80
|
+
addUri = True
|
|
81
|
+
|
|
82
|
+
for item in self._Items:
|
|
83
|
+
|
|
84
|
+
if (not addUri):
|
|
85
|
+
|
|
86
|
+
# check for `afterUri` match; if found, we will start adding uri's
|
|
87
|
+
# to the list with the next item.
|
|
88
|
+
if (afterUri == item.Uri):
|
|
89
|
+
addUri = True
|
|
90
|
+
|
|
91
|
+
elif (addUri):
|
|
92
|
+
|
|
93
|
+
# add item uri to the list.
|
|
94
|
+
if (len(result) > 0):
|
|
95
|
+
result += ","
|
|
96
|
+
result += item.Uri
|
|
97
|
+
|
|
98
|
+
return result
|
|
99
|
+
|
|
100
|
+
|
|
61
101
|
def ToString(self, includeItems:bool=False) -> str:
|
|
62
102
|
"""
|
|
63
103
|
Returns a displayable string representation of the class.
|
|
@@ -839,6 +839,8 @@ class SpotifyClient:
|
|
|
839
839
|
deviceId:str=None
|
|
840
840
|
) -> None:
|
|
841
841
|
"""
|
|
842
|
+
DEPRECATED - use `AddPlayerQueueItems` method instead.
|
|
843
|
+
|
|
842
844
|
Add an item to the end of the user's current playback queue.
|
|
843
845
|
|
|
844
846
|
This method requires the `user-modify-playback-state` scope.
|
|
@@ -863,13 +865,6 @@ class SpotifyClient:
|
|
|
863
865
|
This API only works for users who have Spotify Premium.
|
|
864
866
|
|
|
865
867
|
The order of execution is not guaranteed when you use this API with other Player API endpoints.
|
|
866
|
-
|
|
867
|
-
<details>
|
|
868
|
-
<summary>Sample Code</summary>
|
|
869
|
-
```python
|
|
870
|
-
.. include:: ../docs/include/samplecode/SpotifyClient/AddPlayerQueueItem.py
|
|
871
|
-
```
|
|
872
|
-
</details>
|
|
873
868
|
"""
|
|
874
869
|
apiMethodName:str = 'AddPlayerQueueItem'
|
|
875
870
|
apiMethodParms:SIMethodParmListContext = None
|
|
@@ -921,6 +916,140 @@ class SpotifyClient:
|
|
|
921
916
|
_logsi.LeaveMethod(SILevel.Debug, apiMethodName)
|
|
922
917
|
|
|
923
918
|
|
|
919
|
+
def AddPlayerQueueItems(
|
|
920
|
+
self,
|
|
921
|
+
uris:str,
|
|
922
|
+
deviceId:str=None,
|
|
923
|
+
verifyDeviceId:bool=True,
|
|
924
|
+
delay:float=0.15,
|
|
925
|
+
) -> None:
|
|
926
|
+
"""
|
|
927
|
+
Add one or more items to the end of the user's current playback queue.
|
|
928
|
+
|
|
929
|
+
This method requires the `user-modify-playback-state` scope.
|
|
930
|
+
|
|
931
|
+
Args:
|
|
932
|
+
uris (str):
|
|
933
|
+
A list of Spotify track or episode URIs to add to the queue; can be track or episode URIs.
|
|
934
|
+
All URIs must be of the same type - you cannot mix and match tracks and episodes!
|
|
935
|
+
Example: [`spotify:track:6zd8T1PBe9JFHmuVnurdRp` ,`spotify:track:1kWUud3vY5ij5r62zxpTRy`].
|
|
936
|
+
It can also be specified as a comma-delimited string.
|
|
937
|
+
Example: `spotify:track:6zd8T1PBe9JFHmuVnurdRp,spotify:track:1kWUud3vY5ij5r62zxpTRy`.
|
|
938
|
+
An unlimited number of items can be added in one request, but the more items the longer it
|
|
939
|
+
will take.
|
|
940
|
+
deviceId (str):
|
|
941
|
+
The id or name of the device this command is targeting.
|
|
942
|
+
If not supplied, the user's currently active device is the target.
|
|
943
|
+
Example: `0d1841b0976bae2a3a310dd74c0f3df354899bc8`
|
|
944
|
+
Example: `Web Player (Chrome)`
|
|
945
|
+
verifyDeviceId (bool):
|
|
946
|
+
True to verify a device id is active; otherwise, false to assume that a
|
|
947
|
+
device id is already active.
|
|
948
|
+
Default is True.
|
|
949
|
+
delay (float):
|
|
950
|
+
Time delay (in seconds) to wait AFTER issuing the add request. This delay will give the
|
|
951
|
+
Spotify web api time to process the queue change before another command is issued.
|
|
952
|
+
Default is 0.15; value range is 0 - 10.
|
|
953
|
+
|
|
954
|
+
Raises:
|
|
955
|
+
SpotifyWebApiError:
|
|
956
|
+
If the Spotify Web API request was for a non-authorization service
|
|
957
|
+
and the response contains error information.
|
|
958
|
+
SpotifApiError:
|
|
959
|
+
If the method fails for any other reason.
|
|
960
|
+
|
|
961
|
+
This API only works for users who have Spotify Premium.
|
|
962
|
+
|
|
963
|
+
The order of execution is not guaranteed when you use this API with other Player API endpoints.
|
|
964
|
+
|
|
965
|
+
The Spotify Web API endpoint is called to add each item individually.
|
|
966
|
+
The Spotify Web API does not currently support adding more than 1 item to the queue at a time.
|
|
967
|
+
|
|
968
|
+
<details>
|
|
969
|
+
<summary>Sample Code</summary>
|
|
970
|
+
```python
|
|
971
|
+
.. include:: ../docs/include/samplecode/SpotifyClient/AddPlayerQueueItems.py
|
|
972
|
+
```
|
|
973
|
+
</details>
|
|
974
|
+
"""
|
|
975
|
+
apiMethodName:str = 'AddPlayerQueueItems'
|
|
976
|
+
apiMethodParms:SIMethodParmListContext = None
|
|
977
|
+
|
|
978
|
+
try:
|
|
979
|
+
|
|
980
|
+
# trace.
|
|
981
|
+
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
982
|
+
apiMethodParms.AppendKeyValue("uris", uris)
|
|
983
|
+
apiMethodParms.AppendKeyValue("deviceId", deviceId)
|
|
984
|
+
apiMethodParms.AppendKeyValue("verifyDeviceId", verifyDeviceId)
|
|
985
|
+
apiMethodParms.AppendKeyValue("delay", delay)
|
|
986
|
+
_logsi.LogMethodParmList(SILevel.Verbose, "Add items to playback queue", apiMethodParms)
|
|
987
|
+
|
|
988
|
+
# validations.
|
|
989
|
+
delay = validateDelay(delay, 0.15, 10)
|
|
990
|
+
if (verifyDeviceId is None):
|
|
991
|
+
verifyDeviceId = True
|
|
992
|
+
|
|
993
|
+
# build a list of all item uri's.
|
|
994
|
+
# remove any leading / trailing spaces in case user put a space between the items.
|
|
995
|
+
arrUris:list[str] = None
|
|
996
|
+
if isinstance(uris, list):
|
|
997
|
+
arrUris = uris
|
|
998
|
+
else:
|
|
999
|
+
arrUris = uris.split(',')
|
|
1000
|
+
for idx in range(0, len(arrUris)):
|
|
1001
|
+
arrUris[idx] = arrUris[idx].strip()
|
|
1002
|
+
|
|
1003
|
+
# if deviceId was not specified, then verify that there is an active player device.
|
|
1004
|
+
if verifyDeviceId:
|
|
1005
|
+
if deviceId is None:
|
|
1006
|
+
deviceId:str = self.VerifyPlayerActiveDeviceId()
|
|
1007
|
+
|
|
1008
|
+
# check for device name; convert to an id if a name was supplied.
|
|
1009
|
+
if verifyDeviceId:
|
|
1010
|
+
deviceId = self.PlayerConvertDeviceNameToId(deviceId)
|
|
1011
|
+
|
|
1012
|
+
# process all uri's.
|
|
1013
|
+
for idx in range(0, len(arrUris)):
|
|
1014
|
+
|
|
1015
|
+
# build spotify web api request parameters.
|
|
1016
|
+
urlParms:dict = \
|
|
1017
|
+
{
|
|
1018
|
+
'uri': arrUris[idx]
|
|
1019
|
+
}
|
|
1020
|
+
if deviceId is not None:
|
|
1021
|
+
urlParms['device_id'] = deviceId
|
|
1022
|
+
|
|
1023
|
+
# execute spotify web api request.
|
|
1024
|
+
msg:SpotifyApiMessage = SpotifyApiMessage(apiMethodName, '/me/player/queue')
|
|
1025
|
+
msg.RequestHeaders[self.AuthToken.HeaderKey] = self.AuthToken.HeaderValue
|
|
1026
|
+
msg.UrlParameters = urlParms
|
|
1027
|
+
self.MakeRequest('POST', msg)
|
|
1028
|
+
|
|
1029
|
+
# give spotify web api time to process the change.
|
|
1030
|
+
if delay > 0:
|
|
1031
|
+
_logsi.LogVerbose(TRACE_MSG_DELAY_DEVICE % delay)
|
|
1032
|
+
time.sleep(delay)
|
|
1033
|
+
|
|
1034
|
+
|
|
1035
|
+
# process results.
|
|
1036
|
+
# no results to process - this is pass or fail.
|
|
1037
|
+
return
|
|
1038
|
+
|
|
1039
|
+
except SpotifyApiError: raise # pass handled exceptions on thru
|
|
1040
|
+
except SpotifyWebApiError: raise # pass handled exceptions on thru
|
|
1041
|
+
except SpotifyWebApiAuthenticationError: raise # pass handled exceptions on thru
|
|
1042
|
+
except Exception as ex:
|
|
1043
|
+
|
|
1044
|
+
# format unhandled exception.
|
|
1045
|
+
raise SpotifyApiError(SAAppMessages.UNHANDLED_EXCEPTION.format(apiMethodName, str(ex)), ex, logsi=_logsi)
|
|
1046
|
+
|
|
1047
|
+
finally:
|
|
1048
|
+
|
|
1049
|
+
# trace.
|
|
1050
|
+
_logsi.LeaveMethod(SILevel.Debug, apiMethodName)
|
|
1051
|
+
|
|
1052
|
+
|
|
924
1053
|
def AddPlaylistCoverImage(self,
|
|
925
1054
|
playlistId:str,
|
|
926
1055
|
imagePath:str
|
|
@@ -2728,7 +2857,8 @@ class SpotifyClient:
|
|
|
2728
2857
|
|
|
2729
2858
|
# update result object with final paging details.
|
|
2730
2859
|
result.Total = pageObj.Total
|
|
2731
|
-
|
|
2860
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
2861
|
+
|
|
2732
2862
|
# sort result items.
|
|
2733
2863
|
if (len(result.Items) > 0):
|
|
2734
2864
|
if (sortResult is True):
|
|
@@ -2895,6 +3025,7 @@ class SpotifyClient:
|
|
|
2895
3025
|
|
|
2896
3026
|
# update result object with final paging details.
|
|
2897
3027
|
result.Total = pageObj.Total
|
|
3028
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
2898
3029
|
|
|
2899
3030
|
# sort result items.
|
|
2900
3031
|
if (len(result.Items) > 0):
|
|
@@ -3162,6 +3293,7 @@ class SpotifyClient:
|
|
|
3162
3293
|
|
|
3163
3294
|
# update result object with final paging details.
|
|
3164
3295
|
result.Total = pageObj.Total
|
|
3296
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
3165
3297
|
|
|
3166
3298
|
# do not sort items, as they are in playable order.
|
|
3167
3299
|
|
|
@@ -3429,6 +3561,7 @@ class SpotifyClient:
|
|
|
3429
3561
|
|
|
3430
3562
|
# update result object with final paging details.
|
|
3431
3563
|
result.Total = pageObj.Total
|
|
3564
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
3432
3565
|
|
|
3433
3566
|
# sort result items.
|
|
3434
3567
|
if (len(result.Items) > 0):
|
|
@@ -3730,6 +3863,7 @@ class SpotifyClient:
|
|
|
3730
3863
|
def GetArtistRelatedArtists(
|
|
3731
3864
|
self,
|
|
3732
3865
|
artistId:str=None,
|
|
3866
|
+
sortResult:bool=True,
|
|
3733
3867
|
) -> list[Artist]:
|
|
3734
3868
|
"""
|
|
3735
3869
|
Get Spotify catalog information about artists similar to a given artist.
|
|
@@ -3741,6 +3875,10 @@ class SpotifyClient:
|
|
|
3741
3875
|
Example: `6APm8EjxOHSYM5B4i3vT3q`
|
|
3742
3876
|
If null, the currently playing artist uri id value is used; a Spotify Free or Premium account
|
|
3743
3877
|
is required to correctly read the currently playing context.
|
|
3878
|
+
sortResult (bool):
|
|
3879
|
+
True to sort the items by name; otherwise, False to leave the items in the same order they
|
|
3880
|
+
were returned in by the Spotify Web API.
|
|
3881
|
+
Default: True
|
|
3744
3882
|
|
|
3745
3883
|
Returns:
|
|
3746
3884
|
A list of `Artist` objects that contain the artist details.
|
|
@@ -3768,8 +3906,13 @@ class SpotifyClient:
|
|
|
3768
3906
|
# trace.
|
|
3769
3907
|
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
3770
3908
|
apiMethodParms.AppendKeyValue("artistId", artistId)
|
|
3909
|
+
apiMethodParms.AppendKeyValue("sortResult", sortResult)
|
|
3771
3910
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information about artists similar to a given artist", apiMethodParms)
|
|
3772
|
-
|
|
3911
|
+
|
|
3912
|
+
# validations.
|
|
3913
|
+
if sortResult is None:
|
|
3914
|
+
sortResult = True
|
|
3915
|
+
|
|
3773
3916
|
# if artistId not specified, then return currently playing artist id value.
|
|
3774
3917
|
if (artistId is None) or (len(artistId.strip()) == 0):
|
|
3775
3918
|
uri = self.GetPlayerNowPlayingArtistUri()
|
|
@@ -3789,6 +3932,11 @@ class SpotifyClient:
|
|
|
3789
3932
|
for item in items:
|
|
3790
3933
|
result.append(Artist(root=item))
|
|
3791
3934
|
|
|
3935
|
+
# sort result items.
|
|
3936
|
+
if (len(result) > 0):
|
|
3937
|
+
if (sortResult is True):
|
|
3938
|
+
result.sort(key=lambda x: (x.Name or "").lower(), reverse=False)
|
|
3939
|
+
|
|
3792
3940
|
# trace.
|
|
3793
3941
|
_logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Artist]'), result)
|
|
3794
3942
|
return result
|
|
@@ -4021,6 +4169,7 @@ class SpotifyClient:
|
|
|
4021
4169
|
# update result object with final paging details.
|
|
4022
4170
|
result.Total = pageObj.Total
|
|
4023
4171
|
result.CursorAfter = pageObj.CursorAfter
|
|
4172
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
4024
4173
|
|
|
4025
4174
|
# sort result items.
|
|
4026
4175
|
if (len(result.Items) > 0):
|
|
@@ -4049,6 +4198,7 @@ class SpotifyClient:
|
|
|
4049
4198
|
self,
|
|
4050
4199
|
artistId:str=None,
|
|
4051
4200
|
market:str=None,
|
|
4201
|
+
sortResult:bool=True,
|
|
4052
4202
|
) -> list[Track]:
|
|
4053
4203
|
"""
|
|
4054
4204
|
Get Spotify catalog information about an artist's top tracks by country.
|
|
@@ -4067,6 +4217,10 @@ class SpotifyClient:
|
|
|
4067
4217
|
Note: If neither market or user country are provided, the content is considered unavailable for the client.
|
|
4068
4218
|
Users can view the country that is associated with their account in the account settings.
|
|
4069
4219
|
Example: `ES`
|
|
4220
|
+
sortResult (bool):
|
|
4221
|
+
True to sort the items by name; otherwise, False to leave the items in the same order they
|
|
4222
|
+
were returned in by the Spotify Web API.
|
|
4223
|
+
Default: True
|
|
4070
4224
|
|
|
4071
4225
|
Returns:
|
|
4072
4226
|
A list of `Track` objects that contain the track details.
|
|
@@ -4095,8 +4249,13 @@ class SpotifyClient:
|
|
|
4095
4249
|
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
4096
4250
|
apiMethodParms.AppendKeyValue("artistId", artistId)
|
|
4097
4251
|
apiMethodParms.AppendKeyValue("market", market)
|
|
4252
|
+
apiMethodParms.AppendKeyValue("sortResult", sortResult)
|
|
4098
4253
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify catalog information about an artist's top tracks", apiMethodParms)
|
|
4099
4254
|
|
|
4255
|
+
# validations.
|
|
4256
|
+
if sortResult is None:
|
|
4257
|
+
sortResult = True
|
|
4258
|
+
|
|
4100
4259
|
# ensure market was either supplied or implied; default if neither.
|
|
4101
4260
|
market = self._ValidateMarket(market)
|
|
4102
4261
|
|
|
@@ -4125,6 +4284,11 @@ class SpotifyClient:
|
|
|
4125
4284
|
for item in items:
|
|
4126
4285
|
result.append(Track(root=item))
|
|
4127
4286
|
|
|
4287
|
+
# sort result items.
|
|
4288
|
+
if (len(result) > 0):
|
|
4289
|
+
if (sortResult is True):
|
|
4290
|
+
result.sort(key=lambda x: (x.Name or "").lower(), reverse=False)
|
|
4291
|
+
|
|
4128
4292
|
# trace.
|
|
4129
4293
|
_logsi.LogArray(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, 'list[Track]'), result)
|
|
4130
4294
|
return result
|
|
@@ -4401,6 +4565,7 @@ class SpotifyClient:
|
|
|
4401
4565
|
|
|
4402
4566
|
# update result object with final paging details.
|
|
4403
4567
|
result.Total = pageObj.Total
|
|
4568
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
4404
4569
|
|
|
4405
4570
|
# no sorting, as chapters are in playable order.
|
|
4406
4571
|
|
|
@@ -4553,6 +4718,7 @@ class SpotifyClient:
|
|
|
4553
4718
|
|
|
4554
4719
|
# update result object with final paging details.
|
|
4555
4720
|
result.Total = pageObj.Total
|
|
4721
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
4556
4722
|
|
|
4557
4723
|
# sort result items.
|
|
4558
4724
|
if (len(result.Items) > 0):
|
|
@@ -4946,6 +5112,7 @@ class SpotifyClient:
|
|
|
4946
5112
|
|
|
4947
5113
|
# update result object with final paging details.
|
|
4948
5114
|
result.Total = pageObj.Total
|
|
5115
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
4949
5116
|
|
|
4950
5117
|
# sort result items.
|
|
4951
5118
|
if (len(result.Items) > 0):
|
|
@@ -5231,6 +5398,7 @@ class SpotifyClient:
|
|
|
5231
5398
|
|
|
5232
5399
|
# update result object with final paging details.
|
|
5233
5400
|
result.Total = pageObj.Total
|
|
5401
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
5234
5402
|
|
|
5235
5403
|
# sort result items.
|
|
5236
5404
|
if (len(result.Items) > 0):
|
|
@@ -5692,6 +5860,7 @@ class SpotifyClient:
|
|
|
5692
5860
|
|
|
5693
5861
|
# update result object with final paging details.
|
|
5694
5862
|
result.Total = pageObj.Total
|
|
5863
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
5695
5864
|
|
|
5696
5865
|
# sort result items.
|
|
5697
5866
|
if (len(result.Items) > 0):
|
|
@@ -5984,6 +6153,7 @@ class SpotifyClient:
|
|
|
5984
6153
|
|
|
5985
6154
|
# update result object with final paging details.
|
|
5986
6155
|
result.Total = pageObj.Total
|
|
6156
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
5987
6157
|
|
|
5988
6158
|
# sort result items.
|
|
5989
6159
|
if (len(result.Items) > 0):
|
|
@@ -7391,6 +7561,7 @@ class SpotifyClient:
|
|
|
7391
7561
|
result.Total = result.ItemsCount
|
|
7392
7562
|
result.CursorAfter = pageObj.CursorAfter
|
|
7393
7563
|
result.CursorBefore = pageObj.CursorBefore
|
|
7564
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
7394
7565
|
|
|
7395
7566
|
# trace.
|
|
7396
7567
|
_logsi.LogObject(SILevel.Verbose, TRACE_METHOD_RESULT_TYPE % (apiMethodName, type(result).__name__), result, excludeNonPublic=True)
|
|
@@ -7814,6 +7985,7 @@ class SpotifyClient:
|
|
|
7814
7985
|
|
|
7815
7986
|
# update result object with final paging details.
|
|
7816
7987
|
result.Total = pageObj.Total
|
|
7988
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
7817
7989
|
|
|
7818
7990
|
# do not sort this list, as it is in play order.
|
|
7819
7991
|
|
|
@@ -7966,6 +8138,7 @@ class SpotifyClient:
|
|
|
7966
8138
|
|
|
7967
8139
|
# update result object with final paging details.
|
|
7968
8140
|
result.Total = pageObj.Total
|
|
8141
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
7969
8142
|
|
|
7970
8143
|
# sort result items.
|
|
7971
8144
|
if (len(result.Items) > 0):
|
|
@@ -8127,6 +8300,7 @@ class SpotifyClient:
|
|
|
8127
8300
|
|
|
8128
8301
|
# update result object with final paging details.
|
|
8129
8302
|
result.Total = pageObj.Total
|
|
8303
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
8130
8304
|
|
|
8131
8305
|
# sort result items.
|
|
8132
8306
|
if (len(result.Items) > 0):
|
|
@@ -8407,6 +8581,7 @@ class SpotifyClient:
|
|
|
8407
8581
|
|
|
8408
8582
|
# update result object with final paging details.
|
|
8409
8583
|
result.Total = pageObj.Total
|
|
8584
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
8410
8585
|
|
|
8411
8586
|
# no sort, as items are in playable order.
|
|
8412
8587
|
|
|
@@ -8586,6 +8761,7 @@ class SpotifyClient:
|
|
|
8586
8761
|
|
|
8587
8762
|
# update result object with final paging details.
|
|
8588
8763
|
result.Total = pageObj.Total
|
|
8764
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
8589
8765
|
|
|
8590
8766
|
# sort result items.
|
|
8591
8767
|
if (len(result.Items) > 0):
|
|
@@ -9562,6 +9738,7 @@ class SpotifyClient:
|
|
|
9562
9738
|
|
|
9563
9739
|
# update result object with final paging details.
|
|
9564
9740
|
result.Total = pageObj.Total
|
|
9741
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
9565
9742
|
|
|
9566
9743
|
# sort result items.
|
|
9567
9744
|
if (len(result.Items) > 0):
|
|
@@ -10490,6 +10667,7 @@ class SpotifyClient:
|
|
|
10490
10667
|
|
|
10491
10668
|
# update result object with final paging details.
|
|
10492
10669
|
result.Total = pageObj.Total
|
|
10670
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
10493
10671
|
|
|
10494
10672
|
# sort result items.
|
|
10495
10673
|
if (len(result.Items) > 0):
|
|
@@ -10656,6 +10834,7 @@ class SpotifyClient:
|
|
|
10656
10834
|
|
|
10657
10835
|
# update result object with final paging details.
|
|
10658
10836
|
result.Total = pageObj.Total
|
|
10837
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
10659
10838
|
|
|
10660
10839
|
# sort result items.
|
|
10661
10840
|
if (len(result.Items) > 0):
|
|
@@ -11284,6 +11463,25 @@ class SpotifyClient:
|
|
|
11284
11463
|
# if so, then use the found device id in case a device name was specified.
|
|
11285
11464
|
if scDevice is not None:
|
|
11286
11465
|
deviceId = scDevice.Id
|
|
11466
|
+
|
|
11467
|
+
# left this here in case we want to implement it in the future.
|
|
11468
|
+
|
|
11469
|
+
# # are we backfilling the player queue? if so, we can only have 50 uris total.
|
|
11470
|
+
# if (backfillUrisPageOffset > -1) and (len(arrUris) < 50):
|
|
11471
|
+
|
|
11472
|
+
# # are we playing tracks?
|
|
11473
|
+
# if (len(arrUris) > 0) and (SpotifyClient.GetTypeFromUri(arrUris[0]) == 'track'):
|
|
11474
|
+
|
|
11475
|
+
# _logsi.LogVerbose("Backfilling player queue items from users top tracks")
|
|
11476
|
+
|
|
11477
|
+
# # get list of users top tracks (50 max items).
|
|
11478
|
+
# pageObj:TrackPage = self.GetUsersTopTracks(timeRange='medium_term', offset=backfillUrisPageOffset, limit=(50 - len(arrUris)), sortResult=False)
|
|
11479
|
+
|
|
11480
|
+
# # add them to the player queue; no need to validate the device id, since we
|
|
11481
|
+
# # know there is an active device id by this point.
|
|
11482
|
+
# item:Track
|
|
11483
|
+
# for item in pageObj.Items:
|
|
11484
|
+
# arrUris.append(item.Uri)
|
|
11287
11485
|
|
|
11288
11486
|
# build spotify web api request parameters.
|
|
11289
11487
|
reqData:dict = \
|
|
@@ -11308,7 +11506,7 @@ class SpotifyClient:
|
|
|
11308
11506
|
if delay > 0:
|
|
11309
11507
|
_logsi.LogVerbose(TRACE_MSG_DELAY_DEVICE % delay)
|
|
11310
11508
|
time.sleep(delay)
|
|
11311
|
-
|
|
11509
|
+
|
|
11312
11510
|
# process results.
|
|
11313
11511
|
# no results to process - this is pass or fail.
|
|
11314
11512
|
return
|
|
@@ -14029,6 +14227,7 @@ class SpotifyClient:
|
|
|
14029
14227
|
|
|
14030
14228
|
# update result object with final paging details.
|
|
14031
14229
|
result.Total = pageObj.Total
|
|
14230
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
14032
14231
|
|
|
14033
14232
|
# do not sort, as spotify uses intelligent AI to return results in its order.
|
|
14034
14233
|
|
|
@@ -14221,6 +14420,7 @@ class SpotifyClient:
|
|
|
14221
14420
|
|
|
14222
14421
|
# update result object with final paging details.
|
|
14223
14422
|
result.Total = pageObj.Total
|
|
14423
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
14224
14424
|
|
|
14225
14425
|
# do not sort, as spotify uses intelligent AI to return results in its order.
|
|
14226
14426
|
|
|
@@ -14415,6 +14615,7 @@ class SpotifyClient:
|
|
|
14415
14615
|
|
|
14416
14616
|
# update result object with final paging details.
|
|
14417
14617
|
result.Total = pageObj.Total
|
|
14618
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
14418
14619
|
|
|
14419
14620
|
# do not sort, as spotify uses intelligent AI to return results in its order.
|
|
14420
14621
|
|
|
@@ -14607,6 +14808,7 @@ class SpotifyClient:
|
|
|
14607
14808
|
|
|
14608
14809
|
# update result object with final paging details.
|
|
14609
14810
|
result.Total = pageObj.Total
|
|
14811
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
14610
14812
|
|
|
14611
14813
|
# do not sort, as spotify uses intelligent AI to return results in its order.
|
|
14612
14814
|
|
|
@@ -14799,6 +15001,7 @@ class SpotifyClient:
|
|
|
14799
15001
|
|
|
14800
15002
|
# update result object with final paging details.
|
|
14801
15003
|
result.Total = pageObj.Total
|
|
15004
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
14802
15005
|
|
|
14803
15006
|
# do not sort, as spotify uses intelligent AI to return results in its order.
|
|
14804
15007
|
|
|
@@ -14991,6 +15194,7 @@ class SpotifyClient:
|
|
|
14991
15194
|
|
|
14992
15195
|
# update result object with final paging details.
|
|
14993
15196
|
result.Total = pageObj.Total
|
|
15197
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
14994
15198
|
|
|
14995
15199
|
# do not sort, as spotify uses intelligent AI to return results in its order.
|
|
14996
15200
|
|
|
@@ -15183,6 +15387,7 @@ class SpotifyClient:
|
|
|
15183
15387
|
|
|
15184
15388
|
# update result object with final paging details.
|
|
15185
15389
|
result.Total = pageObj.Total
|
|
15390
|
+
result.DateLastRefreshed = datetime.utcnow().timestamp()
|
|
15186
15391
|
|
|
15187
15392
|
# do not sort, as spotify uses intelligent AI to return results in its order.
|
|
15188
15393
|
|
|
File without changes
|
|
File without changes
|
{spotifywebapiPython-1.0.112.dist-info → spotifywebapiPython-1.0.114.dist-info}/top_level.txt
RENAMED
|
File without changes
|