diff --git a/README.md b/README.md index 5d38f72..4acde38 100755 --- a/README.md +++ b/README.md @@ -46,11 +46,10 @@ scdl me -f --version Show version -l [url] URL can be track/playlist/user -n [maxtracks] Download the n last tracks of a playlist according to the creation date --s Download the stream of a user (token needed) -a Download all tracks of user (including reposts) -t Download all uploads of a user (no reposts) --f Download all favorites of a user --C Download all commented by a user +-f Download all favorites (likes) of a user +-C Download all tracks commented on by a user -p Download all playlists of a user -r Download all reposts of user -c Continue if a downloaded file already exists diff --git a/scdl/scdl.py b/scdl/scdl.py index 032519f..4aaf302 100755 --- a/scdl/scdl.py +++ b/scdl/scdl.py @@ -22,11 +22,10 @@ Options: --version Show version -l [url] URL can be track/playlist/user -n [maxtracks] Download the n last tracks of a playlist according to the creation date - -s Download the stream of a user (token needed) -a Download all tracks of user (including reposts) -t Download all uploads of a user (no reposts) - -f Download all favorites of a user - -C Download all commented by a user + -f Download all favorites (likes) of a user + -C Download all tracks commented on by a user -p Download all playlists of a user -r Download all reposts of user -c Continue if a downloaded file already exists diff --git a/tests/test_user.py b/tests/test_user.py new file mode 100644 index 0000000..ebbb073 --- /dev/null +++ b/tests/test_user.py @@ -0,0 +1,95 @@ +import os +from pathlib import Path + +from tests.utils import assert_track, call_scdl_with_auth + + +def count_files(dir: Path): + return len(list(dir.rglob("*"))) + + +def test_all(tmp_path: Path): + os.chdir(tmp_path) + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/one-thousand-and-one", + "-a", + "-o", + "3", + "--onlymp3", + ) + assert r.returncode == 0 + assert count_files(tmp_path) == 3 + + +def test_tracks(tmp_path: Path): + os.chdir(tmp_path) + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/one-thousand-and-one", + "-t", + "--name-format=track", + "--onlymp3", + ) + assert r.returncode == 0 + assert_track(tmp_path, "track.mp3") + assert count_files(tmp_path) == 1 + + +def test_likes(tmp_path: Path): + os.chdir(tmp_path) + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/one-thousand-and-one", + "-f", + "--onlymp3", + "--name-format={title}", + ) + assert r.returncode == 0 + assert_track( + tmp_path, "Wan Bushi - Eurodance Vibes (part 1+2+3).mp3", check_metadata=False + ) + assert count_files(tmp_path) == 1 + + +def test_commented(tmp_path: Path): + os.chdir(tmp_path) + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/one-thousand-and-one", + "-C", + "--onlymp3", + "--name-format={title}", + ) + assert r.returncode == 0 + assert_track( + tmp_path, "Wan Bushi - Eurodance Vibes (part 1+2+3).mp3", check_metadata=False + ) + assert count_files(tmp_path) == 1 + + +def test_playlists(tmp_path: Path): + os.chdir(tmp_path) + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/one-thousand-and-one", + "-p", + "--onlymp3", + ) + assert r.returncode == 0 + assert count_files(tmp_path) == 3 + + +def test_reposts(tmp_path: Path): + os.chdir(tmp_path) + r = call_scdl_with_auth( + "-l", + "https://soundcloud.com/one-thousand-and-one", + "-r", + "--name-format={title}", + ) + assert r.returncode == 0 + assert_track( + tmp_path, "Wan Bushi - Eurodance Vibes (part 1+2+3).mp3", check_metadata=False + ) + assert count_files(tmp_path) == 1