MusicBrainz search

This commit is contained in:
2025-09-05 11:16:42 +02:00
parent 62f7e38e47
commit 93359f99c5
2 changed files with 11 additions and 3 deletions

View File

@@ -198,6 +198,13 @@ case "${1:-}" in
"$VIEW_LIST_ARTISTS" | "$VIEW_SEARCH_ARTIST") printf "+show-preview" ;;
*) printf "+hide-preview" ;;
esac
# Handle MusicBrainz search views
# - `change` trigger for async. MusicBrainz search
# - input visible but search disabled
case "$view" in
"$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM") printf "+rebind(change)+disable-search" ;;
*) printf "+unbind(change)+enable-search" ;;
esac
# Load lines
printf "+reload($0 --lines %s %s)" "$view" "$mbid"
[ "$mode" = "$MODE_NORMAL" ] && printf "+hide-input"
@@ -220,7 +227,7 @@ case "${1:-}" in
exit 0
;;
"--fzf-change")
fzf_handle_change
fzf_handle_change "$2"
exit 0
;;
"--fzf-key")
@@ -488,6 +495,7 @@ open \"\$(dirname {4})\"" \
--bind="$KEYS_PLAY:" \
--bind="$KEYS_QUEUE:" \
--bind="$KEYS_SHOW_PLAYLIST:" \
--bind="change:execute-silent($0 --fzf-change $FZF_CURRENT_VIEW &)+reload:$0 --fzf-change-reload" \
--preview-window="right,25%,border-left,wrap,<30(hidden)" \
--preview="$0 --preview-artist {3}" \
--delimiter="\t" \

View File

@@ -174,12 +174,13 @@ fzf_reload_after_change() {
sleep 1
done
# Show results
column -t -s "$(printf '\t')" -E 0 "$RESULTS" |
column -t -s "$(printf '\t')" "$RESULTS" |
sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\)$|\t\1\t\2|'
}
# Handle change in query
fzf_handle_change() {
view="$1"
# Kill any running search
if [ -f "$PIDFILE" ]; then
pid=$(cat "$PIDFILE")
@@ -192,7 +193,6 @@ fzf_handle_change() {
echo "$$" >"$PIDFILE"
touch "$LOCKFILE"
sleep 1
view=$(state_get_view)
if [ "$view" = "$VIEW_SEARCH_ARTIST" ]; then
api_mb_search_artist "$FZF_QUERY" |
$JQ -r '.artists[] | [