1 |
commit: 70b71a5584b9d40d8df84ac717c73128ef687fec |
2 |
Author: Andrew Ammerlaan <andrewammerlaan <AT> riseup <DOT> net> |
3 |
AuthorDate: Tue Jan 21 14:34:31 2020 +0000 |
4 |
Commit: Andrew Ammerlaan <andrewammerlaan <AT> riseup <DOT> net> |
5 |
CommitDate: Tue Jan 21 14:34:31 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=70b71a55 |
7 |
|
8 |
dev-python/spotipy: A light weight Py library for Spotify Web API |
9 |
|
10 |
Package-Manager: Portage-2.3.84, Repoman-2.3.20 |
11 |
Signed-off-by: Andrew Ammerlaan <andrewammerlaan <AT> riseup.net> |
12 |
|
13 |
dev-python/spotipy/Manifest | 1 + |
14 |
.../files/spotipy-2.7.1-skip-online-test.patch | 515 +++++++++++++++++++++ |
15 |
dev-python/spotipy/metadata.xml | 13 + |
16 |
dev-python/spotipy/spotipy-2.7.1.ebuild | 41 ++ |
17 |
4 files changed, 570 insertions(+) |
18 |
|
19 |
diff --git a/dev-python/spotipy/Manifest b/dev-python/spotipy/Manifest |
20 |
new file mode 100644 |
21 |
index 0000000..b3343ca |
22 |
--- /dev/null |
23 |
+++ b/dev-python/spotipy/Manifest |
24 |
@@ -0,0 +1 @@ |
25 |
+DIST spotipy-2.7.1.tar.gz 80050 BLAKE2B f4c4be4c8284a0c1fe12d7f963dc1a92c0c9f73ac9981debc193f21502b9106e13311a7ca97bfe00384892da73df7f964a8e8d786371551079902aebf3c32815 SHA512 8751f78e51778ff595ddf4f511bfd9c81b7c46789d91a86c1a6dcd169b55668d48b812e6c6e2befd85a12a3e622127a9ba466c6a5008b1e3cafe25939f26e705 |
26 |
|
27 |
diff --git a/dev-python/spotipy/files/spotipy-2.7.1-skip-online-test.patch b/dev-python/spotipy/files/spotipy-2.7.1-skip-online-test.patch |
28 |
new file mode 100644 |
29 |
index 0000000..0386b96 |
30 |
--- /dev/null |
31 |
+++ b/dev-python/spotipy/files/spotipy-2.7.1-skip-online-test.patch |
32 |
@@ -0,0 +1,515 @@ |
33 |
+diff --git a/tests/test_auth.py b/tests/test_auth.py |
34 |
+deleted file mode 100644 |
35 |
+index 438e88f..0000000 |
36 |
+--- a/tests/test_auth.py |
37 |
++++ /dev/null |
38 |
+@@ -1,363 +0,0 @@ |
39 |
+-# -*- coding: utf-8 -*- |
40 |
+- |
41 |
+-""" |
42 |
+-These tests require user authentication - provide client credentials using the |
43 |
+-following environment variables |
44 |
+- |
45 |
+-:: |
46 |
+- |
47 |
+- 'SPOTIPY_CLIENT_USERNAME' |
48 |
+- 'SPOTIPY_CLIENT_ID' |
49 |
+- 'SPOTIPY_CLIENT_SECRET' |
50 |
+- 'SPOTIPY_REDIRECT_URI' |
51 |
+-""" |
52 |
+- |
53 |
+-from __future__ import print_function |
54 |
+- |
55 |
+-from spotipy import ( |
56 |
+- CLIENT_CREDS_ENV_VARS as CCEV, |
57 |
+- prompt_for_user_token, |
58 |
+- Spotify, |
59 |
+- SpotifyException, |
60 |
+-) |
61 |
+-import os |
62 |
+-import sys |
63 |
+-import unittest |
64 |
+-import warnings |
65 |
+-import requests |
66 |
+- |
67 |
+-sys.path.insert(0, os.path.abspath(os.pardir)) |
68 |
+- |
69 |
+- |
70 |
+-class AuthTestSpotipy(unittest.TestCase): |
71 |
+- """ |
72 |
+- These tests require user authentication - provide client credentials using |
73 |
+- the following environment variables |
74 |
+- |
75 |
+- :: |
76 |
+- |
77 |
+- 'SPOTIPY_CLIENT_USERNAME' |
78 |
+- 'SPOTIPY_CLIENT_ID' |
79 |
+- 'SPOTIPY_CLIENT_SECRET' |
80 |
+- 'SPOTIPY_REDIRECT_URI' |
81 |
+- """ |
82 |
+- |
83 |
+- playlist = "spotify:user:plamere:playlist:2oCEWyyAPbZp9xhVSxZavx" |
84 |
+- playlist_new_id = "spotify:playlist:7GlxpQjjxRjmbb3RP2rDqI" |
85 |
+- four_tracks = ["spotify:track:6RtPijgfPKROxEzTHNRiDp", |
86 |
+- "spotify:track:7IHOIqZUUInxjVkko181PB", |
87 |
+- "4VrWlk8IQxevMvERoX08iC", |
88 |
+- "http://open.spotify.com/track/3cySlItpiPiIAzU3NyHCJf"] |
89 |
+- |
90 |
+- two_tracks = ["spotify:track:6RtPijgfPKROxEzTHNRiDp", |
91 |
+- "spotify:track:7IHOIqZUUInxjVkko181PB"] |
92 |
+- |
93 |
+- other_tracks = ["spotify:track:2wySlB6vMzCbQrRnNGOYKa", |
94 |
+- "spotify:track:29xKs5BAHlmlX1u4gzQAbJ", |
95 |
+- "spotify:track:1PB7gRWcvefzu7t3LJLUlf"] |
96 |
+- |
97 |
+- album_ids = ["spotify:album:6kL09DaURb7rAoqqaA51KU", |
98 |
+- "spotify:album:6RTzC0rDbvagTSJLlY7AKl"] |
99 |
+- |
100 |
+- bad_id = 'BAD_ID' |
101 |
+- |
102 |
+- @classmethod |
103 |
+- def setUpClass(self): |
104 |
+- if sys.version_info >= (3, 2): |
105 |
+- # >= Python3.2 only |
106 |
+- warnings.filterwarnings( |
107 |
+- "ignore", |
108 |
+- category=ResourceWarning, |
109 |
+- message="unclosed.*<ssl.SSLSocket.*>") |
110 |
+- |
111 |
+- missing = list(filter(lambda var: not os.getenv(CCEV[var]), CCEV)) |
112 |
+- |
113 |
+- if missing: |
114 |
+- raise Exception( |
115 |
+- ('Please set the client credentials for the test application' |
116 |
+- ' using the following environment variables: {}').format( |
117 |
+- CCEV.values())) |
118 |
+- |
119 |
+- self.username = os.getenv(CCEV['client_username']) |
120 |
+- |
121 |
+- self.scope = ( |
122 |
+- 'playlist-modify-public ' |
123 |
+- 'user-library-read ' |
124 |
+- 'user-follow-read ' |
125 |
+- 'user-library-modify ' |
126 |
+- 'user-read-private ' |
127 |
+- 'user-top-read ' |
128 |
+- 'user-follow-modify ' |
129 |
+- 'ugc-image-upload' |
130 |
+- ) |
131 |
+- |
132 |
+- self.token = prompt_for_user_token(self.username, scope=self.scope) |
133 |
+- |
134 |
+- self.spotify = Spotify(auth=self.token) |
135 |
+- |
136 |
+- # Helper |
137 |
+- def get_or_create_spotify_playlist(self, playlist_name): |
138 |
+- playlists = self.spotify.user_playlists(self.username) |
139 |
+- while playlists: |
140 |
+- for item in playlists['items']: |
141 |
+- if item['name'] == playlist_name: |
142 |
+- return item |
143 |
+- playlists = self.spotify.next(playlists) |
144 |
+- return self.spotify.user_playlist_create( |
145 |
+- self.username, playlist_name) |
146 |
+- |
147 |
+- # Helper |
148 |
+- def get_as_base64(self, url): |
149 |
+- import base64 |
150 |
+- return base64.b64encode(requests.get(url).content).decode("utf-8") |
151 |
+- |
152 |
+- def test_track_bad_id(self): |
153 |
+- try: |
154 |
+- self.spotify.track(self.bad_id) |
155 |
+- self.assertTrue(False) |
156 |
+- except SpotifyException: |
157 |
+- self.assertTrue(True) |
158 |
+- |
159 |
+- def test_basic_user_profile(self): |
160 |
+- user = self.spotify.user(self.username) |
161 |
+- self.assertTrue(user['id'] == self.username.lower()) |
162 |
+- |
163 |
+- def test_current_user(self): |
164 |
+- user = self.spotify.current_user() |
165 |
+- self.assertTrue(user['id'] == self.username.lower()) |
166 |
+- |
167 |
+- def test_me(self): |
168 |
+- user = self.spotify.me() |
169 |
+- self.assertTrue(user['id'] == self.username.lower()) |
170 |
+- |
171 |
+- def test_user_playlists(self): |
172 |
+- playlists = self.spotify.user_playlists(self.username, limit=5) |
173 |
+- self.assertTrue('items' in playlists) |
174 |
+- self.assertTrue(len(playlists['items']) == 5) |
175 |
+- |
176 |
+- def test_user_playlist_tracks(self): |
177 |
+- playlists = self.spotify.user_playlists(self.username, limit=5) |
178 |
+- self.assertTrue('items' in playlists) |
179 |
+- for playlist in playlists['items']: |
180 |
+- user = playlist['owner']['id'] |
181 |
+- pid = playlist['id'] |
182 |
+- results = self.spotify.user_playlist_tracks(user, pid) |
183 |
+- self.assertTrue(len(results['items']) >= 0) |
184 |
+- |
185 |
+- def test_current_user_saved_albums(self): |
186 |
+- # List |
187 |
+- albums = self.spotify.current_user_saved_albums() |
188 |
+- self.assertTrue(len(albums['items']) > 1) |
189 |
+- |
190 |
+- # Add |
191 |
+- self.spotify.current_user_saved_albums_add(self.album_ids) |
192 |
+- |
193 |
+- # Contains |
194 |
+- self.assertTrue( |
195 |
+- self.spotify.current_user_saved_albums_contains( |
196 |
+- self.album_ids) == [ |
197 |
+- True, True]) |
198 |
+- |
199 |
+- # Remove |
200 |
+- self.spotify.current_user_saved_albums_delete(self.album_ids) |
201 |
+- albums = self.spotify.current_user_saved_albums() |
202 |
+- self.assertTrue(len(albums['items']) > 1) |
203 |
+- |
204 |
+- def test_current_user_playlists(self): |
205 |
+- playlists = self.spotify.current_user_playlists(limit=10) |
206 |
+- self.assertTrue('items' in playlists) |
207 |
+- self.assertTrue(len(playlists['items']) == 10) |
208 |
+- |
209 |
+- def test_user_playlist_follow(self): |
210 |
+- self.spotify.user_playlist_follow_playlist( |
211 |
+- 'plamere', '4erXB04MxwRAVqcUEpu30O') |
212 |
+- follows = self.spotify.user_playlist_is_following( |
213 |
+- 'plamere', '4erXB04MxwRAVqcUEpu30O', [ |
214 |
+- self.spotify.current_user()['id']]) |
215 |
+- |
216 |
+- self.assertTrue(len(follows) == 1, 'proper follows length') |
217 |
+- self.assertTrue(follows[0], 'is following') |
218 |
+- self.spotify.user_playlist_unfollow( |
219 |
+- 'plamere', '4erXB04MxwRAVqcUEpu30O') |
220 |
+- |
221 |
+- follows = self.spotify.user_playlist_is_following( |
222 |
+- 'plamere', '4erXB04MxwRAVqcUEpu30O', [ |
223 |
+- self.spotify.current_user()['id']]) |
224 |
+- self.assertTrue(len(follows) == 1, 'proper follows length') |
225 |
+- self.assertFalse(follows[0], 'is no longer following') |
226 |
+- |
227 |
+- def test_current_user_saved_tracks(self): |
228 |
+- tracks = self.spotify.current_user_saved_tracks() |
229 |
+- self.assertTrue(len(tracks['items']) > 0) |
230 |
+- |
231 |
+- def test_current_user_save_and_unsave_tracks(self): |
232 |
+- tracks = self.spotify.current_user_saved_tracks() |
233 |
+- total = tracks['total'] |
234 |
+- self.spotify.current_user_saved_tracks_add(self.four_tracks) |
235 |
+- |
236 |
+- tracks = self.spotify.current_user_saved_tracks() |
237 |
+- new_total = tracks['total'] |
238 |
+- self.assertTrue(new_total - total == len(self.four_tracks)) |
239 |
+- |
240 |
+- tracks = self.spotify.current_user_saved_tracks_delete( |
241 |
+- self.four_tracks) |
242 |
+- tracks = self.spotify.current_user_saved_tracks() |
243 |
+- new_total = tracks['total'] |
244 |
+- self.assertTrue(new_total == total) |
245 |
+- |
246 |
+- def test_categories(self): |
247 |
+- response = self.spotify.categories() |
248 |
+- self.assertTrue(len(response['categories']) > 0) |
249 |
+- |
250 |
+- def test_category_playlists(self): |
251 |
+- response = self.spotify.categories() |
252 |
+- for cat in response['categories']['items']: |
253 |
+- cat_id = cat['id'] |
254 |
+- response = self.spotify.category_playlists(category_id=cat_id) |
255 |
+- if len(response['playlists']["items"]) > 0: |
256 |
+- break |
257 |
+- self.assertTrue(True) |
258 |
+- |
259 |
+- def test_new_releases(self): |
260 |
+- response = self.spotify.new_releases() |
261 |
+- self.assertTrue(len(response['albums']) > 0) |
262 |
+- |
263 |
+- def test_featured_releases(self): |
264 |
+- response = self.spotify.featured_playlists() |
265 |
+- self.assertTrue(len(response['playlists']) > 0) |
266 |
+- |
267 |
+- def test_current_user_follows(self): |
268 |
+- response = self.spotify.current_user_followed_artists() |
269 |
+- artists = response['artists'] |
270 |
+- self.assertTrue(len(artists['items']) > 0) |
271 |
+- |
272 |
+- def test_current_user_top_tracks(self): |
273 |
+- response = self.spotify.current_user_top_tracks() |
274 |
+- items = response['items'] |
275 |
+- self.assertTrue(len(items) > 0) |
276 |
+- |
277 |
+- def test_current_user_top_artists(self): |
278 |
+- response = self.spotify.current_user_top_artists() |
279 |
+- items = response['items'] |
280 |
+- self.assertTrue(len(items) > 0) |
281 |
+- |
282 |
+- def test_user_playlist_ops(self): |
283 |
+- sp = self.spotify |
284 |
+- # create empty playlist |
285 |
+- playlist = self.get_or_create_spotify_playlist( |
286 |
+- 'spotipy-testing-playlist-1') |
287 |
+- playlist_id = playlist['id'] |
288 |
+- |
289 |
+- # remove all tracks from it |
290 |
+- sp.user_playlist_replace_tracks( |
291 |
+- self.username, playlist_id, []) |
292 |
+- playlist = sp.user_playlist(self.username, playlist_id) |
293 |
+- self.assertTrue(playlist['tracks']['total'] == 0) |
294 |
+- self.assertTrue(len(playlist['tracks']['items']) == 0) |
295 |
+- |
296 |
+- # add tracks to it |
297 |
+- sp.user_playlist_add_tracks( |
298 |
+- self.username, playlist_id, self.four_tracks) |
299 |
+- playlist = sp.user_playlist(self.username, playlist_id) |
300 |
+- self.assertTrue(playlist['tracks']['total'] == 4) |
301 |
+- self.assertTrue(len(playlist['tracks']['items']) == 4) |
302 |
+- |
303 |
+- # remove two tracks from it |
304 |
+- |
305 |
+- sp.user_playlist_remove_all_occurrences_of_tracks(self.username, |
306 |
+- playlist_id, |
307 |
+- self.two_tracks) |
308 |
+- playlist = sp.user_playlist(self.username, playlist_id) |
309 |
+- self.assertTrue(playlist['tracks']['total'] == 2) |
310 |
+- self.assertTrue(len(playlist['tracks']['items']) == 2) |
311 |
+- |
312 |
+- # replace with 3 other tracks |
313 |
+- sp.user_playlist_replace_tracks(self.username, |
314 |
+- playlist_id, |
315 |
+- self.other_tracks) |
316 |
+- playlist = sp.user_playlist(self.username, playlist_id) |
317 |
+- self.assertTrue(playlist['tracks']['total'] == 3) |
318 |
+- self.assertTrue(len(playlist['tracks']['items']) == 3) |
319 |
+- |
320 |
+- def test_playlist(self): |
321 |
+- # New playlist ID |
322 |
+- pl = self.spotify.playlist(self.playlist_new_id) |
323 |
+- self.assertTrue(pl["tracks"]["total"] > 0) |
324 |
+- |
325 |
+- # Old playlist ID |
326 |
+- pl = self.spotify.playlist(self.playlist) |
327 |
+- self.assertTrue(pl["tracks"]["total"] > 0) |
328 |
+- |
329 |
+- def test_playlist_tracks(self): |
330 |
+- # New playlist ID |
331 |
+- pl = self.spotify.playlist_tracks(self.playlist_new_id, limit=2) |
332 |
+- self.assertTrue(len(pl["items"]) == 2) |
333 |
+- self.assertTrue(pl["total"] > 0) |
334 |
+- |
335 |
+- # Old playlist ID |
336 |
+- pl = self.spotify.playlist_tracks(self.playlist, limit=2) |
337 |
+- self.assertTrue(len(pl["items"]) == 2) |
338 |
+- self.assertTrue(pl["total"] > 0) |
339 |
+- |
340 |
+- def test_playlist_upload_cover_image(self): |
341 |
+- pl1 = self.get_or_create_spotify_playlist('spotipy-testing-playlist-1') |
342 |
+- plid = pl1['uri'] |
343 |
+- old_b64 = pl1['images'][0]['url'] |
344 |
+- |
345 |
+- # Upload random dog image |
346 |
+- r = requests.get('https://dog.ceo/api/breeds/image/random') |
347 |
+- dog_base64 = self.get_as_base64(r.json()['message']) |
348 |
+- self.spotify.playlist_upload_cover_image(plid, dog_base64) |
349 |
+- |
350 |
+- # Image must be different |
351 |
+- pl1 = self.spotify.playlist(plid) |
352 |
+- new_b64 = self.get_as_base64(pl1['images'][0]['url']) |
353 |
+- self.assertTrue(old_b64 != new_b64) |
354 |
+- |
355 |
+- def test_user_follows_and_unfollows_artist(self): |
356 |
+- # Initially follows 1 artist |
357 |
+- res = self.spotify.current_user_followed_artists() |
358 |
+- self.assertTrue(res['artists']['total'] == 1) |
359 |
+- |
360 |
+- # Follow 2 more artists |
361 |
+- artists = ["6DPYiyq5kWVQS4RGwxzPC7", "0NbfKEOTQCcwd6o7wSDOHI"] |
362 |
+- self.spotify.user_follow_artists(artists) |
363 |
+- res = self.spotify.current_user_followed_artists() |
364 |
+- self.assertTrue(res['artists']['total'] == 3) |
365 |
+- |
366 |
+- # Unfollow these 2 artists |
367 |
+- self.spotify.user_unfollow_artists(artists) |
368 |
+- res = self.spotify.current_user_followed_artists() |
369 |
+- self.assertTrue(res['artists']['total'] == 1) |
370 |
+- |
371 |
+- def test_user_follows_and_unfollows_user(self): |
372 |
+- # TODO improve after implementing `me/following/contains` |
373 |
+- users = ["11111204", "xlqeojt6n7on0j7coh9go8ifd"] |
374 |
+- |
375 |
+- # Follow 2 more users |
376 |
+- self.spotify.user_follow_users(users) |
377 |
+- |
378 |
+- # Unfollow these 2 users |
379 |
+- self.spotify.user_unfollow_users(users) |
380 |
+- |
381 |
+- def test_deprecated_starred(self): |
382 |
+- pl = self.spotify.user_playlist(self.username) |
383 |
+- self.assertTrue(pl["tracks"] is None) |
384 |
+- self.assertTrue(pl["owner"] is None) |
385 |
+- |
386 |
+- def test_deprecated_user_playlist(self): |
387 |
+- # Test without user due to change from |
388 |
+- # https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/ |
389 |
+- pl = self.spotify.user_playlist(None, self.playlist) |
390 |
+- self.assertTrue(pl["tracks"]["total"] > 0) |
391 |
+- |
392 |
+- def test_deprecated_user_playlis(self): |
393 |
+- # Test without user due to change from |
394 |
+- # https://developer.spotify.com/community/news/2018/06/12/changes-to-playlist-uris/ |
395 |
+- pl = self.spotify.user_playlist_tracks(None, self.playlist, limit=2) |
396 |
+- self.assertTrue(len(pl["items"]) == 2) |
397 |
+- self.assertTrue(pl["total"] > 0) |
398 |
+- |
399 |
+- |
400 |
+-if __name__ == '__main__': |
401 |
+- unittest.main() |
402 |
+diff --git a/tests/test_auth2.py b/tests/test_auth2.py |
403 |
+deleted file mode 100644 |
404 |
+index 47cf798..0000000 |
405 |
+--- a/tests/test_auth2.py |
406 |
++++ /dev/null |
407 |
+@@ -1,91 +0,0 @@ |
408 |
+-# -*- coding: utf-8 -*- |
409 |
+- |
410 |
+-""" |
411 |
+-These tests require user authentication - provide client credentials using the |
412 |
+-following environment variables |
413 |
+- |
414 |
+-:: |
415 |
+- |
416 |
+- 'SPOTIPY_CLIENT_USERNAME' |
417 |
+- 'SPOTIPY_CLIENT_ID' |
418 |
+- 'SPOTIPY_CLIENT_SECRET' |
419 |
+- 'SPOTIPY_REDIRECT_URI' |
420 |
+-""" |
421 |
+- |
422 |
+-from spotipy import ( |
423 |
+- Spotify, |
424 |
+- SpotifyClientCredentials, |
425 |
+-) |
426 |
+-import os |
427 |
+-import sys |
428 |
+-import unittest |
429 |
+- |
430 |
+-sys.path.insert(0, os.path.abspath(os.pardir)) |
431 |
+- |
432 |
+- |
433 |
+-class AuthTestSpotipy(unittest.TestCase): |
434 |
+- """ |
435 |
+- These tests require user authentication - provide client credentials using |
436 |
+- the following environment variables |
437 |
+- |
438 |
+- :: |
439 |
+- |
440 |
+- 'SPOTIPY_CLIENT_USERNAME' |
441 |
+- 'SPOTIPY_CLIENT_ID' |
442 |
+- 'SPOTIPY_CLIENT_SECRET' |
443 |
+- 'SPOTIPY_REDIRECT_URI' |
444 |
+- """ |
445 |
+- |
446 |
+- playlist = "spotify:user:plamere:playlist:2oCEWyyAPbZp9xhVSxZavx" |
447 |
+- four_tracks = ["spotify:track:6RtPijgfPKROxEzTHNRiDp", |
448 |
+- "spotify:track:7IHOIqZUUInxjVkko181PB", |
449 |
+- "4VrWlk8IQxevMvERoX08iC", |
450 |
+- "http://open.spotify.com/track/3cySlItpiPiIAzU3NyHCJf"] |
451 |
+- |
452 |
+- two_tracks = ["spotify:track:6RtPijgfPKROxEzTHNRiDp", |
453 |
+- "spotify:track:7IHOIqZUUInxjVkko181PB"] |
454 |
+- |
455 |
+- other_tracks = ["spotify:track:2wySlB6vMzCbQrRnNGOYKa", |
456 |
+- "spotify:track:29xKs5BAHlmlX1u4gzQAbJ", |
457 |
+- "spotify:track:1PB7gRWcvefzu7t3LJLUlf"] |
458 |
+- |
459 |
+- bad_id = 'BAD_ID' |
460 |
+- |
461 |
+- @classmethod |
462 |
+- def setUpClass(self): |
463 |
+- self.spotify = Spotify( |
464 |
+- client_credentials_manager=SpotifyClientCredentials()) |
465 |
+- self.spotify.trace = False |
466 |
+- |
467 |
+- def test_audio_analysis(self): |
468 |
+- result = self.spotify.audio_analysis(self.four_tracks[0]) |
469 |
+- assert('beats' in result) |
470 |
+- |
471 |
+- def test_audio_features(self): |
472 |
+- results = self.spotify.audio_features(self.four_tracks) |
473 |
+- self.assertTrue(len(results) == len(self.four_tracks)) |
474 |
+- for track in results: |
475 |
+- assert('speechiness' in track) |
476 |
+- |
477 |
+- def test_audio_features_with_bad_track(self): |
478 |
+- bad_tracks = [] |
479 |
+- bad_tracks = ['spotify:track:bad'] |
480 |
+- input = self.four_tracks + bad_tracks |
481 |
+- results = self.spotify.audio_features(input) |
482 |
+- self.assertTrue(len(results) == len(input)) |
483 |
+- for track in results[:-1]: |
484 |
+- if track is not None: |
485 |
+- assert('speechiness' in track) |
486 |
+- self.assertTrue(results[-1] is None) |
487 |
+- |
488 |
+- def test_recommendations(self): |
489 |
+- results = self.spotify.recommendations( |
490 |
+- seed_tracks=self.four_tracks, |
491 |
+- min_danceability=0, |
492 |
+- max_loudness=0, |
493 |
+- target_popularity=50) |
494 |
+- self.assertTrue(len(results['tracks']) == 20) |
495 |
+- |
496 |
+- |
497 |
+-if __name__ == '__main__': |
498 |
+- unittest.main() |
499 |
+diff --git a/tests/test_client_credentials.py b/tests/test_client_credentials.py |
500 |
+deleted file mode 100644 |
501 |
+index acbda5c..0000000 |
502 |
+--- a/tests/test_client_credentials.py |
503 |
++++ /dev/null |
504 |
+@@ -1,43 +0,0 @@ |
505 |
+-# -*- coding: utf-8 -*- |
506 |
+- |
507 |
+-""" Client Credentials Requests Tests """ |
508 |
+- |
509 |
+-from spotipy import ( |
510 |
+- Spotify, |
511 |
+- SpotifyClientCredentials, |
512 |
+-) |
513 |
+-import os |
514 |
+-import sys |
515 |
+-import unittest |
516 |
+- |
517 |
+-sys.path.insert(0, os.path.abspath(os.pardir)) |
518 |
+- |
519 |
+- |
520 |
+-class ClientCredentialsTestSpotipy(unittest.TestCase): |
521 |
+- """ |
522 |
+- These tests require user authentication - provide client credentials using |
523 |
+- the following environment variables |
524 |
+- |
525 |
+- :: |
526 |
+- |
527 |
+- 'SPOTIPY_CLIENT_USERNAME' |
528 |
+- 'SPOTIPY_CLIENT_ID' |
529 |
+- 'SPOTIPY_CLIENT_SECRET' |
530 |
+- 'SPOTIPY_REDIRECT_URI' |
531 |
+- """ |
532 |
+- |
533 |
+- @classmethod |
534 |
+- def setUpClass(self): |
535 |
+- self.spotify = Spotify( |
536 |
+- client_credentials_manager=SpotifyClientCredentials()) |
537 |
+- self.spotify.trace = False |
538 |
+- |
539 |
+- muse_urn = 'spotify:artist:12Chz98pHFMPJEknJQMWvI' |
540 |
+- |
541 |
+- def test_request_with_token(self): |
542 |
+- artist = self.spotify.artist(self.muse_urn) |
543 |
+- self.assertTrue(artist['name'] == 'Muse') |
544 |
+- |
545 |
+- |
546 |
+-if __name__ == '__main__': |
547 |
+- unittest.main() |
548 |
|
549 |
diff --git a/dev-python/spotipy/metadata.xml b/dev-python/spotipy/metadata.xml |
550 |
new file mode 100644 |
551 |
index 0000000..dd0bd9c |
552 |
--- /dev/null |
553 |
+++ b/dev-python/spotipy/metadata.xml |
554 |
@@ -0,0 +1,13 @@ |
555 |
+<?xml version="1.0" encoding="UTF-8"?> |
556 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
557 |
+ |
558 |
+<pkgmetadata> |
559 |
+ <maintainer type="person"> |
560 |
+ <email>andrewammerlaan@××××××.net</email> |
561 |
+ <name>Andrew Ammerlaan</name> |
562 |
+ </maintainer> |
563 |
+ <maintainer type="project"> |
564 |
+ <email>proxy-maint@g.o</email> |
565 |
+ <name>Proxy Maintainers</name> |
566 |
+ </maintainer> |
567 |
+</pkgmetadata> |
568 |
|
569 |
diff --git a/dev-python/spotipy/spotipy-2.7.1.ebuild b/dev-python/spotipy/spotipy-2.7.1.ebuild |
570 |
new file mode 100644 |
571 |
index 0000000..de81368 |
572 |
--- /dev/null |
573 |
+++ b/dev-python/spotipy/spotipy-2.7.1.ebuild |
574 |
@@ -0,0 +1,41 @@ |
575 |
+# Copyright 1999-2020 Gentoo Authors |
576 |
+# Distributed under the terms of the GNU General Public License v2 |
577 |
+ |
578 |
+EAPI=7 |
579 |
+ |
580 |
+PYTHON_COMPAT=( python3_{6,7,8} ) |
581 |
+ |
582 |
+inherit distutils-r1 |
583 |
+ |
584 |
+DESCRIPTION="A light weight Python library for the Spotify Web API" |
585 |
+HOMEPAGE="https://spotipy.readthedocs.io |
586 |
+ https://github.com/plamere/spotipy" |
587 |
+SRC_URI="https://github.com/plamere/${PN}/archive/${PV}.tar.gz -> ${P}.tar.gz" |
588 |
+ |
589 |
+IUSE="examples" |
590 |
+ |
591 |
+LICENSE="MIT" |
592 |
+KEYWORDS="~amd64 ~x86 " |
593 |
+SLOT="0" |
594 |
+ |
595 |
+RDEPEND=" |
596 |
+ dev-python/requests[${PYTHON_USEDEP}] |
597 |
+ dev-python/six[${PYTHON_USEDEP}] |
598 |
+ media-sound/spotify" |
599 |
+ |
600 |
+DEPEND="test? ( dev-python/mock[${PYTHON_USEDEP}] )" |
601 |
+ |
602 |
+distutils_enable_sphinx docs |
603 |
+distutils_enable_tests pytest |
604 |
+ |
605 |
+PATCHES="${FILESDIR}/${P}-skip-online-test.patch" |
606 |
+ |
607 |
+python_test() { |
608 |
+ pytest -vv tests || die "Tests fail with ${EPYTHON}" |
609 |
+} |
610 |
+ |
611 |
+python_install_all() { |
612 |
+ use examples && dodoc -r examples |
613 |
+ |
614 |
+ distutils-r1_python_install_all |
615 |
+} |