spotifywebapiPython 1.0.242__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 +35 -0
- spotifywebapipython/const.py +114 -0
- spotifywebapipython/docs/__init__.html +2156 -0
- spotifywebapipython/docs/codecopy.js +70 -0
- spotifywebapipython/docs/index.html +514 -0
- spotifywebapipython/docs/search.js +46 -0
- spotifywebapipython/docs/spotifywebapipython/const.html +636 -0
- spotifywebapipython/docs/spotifywebapipython/saappmessages.html +540 -0
- spotifywebapipython/docs/spotifywebapipython/sautils.html +620 -0
- spotifywebapipython/docs/spotifywebapipython/spotifyapierror.html +341 -0
- spotifywebapipython/docs/spotifywebapipython/spotifyapimessage.html +598 -0
- spotifywebapipython/docs/spotifywebapipython/spotifyauthtoken.html +612 -0
- spotifywebapipython/docs/spotifywebapipython/spotifyclient.html +16557 -0
- spotifywebapipython/docs/spotifywebapipython/spotifydiscovery.html +518 -0
- spotifywebapipython/docs/spotifywebapipython/spotifywebapiauthenticationerror.html +421 -0
- spotifywebapipython/docs/spotifywebapipython/spotifywebapierror.html +400 -0
- spotifywebapipython/docs/spotifywebapipython/spotifywebplayertoken.html +635 -0
- spotifywebapipython/docs/spotifywebapipython.ico +0 -0
- spotifywebapipython/docs/spotifywebapipython_OLD.ico +0 -0
- spotifywebapipython/models/__init__.py +121 -0
- spotifywebapipython/models/album.py +170 -0
- spotifywebapipython/models/albumpagesaved.py +85 -0
- spotifywebapipython/models/albumpagesimplified.py +88 -0
- spotifywebapipython/models/albumsaved.py +102 -0
- spotifywebapipython/models/albumsimplified.py +308 -0
- spotifywebapipython/models/artist.py +146 -0
- spotifywebapipython/models/artistinfo.py +282 -0
- spotifywebapipython/models/artistinfotourevent.py +127 -0
- spotifywebapipython/models/artistpage.py +70 -0
- spotifywebapipython/models/artistsimplified.py +163 -0
- spotifywebapipython/models/audiobook.py +87 -0
- spotifywebapipython/models/audiobookpagesimplified.py +88 -0
- spotifywebapipython/models/audiobooksimplified.py +362 -0
- spotifywebapipython/models/audiofeatures.py +333 -0
- spotifywebapipython/models/author.py +67 -0
- spotifywebapipython/models/category.py +168 -0
- spotifywebapipython/models/categorypage.py +70 -0
- spotifywebapipython/models/chapter.py +84 -0
- spotifywebapipython/models/chapterpagesimplified.py +88 -0
- spotifywebapipython/models/chaptersimplified.py +387 -0
- spotifywebapipython/models/context.py +113 -0
- spotifywebapipython/models/copyright.py +79 -0
- spotifywebapipython/models/device.py +301 -0
- spotifywebapipython/models/episode.py +84 -0
- spotifywebapipython/models/episodepagesaved.py +85 -0
- spotifywebapipython/models/episodepagesimplified.py +88 -0
- spotifywebapipython/models/episodesaved.py +99 -0
- spotifywebapipython/models/episodesimplified.py +370 -0
- spotifywebapipython/models/explicitcontent.py +80 -0
- spotifywebapipython/models/externalids.py +91 -0
- spotifywebapipython/models/externalurls.py +104 -0
- spotifywebapipython/models/followers.py +81 -0
- spotifywebapipython/models/imageobject.py +193 -0
- spotifywebapipython/models/imagevibrantcolors.py +182 -0
- spotifywebapipython/models/linkedfrom.py +165 -0
- spotifywebapipython/models/narrator.py +67 -0
- spotifywebapipython/models/owner.py +162 -0
- spotifywebapipython/models/pageobject.py +343 -0
- spotifywebapipython/models/playeractions.py +196 -0
- spotifywebapipython/models/playerlastplayedinfo.py +334 -0
- spotifywebapipython/models/playerplaystate.py +467 -0
- spotifywebapipython/models/playerqueueinfo.py +207 -0
- spotifywebapipython/models/playhistory.py +136 -0
- spotifywebapipython/models/playhistorypage.py +85 -0
- spotifywebapipython/models/playlist.py +125 -0
- spotifywebapipython/models/playlistpage.py +85 -0
- spotifywebapipython/models/playlistpagesimplified.py +107 -0
- spotifywebapipython/models/playlistsimplified.py +334 -0
- spotifywebapipython/models/playlisttrack.py +143 -0
- spotifywebapipython/models/playlisttracksummary.py +80 -0
- spotifywebapipython/models/recommendationseed.py +135 -0
- spotifywebapipython/models/restrictions.py +86 -0
- spotifywebapipython/models/resumepoint.py +79 -0
- spotifywebapipython/models/searchresponse.py +391 -0
- spotifywebapipython/models/searchresultbase.py +299 -0
- spotifywebapipython/models/show.py +87 -0
- spotifywebapipython/models/showpagesaved.py +85 -0
- spotifywebapipython/models/showpagesimplified.py +88 -0
- spotifywebapipython/models/showsaved.py +99 -0
- spotifywebapipython/models/showsimplified.py +320 -0
- spotifywebapipython/models/spotifyconnectdevice.py +321 -0
- spotifywebapipython/models/spotifyconnectdevices.py +441 -0
- spotifywebapipython/models/track.py +142 -0
- spotifywebapipython/models/trackpage.py +110 -0
- spotifywebapipython/models/trackpagesaved.py +85 -0
- spotifywebapipython/models/trackpagesimplified.py +88 -0
- spotifywebapipython/models/trackrecommendations.py +88 -0
- spotifywebapipython/models/tracksaved.py +99 -0
- spotifywebapipython/models/tracksimplified.py +398 -0
- spotifywebapipython/models/userprofile.py +184 -0
- spotifywebapipython/models/userprofilesimplified.py +206 -0
- spotifywebapipython/models/zeroconfdiscoveryresult.py +592 -0
- spotifywebapipython/models/zeroconfproperty.py +93 -0
- spotifywebapipython/oauthcli/__init__.py +7 -0
- spotifywebapipython/oauthcli/authclient.py +1229 -0
- spotifywebapipython/saappmessages.py +86 -0
- spotifywebapipython/sautils.py +285 -0
- spotifywebapipython/spotifyapierror.py +66 -0
- spotifywebapipython/spotifyapimessage.py +269 -0
- spotifywebapipython/spotifyauthtoken.py +264 -0
- spotifywebapipython/spotifyclient.py +17885 -0
- spotifywebapipython/spotifyconnect/__init__.py +19 -0
- spotifywebapipython/spotifyconnect/spotifyconnectdeviceeventargs.py +67 -0
- spotifywebapipython/spotifyconnect/spotifyconnectdirectorytask.py +2564 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastapptask.py +467 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastcontroller.py +701 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastlistener.py +359 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastmultizonelistener.py +212 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconfexceptions.py +20 -0
- spotifywebapipython/spotifyconnect/spotifyconnectzeroconflistener.py +335 -0
- spotifywebapipython/spotifydiscovery.py +473 -0
- spotifywebapipython/spotifymediatypes.py +53 -0
- spotifywebapipython/spotifywebapiauthenticationerror.py +122 -0
- spotifywebapipython/spotifywebapierror.py +106 -0
- spotifywebapipython/spotifywebplayertoken.py +743 -0
- spotifywebapipython/vibrant/__init__.py +17 -0
- spotifywebapipython/vibrant/generator.py +261 -0
- spotifywebapipython/vibrant/image.py +100 -0
- spotifywebapipython/vibrant/main.py +34 -0
- spotifywebapipython/vibrant/models.py +93 -0
- spotifywebapipython/vibrant/utils.py +56 -0
- spotifywebapipython/zeroconfapi/__init__.py +23 -0
- spotifywebapipython/zeroconfapi/authenticationtypes.py +38 -0
- spotifywebapipython/zeroconfapi/blobbuilder.py +370 -0
- spotifywebapipython/zeroconfapi/credentials.py +37 -0
- spotifywebapipython/zeroconfapi/cryptodiffiehellman.py +89 -0
- spotifywebapipython/zeroconfapi/helpers.py +64 -0
- spotifywebapipython/zeroconfapi/spotifyzeroconfapierror.py +108 -0
- spotifywebapipython/zeroconfapi/zeroconfconnect.py +1327 -0
- spotifywebapipython/zeroconfapi/zeroconfgetinfo.py +572 -0
- spotifywebapipython/zeroconfapi/zeroconfgetinfoalias.py +109 -0
- spotifywebapipython/zeroconfapi/zeroconfgetinfodrmmediaformat.py +90 -0
- spotifywebapipython/zeroconfapi/zeroconfresponse.py +195 -0
- spotifywebapipython-1.0.242.dist-info/LICENSE +22 -0
- spotifywebapipython-1.0.242.dist-info/METADATA +219 -0
- spotifywebapipython-1.0.242.dist-info/RECORD +138 -0
- spotifywebapipython-1.0.242.dist-info/WHEEL +5 -0
- spotifywebapipython-1.0.242.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
|
|
6
|
+
@export
|
|
7
|
+
class ExternalUrls:
|
|
8
|
+
"""
|
|
9
|
+
Spotify Web API ExternalUrls object.
|
|
10
|
+
|
|
11
|
+
Contains known external URLs for various object types: artist, track, etc.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, root:dict=None) -> None:
|
|
15
|
+
"""
|
|
16
|
+
Initializes a new instance of the class.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
root (dict):
|
|
20
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
21
|
+
attributes; otherwise, None to not load attributes.
|
|
22
|
+
"""
|
|
23
|
+
self._Ean:str = None
|
|
24
|
+
self._Isrc:str = None
|
|
25
|
+
self._Spotify:str = None
|
|
26
|
+
self._Upc:str = None
|
|
27
|
+
|
|
28
|
+
if (root is None):
|
|
29
|
+
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
else:
|
|
33
|
+
|
|
34
|
+
self._Ean = root.get('ean', None)
|
|
35
|
+
self._Isrc = root.get('isrc', None)
|
|
36
|
+
self._Spotify = root.get('spotify', None)
|
|
37
|
+
self._Upc = root.get('upc', None)
|
|
38
|
+
|
|
39
|
+
# TODO - test to see if anything other than 'spotify' is returned in this object
|
|
40
|
+
if self._Ean is not None or self._Isrc is not None or self._Upc is not None:
|
|
41
|
+
x:int = 0
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def __repr__(self) -> str:
|
|
45
|
+
return self.ToString()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def __str__(self) -> str:
|
|
49
|
+
return self.ToString()
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def Ean(self) -> str:
|
|
54
|
+
"""
|
|
55
|
+
International Article Number.
|
|
56
|
+
"""
|
|
57
|
+
return self._Ean
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def Isrc(self) -> str:
|
|
62
|
+
"""
|
|
63
|
+
International Standard Recording Code.
|
|
64
|
+
"""
|
|
65
|
+
return self._Isrc
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def Spotify(self) -> str:
|
|
70
|
+
"""
|
|
71
|
+
The Spotify URL for the object.
|
|
72
|
+
"""
|
|
73
|
+
return self._Spotify
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def Upc(self) -> str:
|
|
78
|
+
"""
|
|
79
|
+
Universal Product Code.
|
|
80
|
+
"""
|
|
81
|
+
return self._Upc
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
def ToDictionary(self) -> dict:
|
|
85
|
+
"""
|
|
86
|
+
Returns a dictionary representation of the class.
|
|
87
|
+
"""
|
|
88
|
+
result:dict = \
|
|
89
|
+
{
|
|
90
|
+
'spotify': self._Spotify,
|
|
91
|
+
}
|
|
92
|
+
return result
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def ToString(self) -> str:
|
|
96
|
+
"""
|
|
97
|
+
Returns a displayable string representation of the class.
|
|
98
|
+
"""
|
|
99
|
+
msg:str = 'ExternalUrls:'
|
|
100
|
+
if self._Spotify is not None: msg = '%s\n Spotify="%s"' % (msg, str(self._Spotify))
|
|
101
|
+
if self._Ean is not None: msg = '%s\n Ean="%s"' % (msg, str(self._Ean))
|
|
102
|
+
if self._Isrc is not None: msg = '%s\n Isrc="%s"' % (msg, str(self._Isrc))
|
|
103
|
+
if self._Upc is not None: msg = '%s\n Upc="%s"' % (msg, str(self._Upc))
|
|
104
|
+
return msg
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
|
|
6
|
+
@export
|
|
7
|
+
class Followers:
|
|
8
|
+
"""
|
|
9
|
+
Spotify Web API Followers object.
|
|
10
|
+
|
|
11
|
+
Contains information about the followers of an artist.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
def __init__(self, root:dict=None) -> None:
|
|
15
|
+
"""
|
|
16
|
+
Initializes a new instance of the class.
|
|
17
|
+
|
|
18
|
+
Args:
|
|
19
|
+
root (dict):
|
|
20
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
21
|
+
attributes; otherwise, None to not load attributes.
|
|
22
|
+
"""
|
|
23
|
+
self._Href:str = None
|
|
24
|
+
self._Total:int = None
|
|
25
|
+
|
|
26
|
+
if (root is None):
|
|
27
|
+
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
else:
|
|
31
|
+
|
|
32
|
+
self._Href = root.get('href', None)
|
|
33
|
+
self._Total = root.get('total', None)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def __repr__(self) -> str:
|
|
37
|
+
return self.ToString()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def __str__(self) -> str:
|
|
41
|
+
return self.ToString()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def Href(self) -> str:
|
|
46
|
+
"""
|
|
47
|
+
This will always be set to null, as the Web API does not support it at the moment.
|
|
48
|
+
"""
|
|
49
|
+
return self._Href
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
@property
|
|
53
|
+
def Total(self) -> int:
|
|
54
|
+
"""
|
|
55
|
+
The total number of followers.
|
|
56
|
+
|
|
57
|
+
Example: `31288`
|
|
58
|
+
"""
|
|
59
|
+
return self._Total
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def ToDictionary(self) -> dict:
|
|
63
|
+
"""
|
|
64
|
+
Returns a dictionary representation of the class.
|
|
65
|
+
"""
|
|
66
|
+
result:dict = \
|
|
67
|
+
{
|
|
68
|
+
'href': self._Href,
|
|
69
|
+
'total': self._Total,
|
|
70
|
+
}
|
|
71
|
+
return result
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def ToString(self) -> str:
|
|
75
|
+
"""
|
|
76
|
+
Returns a displayable string representation of the class.
|
|
77
|
+
"""
|
|
78
|
+
msg:str = 'Followers:'
|
|
79
|
+
if self._Total is not None: msg = '%s\n Total=%s' % (msg, str(self._Total))
|
|
80
|
+
if self._Href is not None: msg = '%s\n Href="%s"' % (msg, str(self._Href))
|
|
81
|
+
return msg
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
|
|
6
|
+
@export
|
|
7
|
+
class ImageObject:
|
|
8
|
+
"""
|
|
9
|
+
Spotify Web API Image object.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def __init__(self, root:dict=None) -> None:
|
|
13
|
+
"""
|
|
14
|
+
Initializes a new instance of the class.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
root (dict):
|
|
18
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
19
|
+
attributes; otherwise, None to not load attributes.
|
|
20
|
+
"""
|
|
21
|
+
self._Height:int = None
|
|
22
|
+
self._Url:str = None
|
|
23
|
+
self._Width:int = None
|
|
24
|
+
|
|
25
|
+
if (root is None):
|
|
26
|
+
|
|
27
|
+
pass
|
|
28
|
+
|
|
29
|
+
else:
|
|
30
|
+
|
|
31
|
+
self._Height = root.get('height', None)
|
|
32
|
+
self._Url = root.get('url', None)
|
|
33
|
+
self._Width = root.get('width', None)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def __repr__(self) -> str:
|
|
37
|
+
return self.ToString()
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def __str__(self) -> str:
|
|
41
|
+
return self.ToString()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@property
|
|
45
|
+
def Height(self) -> int:
|
|
46
|
+
"""
|
|
47
|
+
The image height in pixels.
|
|
48
|
+
|
|
49
|
+
Example: `300`
|
|
50
|
+
"""
|
|
51
|
+
return self._Height
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def Url(self) -> str:
|
|
56
|
+
"""
|
|
57
|
+
The source URL of the image.
|
|
58
|
+
|
|
59
|
+
Example: `https://i.scdn.co/image/ab67616d00001e02ff9ca10b55ce82ae553c8228`
|
|
60
|
+
"""
|
|
61
|
+
return self._Url
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def Width(self) -> int:
|
|
66
|
+
"""
|
|
67
|
+
The image width in pixels.
|
|
68
|
+
|
|
69
|
+
Example: `300`
|
|
70
|
+
"""
|
|
71
|
+
return self._Width
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
@staticmethod
|
|
75
|
+
def GetImageHighestResolution(
|
|
76
|
+
images:list,
|
|
77
|
+
desiredWidth:int=None,
|
|
78
|
+
) -> str:
|
|
79
|
+
"""
|
|
80
|
+
Returns the highest resolution order image from a list of `ImageObject` items.
|
|
81
|
+
|
|
82
|
+
Args:
|
|
83
|
+
images (list[ImageObject]):
|
|
84
|
+
The cover art for the media in various sizes, usually widest first.
|
|
85
|
+
desiredWidth (int):
|
|
86
|
+
A desired resolution width to return (if found); if not found, then the
|
|
87
|
+
highest resolution is returned.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
The highest resolution order image from the list of `images`.
|
|
91
|
+
|
|
92
|
+
The Spotify Web API normally returns a list of `ImageObject` items with the
|
|
93
|
+
highest resolution image as the first list item; however, the GetShowFavorites
|
|
94
|
+
returns them in the reverse order.
|
|
95
|
+
"""
|
|
96
|
+
result:str = None
|
|
97
|
+
resultWidth:int = 0
|
|
98
|
+
|
|
99
|
+
if (images is not None) and (len(images) > 0):
|
|
100
|
+
|
|
101
|
+
# set default image to return.
|
|
102
|
+
result = images[0].Url
|
|
103
|
+
resultWidth:int = (images[0].Width or 0) # in case width is null
|
|
104
|
+
|
|
105
|
+
# search for the highest resolution image and return it.
|
|
106
|
+
image: ImageObject
|
|
107
|
+
for image in images:
|
|
108
|
+
|
|
109
|
+
imageWidth:int = (image.Width or 0) # in case width is null
|
|
110
|
+
|
|
111
|
+
# check for exact desired width match.
|
|
112
|
+
if (desiredWidth is not None) and (desiredWidth == imageWidth):
|
|
113
|
+
result = image.Url
|
|
114
|
+
resultWidth = imageWidth
|
|
115
|
+
break
|
|
116
|
+
|
|
117
|
+
# check for largest resolution width match.
|
|
118
|
+
if (imageWidth > resultWidth):
|
|
119
|
+
result = image.Url
|
|
120
|
+
resultWidth = imageWidth
|
|
121
|
+
|
|
122
|
+
return result
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@staticmethod
|
|
126
|
+
def GetImageHighestResolutionWidth(
|
|
127
|
+
images:list,
|
|
128
|
+
desiredWidth:int=None,
|
|
129
|
+
) -> str:
|
|
130
|
+
"""
|
|
131
|
+
Returns the highest resolution order image width from a list of `ImageObject` items.
|
|
132
|
+
|
|
133
|
+
Args:
|
|
134
|
+
images (list[ImageObject]):
|
|
135
|
+
The cover art for the media in various sizes, usually widest first.
|
|
136
|
+
desiredWidth (int):
|
|
137
|
+
A desired resolution width to return (if found); if not found, then the
|
|
138
|
+
highest resolution is returned.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
The highest resolution order image width from the list of `images`.
|
|
142
|
+
|
|
143
|
+
The Spotify Web API normally returns a list of `ImageObject` items with the
|
|
144
|
+
highest resolution image as the first list item; however, the GetShowFavorites
|
|
145
|
+
returns them in the reverse order.
|
|
146
|
+
"""
|
|
147
|
+
resultWidth:int = 0
|
|
148
|
+
|
|
149
|
+
if (images is not None) and (len(images) > 0):
|
|
150
|
+
|
|
151
|
+
# set default image width to return.
|
|
152
|
+
resultWidth:int = (images[0].Width or 0) # in case width is null
|
|
153
|
+
|
|
154
|
+
# search for the highest resolution image width and return it.
|
|
155
|
+
image: ImageObject
|
|
156
|
+
for image in images:
|
|
157
|
+
|
|
158
|
+
imageWidth:int = (image.Width or 0) # in case width is null
|
|
159
|
+
|
|
160
|
+
# check for exact desired width match.
|
|
161
|
+
if (desiredWidth is not None) and (desiredWidth == imageWidth):
|
|
162
|
+
resultWidth = imageWidth
|
|
163
|
+
break
|
|
164
|
+
|
|
165
|
+
# check for largest resolution width match.
|
|
166
|
+
if (imageWidth > resultWidth):
|
|
167
|
+
resultWidth = imageWidth
|
|
168
|
+
|
|
169
|
+
return resultWidth
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def ToDictionary(self) -> dict:
|
|
173
|
+
"""
|
|
174
|
+
Returns a dictionary representation of the class.
|
|
175
|
+
"""
|
|
176
|
+
result:dict = \
|
|
177
|
+
{
|
|
178
|
+
'url': self._Url,
|
|
179
|
+
'height': self._Height,
|
|
180
|
+
'width': self._Width,
|
|
181
|
+
}
|
|
182
|
+
return result
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
def ToString(self) -> str:
|
|
186
|
+
"""
|
|
187
|
+
Returns a displayable string representation of the class.
|
|
188
|
+
"""
|
|
189
|
+
msg:str = 'ImageObject:'
|
|
190
|
+
if self._Width is not None: msg = '%s\n Width="%s"' % (msg, str(self._Width))
|
|
191
|
+
if self._Height is not None: msg = '%s\n Height="%s"' % (msg, str(self._Height))
|
|
192
|
+
if self._Url is not None: msg = '%s\n Url="%s"' % (msg, str(self._Url))
|
|
193
|
+
return msg
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
from ..vibrant import Palette, Swatch
|
|
3
|
+
|
|
4
|
+
# our package imports.
|
|
5
|
+
from ..sautils import export
|
|
6
|
+
|
|
7
|
+
@export
|
|
8
|
+
class ImageVibrantColors:
|
|
9
|
+
"""
|
|
10
|
+
Image Vibrant Colors object.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, root:Palette=None) -> None:
|
|
14
|
+
"""
|
|
15
|
+
Initializes a new instance of the class.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
root (Palette):
|
|
19
|
+
Vibrant Palette object that contains extracted color information used to load object
|
|
20
|
+
attributes; otherwise, None to not load attributes.
|
|
21
|
+
"""
|
|
22
|
+
self._EmptySwatch:Swatch = Swatch(rgb=[0,0,0], population=0, hsl=[0.0,0.0,0.0])
|
|
23
|
+
|
|
24
|
+
self._DarkMuted:Swatch = None
|
|
25
|
+
self._DarkVibrant:Swatch = None
|
|
26
|
+
self._LightMuted:Swatch = None
|
|
27
|
+
self._LightVibrant:Swatch = None
|
|
28
|
+
self._Muted:Swatch = None
|
|
29
|
+
self._Vibrant:Swatch = None
|
|
30
|
+
|
|
31
|
+
if (not isinstance(root, Palette)):
|
|
32
|
+
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
else:
|
|
36
|
+
|
|
37
|
+
# store vibrant color palette information.
|
|
38
|
+
self._DarkMuted = root.dark_muted
|
|
39
|
+
self._DarkVibrant = root.dark_vibrant
|
|
40
|
+
self._LightMuted = root.light_muted
|
|
41
|
+
self._LightVibrant = root.light_vibrant
|
|
42
|
+
self._Muted = root.muted
|
|
43
|
+
self._Vibrant = root.vibrant
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def __repr__(self) -> str:
|
|
47
|
+
return self.ToString()
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def __str__(self) -> str:
|
|
51
|
+
return self.ToString()
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@property
|
|
55
|
+
def DarkMuted(self) -> Swatch:
|
|
56
|
+
"""
|
|
57
|
+
A dark but muted version of the color palette.
|
|
58
|
+
|
|
59
|
+
This value represents a dark, muted color from the image, meaning the color is darker than
|
|
60
|
+
others in the image and has lower saturation. The resulting color is not vibrant or bright
|
|
61
|
+
but still retains some of the overall mood or tone of the image.
|
|
62
|
+
|
|
63
|
+
This value is typically used when you want a darker, less intense color that adds subtle depth
|
|
64
|
+
to a design. It's great for backgrounds, sidebars, or any UI element where you want a muted,
|
|
65
|
+
non-intrusive tone.
|
|
66
|
+
"""
|
|
67
|
+
return self._DarkMuted or self._EmptySwatch
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@property
|
|
71
|
+
def DarkVibrant(self) -> Swatch:
|
|
72
|
+
"""
|
|
73
|
+
A darker and vibrant version of the dominant color.
|
|
74
|
+
|
|
75
|
+
This value represents a darker shade of the vibrant dominant color, retaining its saturation
|
|
76
|
+
and richness. It's typically used when you want to use a darker variant of the most dominant
|
|
77
|
+
color in the image, but still with significant visual impact.
|
|
78
|
+
|
|
79
|
+
This value is commonly used for prominent elements that need to stand out in a dark color
|
|
80
|
+
palette, like header bars, call-to-action buttons, or elements that need to grab attention
|
|
81
|
+
but in a muted, dark fashion.
|
|
82
|
+
"""
|
|
83
|
+
return self._DarkVibrant or self._EmptySwatch
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
@property
|
|
87
|
+
def LightMuted(self) -> Swatch:
|
|
88
|
+
"""
|
|
89
|
+
A lighter but muted version of the color palette.
|
|
90
|
+
|
|
91
|
+
This value represents a light color with low saturation. It's a softer and more desaturated
|
|
92
|
+
version of the most prominent light color in the image.
|
|
93
|
+
|
|
94
|
+
This value is great for when you need a color that won't draw too much attention but still
|
|
95
|
+
provides a harmonious tone. It can be used for backgrounds, UI components, or designs that need
|
|
96
|
+
to remain visually calm or neutral.
|
|
97
|
+
"""
|
|
98
|
+
return self._LightMuted or self._EmptySwatch
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@property
|
|
102
|
+
def LightVibrant(self) -> Swatch:
|
|
103
|
+
"""
|
|
104
|
+
A lighter and vibrant version of the dominant color.
|
|
105
|
+
|
|
106
|
+
This value represents a light, saturated color that retains vibrancy. It's less dark than the
|
|
107
|
+
darkVibrant swatch, but it maintains high saturation, making it stand out in designs that require
|
|
108
|
+
a colorful but light tone.
|
|
109
|
+
|
|
110
|
+
This value is typically used for elements that need to draw attention in a design without being
|
|
111
|
+
overpowering. It's useful for buttons, highlights, or icons that need to stand out in a bright,
|
|
112
|
+
colorful design while maintaining a softer appearance compared to darker vibrant tones.
|
|
113
|
+
"""
|
|
114
|
+
return self._LightVibrant or self._EmptySwatch
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
@property
|
|
118
|
+
def Muted(self) -> Swatch:
|
|
119
|
+
"""
|
|
120
|
+
A color that is less saturated and has a softer tone.
|
|
121
|
+
|
|
122
|
+
This value corresponds to a color that is desaturated or toned down. While it may be one of the
|
|
123
|
+
prominent colors in the image, its saturation is significantly reduced, making it softer and more
|
|
124
|
+
subtle compared to the vibrant color.
|
|
125
|
+
|
|
126
|
+
This value is useful in situations where you want a color that's not overpowering but still retains
|
|
127
|
+
visual presence. It works well for backgrounds, borders, or UI components that should be visible without
|
|
128
|
+
grabbing too much attention.
|
|
129
|
+
"""
|
|
130
|
+
return self._Muted or self._EmptySwatch
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@property
|
|
134
|
+
def Vibrant(self) -> Swatch:
|
|
135
|
+
"""
|
|
136
|
+
The most dominant, bright, and saturated color in the image.
|
|
137
|
+
|
|
138
|
+
This value corresponds to the most vibrant color from the image, meaning it's the most saturated and
|
|
139
|
+
intense color found in the image. It's the color that grabs attention due to its brightness and boldness.
|
|
140
|
+
|
|
141
|
+
This value is ideal for creating designs that need a bold, eye-catching focal point. It can be used for
|
|
142
|
+
accent colors, calls to action (CTAs), buttons, and any design element where you want the color to stand
|
|
143
|
+
out and be visually stimulating.
|
|
144
|
+
"""
|
|
145
|
+
return self._Vibrant or self._EmptySwatch
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
def ToDictionary(self) -> dict:
|
|
149
|
+
"""
|
|
150
|
+
Returns a dictionary representation of the class.
|
|
151
|
+
"""
|
|
152
|
+
result:dict = \
|
|
153
|
+
{
|
|
154
|
+
'dark_muted': self.DarkMuted.ToDictionary(),
|
|
155
|
+
'dark_vibrant': self.DarkVibrant.ToDictionary(),
|
|
156
|
+
'light_muted': self.LightMuted.ToDictionary(),
|
|
157
|
+
'light_vibrant': self.LightVibrant.ToDictionary(),
|
|
158
|
+
'muted': self.Muted.ToDictionary(),
|
|
159
|
+
'vibrant': self.Vibrant.ToDictionary(),
|
|
160
|
+
}
|
|
161
|
+
return result
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def ToString(self, includeTitle:bool=True) -> str:
|
|
165
|
+
"""
|
|
166
|
+
Returns a displayable string representation of the class.
|
|
167
|
+
|
|
168
|
+
Args:
|
|
169
|
+
includeTitle (str):
|
|
170
|
+
True to include the class name title prefix.
|
|
171
|
+
"""
|
|
172
|
+
msg:str = ''
|
|
173
|
+
if includeTitle:
|
|
174
|
+
msg = 'ImageVibrantColors:'
|
|
175
|
+
|
|
176
|
+
msg = '%s\n DarkMuted: %s' % (msg, self.DarkMuted.ToString(False))
|
|
177
|
+
msg = '%s\n DarkVibrant: %s' % (msg, self.DarkVibrant.ToString(False))
|
|
178
|
+
msg = '%s\n LightMuted: %s' % (msg, self.LightMuted.ToString(False))
|
|
179
|
+
msg = '%s\n LightVibrant: %s' % (msg, self.LightVibrant.ToString(False))
|
|
180
|
+
msg = '%s\n Muted: %s' % (msg, self.Muted.ToString(False))
|
|
181
|
+
msg = '%s\n Vibrant: %s' % (msg, self.Vibrant.ToString(False))
|
|
182
|
+
return msg
|