reorganized code
This commit is contained in:
31
src/main.sh
31
src/main.sh
@@ -55,7 +55,7 @@ if [ "${1:-}" = "--internal-search" ]; then
|
||||
echo "$$" >"$PIDFILE"
|
||||
touch "$LOCKFILE"
|
||||
sleep 1
|
||||
__api_mb_search_artists "$2" |
|
||||
api_mb_search_artists "$2" |
|
||||
$JQ -r '.artists[] | [
|
||||
.id,
|
||||
.type,
|
||||
@@ -76,15 +76,20 @@ if [ "${1:-}" = "--internal-search" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--internal-list-releases-fresh" ]; then
|
||||
if [ "${1:-}" = "--internal-list-releases" ]; then
|
||||
print "NOT IMPLEMENTED"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--internal-list-releasegroups-fresh" ]; then
|
||||
artistid="$2"
|
||||
cache_delete_artist "$artistid"
|
||||
shift 2
|
||||
set -- "--internal-list-releases" "$artistid"
|
||||
set -- "--internal-list-releasegroups" "$artistid"
|
||||
mb_artist "$artistid" >/dev/null
|
||||
fi
|
||||
|
||||
if [ "${1:-}" = "--internal-list-releases" ]; then
|
||||
if [ "${1:-}" = "--internal-list-releasegroups" ]; then
|
||||
name=$(mb_artist "$2" | $JQ -r '.name')
|
||||
mb_artist_releasegroups "$2" |
|
||||
$JQ -r '."release-groups"[] | [
|
||||
@@ -158,10 +163,10 @@ fi
|
||||
while true; do
|
||||
case "${1:-}" in
|
||||
"--show-artist")
|
||||
name=$(mb_artist "$2" | $JQ -r '.name')
|
||||
secsymb=$(printf "$FORMAT_TYPE_HAS_SECONDARY" "")
|
||||
name="$(mb_artist "$2" | $JQ -r '.name')"
|
||||
secsymb="$(printf "$FORMAT_TYPE_HAS_SECONDARY" "")"
|
||||
sel=$(
|
||||
$0 --internal-list-releases "$2" |
|
||||
$0 --internal-list-releasegroups "$2" |
|
||||
$FZF \
|
||||
--ansi \
|
||||
--reverse \
|
||||
@@ -173,10 +178,20 @@ while true; do
|
||||
--with-nth="{1}" \
|
||||
--bind="alt-1:change-query(!$secsymb ),alt-2:change-query($secsymb )" \
|
||||
--bind="ctrl-d:half-page-down,ctrl-u:half-page-up" \
|
||||
--bind="ctrl-r:reload:$0 --internal-list-releases-fresh \"$2\""
|
||||
--bind="ctrl-r:reload:$0 --internal-list-releasegroups-fresh \"$2\""
|
||||
)
|
||||
[ "$sel" ] && set -- "--show-release" "$sel"
|
||||
;;
|
||||
"--show-release-group")
|
||||
title="$(mb_releasegroup "$2" |
|
||||
$JQ -r '.title')"
|
||||
artist="$(mb_releasegroup "$2" |
|
||||
$JQ -r '."artist-credit" | map(([.name, .joinphrase]|join(""))) | join("")')"
|
||||
echo "$title"
|
||||
echo "$artist"
|
||||
exit 0
|
||||
set -- ""
|
||||
;;
|
||||
*)
|
||||
sel=$(
|
||||
printf "" |
|
||||
|
Reference in New Issue
Block a user