MusicBrainz search
This commit is contained in:
10
src/main.sh
10
src/main.sh
@@ -198,6 +198,13 @@ case "${1:-}" in
|
|||||||
"$VIEW_LIST_ARTISTS" | "$VIEW_SEARCH_ARTIST") printf "+show-preview" ;;
|
"$VIEW_LIST_ARTISTS" | "$VIEW_SEARCH_ARTIST") printf "+show-preview" ;;
|
||||||
*) printf "+hide-preview" ;;
|
*) printf "+hide-preview" ;;
|
||||||
esac
|
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
|
# Load lines
|
||||||
printf "+reload($0 --lines %s %s)" "$view" "$mbid"
|
printf "+reload($0 --lines %s %s)" "$view" "$mbid"
|
||||||
[ "$mode" = "$MODE_NORMAL" ] && printf "+hide-input"
|
[ "$mode" = "$MODE_NORMAL" ] && printf "+hide-input"
|
||||||
@@ -220,7 +227,7 @@ case "${1:-}" in
|
|||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--fzf-change")
|
"--fzf-change")
|
||||||
fzf_handle_change
|
fzf_handle_change "$2"
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"--fzf-key")
|
"--fzf-key")
|
||||||
@@ -488,6 +495,7 @@ open \"\$(dirname {4})\"" \
|
|||||||
--bind="$KEYS_PLAY:" \
|
--bind="$KEYS_PLAY:" \
|
||||||
--bind="$KEYS_QUEUE:" \
|
--bind="$KEYS_QUEUE:" \
|
||||||
--bind="$KEYS_SHOW_PLAYLIST:" \
|
--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-window="right,25%,border-left,wrap,<30(hidden)" \
|
||||||
--preview="$0 --preview-artist {3}" \
|
--preview="$0 --preview-artist {3}" \
|
||||||
--delimiter="\t" \
|
--delimiter="\t" \
|
||||||
|
@@ -174,12 +174,13 @@ fzf_reload_after_change() {
|
|||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
# Show results
|
# 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|'
|
sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\)$|\t\1\t\2|'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Handle change in query
|
# Handle change in query
|
||||||
fzf_handle_change() {
|
fzf_handle_change() {
|
||||||
|
view="$1"
|
||||||
# Kill any running search
|
# Kill any running search
|
||||||
if [ -f "$PIDFILE" ]; then
|
if [ -f "$PIDFILE" ]; then
|
||||||
pid=$(cat "$PIDFILE")
|
pid=$(cat "$PIDFILE")
|
||||||
@@ -192,7 +193,6 @@ fzf_handle_change() {
|
|||||||
echo "$$" >"$PIDFILE"
|
echo "$$" >"$PIDFILE"
|
||||||
touch "$LOCKFILE"
|
touch "$LOCKFILE"
|
||||||
sleep 1
|
sleep 1
|
||||||
view=$(state_get_view)
|
|
||||||
if [ "$view" = "$VIEW_SEARCH_ARTIST" ]; then
|
if [ "$view" = "$VIEW_SEARCH_ARTIST" ]; then
|
||||||
api_mb_search_artist "$FZF_QUERY" |
|
api_mb_search_artist "$FZF_QUERY" |
|
||||||
$JQ -r '.artists[] | [
|
$JQ -r '.artists[] | [
|
||||||
|
Reference in New Issue
Block a user