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,334 @@
1
+ # external package imports.
2
+ import copy
3
+
4
+ # our package imports.
5
+ from ..sautils import export
6
+ from ..spotifymediatypes import SpotifyMediaTypes
7
+ from .context import Context
8
+ from .device import Device
9
+ from .episode import Episode
10
+ from .playerplaystate import PlayerPlayState
11
+ from .searchresultbase import SearchResultBase
12
+ from .track import Track
13
+
14
+ @export
15
+ class PlayerLastPlayedInfo:
16
+ """
17
+ Player Last Played Information object.
18
+
19
+ Contains information about the content that was last playing on the Spotify Player,
20
+ including context, item (track / episode), progress, and active device.
21
+
22
+ This is a helper object, and is not part of the Spotify Web API specification.
23
+ """
24
+
25
+ def __init__(self, root:PlayerPlayState=None) -> None:
26
+ """
27
+ Initializes a new instance of the class.
28
+
29
+ Args:
30
+ root (PlayerPlayState):
31
+ Spotify Web API PlayerPlayState object, used to load object
32
+ attributes; otherwise, None to not load attributes.
33
+ """
34
+ self._Context:Context = None
35
+ self._Device:Device = None
36
+ self._DeviceMusicSource:str = None
37
+ self._IsDeviceState:bool = False
38
+ self._IsEmpty:bool = True
39
+ self._Item:object = None
40
+ self._ItemType:str = None
41
+ self._ProgressMS:int = None
42
+ self._RepeatState:str = None
43
+ self._ShuffleState:bool = None
44
+ self._Timestamp:int = None
45
+
46
+ # is this a PlayerPlayState object? if not, then don't bother!
47
+ if (isinstance(root, PlayerPlayState)):
48
+
49
+ # deep copy the object
50
+ rootCopy:PlayerPlayState = copy.deepcopy(root)
51
+
52
+ # update individual properties.
53
+ self._Context = rootCopy.Context
54
+ self._Device = rootCopy.Device
55
+ self._DeviceMusicSource = rootCopy.DeviceMusicSource
56
+ self._IsDeviceState = rootCopy.IsDeviceState
57
+ self._IsEmpty = rootCopy.IsEmpty
58
+ self._Item = rootCopy.Item
59
+ self._ItemType = rootCopy.ItemType
60
+ self._ProgressMS = rootCopy.ProgressMS
61
+ self._RepeatState = rootCopy.RepeatState
62
+ self._ShuffleState = rootCopy.ShuffleState
63
+ self._Timestamp = rootCopy.Timestamp
64
+
65
+ # post load validations.
66
+ # if self._Context is None:
67
+ # self._Context = Context()
68
+ if self._Device is None:
69
+ self._Device = Device()
70
+ # if self._Item is None:
71
+ # self._Item = SearchResultBase()
72
+
73
+ if self._ProgressMS is None:
74
+ self._ProgressMS = 0
75
+ if self._RepeatState is None:
76
+ self._RepeatState = 'off'
77
+ if self._ShuffleState is None:
78
+ self._ShuffleState = False
79
+ if self._Timestamp is None:
80
+ self._Timestamp = 0
81
+
82
+
83
+ def __repr__(self) -> str:
84
+ return self.ToString()
85
+
86
+
87
+ def __str__(self) -> str:
88
+ return self.ToString()
89
+
90
+
91
+ @property
92
+ def Context(self) -> Context:
93
+ """
94
+ A Context Object; can be null.
95
+ """
96
+ return self._Context
97
+
98
+
99
+ @property
100
+ def Device(self) -> Device:
101
+ """
102
+ The device that was active when the item was last playing.
103
+ """
104
+ return self._Device
105
+
106
+
107
+ @property
108
+ def DeviceMusicSource(self) -> str:
109
+ """
110
+ The device music source.
111
+ This value is device manufacturer specific.
112
+ For example, a Sonos source will contain values like "UNKNOWN", "SPOTIFY_CONNECT", etc.
113
+
114
+ This is a helper property, and is not part of the Spotify Web API specification.
115
+ """
116
+ return self._DeviceMusicSource
117
+
118
+
119
+ @property
120
+ def IsAdvertisement(self) -> bool:
121
+ """
122
+ True if the item type is an advertisement; otherwise, false.
123
+ """
124
+ if self._Item.Type == "ad":
125
+ return True
126
+ return False
127
+
128
+
129
+ @property
130
+ def IsDeviceState(self) -> bool:
131
+ """
132
+ True if playstate was built from a device playstate;
133
+ otherwise, false if playstate was built from a Spotify Web API playstate.
134
+ """
135
+ return self._IsDeviceState
136
+
137
+ @property
138
+ def IsEmpty(self) -> bool:
139
+ """
140
+ True if Spotify playstate returned an empty response; otherwise, false.
141
+
142
+ Note that for Sonos devices, the Spotify Web API reports an empty playstate since
143
+ the SoCo API is actually controlling player.
144
+
145
+ This is a helper property, and is not part of the Spotify Web API specification.
146
+ """
147
+ return self._IsEmpty
148
+
149
+
150
+ @property
151
+ def IsMuted(self) -> bool:
152
+ """
153
+ True if the player device volume is zero (muted) OR there is no device;
154
+ otherwise, false.
155
+ """
156
+ if self._Device is None:
157
+ return True
158
+ else:
159
+ return self._Device.IsMuted
160
+
161
+
162
+ @property
163
+ def IsRepeatEnabled(self) -> bool:
164
+ """
165
+ True if repeat play (one or all) is enabled; otherwise, False.
166
+
167
+ The `RepeatState` property contains the actual repeat setting.
168
+ """
169
+ if self._RepeatState != 'off':
170
+ return True
171
+ return False
172
+
173
+
174
+ @property
175
+ def IsShuffleEnabled(self) -> bool:
176
+ """
177
+ True if shuffle play is enabled; otherwise, False.
178
+ """
179
+ if (self.ShuffleState == 'on') or (self.ShuffleState == True):
180
+ return True
181
+ return False
182
+
183
+
184
+ @property
185
+ def Item(self) -> object:
186
+ """
187
+ The playing track or episode; can be null.
188
+
189
+ Will be of type `Track`, `Episode`, or null.
190
+ """
191
+ return self._Item
192
+
193
+
194
+ @property
195
+ def ItemType(self) -> str:
196
+ """
197
+ The type of the item playing; can be null.
198
+ This value will be null if the `Item` property value is null.
199
+
200
+ If not null, it can be one of: `audiobook`, `podcast`, `track`.
201
+
202
+ Note that this is not a Spotify Web API property; it is loaded from our API so
203
+ that the type of episode can be determined programatically (e.g. audiobook or podcast).
204
+ """
205
+ return self._ItemType
206
+
207
+
208
+ @property
209
+ def ProgressMS(self) -> int:
210
+ """
211
+ Progress into the currently playing track or episode; can be null.
212
+ """
213
+ return self._ProgressMS
214
+
215
+ @ProgressMS.setter
216
+ def ProgressMS(self, value:int):
217
+ """
218
+ Sets the ProgressMS property value.
219
+ """
220
+ if isinstance(value, int):
221
+ self._ProgressMS = value
222
+
223
+
224
+ @property
225
+ def RepeatState(self) -> str:
226
+ """
227
+ The repeat state of the playing track: `off`, `track`, or `context`.
228
+ """
229
+ return self._RepeatState
230
+
231
+
232
+ @property
233
+ def ShuffleState(self) -> bool:
234
+ """
235
+ If shuffle is enabled, True or False.
236
+ """
237
+ return self._ShuffleState
238
+
239
+
240
+ @property
241
+ def Summary(self) -> str:
242
+ """
243
+ Returns a summary of what is playing.
244
+ """
245
+ result:str = ''
246
+ if self._Item is None:
247
+
248
+ result = "unavailable"
249
+
250
+ else:
251
+
252
+ if self._Item.Type == SpotifyMediaTypes.TRACK.value:
253
+ track:Track = self._Item
254
+ result = 'Track "%s" (%s)' % (track.Name, track.Id)
255
+ elif self._Item.Type == SpotifyMediaTypes.EPISODE.value:
256
+ episode:Episode = self._Item
257
+ result = 'Episode "%s" (%s)' % (episode.Name, episode.Id)
258
+ elif self._Item.Type == 'audiobook':
259
+ episode:Episode = self._Item
260
+ result = 'Chapter "%s" (%s)' % (episode.Name, episode.Id)
261
+ elif self._Item.Type == 'podcast':
262
+ episode:Episode = self._Item
263
+ result = 'Podcast "%s" (%s)' % (episode.Name, episode.Id)
264
+
265
+ return result
266
+
267
+
268
+ @property
269
+ def Timestamp(self) -> int:
270
+ """
271
+ Unix Millisecond Timestamp when data was fetched.
272
+ """
273
+ return self._Timestamp
274
+
275
+
276
+ def ToDictionary(self) -> dict:
277
+ """
278
+ Returns a dictionary representation of the class.
279
+ """
280
+ context:dict = {}
281
+ if self._Context is not None:
282
+ context = self._Context.ToDictionary()
283
+
284
+ device:dict = {}
285
+ if self._Device is not None:
286
+ device = self._Device.ToDictionary()
287
+
288
+ item:dict = {}
289
+ if self._Item is not None:
290
+ item = self._Item.ToDictionary()
291
+
292
+ result:dict = \
293
+ {
294
+ 'is_empty': self.IsEmpty,
295
+ 'is_advertisement': self.IsAdvertisement,
296
+ 'is_muted': self.IsMuted,
297
+ 'is_repeat_enabled': self.IsRepeatEnabled,
298
+ 'is_shuffle_enabled': self.IsShuffleEnabled,
299
+ 'is_device_state': self.IsDeviceState,
300
+ 'progress_ms': self._ProgressMS,
301
+ 'repeat_state': self._RepeatState,
302
+ 'shuffle_state': self._ShuffleState,
303
+ 'timestamp': self._Timestamp,
304
+ 'item_type': self._ItemType,
305
+ 'item': item,
306
+ 'context': context,
307
+ 'device_music_source': self._DeviceMusicSource,
308
+ 'device': device,
309
+ }
310
+ return result
311
+
312
+
313
+ def ToString(self) -> str:
314
+ """
315
+ Returns a displayable string representation of the class.
316
+ """
317
+ msg:str = 'PlayerLastPlayedInfo:'
318
+ if self._Device is not None: msg = '%s\n Device Name="%s"' % (msg, str(self._Device.Name))
319
+ msg = '%s\n DeviceMusicSource="%s"' % (msg, str(self._DeviceMusicSource))
320
+ msg = '%s\n IsEmpty="%s"' % (msg, str(self.IsEmpty))
321
+ msg = '%s\n IsAdvertisement="%s"' % (msg, str(self.IsAdvertisement))
322
+ msg = '%s\n IsDeviceState="%s"' % (msg, str(self.IsDeviceState))
323
+ msg = '%s\n IsMuted="%s"' % (msg, str(self.IsMuted))
324
+ msg = '%s\n IsRepeatEnabled="%s"' % (msg, str(self.IsRepeatEnabled))
325
+ msg = '%s\n IsShuffleEnabled="%s"' % (msg, str(self.IsShuffleEnabled))
326
+ msg = '%s\n ProgressMS="%s"' % (msg, str(self._ProgressMS))
327
+ msg = '%s\n RepeatState="%s"' % (msg, str(self._RepeatState))
328
+ msg = '%s\n ShuffleState="%s"' % (msg, str(self._ShuffleState))
329
+ msg = '%s\n Timestamp="%s"' % (msg, str(self._Timestamp))
330
+ msg = '%s\n ItemType="%s"' % (msg, str(self._ItemType))
331
+ if self._Item is not None: msg = '%s\n %s' % (msg, self._Item.ToString())
332
+ if self._Context is not None: msg = '%s\n %s' % (msg, self._Context.ToString())
333
+ if self._Device is not None: msg = '%s\n %s' % (msg, self._Device.ToString())
334
+ return msg