spotifywebapiPython 1.0.162__py3-none-any.whl → 1.0.164__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.162.dist-info → spotifywebapiPython-1.0.164.dist-info}/METADATA +1 -1
- {spotifywebapiPython-1.0.162.dist-info → spotifywebapiPython-1.0.164.dist-info}/RECORD +22 -22
- spotifywebapipython/const.py +1 -1
- spotifywebapipython/docs/__init__.html +14 -3
- 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 +37 -38
- spotifywebapipython/docs/spotifywebapipython/spotifydiscovery.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifywebapiauthenticationerror.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifywebapierror.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/spotifywebplayertoken.html +2 -2
- spotifywebapipython/spotifyclient.py +65 -47
- spotifywebapipython/spotifyconnect/spotifyconnectdirectorytask.py +17 -0
- {spotifywebapiPython-1.0.162.dist-info → spotifywebapiPython-1.0.164.dist-info}/LICENSE +0 -0
- {spotifywebapiPython-1.0.162.dist-info → spotifywebapiPython-1.0.164.dist-info}/WHEEL +0 -0
- {spotifywebapiPython-1.0.162.dist-info → spotifywebapiPython-1.0.164.dist-info}/top_level.txt +0 -0
|
@@ -4,11 +4,9 @@ from datetime import datetime
|
|
|
4
4
|
import json
|
|
5
5
|
from io import BytesIO
|
|
6
6
|
from oauthlib.oauth2 import BackendApplicationClient, WebApplicationClient
|
|
7
|
-
import socket
|
|
8
7
|
from soco import SoCo
|
|
9
8
|
from soco.core import (
|
|
10
9
|
PLAY_MODE_BY_MEANING as SONOS_PLAY_MODE_BY_MEANING,
|
|
11
|
-
PLAY_MODES as SONOS_PLAY_MODES,
|
|
12
10
|
)
|
|
13
11
|
from soco.plugins.sharelink import ShareLinkPlugin
|
|
14
12
|
import time
|
|
@@ -16,7 +14,7 @@ from typing import Tuple, Callable, Union
|
|
|
16
14
|
from urllib3 import PoolManager, Timeout, HTTPResponse
|
|
17
15
|
from urllib.parse import urlencode
|
|
18
16
|
import urllib.parse
|
|
19
|
-
from lxml.etree import fromstring, Element
|
|
17
|
+
from lxml.etree import fromstring, Element
|
|
20
18
|
from lxml import etree
|
|
21
19
|
from zeroconf import Zeroconf
|
|
22
20
|
|
|
@@ -202,6 +200,7 @@ class SpotifyClient:
|
|
|
202
200
|
self._AuthClient:AuthClient = None
|
|
203
201
|
self._ConfigurationCache:dict = {}
|
|
204
202
|
self._DefaultDeviceId:str = None
|
|
203
|
+
self._IsDisposed:bool = False
|
|
205
204
|
self._Manager:PoolManager = manager
|
|
206
205
|
self._SpotifyConnectUsername:str = spotifyConnectUsername
|
|
207
206
|
self._SpotifyConnectPassword:str = spotifyConnectPassword
|
|
@@ -243,7 +242,7 @@ class SpotifyClient:
|
|
|
243
242
|
Finalizes the instance of the class.
|
|
244
243
|
"""
|
|
245
244
|
try:
|
|
246
|
-
self.
|
|
245
|
+
self.Dispose()
|
|
247
246
|
except:
|
|
248
247
|
# ignore exceptions since we are shutting down.
|
|
249
248
|
pass
|
|
@@ -257,7 +256,7 @@ class SpotifyClient:
|
|
|
257
256
|
def __exit__(self, etype, value, traceback) -> None:
|
|
258
257
|
# if called via a context manager (e.g. "with" statement).
|
|
259
258
|
try:
|
|
260
|
-
self.
|
|
259
|
+
self.Dispose()
|
|
261
260
|
except:
|
|
262
261
|
# ignore exceptions since we are shutting down.
|
|
263
262
|
pass
|
|
@@ -487,7 +486,7 @@ class SpotifyClient:
|
|
|
487
486
|
|
|
488
487
|
# if deviceId could not be resolved, then it's an error.
|
|
489
488
|
if (deviceId is None) or (deviceId == "*"):
|
|
490
|
-
raise SpotifyConnectDeviceNotFound("There is no active Spotify player, and a default player device was not configured.")
|
|
489
|
+
raise SpotifyConnectDeviceNotFound("There is no active Spotify player device, and a default player device was not configured.")
|
|
491
490
|
else:
|
|
492
491
|
raise SpotifyConnectDeviceNotFound("Spotify Player device \"%s\" was not found in the Spotify Connect device list; verify the device is discoverable via Zeroconf on the local network." % (deviceId))
|
|
493
492
|
|
|
@@ -976,6 +975,51 @@ class SpotifyClient:
|
|
|
976
975
|
return SPOTIFY_DEFAULT_MARKET
|
|
977
976
|
|
|
978
977
|
|
|
978
|
+
def Dispose(self) -> None:
|
|
979
|
+
"""
|
|
980
|
+
Releases all resources of this instance.
|
|
981
|
+
|
|
982
|
+
This method stops the Spotify Connect Directory task, and ensures
|
|
983
|
+
that any event wirings are removed.
|
|
984
|
+
"""
|
|
985
|
+
apiMethodName:str = 'Dispose'
|
|
986
|
+
|
|
987
|
+
try:
|
|
988
|
+
|
|
989
|
+
# trace.
|
|
990
|
+
apiMethodParms = _logsi.EnterMethodParmList(SILevel.Debug, apiMethodName)
|
|
991
|
+
_logsi.LogMethodParmList(SILevel.Verbose, "Disposing of SpotifyClient instance", apiMethodParms)
|
|
992
|
+
|
|
993
|
+
# are we already disposed? if so, then don't do it again!
|
|
994
|
+
if (self._IsDisposed == True):
|
|
995
|
+
_logsi.LogVerbose("SpotifyClient instance is already disposed")
|
|
996
|
+
return
|
|
997
|
+
else:
|
|
998
|
+
# indicate we are disposed (or in the process thereof).
|
|
999
|
+
self._IsDisposed = True
|
|
1000
|
+
|
|
1001
|
+
# shut down the directory task.
|
|
1002
|
+
try:
|
|
1003
|
+
self.StopSpotifyConnectDirectoryTask()
|
|
1004
|
+
except Exception as ex:
|
|
1005
|
+
pass # ignore exceptions as they have already been logged.
|
|
1006
|
+
|
|
1007
|
+
# trace.
|
|
1008
|
+
_logsi.LogVerbose("Disposal of SpotifyClient instance completed successfully")
|
|
1009
|
+
|
|
1010
|
+
except Exception as ex:
|
|
1011
|
+
|
|
1012
|
+
# log unhandled exception.
|
|
1013
|
+
_logsi.LogException(SAAppMessages.UNHANDLED_EXCEPTION.format(apiMethodName, str(ex)), ex)
|
|
1014
|
+
|
|
1015
|
+
# ignore exceptions as we are disposing!
|
|
1016
|
+
|
|
1017
|
+
finally:
|
|
1018
|
+
|
|
1019
|
+
# trace.
|
|
1020
|
+
_logsi.LeaveMethod(SILevel.Debug, apiMethodName)
|
|
1021
|
+
|
|
1022
|
+
|
|
979
1023
|
def MakeRequest(
|
|
980
1024
|
self,
|
|
981
1025
|
method:str,
|
|
@@ -1191,10 +1235,7 @@ class SpotifyClient:
|
|
|
1191
1235
|
not be resolved or activated.
|
|
1192
1236
|
Examples are `0d1841b0976bae2a3a310dd74c0f3df354899bc8`, `Office`, `*`, None.
|
|
1193
1237
|
verifyDeviceId (bool):
|
|
1194
|
-
DEPRECATED -
|
|
1195
|
-
True to verify a device id is active; otherwise, false to assume that a
|
|
1196
|
-
device id is already active.
|
|
1197
|
-
Default is True.
|
|
1238
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
1198
1239
|
delay (float):
|
|
1199
1240
|
Time delay (in seconds) to wait AFTER issuing the add request. This delay will give the
|
|
1200
1241
|
Spotify web api time to process the queue change before another command is issued.
|
|
@@ -2039,10 +2080,10 @@ class SpotifyClient:
|
|
|
2039
2080
|
The Spotify ID of the playlist.
|
|
2040
2081
|
Example: `3cEYpjA9oz9GiPac4AsH4n`
|
|
2041
2082
|
userIds (str):
|
|
2083
|
+
DEPRECATED - A single item list containing current user's Spotify Username; Maximum of 1 id.
|
|
2042
2084
|
A comma-separated list of Spotify User ID's to check.
|
|
2043
2085
|
Maximum: 5 ID's.
|
|
2044
2086
|
Example: `1kWUud3vY5ij5r62zxpTRy,2takcwOaAZWiXQijPHIx7B`
|
|
2045
|
-
DEPRECATED - A single item list containing current user's Spotify Username; Maximum of 1 id.
|
|
2046
2087
|
|
|
2047
2088
|
Returns:
|
|
2048
2089
|
Array of boolean, containing a single boolean status that indicates
|
|
@@ -9593,19 +9634,13 @@ class SpotifyClient:
|
|
|
9593
9634
|
The device id / name value to check.
|
|
9594
9635
|
verifyUserContext (bool):
|
|
9595
9636
|
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
9596
|
-
If True, the active user context of the resolved device is checked to ensure it
|
|
9597
|
-
matches the user context specified on the class constructor.
|
|
9598
|
-
If False, the user context will not be checked.
|
|
9599
|
-
Default is True.
|
|
9600
9637
|
verifyTimeout (float):
|
|
9601
9638
|
Maximum time to wait (in seconds) for the device to become active in the Spotify
|
|
9602
9639
|
Connect device list. This value is only used if a Connect command has to be
|
|
9603
9640
|
issued to activate the device.
|
|
9604
9641
|
Default is 5; value range is 0 - 10.
|
|
9605
9642
|
refreshDeviceList (bool):
|
|
9606
|
-
|
|
9607
|
-
Spotify Connect device list cache.
|
|
9608
|
-
Default is False.
|
|
9643
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
9609
9644
|
activateDevice (bool):
|
|
9610
9645
|
True to activate the device if necessary; otherwise, False.
|
|
9611
9646
|
Default is True.
|
|
@@ -9664,7 +9699,7 @@ class SpotifyClient:
|
|
|
9664
9699
|
apiMethodParms.AppendKeyValue("deviceValue", deviceValue)
|
|
9665
9700
|
apiMethodParms.AppendKeyValue("verifyUserContext (DEPRECATED)", verifyUserContext)
|
|
9666
9701
|
apiMethodParms.AppendKeyValue("verifyTimeout", verifyTimeout)
|
|
9667
|
-
apiMethodParms.AppendKeyValue("refreshDeviceList", refreshDeviceList)
|
|
9702
|
+
apiMethodParms.AppendKeyValue("refreshDeviceList (DEPRECATED)", refreshDeviceList)
|
|
9668
9703
|
apiMethodParms.AppendKeyValue("activateDevice", activateDevice)
|
|
9669
9704
|
apiMethodParms.AppendKeyValue("delay", delay)
|
|
9670
9705
|
_logsi.LogMethodParmList(SILevel.Verbose, "Get Spotify Connect Device object for deviceValue \"%s\"" % (deviceValue), apiMethodParms)
|
|
@@ -9674,8 +9709,6 @@ class SpotifyClient:
|
|
|
9674
9709
|
verifyTimeout = validateDelay(verifyTimeout, 5, 10)
|
|
9675
9710
|
if (activateDevice is None):
|
|
9676
9711
|
activateDevice = True
|
|
9677
|
-
if (refreshDeviceList is None):
|
|
9678
|
-
refreshDeviceList = False
|
|
9679
9712
|
|
|
9680
9713
|
# resolve the device id from the specified device value.
|
|
9681
9714
|
# returned value will be null if the device could not be resolved!
|
|
@@ -9802,9 +9835,9 @@ class SpotifyClient:
|
|
|
9802
9835
|
if sonosMusicSource != "SPOTIFY_CONNECT":
|
|
9803
9836
|
_logsi.LogVerbose("Sonos device %s music source after Connect is not SPOTIFY_CONNECT; it will probably fail to play" % (scDevice.Title))
|
|
9804
9837
|
|
|
9805
|
-
|
|
9806
|
-
|
|
9807
|
-
|
|
9838
|
+
# at this point the Sonos music source should be set to SPOTIFY_CONNECT, and control
|
|
9839
|
+
# transferred to the device. note that the Sonos device will still NOT appear in the
|
|
9840
|
+
# player device list, but SHOULD be the active (restricted) device in player state.
|
|
9808
9841
|
|
|
9809
9842
|
# wait for the device to enter the Spotify Web API player device list, or
|
|
9810
9843
|
# to become the active device.
|
|
@@ -9876,10 +9909,7 @@ class SpotifyClient:
|
|
|
9876
9909
|
True (default) to return real-time information about devices and update the cache;
|
|
9877
9910
|
otherwise, False to just return the cached value.
|
|
9878
9911
|
sortResult (bool):
|
|
9879
|
-
DEPRECATED - no longer used,
|
|
9880
|
-
True to sort the items by name; otherwise, False to leave the items in the same order they
|
|
9881
|
-
were returned in by the Spotify Web API.
|
|
9882
|
-
Default: True
|
|
9912
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
9883
9913
|
|
|
9884
9914
|
Returns:
|
|
9885
9915
|
A `SpotifyConnectDevices` object that contain Spotify Connect devices that are registered
|
|
@@ -11661,9 +11691,10 @@ class SpotifyClient:
|
|
|
11661
11691
|
|
|
11662
11692
|
Args:
|
|
11663
11693
|
contextUri (str):
|
|
11664
|
-
Spotify URI of the context to play.
|
|
11694
|
+
Spotify URI (or URL) of the context to play.
|
|
11665
11695
|
Valid contexts are albums, artists & playlists.
|
|
11666
11696
|
Example: `spotify:album:6vc9OTcyd3hyzabCmsdnwE`.
|
|
11697
|
+
Example: `https://open.spotify.com/playlist/4ufyQwaLq1MR49KvGRCNAo`.
|
|
11667
11698
|
offsetUri (str):
|
|
11668
11699
|
Indicates from what Uri in the context playback should start.
|
|
11669
11700
|
Only available when contextUri corresponds to an artist, album or playlist.
|
|
@@ -11696,10 +11727,7 @@ class SpotifyClient:
|
|
|
11696
11727
|
another command is issued.
|
|
11697
11728
|
Default is 0.50; value range is 0 - 10.
|
|
11698
11729
|
resolveDeviceId (bool):
|
|
11699
|
-
DEPRECATED -
|
|
11700
|
-
True to resolve the supplied `deviceId` value; otherwise, False not resolve the `deviceId`
|
|
11701
|
-
value as it has already been resolved.
|
|
11702
|
-
Default is True.
|
|
11730
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
11703
11731
|
|
|
11704
11732
|
Raises:
|
|
11705
11733
|
SpotifyWebApiError:
|
|
@@ -11921,10 +11949,7 @@ class SpotifyClient:
|
|
|
11921
11949
|
another command is issued.
|
|
11922
11950
|
Default is 0.50; value range is 0 - 10.
|
|
11923
11951
|
resolveDeviceId (bool):
|
|
11924
|
-
DEPRECATED -
|
|
11925
|
-
True to resolve the supplied `deviceId` value; otherwise, False not resolve the `deviceId`
|
|
11926
|
-
value as it has already been resolved.
|
|
11927
|
-
Default is True.
|
|
11952
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
11928
11953
|
limitTotal (int):
|
|
11929
11954
|
The maximum number of items to retrieve from favorites.
|
|
11930
11955
|
Default is 200; value range is 1 - 750.
|
|
@@ -12058,10 +12083,7 @@ class SpotifyClient:
|
|
|
12058
12083
|
another command is issued.
|
|
12059
12084
|
Default is 0.50; value range is 0 - 10.
|
|
12060
12085
|
resolveDeviceId (bool):
|
|
12061
|
-
DEPRECATED -
|
|
12062
|
-
True to resolve the supplied `deviceId` value; otherwise, False not resolve the `deviceId`
|
|
12063
|
-
value as it has already been resolved.
|
|
12064
|
-
Default is True.
|
|
12086
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
12065
12087
|
|
|
12066
12088
|
Raises:
|
|
12067
12089
|
SpotifyWebApiError:
|
|
@@ -13124,9 +13146,7 @@ class SpotifyClient:
|
|
|
13124
13146
|
another command is issued.
|
|
13125
13147
|
Default is 0.50; value range is 0 - 10.
|
|
13126
13148
|
refreshDeviceList (bool):
|
|
13127
|
-
|
|
13128
|
-
Spotify Connect device list cache.
|
|
13129
|
-
Default is True.
|
|
13149
|
+
DEPRECATED - no longer used, but left here to maintain compatibility.
|
|
13130
13150
|
forceActivateDevice (bool):
|
|
13131
13151
|
True to issue a Spotify Connect Disconnect call prior to transfer, which will
|
|
13132
13152
|
force the device to reconnect to Spotify Connect; otherwise, False to not
|
|
@@ -13177,7 +13197,7 @@ class SpotifyClient:
|
|
|
13177
13197
|
apiMethodParms.AppendKeyValue("deviceId", deviceId)
|
|
13178
13198
|
apiMethodParms.AppendKeyValue("play", play)
|
|
13179
13199
|
apiMethodParms.AppendKeyValue("delay", delay)
|
|
13180
|
-
apiMethodParms.AppendKeyValue("refreshDeviceList", refreshDeviceList)
|
|
13200
|
+
apiMethodParms.AppendKeyValue("refreshDeviceList (DEPRECATED)", refreshDeviceList)
|
|
13181
13201
|
apiMethodParms.AppendKeyValue("forceActivateDevice", forceActivateDevice)
|
|
13182
13202
|
apiMethodParms.AppendKeyValue("deviceIdFrom", deviceIdFrom)
|
|
13183
13203
|
_logsi.LogMethodParmList(SILevel.Verbose, "Transfer playback to a new Spotify Connect device", apiMethodParms)
|
|
@@ -13186,8 +13206,6 @@ class SpotifyClient:
|
|
|
13186
13206
|
delay = validateDelay(delay, 0.50, 10)
|
|
13187
13207
|
if (play is None):
|
|
13188
13208
|
play = True
|
|
13189
|
-
if (refreshDeviceList is None):
|
|
13190
|
-
refreshDeviceList = True
|
|
13191
13209
|
if (forceActivateDevice is None):
|
|
13192
13210
|
forceActivateDevice = True
|
|
13193
13211
|
|
|
@@ -346,6 +346,23 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
346
346
|
|
|
347
347
|
finally:
|
|
348
348
|
|
|
349
|
+
try:
|
|
350
|
+
|
|
351
|
+
# unwire event handlers.
|
|
352
|
+
_logsi.LogVerbose("%s - Unwiring event handlers" % (self.name))
|
|
353
|
+
if (self.DeviceAdded is not None):
|
|
354
|
+
self.DeviceAdded -= self.OnDeviceAdded
|
|
355
|
+
if (self.DeviceRemoved is not None):
|
|
356
|
+
self.DeviceRemoved -= self.OnDeviceRemoved
|
|
357
|
+
if (self.DeviceUpdated is not None):
|
|
358
|
+
self.DeviceUpdated -= self.OnDeviceUpdated
|
|
359
|
+
|
|
360
|
+
except:
|
|
361
|
+
|
|
362
|
+
# trace.
|
|
363
|
+
_logsi.LogException("%s - An unhandled exception occured while unwiring event handlers: %s" % (self.name, str(ex)), ex, logToSystemLogger=False)
|
|
364
|
+
# ignore exceptions, since we are shutting down.
|
|
365
|
+
|
|
349
366
|
try:
|
|
350
367
|
|
|
351
368
|
# stop spotify connect zeroconf discovery browser.
|
|
File without changes
|
|
File without changes
|
{spotifywebapiPython-1.0.162.dist-info → spotifywebapiPython-1.0.164.dist-info}/top_level.txt
RENAMED
|
File without changes
|