about summary refs log tree commit diff stats
path: root/home-manager/soispha/packages/scripts/wrappers/spodi
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-08-01 15:31:42 +0200
committerSoispha <soispha@vhack.eu>2023-08-01 15:42:54 +0200
commit0a608bd781dcda40144097b007fac0a0c60a8ee1 (patch)
treee69fbc1fd0e15e3b86f31f47b776df21f6f0170d /home-manager/soispha/packages/scripts/wrappers/spodi
parentFix(hm/conf/gammastep): Use lighter settings on laptops (diff)
downloadnixos-config-0a608bd781dcda40144097b007fac0a0c60a8ee1.zip
Refactor(treewide): Move module configuration in separate files
Diffstat (limited to 'home-manager/soispha/packages/scripts/wrappers/spodi')
-rwxr-xr-xhome-manager/soispha/packages/scripts/wrappers/spodi45
1 files changed, 45 insertions, 0 deletions
diff --git a/home-manager/soispha/packages/scripts/wrappers/spodi b/home-manager/soispha/packages/scripts/wrappers/spodi
new file mode 100755
index 00000000..4ff53bff
--- /dev/null
+++ b/home-manager/soispha/packages/scripts/wrappers/spodi
@@ -0,0 +1,45 @@
+#!/usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+DOWN_DIR="/home/soispha/media/music/down";
+
+download_url="$1";
+
+
+
+already_downloaded_files="$(mktmp)"
+fd . "$DOWN_DIR" --exclude spotdl.log > "$already_downloaded_files";
+
+config="$(mktmp)"
+cat << EO > "$config"
+--log-level INFO
+--cache-path /home/soispha/.local/share/spotdl/.spotipy
+--audio youtube-music youtube
+--lyrics genius musixmatch azlyrics
+--ffmpeg ffmpeg
+--format mp3
+--output {artists}_-_{title}
+--overwrite skip
+--client-id 5f573c9620494bae87890c0f08a60293
+--client-secret 212476d9b0f3472eaa762d90b19b0ba8
+--threads 16
+--print-errors
+--preload
+EO
+
+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"
+
+
+# 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