faster but quite buggy; no disc state storage

This commit is contained in:
2025-09-04 15:10:16 +02:00
parent b15848887b
commit 8c37cb2fea
7 changed files with 368 additions and 81 deletions

View File

@@ -1,3 +1,54 @@
# Print the command that sets the header.
# @argument $1: view
# @argument $2: mbid
fzf_command_set_header() {
view=$1
mbid=$2
case "$view" in
"$VIEW_SEARCH_ARTIST") header="Search artist on MusicBrainz" ;;
"$VIEW_SEARCH_ALBUM") header="Search album on MusicBrainz" ;;
"$VIEW_LIST_ARTISTS") header="Search locally available artist" ;;
"$VIEW_LIST_ALBUMS") header="Search locally available album" ;;
"$VIEW_ARTIST")
name="$(mb_artist "$mbid" | $JQ -r '.name')"
header=$(printf "$ARTIST_PROMPT" "$name")
;;
"$VIEW_RELEASEGROUP")
title="$(mb_releasegroup "$mbid" |
$JQ -r '.title')"
artist="$(mb_releasegroup "$mbid" |
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
header=$(printf "$FULL_PROMPT" "$artist" "$title")
;;
"$VIEW_RELEASE")
title="$(mb_release "$mbid" |
$JQ -r '.title')"
artist="$(mb_release "$mbid" |
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
header=$(printf "$FULL_PROMPT" "$artist" "$title")
;;
esac
printf "+change-header(%s)" "${header:-"???"}"
}
# Print the command that tells fzf to load the data
# @argument $1: view
# @argument $2: mbid
fzf_command_load_data() {
view=$1
mbid=${2:-}
case "$view" in
"$VIEW_SEARCH_ARTIST") ;;
"$VIEW_SEARCH_ALBUM") ;;
"$VIEW_LIST_ARTISTS") ;;
"$VIEW_LIST_ALBUMS") ;;
"$VIEW_ARTIST") ;;
"$VIEW_RELEASEGROUP") ;;
"$VIEW_RELEASE") ;;
esac
printf "+reload($0 --lines %s %s)" "$VIEW_LIST_ARTISTS" ""
}
# Set prompt of input field
# @argument $1: view
# @argument $2: mode
@@ -25,7 +76,7 @@ __set_prompt() {
;;
esac
[ "$mode" = "$MODE_INSERT" ] && PT="$PROMPT_INSERT" || PT="$PROMPT_NORMAL"
printf "+change-prompt(%s %s)" "$PT" "${PROMPT:-"$SEARCH_PROMPT"}"
printf "+change-header(%s %s)" "$PT" "${PROMPT:-"$SEARCH_PROMPT"}"
}
# Reload data for FZF