imrv: preview artist

This commit is contained in:
2025-07-25 15:58:16 +02:00
parent 5bc17bccc9
commit 5bfb76fadb
2 changed files with 14 additions and 12 deletions

View File

@@ -1,11 +1,12 @@
__shape() {
cat | tr -d '\r' | fold -s -w "$((FZF_PREVIEW_COLUMNS - 4))" | awk '{print " "$0" "}'
}
# Print preview of artist
# @input $1: MusicBrainz Artist ID
__preview_artist() {
desc=$(mb_artist_enwikipedia "$1" | $JQ -r '.extract')
if [ ! "$desc" ]; then
desc=$(mb_artist_discogs "$1" | $JQ -r '.profile' | sed 's/\[a=\([^]]*\)\]/\1/g')
fi
[ "$desc" ] && desc="$(printf "$FORMAT_DESCRIPTION" "$desc")"
desc=$(mb_artist_enwikipedia "$1" | $JQ -r '.extract' | __shape)
[ "$desc" ] || desc=$(mb_artist_discogs "$1" | $JQ -r '.profile' | sed 's/\[a=\([^]]*\)\]/\1/g' | __shape)
if [ "$(mb_artist "$1" | $JQ -r '.type')" = "Person" ]; then
# Show birth place and death place of person
lsb=$(mb_artist "$1" | $JQ -r '."life-span".begin // ""' | head -c 4)
@@ -30,8 +31,9 @@ __preview_artist() {
else
end=""
fi
[ "$begin" ] && begin="$(printf "$FORMAT_LIFESPAN_BORN" "$begin")"
[ "$end" ] && end="$(printf "$FORMAT_LIFESPAN_DIED" "$end")"
[ "$begin" ] && lifespan="$(printf "$FORMAT_LIFESPAN_BORN" "$begin")"
[ "$end" ] && lifespan="$(printf "%s\n$FORMAT_LIFESPAN_DIED" "$lifespan" "$end")"
fi
printf "\n\n%s\n\n%s\n%s" "$desc" "$begin" "$end" | tr -d '\r' | fold -s -w "$((FZF_PREVIEW_COLUMNS - 4))" | awk '{print " "$0" "}' | cat
#link=$(printf "More info:\033]8;;%s\033\\ %s\033]8;;\033\\" "https://musicbrainz.org/" "[MusicBrainz]")
printf "\n\n${COLOR_DESCRIPTION}%s${COLOR_RESET}\n\n${COLOR_LIFESPAN}%s$COLOR_RESET" "$desc" "${lifespan:-}"
}