spotifywebapiPython 1.0.150__py3-none-any.whl → 1.0.151__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.150.dist-info → spotifywebapiPython-1.0.151.dist-info}/METADATA +2 -1
- {spotifywebapiPython-1.0.150.dist-info → spotifywebapiPython-1.0.151.dist-info}/RECORD +24 -24
- spotifywebapipython/const.py +6 -1
- spotifywebapipython/docs/__init__.html +9 -2
- spotifywebapipython/docs/index.html +2 -2
- spotifywebapipython/docs/search.js +1 -1
- spotifywebapipython/docs/spotifywebapipython/const.html +20 -3
- spotifywebapipython/docs/spotifywebapipython/saappmessages.html +2 -2
- spotifywebapipython/docs/spotifywebapipython/sautils.html +65 -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 +42 -2
- 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/models/spotifyconnectdevice.py +12 -0
- spotifywebapipython/sautils.py +50 -0
- spotifywebapipython/spotifyclient.py +491 -163
- spotifywebapipython/spotifyconnect/spotifyconnectdirectorytask.py +61 -0
- {spotifywebapiPython-1.0.150.dist-info → spotifywebapiPython-1.0.151.dist-info}/LICENSE +0 -0
- {spotifywebapiPython-1.0.150.dist-info → spotifywebapiPython-1.0.151.dist-info}/WHEEL +0 -0
- {spotifywebapiPython-1.0.150.dist-info → spotifywebapiPython-1.0.151.dist-info}/top_level.txt +0 -0
|
@@ -6,6 +6,7 @@ from datetime import datetime
|
|
|
6
6
|
import hashlib
|
|
7
7
|
from pychromecast import CastBrowser, CastInfo, Chromecast, get_chromecast_from_cast_info
|
|
8
8
|
import socket
|
|
9
|
+
from soco import SoCo
|
|
9
10
|
import threading
|
|
10
11
|
import time
|
|
11
12
|
from uuid import UUID
|
|
@@ -101,6 +102,7 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
101
102
|
self._CastBrowser:CastBrowser = None
|
|
102
103
|
self._InitialDiscoveryTimeout = initialDiscoveryTimeout
|
|
103
104
|
self._IsStopRequested:bool = False
|
|
105
|
+
self._SonosPlayers:dict = {}
|
|
104
106
|
self._SpotifyClientInstance = spotifyClientInstance
|
|
105
107
|
self._SpotifyConnectBrowser:ServiceBrowser = None
|
|
106
108
|
self._SpotifyConnectDevices:SpotifyConnectDevices = SpotifyConnectDevices()
|
|
@@ -957,6 +959,50 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
957
959
|
return result
|
|
958
960
|
|
|
959
961
|
|
|
962
|
+
def GetSonosPlayer(
|
|
963
|
+
self,
|
|
964
|
+
device:SpotifyConnectDevice,
|
|
965
|
+
) -> SoCo:
|
|
966
|
+
"""
|
|
967
|
+
Returns the Sonos Controller instance for the specified Spotify Connect device.
|
|
968
|
+
Returns the Sonos player instance for the specified Spotify Connect Sonos device.
|
|
969
|
+
|
|
970
|
+
Args:
|
|
971
|
+
device (SpotifyConnectDevice):
|
|
972
|
+
Spotify Connect device instance used to identify the Sonos player.
|
|
973
|
+
|
|
974
|
+
Returns:
|
|
975
|
+
The Sonos Controller instance for the specified Spotify Connect device.
|
|
976
|
+
|
|
977
|
+
Raises:
|
|
978
|
+
SpotifyApiError:
|
|
979
|
+
If a Sonos Controller instance could not be found for the device id.
|
|
980
|
+
|
|
981
|
+
You should invoke "if (scDevice.IsSonos):" logic prior to calling this method, as
|
|
982
|
+
a Sonos Controller instance will not be created for non-Sonos devices and an exception
|
|
983
|
+
will be raised!
|
|
984
|
+
"""
|
|
985
|
+
apiMethodName:str = "GetSonosPlayer"
|
|
986
|
+
|
|
987
|
+
# syncronize access via lock, as we are accessing the collection.
|
|
988
|
+
with self._SpotifyConnectDevices_RLock:
|
|
989
|
+
|
|
990
|
+
result:SpotifyConnectDevice = None
|
|
991
|
+
|
|
992
|
+
# validations.
|
|
993
|
+
if (device is None):
|
|
994
|
+
raise SpotifyApiError(SAAppMessages.ARGUMENT_REQUIRED_ERROR % (apiMethodName, 'device'), logsi=_logsi)
|
|
995
|
+
|
|
996
|
+
# get Sonos Controller instance for device name.
|
|
997
|
+
sonosPlayer:SoCo = self._SonosPlayers.get(device.DiscoveryResult.HostIpAddress, None)
|
|
998
|
+
|
|
999
|
+
# if not found then it's an error.
|
|
1000
|
+
if (sonosPlayer is None):
|
|
1001
|
+
raise SpotifyApiError("Could not find Sonos Controller instance for device: %s" % (device.Title), None, logsi=_logsi)
|
|
1002
|
+
|
|
1003
|
+
return sonosPlayer
|
|
1004
|
+
|
|
1005
|
+
|
|
960
1006
|
def GetSpotifyDeviceIDFromName(
|
|
961
1007
|
self,
|
|
962
1008
|
name:str
|
|
@@ -1738,6 +1784,21 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
1738
1784
|
if (len(self._SpotifyConnectDevices.Items) > 0):
|
|
1739
1785
|
self._SpotifyConnectDevices.Items.sort(key=lambda x: (x.Name or "").lower(), reverse=False)
|
|
1740
1786
|
|
|
1787
|
+
try:
|
|
1788
|
+
|
|
1789
|
+
# if new device is a Sonos, then create a Sonos Controller instance for the device.
|
|
1790
|
+
# use device ip address as the key, as Spotify Web API reports id=null for restricted devices in playerstate!
|
|
1791
|
+
if (scDevice.IsSonos):
|
|
1792
|
+
_logsi.LogVerbose("Sonos device detected; creating Sonos Controller instance for device: %s (ip=%s)" % (scDevice.Title, zeroconfDiscoveryResult.HostIpAddress))
|
|
1793
|
+
self._SonosPlayers[zeroconfDiscoveryResult.HostIpAddress] = SoCo(zeroconfDiscoveryResult.HostIpAddress)
|
|
1794
|
+
|
|
1795
|
+
except:
|
|
1796
|
+
|
|
1797
|
+
# trace.
|
|
1798
|
+
_logsi.LogException("%s - Could not create Sonos Control API reference: %s" % (self.name, str(ex)), ex, logToSystemLogger=False)
|
|
1799
|
+
|
|
1800
|
+
# ignore exceptions, as there is nothing we can do at this point.
|
|
1801
|
+
|
|
1741
1802
|
# raise event.
|
|
1742
1803
|
self._RaiseDeviceAdded(scDevice)
|
|
1743
1804
|
|
|
File without changes
|
|
File without changes
|
{spotifywebapiPython-1.0.150.dist-info → spotifywebapiPython-1.0.151.dist-info}/top_level.txt
RENAMED
|
File without changes
|