about summary refs log tree commit diff stats
path: root/hm/soispha/pkgs/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'hm/soispha/pkgs/scripts')
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/mpc-fav13
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/sort_song33
2 files changed, 46 insertions, 0 deletions
diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-fav b/hm/soispha/pkgs/scripts/wrappers/mpc-fav
new file mode 100755
index 00000000..59121c86
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/mpc-fav
@@ -0,0 +1,13 @@
+#!/usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH
+
+FAV_DIR="$XDG_MUSIC_DIR/playlists/favourites";
+
+cd "$XDG_MUSIC_DIR" || die "No music dir!";
+[ -d "$FAV_DIR" ] && mkdir --parents "$FAV_DIR";
+ln -sr "$(mpc --format '%file%' current)" "$FAV_DIR" || die "Link failed!";
+
+
+# vim: ft=sh
diff --git a/hm/soispha/pkgs/scripts/wrappers/sort_song b/hm/soispha/pkgs/scripts/wrappers/sort_song
new file mode 100755
index 00000000..f539cf15
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/sort_song
@@ -0,0 +1,33 @@
+#!/usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH
+
+case "$("$1" | tr '[:upper:]' '[:lower:]')"  in
+    "lyrics")
+        filter="LYRICS";
+        directory="lyrics";
+        ;;
+    "instrumental")
+        filter="INSTRUMENTAL";
+        directory="instrumental";
+        ;;
+    *)
+        die "Expected 'instrumental|lyrics' but got '$1'";
+esac
+
+process() {
+    mediainfo --Output=JSON "$1" | jq '.media.track | map(.Lyrics) | join("")'
+};
+
+mkdir "../$directory";
+
+fd . --extension=opus | while read -r file; do
+    if [ "$(process "$file")" = '""' ] || [ "$(process "$file")" = '"Instrumental"' ] || [ "$(process "$file")" = '"instrumental"' ]; then
+        echo "INSTRUMENTAL::$file";
+    else
+        echo "LYRICS::$file";
+        fi;
+    done | grep "$filter" | awk 'BEGIN {FS="::"}{print $2}' | while read -r file; do ln -s "../all/$file" "../$directory/$file"; done
+
+# vim: ft=sh