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,84 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .chaptersimplified import ChapterSimplified
|
|
6
|
+
from .audiobooksimplified import AudiobookSimplified
|
|
7
|
+
|
|
8
|
+
@export
|
|
9
|
+
class Chapter(ChapterSimplified):
|
|
10
|
+
"""
|
|
11
|
+
Spotify Web API Chapter object.
|
|
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
|
+
# initialize base class.
|
|
24
|
+
super().__init__(root=root)
|
|
25
|
+
|
|
26
|
+
self._Audiobook:AudiobookSimplified = None
|
|
27
|
+
|
|
28
|
+
if (root is None):
|
|
29
|
+
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
else:
|
|
33
|
+
|
|
34
|
+
# process all collections and objects.
|
|
35
|
+
item:dict = root.get('audiobook',None)
|
|
36
|
+
if item is not None:
|
|
37
|
+
self._Audiobook = AudiobookSimplified(root=item)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def __repr__(self) -> str:
|
|
41
|
+
return self.ToString()
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def __str__(self) -> str:
|
|
45
|
+
return self.ToString()
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@property
|
|
49
|
+
def Audiobook(self) -> AudiobookSimplified:
|
|
50
|
+
"""
|
|
51
|
+
The audiobook for which the chapter belongs.
|
|
52
|
+
|
|
53
|
+
This is a `AudiobookSimplified` object.
|
|
54
|
+
"""
|
|
55
|
+
return self._Audiobook
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def ToDictionary(self) -> dict:
|
|
59
|
+
"""
|
|
60
|
+
Returns a dictionary representation of the class.
|
|
61
|
+
"""
|
|
62
|
+
# get base class result.
|
|
63
|
+
resultBase:dict = super().ToDictionary()
|
|
64
|
+
|
|
65
|
+
result:dict = \
|
|
66
|
+
{
|
|
67
|
+
'audiobook': self._Audiobook.ToDictionary(),
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# combine base class results with these results.
|
|
71
|
+
resultBase.update(result)
|
|
72
|
+
|
|
73
|
+
# return a sorted dictionary.
|
|
74
|
+
return dict(sorted(resultBase.items()))
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def ToString(self) -> str:
|
|
78
|
+
"""
|
|
79
|
+
Returns a displayable string representation of the class.
|
|
80
|
+
"""
|
|
81
|
+
msg:str = 'Chapter: %s' % super().ToString(False)
|
|
82
|
+
if self._Audiobook is not None: msg = '%s\n Audiobook Name="%s"' % (msg, str(self._Audiobook.Name))
|
|
83
|
+
return msg
|
|
84
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .chaptersimplified import ChapterSimplified
|
|
6
|
+
from .pageobject import PageObject
|
|
7
|
+
|
|
8
|
+
@export
|
|
9
|
+
class ChapterPageSimplified(PageObject):
|
|
10
|
+
"""
|
|
11
|
+
Spotify Web API SimplifiedChapterPage object.
|
|
12
|
+
|
|
13
|
+
This allows for multiple pages of `ChapterSimplified` objects to be navigated.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, root:dict=None) -> None:
|
|
17
|
+
"""
|
|
18
|
+
Initializes a new instance of the class.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
root (dict):
|
|
22
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
23
|
+
attributes; otherwise, None to not load attributes.
|
|
24
|
+
"""
|
|
25
|
+
# initialize base class.
|
|
26
|
+
super().__init__(root=root)
|
|
27
|
+
|
|
28
|
+
# initialize storage.
|
|
29
|
+
self._Items:list[ChapterSimplified] = []
|
|
30
|
+
|
|
31
|
+
if (root is None):
|
|
32
|
+
|
|
33
|
+
self._Total = 0
|
|
34
|
+
|
|
35
|
+
else:
|
|
36
|
+
|
|
37
|
+
# process all collections and objects.
|
|
38
|
+
items:list = root.get('items',None)
|
|
39
|
+
if items is not None:
|
|
40
|
+
for item in items:
|
|
41
|
+
if item is not None:
|
|
42
|
+
self._Items.append(ChapterSimplified(root=item))
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def __repr__(self) -> str:
|
|
46
|
+
return self.ToString()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def __str__(self) -> str:
|
|
50
|
+
return self.ToString()
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def Items(self) -> list[ChapterSimplified]:
|
|
55
|
+
"""
|
|
56
|
+
Array of `ChapterSimplified` objects.
|
|
57
|
+
"""
|
|
58
|
+
return self._Items
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def ContainsId(self, itemId:str=False) -> bool:
|
|
62
|
+
"""
|
|
63
|
+
Checks the `Items` collection to see if an item already exists with the
|
|
64
|
+
specified Id value.
|
|
65
|
+
|
|
66
|
+
Returns True if the itemId exists in the collection; otherwise, False.
|
|
67
|
+
"""
|
|
68
|
+
result:bool = False
|
|
69
|
+
|
|
70
|
+
item:ChapterSimplified
|
|
71
|
+
for item in self._Items:
|
|
72
|
+
if item.Id == itemId:
|
|
73
|
+
result = True
|
|
74
|
+
break
|
|
75
|
+
|
|
76
|
+
return result
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def ToString(self, includeItems:bool=False) -> str:
|
|
80
|
+
"""
|
|
81
|
+
Returns a displayable string representation of the class.
|
|
82
|
+
|
|
83
|
+
Args:
|
|
84
|
+
includeItems (bool):
|
|
85
|
+
True to include the Items collection of objects; otherwise, False
|
|
86
|
+
to only return base properties.
|
|
87
|
+
"""
|
|
88
|
+
return 'ChapterPageSimplified: %s' % super().ToString(includeItems)
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .externalurls import ExternalUrls
|
|
6
|
+
from .imageobject import ImageObject
|
|
7
|
+
from .restrictions import Restrictions
|
|
8
|
+
from .resumepoint import ResumePoint
|
|
9
|
+
|
|
10
|
+
@export
|
|
11
|
+
class ChapterSimplified:
|
|
12
|
+
"""
|
|
13
|
+
Spotify Web API Simplified Chapter object.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
def __init__(self, root:dict=None) -> None:
|
|
17
|
+
"""
|
|
18
|
+
Initializes a new instance of the class.
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
root (dict):
|
|
22
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
23
|
+
attributes; otherwise, None to not load attributes.
|
|
24
|
+
"""
|
|
25
|
+
self._AudioPreviewUrl:str = None
|
|
26
|
+
self._AvailableMarkets:list[str] = []
|
|
27
|
+
self._ChapterNumber:int = None
|
|
28
|
+
self._Description:str = None
|
|
29
|
+
self._DurationMS:int = None
|
|
30
|
+
self._Explicit:bool = None
|
|
31
|
+
self._ExternalUrls:ExternalUrls = None
|
|
32
|
+
self._Href:str = None
|
|
33
|
+
self._HtmlDescription:str = None
|
|
34
|
+
self._Id:str = None
|
|
35
|
+
self._Images:list[ImageObject] = []
|
|
36
|
+
self._IsPlayable:bool = None
|
|
37
|
+
self._Languages:list[str] = []
|
|
38
|
+
self._Name:str = None
|
|
39
|
+
self._ReleaseDate:str = None
|
|
40
|
+
self._ReleaseDatePrecision:str = None
|
|
41
|
+
self._Restrictions:Restrictions = None
|
|
42
|
+
self._ResumePoint:ResumePoint = None
|
|
43
|
+
self._Type:str = None
|
|
44
|
+
self._Uri:str = None
|
|
45
|
+
|
|
46
|
+
if (root is None):
|
|
47
|
+
|
|
48
|
+
pass
|
|
49
|
+
|
|
50
|
+
else:
|
|
51
|
+
|
|
52
|
+
self._AudioPreviewUrl = root.get('audio_preview_url', None)
|
|
53
|
+
self._AvailableMarkets = root.get('available_markets', None) or []
|
|
54
|
+
self._ChapterNumber = root.get('chapter_number', None)
|
|
55
|
+
self._Description = root.get('description', None)
|
|
56
|
+
self._DurationMS = root.get('duration_ms', None)
|
|
57
|
+
self._Explicit = root.get('explicit', None)
|
|
58
|
+
self._Href = root.get('href', None)
|
|
59
|
+
self._HtmlDescription = root.get('html_description', None)
|
|
60
|
+
self._Id = root.get('id', None)
|
|
61
|
+
self._IsPlayable = root.get('is_playable', None)
|
|
62
|
+
self._Languages = root.get('languages', None) or []
|
|
63
|
+
self._Name = root.get('name', None)
|
|
64
|
+
self._ReleaseDate = root.get('release_date', None)
|
|
65
|
+
self._ReleaseDatePrecision = root.get('release_date_precision', None)
|
|
66
|
+
self._Type = root.get('type', None)
|
|
67
|
+
self._Uri = root.get('uri', None)
|
|
68
|
+
|
|
69
|
+
# process all collections and objects.
|
|
70
|
+
item:dict = root.get('external_urls',None)
|
|
71
|
+
if item is not None:
|
|
72
|
+
self._ExternalUrls = ExternalUrls(root=item)
|
|
73
|
+
|
|
74
|
+
items:list = root.get('images',None)
|
|
75
|
+
if items is not None:
|
|
76
|
+
for item in items:
|
|
77
|
+
self._Images.append(ImageObject(root=item))
|
|
78
|
+
|
|
79
|
+
item:dict = root.get('restrictions',None)
|
|
80
|
+
if item is not None:
|
|
81
|
+
self._Restrictions = Restrictions(root=item)
|
|
82
|
+
|
|
83
|
+
item:dict = root.get('resume_point',None)
|
|
84
|
+
if item is not None:
|
|
85
|
+
self._ResumePoint = ResumePoint(root=item)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def __repr__(self) -> str:
|
|
89
|
+
return self.ToString()
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def __str__(self) -> str:
|
|
93
|
+
return self.ToString()
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
# implement sorting support.
|
|
97
|
+
def __eq__(self, other):
|
|
98
|
+
try:
|
|
99
|
+
return self.Name == other.Name
|
|
100
|
+
except Exception:
|
|
101
|
+
if (isinstance(self, ChapterSimplified )) and (isinstance(other, ChapterSimplified )):
|
|
102
|
+
return self.Name == other.Name
|
|
103
|
+
return False
|
|
104
|
+
|
|
105
|
+
def __lt__(self, other):
|
|
106
|
+
try:
|
|
107
|
+
return self.Name < other.Name
|
|
108
|
+
except Exception:
|
|
109
|
+
if (isinstance(self, ChapterSimplified )) and (isinstance(other, ChapterSimplified )):
|
|
110
|
+
return self.Name < other.Name
|
|
111
|
+
return False
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
@property
|
|
115
|
+
def AudioPreviewUrl(self) -> str:
|
|
116
|
+
"""
|
|
117
|
+
A URL to a 30 second preview (MP3 format) of the chapter, or null if not available.
|
|
118
|
+
|
|
119
|
+
Important policy note:
|
|
120
|
+
Spotify Audio preview clips can not be a standalone service.
|
|
121
|
+
|
|
122
|
+
Example: `https://p.scdn.co/mp3-preview/2f37da1d4221f40b9d1a98cd191f4d6f1646ad17`
|
|
123
|
+
"""
|
|
124
|
+
return self._AudioPreviewUrl
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
@property
|
|
128
|
+
def AvailableMarkets(self) -> list[str]:
|
|
129
|
+
"""
|
|
130
|
+
A list of the countries in which the chapter can be played, identified by
|
|
131
|
+
their ISO 3166-1 alpha-2 code.
|
|
132
|
+
|
|
133
|
+
Example: `["CA","BR","IT"]`
|
|
134
|
+
"""
|
|
135
|
+
return self._AvailableMarkets
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
@property
|
|
139
|
+
def ChapterNumber(self) -> int:
|
|
140
|
+
"""
|
|
141
|
+
The number of the chapter.
|
|
142
|
+
|
|
143
|
+
Example: `1`
|
|
144
|
+
"""
|
|
145
|
+
return self._ChapterNumber
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
@property
|
|
149
|
+
def Description(self) -> str:
|
|
150
|
+
"""
|
|
151
|
+
A description of the chapter.
|
|
152
|
+
|
|
153
|
+
HTML tags are stripped away from this field, use html_description field in case HTML tags are needed.
|
|
154
|
+
"""
|
|
155
|
+
return self._Description
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
@property
|
|
159
|
+
def DurationMS(self) -> int:
|
|
160
|
+
"""
|
|
161
|
+
The chapter length in milliseconds.
|
|
162
|
+
|
|
163
|
+
Example: `1686230`
|
|
164
|
+
"""
|
|
165
|
+
return self._DurationMS
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
@property
|
|
169
|
+
def Explicit(self) -> bool:
|
|
170
|
+
"""
|
|
171
|
+
Whether or not the chapter has explicit content (true = yes it does; false = no it does not OR unknown).
|
|
172
|
+
"""
|
|
173
|
+
return self._Explicit
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
@property
|
|
177
|
+
def ExternalUrls(self) -> ExternalUrls:
|
|
178
|
+
"""
|
|
179
|
+
Known external URLs for the chapter.
|
|
180
|
+
"""
|
|
181
|
+
return self._ExternalUrls
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
@property
|
|
185
|
+
def Href(self) -> str:
|
|
186
|
+
"""
|
|
187
|
+
A link to the Web API endpoint providing full details of the chapter.
|
|
188
|
+
|
|
189
|
+
Example: `https://api.spotify.com/v1/chapters/0D5wENdkdwbqlrHoaJ9g29`
|
|
190
|
+
"""
|
|
191
|
+
return self._Href
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
@property
|
|
195
|
+
def HtmlDescription(self) -> str:
|
|
196
|
+
"""
|
|
197
|
+
A description of the chapter. This field may contain HTML tags.
|
|
198
|
+
"""
|
|
199
|
+
return self._HtmlDescription
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
@property
|
|
203
|
+
def Id(self) -> str:
|
|
204
|
+
"""
|
|
205
|
+
The Spotify ID for the chapter.
|
|
206
|
+
|
|
207
|
+
Example: `0D5wENdkdwbqlrHoaJ9g29`
|
|
208
|
+
"""
|
|
209
|
+
return self._Id
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@property
|
|
213
|
+
def Images(self) -> list[ImageObject]:
|
|
214
|
+
"""
|
|
215
|
+
The cover art for the chapter in various sizes, widest first.
|
|
216
|
+
"""
|
|
217
|
+
return self._Images
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
@property
|
|
221
|
+
def ImageUrl(self) -> str:
|
|
222
|
+
"""
|
|
223
|
+
Returns the highest resolution order image from the `Images` list, if images
|
|
224
|
+
are defined; otherwise, null.
|
|
225
|
+
"""
|
|
226
|
+
return ImageObject.GetImageHighestResolution(self._Images)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
@property
|
|
230
|
+
def IsPlayable(self) -> bool:
|
|
231
|
+
"""
|
|
232
|
+
True if the chapter is playable in the given market. Otherwise false.
|
|
233
|
+
"""
|
|
234
|
+
return self._IsPlayable
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
@property
|
|
238
|
+
def Languages(self) -> list[str]:
|
|
239
|
+
"""
|
|
240
|
+
A list of the languages used in the chapter, identified by their ISO 639-1 code.
|
|
241
|
+
|
|
242
|
+
Example: `[fr,en]`
|
|
243
|
+
"""
|
|
244
|
+
return self._Languages
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
@property
|
|
248
|
+
def Name(self) -> str:
|
|
249
|
+
"""
|
|
250
|
+
The name of the chapter.
|
|
251
|
+
"""
|
|
252
|
+
return self._Name
|
|
253
|
+
|
|
254
|
+
|
|
255
|
+
@property
|
|
256
|
+
def ReleaseDate(self) -> str:
|
|
257
|
+
"""
|
|
258
|
+
The date the chapter was first released.
|
|
259
|
+
|
|
260
|
+
Example: `1981-12`
|
|
261
|
+
Depending on the precision, it might be shown as "1981" or "1981-12".
|
|
262
|
+
"""
|
|
263
|
+
return self._ReleaseDate
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
@property
|
|
267
|
+
def ReleaseDatePrecision(self) -> str:
|
|
268
|
+
"""
|
|
269
|
+
The precision with which release_date value is known.
|
|
270
|
+
Allowed values: `year`, `month`, `day`.
|
|
271
|
+
|
|
272
|
+
Example: `year`
|
|
273
|
+
"""
|
|
274
|
+
return self._ReleaseDatePrecision
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
@property
|
|
278
|
+
def Restrictions(self) -> Restrictions:
|
|
279
|
+
"""
|
|
280
|
+
Included in the response when a content restriction is applied.
|
|
281
|
+
"""
|
|
282
|
+
return self._Restrictions
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
@property
|
|
286
|
+
def ResumePoint(self) -> ResumePoint:
|
|
287
|
+
"""
|
|
288
|
+
The user's most recent position in the chapter.
|
|
289
|
+
Set if the supplied access token is a user token and has the scope 'user-read-playback-position'.
|
|
290
|
+
"""
|
|
291
|
+
return self._ResumePoint
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
@property
|
|
295
|
+
def Type(self) -> str:
|
|
296
|
+
"""
|
|
297
|
+
The object type: `chapter`.
|
|
298
|
+
"""
|
|
299
|
+
return self._Type
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
@property
|
|
303
|
+
def Uri(self) -> str:
|
|
304
|
+
"""
|
|
305
|
+
The Spotify URI for the chapter.
|
|
306
|
+
|
|
307
|
+
Example: `spotify:chapter:0D5wENdkdwbqlrHoaJ9g29`
|
|
308
|
+
"""
|
|
309
|
+
return self._Uri
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
def ToDictionary(self) -> dict:
|
|
313
|
+
"""
|
|
314
|
+
Returns a dictionary representation of the class.
|
|
315
|
+
"""
|
|
316
|
+
externalUrls:dict = {}
|
|
317
|
+
if self._ExternalUrls is not None:
|
|
318
|
+
externalUrls = self._ExternalUrls.ToDictionary()
|
|
319
|
+
|
|
320
|
+
restrictions:dict = {}
|
|
321
|
+
if self._Restrictions is not None:
|
|
322
|
+
restrictions = self._Restrictions.ToDictionary()
|
|
323
|
+
|
|
324
|
+
resumePoint:dict = {}
|
|
325
|
+
if self._ResumePoint is not None:
|
|
326
|
+
resumePoint = self._ResumePoint.ToDictionary()
|
|
327
|
+
|
|
328
|
+
result:dict = \
|
|
329
|
+
{
|
|
330
|
+
'audio_preview_url': self._AudioPreviewUrl,
|
|
331
|
+
'available_markets': [ item for item in self._AvailableMarkets ],
|
|
332
|
+
'chapter_number': self._ChapterNumber,
|
|
333
|
+
'description': self._Description,
|
|
334
|
+
'duration_ms': self._DurationMS,
|
|
335
|
+
'explicit': self._Explicit,
|
|
336
|
+
'external_urls': externalUrls,
|
|
337
|
+
'href': self._Href,
|
|
338
|
+
'html_description': self._HtmlDescription,
|
|
339
|
+
'id': self._Id,
|
|
340
|
+
'image_url': self.ImageUrl,
|
|
341
|
+
'images': [ item.ToDictionary() for item in self._Images ],
|
|
342
|
+
'is_playable': self._IsPlayable,
|
|
343
|
+
'languages': [ item for item in self._Languages ],
|
|
344
|
+
'name': self._Name,
|
|
345
|
+
'release_date': self._ReleaseDate,
|
|
346
|
+
'release_date_precision': self._ReleaseDatePrecision,
|
|
347
|
+
'restrictions': restrictions,
|
|
348
|
+
'resume_point': resumePoint,
|
|
349
|
+
'type': self._Type,
|
|
350
|
+
'uri': self._Uri,
|
|
351
|
+
}
|
|
352
|
+
return result
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
def ToString(self, includeTitle:bool=True) -> str:
|
|
356
|
+
"""
|
|
357
|
+
Returns a displayable string representation of the class.
|
|
358
|
+
|
|
359
|
+
Args:
|
|
360
|
+
includeTitle (str):
|
|
361
|
+
True to include the class name title prefix.
|
|
362
|
+
"""
|
|
363
|
+
msg:str = ''
|
|
364
|
+
if includeTitle:
|
|
365
|
+
msg = 'ChapterSimplified:'
|
|
366
|
+
|
|
367
|
+
if self._Name is not None: msg = '%s\n Name="%s"' % (msg, str(self._Name))
|
|
368
|
+
if self._Uri is not None: msg = '%s\n Uri="%s"' % (msg, str(self._Uri))
|
|
369
|
+
if self._AudioPreviewUrl is not None: msg = '%s\n AudioPreviewUrl="%s"' % (msg, str(self._AudioPreviewUrl))
|
|
370
|
+
if self._AvailableMarkets is not None: msg = '%s\n AvailableMarkets Count=%s' % (msg, str(len(self._AvailableMarkets)))
|
|
371
|
+
if self._ChapterNumber is not None: msg = '%s\n ChapterNumber="%s"' % (msg, str(self._ChapterNumber))
|
|
372
|
+
if self._Description is not None: msg = '%s\n Description="%s"' % (msg, str(self._Description))
|
|
373
|
+
if self._DurationMS is not None: msg = '%s\n DurationMS="%s"' % (msg, str(self._DurationMS))
|
|
374
|
+
if self._Explicit is not None: msg = '%s\n Explicit="%s"' % (msg, str(self._Explicit))
|
|
375
|
+
#if self._ExternalUrls is not None: msg = '%s\n %s' % (msg, str(self._ExternalUrls))
|
|
376
|
+
if self._Href is not None: msg = '%s\n Href="%s"' % (msg, str(self._Href))
|
|
377
|
+
if self._HtmlDescription is not None: msg = '%s\n HtmlDescription="%s"' % (msg, str(self._HtmlDescription))
|
|
378
|
+
if self._Id is not None: msg = '%s\n Id="%s"' % (msg, str(self._Id))
|
|
379
|
+
if self._Images is not None: msg = '%s\n Images Count=%s' % (msg, str(len(self._Images)))
|
|
380
|
+
if self._IsPlayable is not None: msg = '%s\n IsPlayable="%s"' % (msg, str(self._IsPlayable))
|
|
381
|
+
if self._Languages is not None: msg = '%s\n Languages Count=%s' % (msg, str(len(self._Languages)))
|
|
382
|
+
if self._ReleaseDate is not None: msg = '%s\n ReleaseDate="%s"' % (msg, str(self._ReleaseDate))
|
|
383
|
+
if self._ReleaseDatePrecision is not None: msg = '%s\n ReleaseDatePrecision="%s"' % (msg, str(self._ReleaseDatePrecision))
|
|
384
|
+
if self._Restrictions is not None: msg = '%s\n %s' % (msg, str(self._Restrictions))
|
|
385
|
+
if self._ResumePoint is not None: msg = '%s\n %s' % (msg, str(self._ResumePoint))
|
|
386
|
+
if self._Type is not None: msg = '%s\n Type="%s"' % (msg, str(self._Type))
|
|
387
|
+
return msg
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
# external package imports.
|
|
2
|
+
|
|
3
|
+
# our package imports.
|
|
4
|
+
from ..sautils import export
|
|
5
|
+
from .externalurls import ExternalUrls
|
|
6
|
+
|
|
7
|
+
@export
|
|
8
|
+
class Context:
|
|
9
|
+
"""
|
|
10
|
+
Spotify Web API Context object.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, root:dict=None) -> None:
|
|
14
|
+
"""
|
|
15
|
+
Initializes a new instance of the class.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
root (dict):
|
|
19
|
+
Spotify Web API JSON response in dictionary format, used to load object
|
|
20
|
+
attributes; otherwise, None to not load attributes.
|
|
21
|
+
"""
|
|
22
|
+
# initialize storage.
|
|
23
|
+
self._ExternalUrls:ExternalUrls = None
|
|
24
|
+
self._Href:str = None
|
|
25
|
+
self._Type:str = None
|
|
26
|
+
self._Uri:str = None
|
|
27
|
+
|
|
28
|
+
if (root is None):
|
|
29
|
+
|
|
30
|
+
pass
|
|
31
|
+
|
|
32
|
+
else:
|
|
33
|
+
|
|
34
|
+
self._Href = root.get('href', None)
|
|
35
|
+
self._Type = root.get('type', None)
|
|
36
|
+
self._Uri = root.get('uri', None)
|
|
37
|
+
|
|
38
|
+
# process all collections and objects.
|
|
39
|
+
item:dict = root.get('external_urls',None)
|
|
40
|
+
if item is not None:
|
|
41
|
+
self._ExternalUrls = ExternalUrls(root=item)
|
|
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 ExternalUrls(self) -> ExternalUrls:
|
|
54
|
+
"""
|
|
55
|
+
External URLs for this context.
|
|
56
|
+
"""
|
|
57
|
+
return self._ExternalUrls
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
@property
|
|
61
|
+
def Href(self) -> str:
|
|
62
|
+
"""
|
|
63
|
+
A link to the Web API endpoint providing full details of the context.
|
|
64
|
+
"""
|
|
65
|
+
return self._Href
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def Type(self) -> str:
|
|
70
|
+
"""
|
|
71
|
+
Object type, such as `artist`, `playlist`, `album` or `show`.
|
|
72
|
+
"""
|
|
73
|
+
return self._Type
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
@property
|
|
77
|
+
def Uri(self) -> str:
|
|
78
|
+
"""
|
|
79
|
+
The Spotify URI for the context.
|
|
80
|
+
|
|
81
|
+
Example: `spotify:album:2up3OPMp9Tb4dAKM2erWXQ`
|
|
82
|
+
"""
|
|
83
|
+
return self._Uri
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def ToDictionary(self) -> dict:
|
|
87
|
+
"""
|
|
88
|
+
Returns a dictionary representation of the class.
|
|
89
|
+
"""
|
|
90
|
+
externalUrls:dict = {}
|
|
91
|
+
if self._ExternalUrls is not None:
|
|
92
|
+
externalUrls = self._ExternalUrls.ToDictionary()
|
|
93
|
+
|
|
94
|
+
result:dict = \
|
|
95
|
+
{
|
|
96
|
+
'external_urls': externalUrls,
|
|
97
|
+
'href': self._Href,
|
|
98
|
+
'type': self._Type,
|
|
99
|
+
'uri': self._Uri,
|
|
100
|
+
}
|
|
101
|
+
return result
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
def ToString(self) -> str:
|
|
105
|
+
"""
|
|
106
|
+
Returns a displayable string representation of the class.
|
|
107
|
+
"""
|
|
108
|
+
msg:str = 'Context:'
|
|
109
|
+
if self._Uri is not None: msg = '%s\n Uri="%s"' % (msg, str(self._Uri))
|
|
110
|
+
#if self._ExternalUrls is not None: msg = '%s\n %s' % (msg, str(self._ExternalUrls))
|
|
111
|
+
if self._Href is not None: msg = '%s\n Href="%s"' % (msg, str(self._Href))
|
|
112
|
+
if self._Type is not None: msg = '%s\n Type="%s"' % (msg, str(self._Type))
|
|
113
|
+
return msg
|