mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
Add support for .m3u playlists (#401)
* Add support for .m3u playlists * Run black code formatter on changes * Stay consistent with Spotify test track
This commit is contained in:
@@ -2,13 +2,19 @@ import builtins
|
||||
import os
|
||||
|
||||
from spotdl import spotify_tools
|
||||
from spotdl import youtube_tools
|
||||
from spotdl import const
|
||||
from spotdl import spotdl
|
||||
|
||||
import loader
|
||||
|
||||
|
||||
PLAYLIST_URL = "https://open.spotify.com/user/alex/playlist/0iWOVoumWlkXIrrBTSJmN8"
|
||||
ALBUM_URL = "https://open.spotify.com/album/499J8bIsEnU7DSrosFDJJg"
|
||||
ARTIST_URL = "https://open.spotify.com/artist/4dpARuHxo51G3z768sgnrY"
|
||||
|
||||
loader.load_defaults()
|
||||
|
||||
|
||||
def test_user_playlists(tmpdir, monkeypatch):
|
||||
expect_tracks = 21
|
||||
@@ -31,21 +37,40 @@ def test_playlist(tmpdir):
|
||||
|
||||
def test_album(tmpdir):
|
||||
expect_tracks = 15
|
||||
global text_file
|
||||
text_file = os.path.join(str(tmpdir), "test_al.txt")
|
||||
spotify_tools.write_album(ALBUM_URL, text_file)
|
||||
with open(text_file, "r") as f:
|
||||
tracks = len(f.readlines())
|
||||
assert tracks == expect_tracks
|
||||
|
||||
|
||||
def test_m3u(tmpdir):
|
||||
expect_m3u = (
|
||||
"#EXTM3U\n\n"
|
||||
"#EXTINF:47,Eminem - Encore - Curtains Up\n"
|
||||
"http://www.youtube.com/watch?v=0BZ6JYwrl2Y\n"
|
||||
"#EXTINF:226,Alan Walker - Spectre [NCS Release]\n"
|
||||
"http://www.youtube.com/watch?v=AOeY-nDp7hI\n"
|
||||
)
|
||||
m3u_track_file = os.path.join(str(tmpdir), "m3u_test.txt")
|
||||
with open(m3u_track_file, "w") as track_file:
|
||||
track_file.write("\nhttps://open.spotify.com/track/2nT5m433s95hvYJH4S7ont")
|
||||
track_file.write("\nhttp://www.youtube.com/watch?v=AOeY-nDp7hI")
|
||||
youtube_tools.generate_m3u(m3u_track_file)
|
||||
m3u_file = "{}.m3u".format(m3u_track_file.split(".")[0])
|
||||
with open(m3u_file, "r") as m3u_in:
|
||||
m3u = m3u_in.readlines()
|
||||
assert "".join(m3u) == expect_m3u
|
||||
|
||||
|
||||
def test_all_albums(tmpdir):
|
||||
#current number of tracks on spotify since as of 10/10/2018
|
||||
#in US market only
|
||||
# current number of tracks on spotify since as of 10/10/2018
|
||||
# in US market only
|
||||
expect_tracks = 49
|
||||
global text_file
|
||||
text_file = os.path.join(str(tmpdir), 'test_ab.txt')
|
||||
text_file = os.path.join(str(tmpdir), "test_ab.txt")
|
||||
spotify_tools.write_all_albums_from_artist(ARTIST_URL, text_file)
|
||||
with open(text_file, 'r') as f:
|
||||
with open(text_file, "r") as f:
|
||||
tracks = len(f.readlines())
|
||||
assert tracks == expect_tracks
|
||||
|
||||
|
||||
Reference in New Issue
Block a user