mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Some cleanup
This commit is contained in:
@@ -18,6 +18,8 @@ def generate_token():
|
|||||||
token = credentials.get_access_token()
|
token = credentials.get_access_token()
|
||||||
return token
|
return token
|
||||||
|
|
||||||
|
# token is mandatory when using Spotify's API
|
||||||
|
# https://developer.spotify.com/news-stories/2017/01/27/removing-unauthenticated-calls-to-the-web-api/
|
||||||
token = generate_token()
|
token = generate_token()
|
||||||
spotify = spotipy.Spotify(auth=token)
|
spotify = spotipy.Spotify(auth=token)
|
||||||
|
|
||||||
|
|||||||
@@ -192,11 +192,6 @@ def grab_single(raw_song, number=None):
|
|||||||
log.error('No audio streams available')
|
log.error('No audio streams available')
|
||||||
|
|
||||||
|
|
||||||
# token is mandatory when using Spotify's API
|
|
||||||
# https://developer.spotify.com/news-stories/2017/01/27/removing-unauthenticated-calls-to-the-web-api/
|
|
||||||
token = spotify_tools.generate_token()
|
|
||||||
spotify = spotipy.Spotify(auth=token)
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
const.args = handle.get_arguments()
|
const.args = handle.get_arguments()
|
||||||
internals.filter_path(const.args.folder)
|
internals.filter_path(const.args.folder)
|
||||||
|
|||||||
@@ -4,25 +4,26 @@ import spotdl
|
|||||||
|
|
||||||
username = 'alex'
|
username = 'alex'
|
||||||
|
|
||||||
|
spotify = spotdl.spotify_tools.spotify
|
||||||
|
|
||||||
def test_user():
|
def test_user():
|
||||||
expect_playlists = 7
|
expect_playlists = 7
|
||||||
playlists = spotdl.spotify.user_playlists(username)
|
playlists = spotify.user_playlists(username)
|
||||||
playlists = len(playlists['items'])
|
playlists = len(playlists['items'])
|
||||||
assert playlists == expect_playlists
|
assert playlists == expect_playlists
|
||||||
|
|
||||||
|
|
||||||
def test_playlist():
|
def test_playlist():
|
||||||
expect_tracks = 14
|
expect_tracks = 14
|
||||||
playlist = spotdl.spotify.user_playlists(username)['items'][0]
|
playlist = spotify.user_playlists(username)['items'][0]
|
||||||
tracks = playlist['tracks']['total']
|
tracks = playlist['tracks']['total']
|
||||||
assert tracks == expect_tracks
|
assert tracks == expect_tracks
|
||||||
|
|
||||||
|
|
||||||
def test_tracks():
|
def test_tracks():
|
||||||
playlist = spotdl.spotify.user_playlists(username)['items'][0]
|
playlist = spotify.user_playlists(username)['items'][0]
|
||||||
expect_lines = playlist['tracks']['total']
|
expect_lines = playlist['tracks']['total']
|
||||||
result = spotdl.spotify.user_playlist(
|
result = spotify.user_playlist(
|
||||||
playlist['owner']['id'], playlist['id'], fields='tracks,next')
|
playlist['owner']['id'], playlist['id'], fields='tracks,next')
|
||||||
tracks = result['tracks']
|
tracks = result['tracks']
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user