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.
Files changed (138) hide show
  1. spotifywebapipython/__init__.py +35 -0
  2. spotifywebapipython/const.py +114 -0
  3. spotifywebapipython/docs/__init__.html +2156 -0
  4. spotifywebapipython/docs/codecopy.js +70 -0
  5. spotifywebapipython/docs/index.html +514 -0
  6. spotifywebapipython/docs/search.js +46 -0
  7. spotifywebapipython/docs/spotifywebapipython/const.html +636 -0
  8. spotifywebapipython/docs/spotifywebapipython/saappmessages.html +540 -0
  9. spotifywebapipython/docs/spotifywebapipython/sautils.html +620 -0
  10. spotifywebapipython/docs/spotifywebapipython/spotifyapierror.html +341 -0
  11. spotifywebapipython/docs/spotifywebapipython/spotifyapimessage.html +598 -0
  12. spotifywebapipython/docs/spotifywebapipython/spotifyauthtoken.html +612 -0
  13. spotifywebapipython/docs/spotifywebapipython/spotifyclient.html +16557 -0
  14. spotifywebapipython/docs/spotifywebapipython/spotifydiscovery.html +518 -0
  15. spotifywebapipython/docs/spotifywebapipython/spotifywebapiauthenticationerror.html +421 -0
  16. spotifywebapipython/docs/spotifywebapipython/spotifywebapierror.html +400 -0
  17. spotifywebapipython/docs/spotifywebapipython/spotifywebplayertoken.html +635 -0
  18. spotifywebapipython/docs/spotifywebapipython.ico +0 -0
  19. spotifywebapipython/docs/spotifywebapipython_OLD.ico +0 -0
  20. spotifywebapipython/models/__init__.py +121 -0
  21. spotifywebapipython/models/album.py +170 -0
  22. spotifywebapipython/models/albumpagesaved.py +85 -0
  23. spotifywebapipython/models/albumpagesimplified.py +88 -0
  24. spotifywebapipython/models/albumsaved.py +102 -0
  25. spotifywebapipython/models/albumsimplified.py +308 -0
  26. spotifywebapipython/models/artist.py +146 -0
  27. spotifywebapipython/models/artistinfo.py +282 -0
  28. spotifywebapipython/models/artistinfotourevent.py +127 -0
  29. spotifywebapipython/models/artistpage.py +70 -0
  30. spotifywebapipython/models/artistsimplified.py +163 -0
  31. spotifywebapipython/models/audiobook.py +87 -0
  32. spotifywebapipython/models/audiobookpagesimplified.py +88 -0
  33. spotifywebapipython/models/audiobooksimplified.py +362 -0
  34. spotifywebapipython/models/audiofeatures.py +333 -0
  35. spotifywebapipython/models/author.py +67 -0
  36. spotifywebapipython/models/category.py +168 -0
  37. spotifywebapipython/models/categorypage.py +70 -0
  38. spotifywebapipython/models/chapter.py +84 -0
  39. spotifywebapipython/models/chapterpagesimplified.py +88 -0
  40. spotifywebapipython/models/chaptersimplified.py +387 -0
  41. spotifywebapipython/models/context.py +113 -0
  42. spotifywebapipython/models/copyright.py +79 -0
  43. spotifywebapipython/models/device.py +301 -0
  44. spotifywebapipython/models/episode.py +84 -0
  45. spotifywebapipython/models/episodepagesaved.py +85 -0
  46. spotifywebapipython/models/episodepagesimplified.py +88 -0
  47. spotifywebapipython/models/episodesaved.py +99 -0
  48. spotifywebapipython/models/episodesimplified.py +370 -0
  49. spotifywebapipython/models/explicitcontent.py +80 -0
  50. spotifywebapipython/models/externalids.py +91 -0
  51. spotifywebapipython/models/externalurls.py +104 -0
  52. spotifywebapipython/models/followers.py +81 -0
  53. spotifywebapipython/models/imageobject.py +193 -0
  54. spotifywebapipython/models/imagevibrantcolors.py +182 -0
  55. spotifywebapipython/models/linkedfrom.py +165 -0
  56. spotifywebapipython/models/narrator.py +67 -0
  57. spotifywebapipython/models/owner.py +162 -0
  58. spotifywebapipython/models/pageobject.py +343 -0
  59. spotifywebapipython/models/playeractions.py +196 -0
  60. spotifywebapipython/models/playerlastplayedinfo.py +334 -0
  61. spotifywebapipython/models/playerplaystate.py +467 -0
  62. spotifywebapipython/models/playerqueueinfo.py +207 -0
  63. spotifywebapipython/models/playhistory.py +136 -0
  64. spotifywebapipython/models/playhistorypage.py +85 -0
  65. spotifywebapipython/models/playlist.py +125 -0
  66. spotifywebapipython/models/playlistpage.py +85 -0
  67. spotifywebapipython/models/playlistpagesimplified.py +107 -0
  68. spotifywebapipython/models/playlistsimplified.py +334 -0
  69. spotifywebapipython/models/playlisttrack.py +143 -0
  70. spotifywebapipython/models/playlisttracksummary.py +80 -0
  71. spotifywebapipython/models/recommendationseed.py +135 -0
  72. spotifywebapipython/models/restrictions.py +86 -0
  73. spotifywebapipython/models/resumepoint.py +79 -0
  74. spotifywebapipython/models/searchresponse.py +391 -0
  75. spotifywebapipython/models/searchresultbase.py +299 -0
  76. spotifywebapipython/models/show.py +87 -0
  77. spotifywebapipython/models/showpagesaved.py +85 -0
  78. spotifywebapipython/models/showpagesimplified.py +88 -0
  79. spotifywebapipython/models/showsaved.py +99 -0
  80. spotifywebapipython/models/showsimplified.py +320 -0
  81. spotifywebapipython/models/spotifyconnectdevice.py +321 -0
  82. spotifywebapipython/models/spotifyconnectdevices.py +441 -0
  83. spotifywebapipython/models/track.py +142 -0
  84. spotifywebapipython/models/trackpage.py +110 -0
  85. spotifywebapipython/models/trackpagesaved.py +85 -0
  86. spotifywebapipython/models/trackpagesimplified.py +88 -0
  87. spotifywebapipython/models/trackrecommendations.py +88 -0
  88. spotifywebapipython/models/tracksaved.py +99 -0
  89. spotifywebapipython/models/tracksimplified.py +398 -0
  90. spotifywebapipython/models/userprofile.py +184 -0
  91. spotifywebapipython/models/userprofilesimplified.py +206 -0
  92. spotifywebapipython/models/zeroconfdiscoveryresult.py +592 -0
  93. spotifywebapipython/models/zeroconfproperty.py +93 -0
  94. spotifywebapipython/oauthcli/__init__.py +7 -0
  95. spotifywebapipython/oauthcli/authclient.py +1229 -0
  96. spotifywebapipython/saappmessages.py +86 -0
  97. spotifywebapipython/sautils.py +285 -0
  98. spotifywebapipython/spotifyapierror.py +66 -0
  99. spotifywebapipython/spotifyapimessage.py +269 -0
  100. spotifywebapipython/spotifyauthtoken.py +264 -0
  101. spotifywebapipython/spotifyclient.py +17885 -0
  102. spotifywebapipython/spotifyconnect/__init__.py +19 -0
  103. spotifywebapipython/spotifyconnect/spotifyconnectdeviceeventargs.py +67 -0
  104. spotifywebapipython/spotifyconnect/spotifyconnectdirectorytask.py +2564 -0
  105. spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastapptask.py +467 -0
  106. spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastcontroller.py +701 -0
  107. spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastlistener.py +359 -0
  108. spotifywebapipython/spotifyconnect/spotifyconnectzeroconfcastmultizonelistener.py +212 -0
  109. spotifywebapipython/spotifyconnect/spotifyconnectzeroconfexceptions.py +20 -0
  110. spotifywebapipython/spotifyconnect/spotifyconnectzeroconflistener.py +335 -0
  111. spotifywebapipython/spotifydiscovery.py +473 -0
  112. spotifywebapipython/spotifymediatypes.py +53 -0
  113. spotifywebapipython/spotifywebapiauthenticationerror.py +122 -0
  114. spotifywebapipython/spotifywebapierror.py +106 -0
  115. spotifywebapipython/spotifywebplayertoken.py +743 -0
  116. spotifywebapipython/vibrant/__init__.py +17 -0
  117. spotifywebapipython/vibrant/generator.py +261 -0
  118. spotifywebapipython/vibrant/image.py +100 -0
  119. spotifywebapipython/vibrant/main.py +34 -0
  120. spotifywebapipython/vibrant/models.py +93 -0
  121. spotifywebapipython/vibrant/utils.py +56 -0
  122. spotifywebapipython/zeroconfapi/__init__.py +23 -0
  123. spotifywebapipython/zeroconfapi/authenticationtypes.py +38 -0
  124. spotifywebapipython/zeroconfapi/blobbuilder.py +370 -0
  125. spotifywebapipython/zeroconfapi/credentials.py +37 -0
  126. spotifywebapipython/zeroconfapi/cryptodiffiehellman.py +89 -0
  127. spotifywebapipython/zeroconfapi/helpers.py +64 -0
  128. spotifywebapipython/zeroconfapi/spotifyzeroconfapierror.py +108 -0
  129. spotifywebapipython/zeroconfapi/zeroconfconnect.py +1327 -0
  130. spotifywebapipython/zeroconfapi/zeroconfgetinfo.py +572 -0
  131. spotifywebapipython/zeroconfapi/zeroconfgetinfoalias.py +109 -0
  132. spotifywebapipython/zeroconfapi/zeroconfgetinfodrmmediaformat.py +90 -0
  133. spotifywebapipython/zeroconfapi/zeroconfresponse.py +195 -0
  134. spotifywebapipython-1.0.242.dist-info/LICENSE +22 -0
  135. spotifywebapipython-1.0.242.dist-info/METADATA +219 -0
  136. spotifywebapipython-1.0.242.dist-info/RECORD +138 -0
  137. spotifywebapipython-1.0.242.dist-info/WHEEL +5 -0
  138. spotifywebapipython-1.0.242.dist-info/top_level.txt +1 -0
