blob: 1936c7bc682dcc0c5b755c49beb901e1c18dcdba (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/usr/bin/env dash
# shellcheck source=/dev/null
SHELL_LIBRARY_VERSION="1.10.2" . %SHELL_LIBRARY_PATH
# This path must not contain spaces
DOWN_DIR="/home/soispha/media/music/down/spotify";
download_url="$1";
already_downloaded_files="$(mktmp)"
fd . "$DOWN_DIR" --exclude spotdl.log --exclude spotdl-errors.log > "$already_downloaded_files";
config="$(mktmp)"
cat << EOF | clean > "$config"
# Main options
--audio slider-kz soundcloud bandcamp youtube-music
--lyrics genius musixmatch azlyrics synced
# FFmpeg options
--ffmpeg ffmpeg
--threads 16
--bitrate 256k
# Spotify options
--cache-path /home/soispha/.local/share/spotdl/.spotipy
# Output options
--preload
--format opus
--output {artists}_-_{title}
--print-errors
--save-errors $DOWN_DIR/spotdl-errors.log
# TODO: Reactive whence spotdl support for these has improved <2023-12-19>
# --generate-lrc
--overwrite skip
# Misc options
--log-level INFO
EOF
if [ -z "$NO_CHECK" ] && [ "$(wc -l < "$already_downloaded_files" )" -ne 0 ];then
die "something is already downloaded"
fi
rm "$DOWN_DIR/spotdl.log"
cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR"
touch "$DOWN_DIR/spotdl-errors.log"
# The sub shell needs to be unquoted, as the arguments may not be treated as one.
# shellcheck disable=2046
unbuffer spotdl $(cat "$config") download "$download_url" | tee "$DOWN_DIR/spotdl.log"
[ -d ~/.spotdl ] && rm -r ~/.spotdl
# vim: ft=sh
|