imprv: main view

This commit is contained in:
2025-07-18 09:27:24 +02:00
parent c85f3df62e
commit 1373fd7bb8

39
fuzique
View File

@@ -54,9 +54,9 @@ if [ "${1:-}" = "--browse" ]; then
p=$(echo "$rel" | cut -d '/' -f 1)
grep -F "$ROOT/$p/" "$release_file_browse"
elif [ "$d" -eq 2 ]; then
cat "$artists_file_search"
cat "$artists_file_browse"
else
cat "$artists_file_search"
cat "$artists_file_browse"
fi
fi
exit 0
@@ -76,6 +76,7 @@ if [ "${1:-}" = "--prompt" ]; then
artist=$(echo "$rel" | cut -d "/" -f 1)
release=$(echo "$rel" | cut -d "/" -f 2)
d=$(echo "$rel" | awk -F'/' '{ print NF }')
[ "$d" -eq 1 ] && printf "$BROWSE_PROMPT_ROOT"
[ "$d" -eq 2 ] && printf "$BROWSE_PROMPT_ARTIST" "$artist"
[ "$d" -eq 3 ] && printf "$BROWSE_PROMPT_RELEASE" "$artist" "$release"
;;
@@ -89,26 +90,17 @@ fi
if [ "${1:-}" = "--preview" ]; then
shift
file="$1"
[ ! -f "$file" ] && exit 0
rel=${file#"$ROOT/"}
artist=$(echo "$rel" | cut -d "/" -f 1)
release=$(echo "$rel" | cut -d "/" -f 2)
track=$(echo "$rel" | cut -d "/" -f 3)
if [ "$track" ]; then
echo "Tracka info..."
echo "$track"
echo "(not implemented: track info for $track)"
elif [ "$release" ]; then
echo "Release info..."
echo "$release"
echo "(not implemented: release info for $release)"
elif [ "$artist" ]; then
echo "Artist info..."
echo "(not implemented: artist info for $artist)"
fi
tags=$(ffprobe -v quiet -show_entries format -of json "$file" | jq)
{
echo "## Lyrics"
echo ""
printf "%s" "$tags" | jq -C -r '.format.tags.LYRICS'
} | $CAT
exit 0
fi
@@ -233,6 +225,7 @@ TFMT="${TFMT:-"🎵 ${TRACK_COLOR}%s${OFF}"}"
PLAYLIST_POINTER="${PLAYLIST_POINTER:-👉}"
EMPTY_PLAYLIST_STRING="${EMPTY_PLAYLIST_STRING:-"\033[38;5;251m(empty playlist)${OFF}"}"
SEARCH_PROMPT=${SEARCH_PROMPT:-"🔎 search〉"}
BROWSE_PROMPT_ROOT="${BROWSE_PROMPT_ROOT:-"$SEARCH_PROMPT"}"
BROWSE_PROMPT_ARTIST="${BROWSE_PROMPT_ARTIST:-"$AFMT 〉"}"
BROWSE_PROMPT_RELEASE="${BROWSE_PROMPT_RELEASE:-"$AFMT 》 $RFMT 〉"}"
@@ -256,7 +249,7 @@ if [ "${1:-}" = "--reset-cache" ] || [ ! -f "$CACHE_FILE" ]; then
fi
# Parse
artists_file_search=$(mktemp)
artists_file_browse=$(mktemp)
release_file_browse=$(mktemp)
release_file_search=$(mktemp)
tracks_file_browse=$(mktemp)
@@ -266,10 +259,10 @@ tracks_file_search=$(mktemp)
export ROOT MPV_SOCKET \
AFMT RFMT TFMT \
PLAYLIST_POINTER EMPTY_PLAYLIST_STRING \
SEARCH_PROMPT BROWSE_PROMPT_ARTIST BROWSE_PROMPT_RELEASE \
SEARCH_PROMPT BROWSE_PROMPT_ROOT BROWSE_PROMPT_ARTIST BROWSE_PROMPT_RELEASE \
MODE_SEARCH MODE_BROWSE MODE_PLAYLIST \
release_file_browse tracks_file_browse \
tracks_file_search artists_file_search release_file_search
artists_file_browse release_file_browse tracks_file_browse \
tracks_file_search release_file_search
awk \
-F'/' \
@@ -277,9 +270,9 @@ awk \
-v rfmt="$RFMT" \
-v tfmt="$TFMT" \
-v depth="$DEPTH" \
-v artists_file_browse="$artists_file_browse" \
-v release_file_browse="$release_file_browse" \
-v tracks_file_browse="$tracks_file_browse" \
-v artists_file_search="$artists_file_search" \
-v release_file_search="$release_file_search" \
-v tracks_file_search="$tracks_file_search" \
-v mode_browse="$MODE_BROWSE" \
@@ -293,9 +286,9 @@ awk \
NF >= depth + 1 { ar = sprintf(afmt, $iartist) }
NF >= depth + 2 { rl = sprintf(rfmt, $irelease) }
NF >= depth + 3 { tr = $itrack; gsub(/\..*$/, "", tr); tr = sprintf(tfmt, tr) }
NF == depth + 1 { print ar, $0, mode_browse >> artists_file_browse }
NF == depth + 2 { print rl, $0, mode_browse >> release_file_browse }
NF == depth + 3 { print tr, $0, mode_browse >> tracks_file_browse }
NF == depth + 1 { print ar, $0, mode_search >> artists_file_search }
NF == depth + 2 { print rl "|" ar, $0, mode_search >> release_file_search }
NF == depth + 3 { print tr "|" rl "|" ar, $0, mode_search >> tracks_file_search }
' <"$CACHE_FILE"
@@ -313,7 +306,7 @@ $FZF \
--bind="ctrl-w:toggle-preview-wrap" \
--preview-window="right,30%" \
--preview="$0 --preview {2}" \
--bind="alt-1:reload:column -t -s '|' -E 0 \"$artists_file_search\"" \
--bind="alt-1:reload:cat \"$artists_file_browse\"" \
--bind="alt-2:reload:column -t -s '|' -E 0 \"$release_file_search\"" \
--bind="alt-3:reload:column -t -s '|' -E 0 \"$tracks_file_search\"" \
--bind="ctrl-p:reload:$0 --show-playlist" \
@@ -360,11 +353,11 @@ $FZF \
" \
--bind="ctrl-l:reload($0 --browse l {2})+clear-query+pos(1)" \
--bind="ctrl-h:reload($0 --browse h {2})+clear-query+pos(1)" \
<"$artists_file_search" || true
<"$artists_file_browse" || true
printf '{ "command": ["quit"] }\n' | socat - "$MPV_SOCKET"
rm -f "$MPV_SOCKET" \
"$artists_file_search" \
"$artists_file_browse" \
"$release_file_browse" \
"$release_file_search" \
"$tracks_file_browse" \