From a5646b8f6e11738064386365288eba99cb47903f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Wed, 23 Jul 2025 12:58:20 +0200 Subject: [PATCH] minor iprv --- src/main.sh | 22 +++++++++++++++++++--- src/sh/cache.sh | 7 +++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/main.sh b/src/main.sh index 30a5e79..62302fd 100755 --- a/src/main.sh +++ b/src/main.sh @@ -53,10 +53,16 @@ if [ "${1:-}" = "--internal-search" ]; then [ ! "${2}" ] && exit 0 # Save current pid echo "$$" >"$PIDFILE" - sleep 1 touch "$LOCKFILE" __api_mb_search_artists "$2" | - $JQ -r '.artists[] | [.id, .type, .name, .disambiguation, .["life-span"].begin, .["life-span"].end] | join("\t")' | + $JQ -r '.artists[] | [ + .id, + .type, + .name, + .disambiguation, + .["life-span"].begin, + .["life-span"].end + ] | join("\t")' | awk \ -F "\t" \ -v format_person="$FORMAT_PERSON" \ @@ -69,6 +75,14 @@ if [ "${1:-}" = "--internal-search" ]; then exit 0 fi +if [ "${1:-}" = "--internal-list-releases-fresh" ]; then + artistid="$2" + cache_delete_artist "$artistid" + shift 2 + set -- "--internal-list-releases" "$artistid" + mb_artist "$artistid" >/dev/null +fi + if [ "${1:-}" = "--internal-list-releases" ]; then __api_mb_browse_release_groups "$2" | $JQ -r '."release-groups"[] | [ @@ -142,10 +156,12 @@ while true; do $FZF \ --ansi \ --reverse \ + --cycle \ --delimiter="\t" \ --prompt="$(printf "$ARTIST_PROMPT" "$name")" \ --accept-nth="{2}" \ - --with-nth="{1}" + --with-nth="{1}" \ + --bind="ctrl-r:reload:$0 --internal-list-releases-fresh \"$2\"" ) [ "$sel" ] && set -- "--show-release" "$sel" ;; diff --git a/src/sh/cache.sh b/src/sh/cache.sh index 1f1ddd6..9192aea 100644 --- a/src/sh/cache.sh +++ b/src/sh/cache.sh @@ -27,6 +27,13 @@ __put_artist_json() { [ -s "$tmpf" ] && mv "$tmpf" "$f" || printf "{}" >"$f" } +# Delete all cache associated to the given artist +# argument $1: MusicBrainz Artist ID +cache_delete_artist() { + artistdir="$CACHEDIR/$1" + rm -rf "$artistdir" +} + # Returns the cached MusicBrainz data for the artist given by the MusicBrainz # Artist ID in $1 cache_get_artist_mb() {