cleaned up
This commit is contained in:
@@ -10,75 +10,27 @@ fzf_command_set_header() {
|
||||
"$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')"
|
||||
name="$(mb_artist "$mbid" | $JQ '.name')"
|
||||
header=$(printf "$ARTIST_PROMPT" "$name")
|
||||
;;
|
||||
"$VIEW_RELEASEGROUP")
|
||||
title="$(mb_releasegroup "$mbid" |
|
||||
$JQ -r '.title')"
|
||||
$JQ '.title')"
|
||||
artist="$(mb_releasegroup "$mbid" |
|
||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||
$JQ '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||
header=$(printf "$FULL_PROMPT" "$artist" "$title")
|
||||
;;
|
||||
"$VIEW_RELEASE")
|
||||
title="$(mb_release "$mbid" |
|
||||
$JQ -r '.title')"
|
||||
$JQ '.title')"
|
||||
artist="$(mb_release "$mbid" |
|
||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||
$JQ '."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
|
||||
__set_prompt() {
|
||||
view=$1
|
||||
mode=$2
|
||||
case "$view" in
|
||||
"$VIEW_ARTIST")
|
||||
name="$(mb_artist "$args" | $JQ -r '.name')"
|
||||
PROMPT=$(printf "$ARTIST_PROMPT" "$name")
|
||||
;;
|
||||
"$VIEW_RELEASEGROUP")
|
||||
title="$(mb_releasegroup "$args" |
|
||||
$JQ -r '.title')"
|
||||
artist="$(mb_releasegroup "$args" |
|
||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||
PROMPT=$(printf "$FULL_PROMPT" "$artist" "$title")
|
||||
;;
|
||||
"$VIEW_RELEASE")
|
||||
title="$(mb_release "$args" |
|
||||
$JQ -r '.title')"
|
||||
artist="$(mb_release "$args" |
|
||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||
PROMPT=$(printf "$FULL_PROMPT" "$artist" "$title")
|
||||
;;
|
||||
esac
|
||||
[ "$mode" = "$MODE_INSERT" ] && PT="$PROMPT_INSERT" || PT="$PROMPT_NORMAL"
|
||||
printf "+change-header(%s %s)" "$PT" "${PROMPT:-"$SEARCH_PROMPT"}"
|
||||
}
|
||||
|
||||
# Reload hook that is used after change in query
|
||||
fzf_reload_after_change() {
|
||||
# Wait for async. process to terminate
|
||||
@@ -108,7 +60,7 @@ fzf_handle_change() {
|
||||
sleep 1
|
||||
if [ "$view" = "$VIEW_SEARCH_ARTIST" ]; then
|
||||
api_mb_search_artist "$FZF_QUERY" |
|
||||
$JQ -r '.artists[] | [
|
||||
$JQ '.artists[] | [
|
||||
.id,
|
||||
.type,
|
||||
.name,
|
||||
@@ -127,7 +79,7 @@ fzf_handle_change() {
|
||||
true
|
||||
else
|
||||
api_mb_search_releasegroup "$FZF_QUERY" |
|
||||
$JQ -r '."release-groups"[] | [
|
||||
$JQ '."release-groups"[] | [
|
||||
.id,
|
||||
."primary-type",
|
||||
(."secondary-types" // []|join(";")),
|
||||
|
Reference in New Issue
Block a user