about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-05-06 09:09:41 +0200
committerSoispha <soispha@vhack.eu>2023-05-09 19:33:15 +0200
commit470c6024b0d86d5366fab3b0a8e53e3c407d679b (patch)
tree19e33510ca9f69373d6da05b35c3776ef4b75692
parentBuild(flake): Update (diff)
downloadnixos-config-470c6024b0d86d5366fab3b0a8e53e3c407d679b.tar.gz
nixos-config-470c6024b0d86d5366fab3b0a8e53e3c407d679b.zip
Fix(hm/pkgs/scrs/spodi): Rework to nixos
-rw-r--r--home-manager/packages/scripts.nix2
-rwxr-xr-xhome-manager/packages/scripts/wrappers/spodi20
2 files changed, 11 insertions, 11 deletions
diff --git a/home-manager/packages/scripts.nix b/home-manager/packages/scripts.nix
index a647076c..f5a06348 100644
--- a/home-manager/packages/scripts.nix
+++ b/home-manager/packages/scripts.nix
@@ -68,7 +68,7 @@
   spodi-scr = write_script {
     name = "spodi";
     path = "wrappers";
-    dependencies = builtins.attrValues {inherit (pkgs) gawk expect spotdl;};
+    dependencies = builtins.attrValues {inherit (pkgs) gawk expect spotdl fd coreutils ;};
   };
   virsh-del-scr = write_script {
     name = "virsh-del";
diff --git a/home-manager/packages/scripts/wrappers/spodi b/home-manager/packages/scripts/wrappers/spodi
index b3cf9013..6f92140d 100755
--- a/home-manager/packages/scripts/wrappers/spodi
+++ b/home-manager/packages/scripts/wrappers/spodi
@@ -4,16 +4,17 @@
 . %SHELL_LIBRARY_PATH
 
 
-DOWN_DIR=/home/dt/media/playlist/down/
+DOWN_DIR=/home/soispha/media/music/down/
 
 
-tmp=$(mktemp)
-config=$(mktemp)
+tmp=$(mktmp)
+config=$(mktmp)
+
+fd . "$DOWN_DIR" --exclude spotdl.log > "$tmp";
 
-for e in "$DOWN_DIR"/*.mp3;do echo "$e" >> "$tmp";done
 cat << EO > "$config"
 --log-level INFO
---cache-path /home/dt/.config/spotdl/.spotipy
+--cache-path /home/soispha/.config/spotdl/.spotipy
 --audio youtube-music youtube
 --lyrics genius musixmatch azlyrics
 --ffmpeg ffmpeg
@@ -29,11 +30,10 @@ EO
 
 [ "$(wc -l "$tmp" | awk '{print $1}')" -gt 2 ] && die "something is already downloaded"
 
-rm ${DOWN_DIR}spotdl.log
-cd $DOWN_DIR || die "BUG: no $DOWN_DIR"
+rm "${DOWN_DIR}spotdl.log"
+cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR"
 
-unbuffer spotdl $(cat "$config") download "$1" | tee $DOWN_DIR/spotdl.log
+# The sub shell needs to be unquoted, as the arguments may not be treated as one.
+unbuffer spotdl $(cat "$config") download "$1" | tee "$DOWN_DIR/spotdl.log"
 
 [ -d ~/.spotdl ] && rm -r ~/.spotdl
-rm "$tmp"
-rm "$config"