@@ -0,0 +1,121 @@
1
+ # import all classes from the namespace.
2
+ from .album import Album, AlbumSimplified
3
+ from .albumpagesaved import AlbumPageSaved, AlbumSaved
4
+ from .albumpagesimplified import AlbumPageSimplified
5
+ from .artist import Artist, ArtistSimplified
6
+ from .artistinfo import ArtistInfo, ArtistInfoTourEvent
7
+ from .artistpage import ArtistPage
8
+ from .audiobook import Audiobook, AudiobookSimplified
9
+ from .audiobookpagesimplified import AudiobookPageSimplified
10
+ from .audiofeatures import AudioFeatures
11
+ from .author import Author
12
+ from .category import Category
13
+ from .categorypage import CategoryPage
14
+ from .chapter import Chapter, ChapterSimplified
15
+ from .chapterpagesimplified import ChapterPageSimplified
16
+ from .context import Context
17
+ from .copyright import Copyright
18
+ from .device import Device
19
+ from .episode import Episode, EpisodeSimplified
20
+ from .episodepagesaved import EpisodePageSaved, EpisodeSaved
21
+ from .episodepagesimplified import EpisodePageSimplified
22
+ from .explicitcontent import ExplicitContent
23
+ from .externalids import ExternalIds
24
+ from .externalurls import ExternalUrls
25
+ from .followers import Followers
26
+ from .imageobject import ImageObject
27
+ from .imagevibrantcolors import ImageVibrantColors
28
+ from .linkedfrom import LinkedFrom
29
+ from .narrator import Narrator
30
+ from .owner import Owner
31
+ from .pageobject import PageObject
32
+ from .playeractions import PlayerActions
33
+ from .playerlastplayedinfo import PlayerLastPlayedInfo
34
+ from .playerplaystate import PlayerPlayState
35
+ from .playerqueueinfo import PlayerQueueInfo
36
+ from .playhistory import PlayHistory
37
+ from .playhistorypage import PlayHistoryPage
38
+ from .playlist import Playlist, PlaylistSimplified
39
+ from .playlistpage import PlaylistPage
40
+ from .playlistpagesimplified import PlaylistPageSimplified
41
+ from .playlisttrack import PlaylistTrack
42
+ from .playlisttracksummary import PlaylistTrackSummary
43
+ from .recommendationseed import RecommendationSeed
44
+ from .restrictions import Restrictions
45
+ from .resumepoint import ResumePoint
46
+ from .searchresponse import SearchResponse
47
+ from .searchresultbase import SearchResultBase
48
+ from .show import Show, ShowSimplified
49
+ from .showpagesaved import ShowPageSaved, ShowSaved
50
+ from .showpagesimplified import ShowPageSimplified
51
+ from .spotifyconnectdevices import SpotifyConnectDevices, SpotifyConnectDevice
52
+ from .track import Track, TrackSimplified
53
+ from .trackpage import TrackPage
54
+ from .trackpagesaved import TrackPageSaved, TrackSaved
55
+ from .trackpagesimplified import TrackPageSimplified
56
+ from .trackrecommendations import TrackRecommendations
57
+ from .userprofile import UserProfile, UserProfileSimplified
58
+ from .zeroconfdiscoveryresult import ZeroconfDiscoveryResult
59
+ from .zeroconfproperty import ZeroconfProperty
60
+
61
+ # all classes to import when "import *" is specified.
62
+ __all__ = [
63
+ 'Album','AlbumSimplified',
64
+ 'AlbumPageSaved','AlbumSaved',
65
+ 'AlbumPageSimplified',
66
+ 'Artist','ArtistSimplified',
67
+ 'ArtistInfo', 'ArtistInfoTourEvent',
68
+ 'ArtistPage',
69
+ 'Audiobook','AudiobookSimplified',
70
+ 'AudiobookPageSimplified',
71
+ 'AudioFeatures',
72
+ 'Author',
73
+ 'Category',
74
+ 'CategoryPage',
75
+ 'Chapter','ChapterSimplified',
76
+ 'ChapterPageSimplified',
77
+ 'Context',
78
+ 'Copyright',
79
+ 'Device',
80
+ 'Episode','EpisodeSimplified',
81
+ 'EpisodePageSaved','EpisodeSaved',
82
+ 'EpisodePageSimplified',
83
+ 'ExplicitContent',
84
+ 'ExternalIds',
85
+ 'ExternalUrls',
86
+ 'Followers',
87
+ 'ImageObject',
88
+ 'ImageVibrantColors',
89
+ 'LinkedFrom',
90
+ 'Narrator',
91
+ 'Owner',
92
+ 'PageObject',
93
+ 'PlayerActions',
94
+ 'PlayerLastPlayedInfo',
95
+ 'PlayerPlayState',
96
+ 'PlayerQueueInfo',
97
+ 'PlayHistory',
98
+ 'PlayHistoryPage',
99
+ 'Playlist','PlaylistSimplified',
100
+ 'PlaylistPage',
101
+ 'PlaylistPageSimplified',
102
+ 'PlaylistTrack',
103
+ 'PlaylistTrackSummary',
104
+ 'RecommendationSeed',
105
+ 'Restrictions',
106
+ 'ResumePoint',
107
+ 'SearchResponse',
108
+ 'SearchResultBase',
109
+ 'Show','ShowSimplified',
110
+ 'ShowPageSaved','ShowSaved',
111
+ 'ShowPageSimplified',
112
+ 'SpotifyConnectDevices', 'SpotifyConnectDevice',
113
+ 'Track','TrackSimplified',
114
+ 'TrackPage',
115
+ 'TrackPageSaved','TrackSaved',
116
+ 'TrackPageSimplified',
117
+ 'TrackRecommendations',
118
+ 'UserProfile','UserProfileSimplified',
119
+ 'ZeroconfDiscoveryResult',
120
+ 'ZeroconfProperty',
121
+ ]
@@ -0,0 +1,170 @@
1
+ # external package imports.
2
+
3
+ # our package imports.
4
+ from ..sautils import export
5
+ from .albumsimplified import AlbumSimplified
6
+ from .copyright import Copyright
7
+ from .externalids import ExternalIds
8
+ from .externalurls import ExternalUrls
9
+ from .trackpagesimplified import TrackPageSimplified
10
+
11
+ @export
12
+ class Album(AlbumSimplified):
13
+ """
14
+ Spotify Web API Album object.
15
+ """
16
+
17
+ def __init__(self, root:dict=None) -> None:
18
+ """
19
+ Initializes a new instance of the class.
20
+
21
+ Args:
22
+ root (dict):
23
+ Spotify Web API JSON response in dictionary format, used to load object
24
+ attributes; otherwise, None to not load attributes.
25
+ """
26
+ # initialize base class.
27
+ super().__init__(root=root)
28
+
29
+ # initialize storage.
30
+ self._Copyrights:list[Copyright] = []
31
+ self._ExternalIds:ExternalIds = None
32
+ self._Genres:list[str] = []
33
+ self._Label:str = None
34
+ self._Popularity:int = None
35
+ self._Tracks:TrackPageSimplified = None
36
+
37
+ if (root is None):
38
+
39
+ pass
40
+
41
+ else:
42
+
43
+ self._Label = root.get('label', None)
44
+ self._Popularity = root.get('popularity', None)
45
+
46
+ # process all collections and objects.
47
+ items:list = root.get('copyrights',None)
48
+ if items is not None:
49
+ for item in items:
50
+ self._Copyrights.append(Copyright(root=item))
51
+
52
+ item:dict = root.get('external_ids',None)
53
+ if item is not None:
54
+ self._ExternalIds = ExternalIds(root=item)
55
+
56
+ items:list[str] = root.get('genres',None)
57
+ if items is not None:
58
+ for item in items:
59
+ self._Genres.append(item)
60
+
61
+ item:dict = root.get('tracks',None)
62
+ if item is not None:
63
+ self._Tracks = TrackPageSimplified(root=item)
64
+
65
+
66
+ def __repr__(self) -> str:
67
+ return self.ToString()
68
+
69
+
70
+ def __str__(self) -> str:
71
+ return self.ToString()
72
+
73
+
74
+ @property
75
+ def Copyrights(self) -> list[Copyright]:
76
+ """
77
+ The copyright statements of the album.
78
+ """
79
+ return self._Copyrights
80
+
81
+
82
+ @property
83
+ def ExternalIds(self) -> ExternalUrls:
84
+ """
85
+ Known external IDs for the album.
86
+ """
87
+ return self._ExternalIds
88
+
89
+
90
+ @property
91
+ def Genres(self) -> list[str]:
92
+ """
93
+ A list of the genres the album is associated with. If not yet classified, the array is empty.
94
+
95
+ Example: `["Egg punk","Noise rock"]`
96
+ """
97
+ return self._Genres
98
+
99
+
100
+ @property
101
+ def Label(self) -> str:
102
+ """
103
+ The label associated with the album.
104
+ """
105
+ return self._Label
106
+
107
+
108
+ @property
109
+ def Popularity(self) -> int:
110
+ """
111
+ The popularity of the album.
112
+
113
+ The value will be between 0 and 100, with 100 being the most popular.
114
+ """
115
+ return self._Popularity
116
+
117
+
118
+ @property
119
+ def Tracks(self) -> TrackPageSimplified:
120
+ """
121
+ The tracks of the album.
122
+
123
+ This is a `TrackPageSimplified` object, meaning only 50 tracks max are listed per request.
124
+ """
125
+ return self._Tracks
126
+
127
+
128
+ def ToDictionary(self) -> dict:
129
+ """
130
+ Returns a dictionary representation of the class.
131
+ """
132
+ # get base class result.
133
+ resultBase:dict = super().ToDictionary()
134
+
135
+ externalIds:dict = {}
136
+ if self._ExternalIds is not None:
137
+ externalIds = self._ExternalIds.ToDictionary()
138
+
139
+ result:dict = \
140
+ {
141
+ 'copyrights': [ item.ToDictionary() for item in self._Copyrights ],
142
+ 'external_ids': externalIds,
143
+ 'genres': [ item for item in self._Genres ],
144
+ 'label': self._Label,
145
+ 'popularity': self._Popularity,
146
+ }
147
+
148
+ # only add the tracks key if data is present.
149
+ if self._Tracks is not None:
150
+ tracks:dict = self._Tracks.ToDictionary()
151
+ result['tracks'] = tracks
152
+
153
+ # combine base class results with these results.
154
+ resultBase.update(result)
155
+
156
+ # return a sorted dictionary.
157
+ return dict(sorted(resultBase.items()))
158
+
159
+
160
+ def ToString(self) -> str:
161
+ """
162
+ Returns a displayable string representation of the class.
163
+ """
164
+ msg:str = 'Album: %s' % super().ToString(False)
165
+ #if self._Copyrights is not None: msg = '%s\n %s' % (msg, str(self._Copyrights))
166
+ #if self._ExternalIds is not None: msg = '%s\n %s' % (msg, str(self._ExternalIds))
167
+ if self._Genres is not None: msg = '%s\n Genres Count=%s' % (msg, str(len(self._Genres)))
168
+ if self._Label is not None: msg = '%s\n Label="%s"' % (msg, str(self._Label))
169
+ if self._Popularity is not None: msg = '%s\n Popularity="%s"' % (msg, str(self._Popularity))
170
+ return msg
@@ -0,0 +1,85 @@
1
+ # external package imports.
2
+
3
+ # our package imports.
4
+ from ..sautils import export
5
+ from .album import Album
6
+ from .albumsaved import AlbumSaved
7
+ from .pageobject import PageObject
8
+
9
+ @export
10
+ class AlbumPageSaved(PageObject):
11
+ """
12
+ Spotify Web API AlbumPageSaved object.
13
+
14
+ This allows for multiple pages of `AlbumSaved` objects to be navigated.
15
+ """
16
+
17
+ def __init__(self, root:dict=None) -> None:
18
+ """
19
+ Initializes a new instance of the class.
20
+
21
+ Args:
22
+ root (dict):
23
+ Spotify Web API JSON response in dictionary format, used to load object
24
+ attributes; otherwise, None to not load attributes.
25
+ """
26
+ # initialize base class.
27
+ super().__init__(root=root)
28
+
29
+ # initialize storage.
30
+ self._Items:list[AlbumSaved] = []
31
+
32
+ if (root is None):
33
+
34
+ pass
35
+
36
+ else:
37
+
38
+ # process all collections and objects.
39
+ items:list = root.get('items',None)
40
+ if items is not None:
41
+ for item in items:
42
+ if item is not None:
43
+ self._Items.append(AlbumSaved(root=item))
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 Items(self) -> list[AlbumSaved]:
56
+ """
57
+ Array of `AlbumSaved` objects.
58
+ """
59
+ return self._Items
60
+
61
+
62
+ def GetAlbums(self) -> list[Album]:
63
+ """
64
+ Gets a list of all albums contained in the underlying `Items` list.
65
+
66
+ This is a convenience method so one does not have to loop through the `Items`
67
+ array of AlbumSaved objects to get the list of albums.
68
+ """
69
+ result:list[Album] = []
70
+ item:AlbumSaved
71
+ for item in self._Items:
72
+ result.append(item.Album)
73
+ return result
74
+
75
+
76
+ def ToString(self, includeItems:bool=False) -> str:
77
+ """
78
+ Returns a displayable string representation of the class.
79
+
80
+ Args:
81
+ includeItems (bool):
82
+ True to include the Items collection of objects; otherwise, False
83
+ to only return base properties.
84
+ """
85
+ return 'AlbumPageSaved: %s' % super().ToString(includeItems)
@@ -0,0 +1,88 @@
1
+ # external package imports.
2
+
3
+ # our package imports.
4
+ from ..sautils import export
5
+ from .albumsimplified import AlbumSimplified
6
+ from .pageobject import PageObject
7
+
8
+ @export
9
+ class AlbumPageSimplified(PageObject):
10
+ """
11
+ Spotify Web API SimplifiedAlbumPage object.
12
+
13
+ This allows for multiple pages of `AlbumSimplified` 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[AlbumSimplified] = []
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(AlbumSimplified(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[AlbumSimplified]:
55
+ """
56
+ Array of `AlbumSimplified` 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:AlbumSimplified
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 'AlbumPageSimplified: %s' % super().ToString(includeItems)
@@ -0,0 +1,102 @@
1
+ # external package imports.
2
+
3
+ # our package imports.
4
+ from ..sautils import export
5
+ from .album import Album
6
+
7
+ @export
8
+ class AlbumSaved:
9
+ """
10
+ Spotify Web API SavedAlbum 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
+ self._Album:Album = None
23
+ self._AddedAt:str = None
24
+
25
+ if (root is None):
26
+
27
+ pass
28
+
29
+ else:
30
+
31
+ self._AddedAt = root.get('added_at', None)
32
+
33
+ # process all collections and objects.
34
+ item:dict = root.get('album',None)
35
+ if item is not None:
36
+ self._Album = Album(root=item)
37
+
38
+
39
+ def __repr__(self) -> str:
40
+ return self.ToString()
41
+
42
+
43
+ def __str__(self) -> str:
44
+ return self.ToString()
45
+
46
+
47
+ @property
48
+ def AddedAt(self) -> str:
49
+ """
50
+ The date and time the album was saved.
51
+
52
+ Timestamps are returned in ISO 8601 format as Coordinated Universal Time (UTC) with a zero
53
+ offset: YYYY-MM-DDTHH:MM:SSZ. If the time is imprecise (for example, the date/time of an
54
+ album release), an additional field indicates the precision; see for example, release_date
55
+ in an album object.
56
+ """
57
+ return self._AddedAt
58
+
59
+
60
+ @property
61
+ def Album(self) -> Album:
62
+ """
63
+ Information about the album.
64
+ """
65
+ return self._Album
66
+
67
+
68
+ def ToDictionary(self) -> dict:
69
+ """
70
+ Returns a dictionary representation of the class.
71
+ """
72
+ album:dict = {}
73
+ if self._Album is not None:
74
+ album = self._Album.ToDictionary()
75
+
76
+ result:dict = \
77
+ {
78
+ 'added_at': self._AddedAt,
79
+ 'album': album
80
+ }
81
+ return result
82
+
83
+
84
+ def ToString(self, includeItems:bool=False) -> str:
85
+ """
86
+ Returns a displayable string representation of the class.
87
+
88
+ Args:
89
+ includeItems (bool):
90
+ True to include the Items collection of objects; otherwise, False
91
+ to only return base properties.
92
+ """
93
+ msg:str = 'AlbumSaved:'
94
+ if self._AddedAt is not None: msg = '%s\n AddedAt="%s"' % (msg, str(self._AddedAt))
95
+
96
+ if self._Album is not None:
97
+ if (includeItems):
98
+ msg = '%s\n %s' % (msg, str(self._Album))
99
+ else:
100
+ msg = '%s, Album Name="%s"' % (msg, self._Album.Name)
101
+
102
+ return msg