spotifywebapiPython 1.0.151__py3-none-any.whl → 1.0.152__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.151.dist-info → spotifywebapiPython-1.0.152.dist-info}/METADATA +1 -1
- {spotifywebapiPython-1.0.151.dist-info → spotifywebapiPython-1.0.152.dist-info}/RECORD +24 -24
- spotifywebapipython/const.py +1 -1
- spotifywebapipython/docs/__init__.html +8 -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 +337 -160
- 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/playerplaystate.py +42 -0
- spotifywebapipython/spotifyclient.py +773 -550
- spotifywebapipython/spotifyconnect/spotifyconnectdirectorytask.py +37 -16
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfexceptions.py +10 -0
- {spotifywebapiPython-1.0.151.dist-info → spotifywebapiPython-1.0.152.dist-info}/LICENSE +0 -0
- {spotifywebapiPython-1.0.151.dist-info → spotifywebapiPython-1.0.152.dist-info}/WHEEL +0 -0
- {spotifywebapiPython-1.0.151.dist-info → spotifywebapiPython-1.0.152.dist-info}/top_level.txt +0 -0
|
@@ -13,6 +13,7 @@ from uuid import UUID
|
|
|
13
13
|
from zeroconf import Zeroconf, ServiceBrowser
|
|
14
14
|
|
|
15
15
|
# our package imports.
|
|
16
|
+
from .spotifyconnectzeroconfexceptions import SpotifyConnectDeviceNotFound
|
|
16
17
|
from .spotifyconnectzeroconfcastapptask import SpotifyConnectZeroconfCastAppTask
|
|
17
18
|
from .spotifyconnectzeroconfcastlistener import SpotifyConnectZeroconfCastListener
|
|
18
19
|
from .spotifyconnectdeviceeventargs import SpotifyConnectDeviceEventArgs
|
|
@@ -733,33 +734,42 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
733
734
|
self,
|
|
734
735
|
value:str,
|
|
735
736
|
refreshDynamicDevices:bool=True,
|
|
737
|
+
raiseExceptionIfNotFound:bool=True,
|
|
736
738
|
) -> SpotifyConnectDevice:
|
|
737
739
|
"""
|
|
738
|
-
Returns a `SpotifyConnectDevice` object for the specified device name / id if found
|
|
739
|
-
|
|
740
|
+
Returns a `SpotifyConnectDevice` object for the specified device name / id if found
|
|
741
|
+
in the devices collection. otherwise, returns the currently active player
|
|
742
|
+
`SpotifyConnectDevice` object is returned. otherwise, null is returned.
|
|
740
743
|
|
|
741
744
|
Args:
|
|
742
|
-
value (str):
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
745
|
+
value (str | None):
|
|
746
|
+
The target player device identifier.
|
|
747
|
+
This could be an id, name, a default device indicator (e.g. "*"), or null
|
|
748
|
+
to utilize the active player device.
|
|
749
|
+
Examples are `0d1841b0976bae2a3a310dd74c0f3df354899bc8`, `Office`, `*`, None.
|
|
746
750
|
refreshDynamicDevices (bool):
|
|
747
751
|
True to refresh the list of dynamically added devices and the active player
|
|
748
752
|
state from real-time Spotify Web API data; otherwise, false to use the
|
|
749
753
|
current cached state and device list.
|
|
750
754
|
Default is True.
|
|
755
|
+
raiseExceptionIfNotFound (bool):
|
|
756
|
+
True to raise an exception if a device could not be resolved;
|
|
757
|
+
otherwise, False to just return a null value.
|
|
758
|
+
Default is True.
|
|
751
759
|
|
|
752
760
|
Returns:
|
|
753
|
-
A `SpotifyConnectDevice` object for the specified device name / id
|
|
761
|
+
A `SpotifyConnectDevice` object for the specified device name / id if found;
|
|
762
|
+
otherwise, null.
|
|
754
763
|
|
|
755
764
|
Raises:
|
|
765
|
+
SpotifyConnectDeviceNotFound:
|
|
766
|
+
If the `raiseExceptionIfNotFound` argument value is True, and the specified
|
|
767
|
+
device value was not found or there was no default device found.
|
|
756
768
|
SpotifyApiError:
|
|
757
|
-
If the specified device value was not found.
|
|
758
|
-
If there was no defaualt device found.
|
|
759
769
|
If an error occured while obtaining current Spotify Web API Player device data.
|
|
760
770
|
|
|
761
|
-
|
|
762
|
-
to the copy do not affect the internal master device entry.
|
|
771
|
+
If a SpotifyConnectDevice object is returned, it will be a copy of the internal master
|
|
772
|
+
device entry; any changes made to the copy do not affect the internal master device entry.
|
|
763
773
|
|
|
764
774
|
<details>
|
|
765
775
|
<summary>Sample Code</summary>
|
|
@@ -790,6 +800,8 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
790
800
|
value = None
|
|
791
801
|
if (not isinstance(refreshDynamicDevices, bool)):
|
|
792
802
|
refreshDynamicDevices = True
|
|
803
|
+
if (not isinstance(raiseExceptionIfNotFound, bool)):
|
|
804
|
+
raiseExceptionIfNotFound = True
|
|
793
805
|
valueOriginal:str = value
|
|
794
806
|
|
|
795
807
|
# get currently active player device.
|
|
@@ -806,6 +818,10 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
806
818
|
_logsi.LogObject(SILevel.Verbose, "Spotify Player device \"%s\" (%s) was found in the Spotify Connect Devices collection (by Active PlayerState)" % (scActiveDevice.Name, scActiveDevice.Id), scActiveDevice, excludeNonPublic=True)
|
|
807
819
|
return scActiveDevice
|
|
808
820
|
|
|
821
|
+
# if no active player device, then let's use the default device value.
|
|
822
|
+
_logsi.LogVerbose("Spotify Player has no active device; defaulting device selection to use DefaultDeviceId: \"%s\"" % (self.SpotifyClientInstance.DefaultDeviceId))
|
|
823
|
+
value = self.SpotifyClientInstance.DefaultDeviceId
|
|
824
|
+
|
|
809
825
|
# was a default device value specified?
|
|
810
826
|
# if so, then use the `defaultDeviceId` value; if the `defaultDeviceId` value is not in the device list,
|
|
811
827
|
# then we will catch it with the `GetDeviceById` / `GetDeviceByName` logic.
|
|
@@ -824,7 +840,7 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
824
840
|
_logsi.LogObject(SILevel.Verbose, "Spotify Player default device (*) was not configured; using active player device: %s" % (scActiveDevice.Title), scActiveDevice, excludeNonPublic=True)
|
|
825
841
|
return scActiveDevice
|
|
826
842
|
# if no default device and no active player, then it's an error!
|
|
827
|
-
raise SpotifyApiError("Spotify Player default device (*) was not configured, and there is no active Spotify Player device", logsi=_logsi)
|
|
843
|
+
#raise SpotifyApiError("Spotify Player default device (*) was not configured, and there is no active Spotify Player device", logsi=_logsi)
|
|
828
844
|
|
|
829
845
|
# assign default device value.
|
|
830
846
|
_logsi.LogVerbose("Spotify Player device default \"%s\" will be used for selecting a device (by default *)" % (defaultDeviceId))
|
|
@@ -860,8 +876,13 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
860
876
|
_logsi.LogObject(SILevel.Verbose, "Spotify Player default device \"%s\" was not found in the Spotify Connect Devices collection; using active player device: %s" % (value, scActiveDevice.Title), scActiveDevice, excludeNonPublic=True)
|
|
861
877
|
return scActiveDevice
|
|
862
878
|
|
|
863
|
-
# at this point we could not resolve the device name / id
|
|
864
|
-
raise
|
|
879
|
+
# at this point we could not resolve the device name / id, and there is no active player
|
|
880
|
+
# available; raise exception / return null as requested by the caller.
|
|
881
|
+
if (raiseExceptionIfNotFound):
|
|
882
|
+
raise SpotifyConnectDeviceNotFound("Spotify Player device \"%s\" was not found, and there is no active Spotify player" % (value))
|
|
883
|
+
else:
|
|
884
|
+
_logsi.LogVerbose("Spotify Player device \"%s\" was not found, and there is no active Spotify player" % (value))
|
|
885
|
+
return None
|
|
865
886
|
|
|
866
887
|
except SpotifyApiError: raise # pass handled exceptions on thru
|
|
867
888
|
except Exception as ex:
|
|
@@ -1059,9 +1080,9 @@ class SpotifyConnectDirectoryTask(threading.Thread):
|
|
|
1059
1080
|
|
|
1060
1081
|
# trace.
|
|
1061
1082
|
if (scDevice is None):
|
|
1062
|
-
_logsi.LogVerbose("Spotify Player playstate
|
|
1083
|
+
_logsi.LogVerbose("Spotify Player playstate device is not present; no active device")
|
|
1063
1084
|
else:
|
|
1064
|
-
_logsi.LogObject(SILevel.Verbose, "Spotify Player playstate active device instance %s" % (scDevice.Title), scDevice, excludeNonPublic=True)
|
|
1085
|
+
_logsi.LogObject(SILevel.Verbose, "Spotify Player playstate active device instance: %s" % (scDevice.Title), scDevice, excludeNonPublic=True)
|
|
1065
1086
|
|
|
1066
1087
|
# return real-time active Spotify Player device.
|
|
1067
1088
|
return scDevice
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
# our package imports.
|
|
2
|
+
from spotifywebapipython import SpotifyApiError
|
|
3
|
+
|
|
4
|
+
|
|
1
5
|
class SpotifyConnectZeroconfLaunchError(Exception):
|
|
2
6
|
"""
|
|
3
7
|
Exception raised when a cast app fails to launch.
|
|
@@ -8,3 +12,9 @@ class SpotifyConnectZeroconfPlaybackTransferError(Exception):
|
|
|
8
12
|
"""
|
|
9
13
|
Exception raised when a cast app fails to receive transfer of playback control.
|
|
10
14
|
"""
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class SpotifyConnectDeviceNotFound(SpotifyApiError):
|
|
18
|
+
"""
|
|
19
|
+
Exception raised when a Spotify Connect device could not be resolved.
|
|
20
|
+
"""
|
|
File without changes
|
|
File without changes
|
{spotifywebapiPython-1.0.151.dist-info → spotifywebapiPython-1.0.152.dist-info}/top_level.txt
RENAMED
|
File without changes
|