mirror of
https://github.com/KevinMidboe/spotify-downloader.git
synced 2025-10-29 18:00:15 +00:00
[WIP] Refactor spotdl.py; introduced classes (#410)
* Refactor spotdl.py; introduced classes * introduce CheckExists class * Move these classes to download.py * Fix refresh_token * Add a changelog entry
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import os
|
||||
|
||||
from spotdl import const
|
||||
from spotdl import spotdl
|
||||
from spotdl import downloader
|
||||
|
||||
import loader
|
||||
|
||||
@@ -16,5 +16,6 @@ def test_dry_download_list(tmpdir):
|
||||
file_path = os.path.join(const.args.folder, "test_list.txt")
|
||||
with open(file_path, "w") as f:
|
||||
f.write(TRACK_URL)
|
||||
downloaded_song, *_ = spotdl.download_list(file_path)
|
||||
list_dl = downloader.ListDownloader(file_path)
|
||||
downloaded_song, *_ = list_dl.download_list()
|
||||
assert downloaded_song == TRACK_URL
|
||||
|
||||
@@ -6,7 +6,7 @@ from spotdl import spotify_tools
|
||||
from spotdl import youtube_tools
|
||||
from spotdl import convert
|
||||
from spotdl import metadata
|
||||
from spotdl import spotdl
|
||||
from spotdl import downloader
|
||||
|
||||
import loader
|
||||
|
||||
@@ -55,7 +55,8 @@ def test_check_track_exists_before_download(tmpdir):
|
||||
songname = internals.format_string(const.args.file_format, meta_tags)
|
||||
global file_name
|
||||
file_name = internals.sanitize_title(songname)
|
||||
check = spotdl.check_exists(file_name, TRACK_URL, meta_tags)
|
||||
track_existence = downloader.CheckExists(file_name, meta_tags)
|
||||
check = track_existence.already_exists(TRACK_URL)
|
||||
assert check == expect_check
|
||||
|
||||
|
||||
@@ -146,6 +147,7 @@ class TestEmbedMetadata:
|
||||
|
||||
def test_check_track_exists_after_download():
|
||||
expect_check = True
|
||||
check = spotdl.check_exists(file_name, TRACK_URL, meta_tags)
|
||||
track_existence = downloader.CheckExists(file_name, meta_tags)
|
||||
check = track_existence.already_exists(TRACK_URL)
|
||||
os.remove(track_path + ".mp3")
|
||||
assert check == expect_check
|
||||
|
||||
@@ -5,7 +5,7 @@ from spotdl import const
|
||||
from spotdl import internals
|
||||
from spotdl import spotify_tools
|
||||
from spotdl import youtube_tools
|
||||
from spotdl import spotdl
|
||||
from spotdl import downloader
|
||||
|
||||
import loader
|
||||
|
||||
@@ -112,7 +112,8 @@ def test_check_exists(tmpdir):
|
||||
# prerequisites for determining filename
|
||||
global file_name
|
||||
file_name = internals.sanitize_title(title)
|
||||
check = spotdl.check_exists(file_name, TRACK_SEARCH, metadata)
|
||||
track_existence = downloader.CheckExists(file_name, metadata)
|
||||
check = track_existence.already_exists(TRACK_SEARCH)
|
||||
assert check == expect_check
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user