From 04e4fe4fe6329a279c220496d2c78ba5a9bc186d Mon Sep 17 00:00:00 2001 From: Soispha Date: Wed, 7 Feb 2024 20:54:29 +0100 Subject: feat(hm/pkgs/scrs): Add `mpc-fav` and `sort_song` --- hm/soispha/pkgs/scripts/wrappers/mpc-fav | 13 ++++++++++++ hm/soispha/pkgs/scripts/wrappers/sort_song | 33 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100755 hm/soispha/pkgs/scripts/wrappers/mpc-fav create mode 100755 hm/soispha/pkgs/scripts/wrappers/sort_song (limited to 'hm/soispha/pkgs/scripts') 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 -- cgit 1.4.1