From 99047aedba00c88e9c5ed914e9ac345def9e6acc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=84min=20Baumeler?= Date: Mon, 6 Oct 2025 22:36:22 +0200 Subject: [PATCH] feat: play and queue from artist search and album list --- src/main.sh | 1 - src/sh/cache.sh | 6 ++-- src/sh/mb.sh | 1 - src/sh/playback.sh | 90 +++++++++++++++++++++++++++++++++++++++++++--- 4 files changed, 88 insertions(+), 10 deletions(-) diff --git a/src/main.sh b/src/main.sh index 0288d36..790dd80 100755 --- a/src/main.sh +++ b/src/main.sh @@ -141,7 +141,6 @@ case "${1:-}" in # @argument $3: MusicBrainz ID of current object # @argument $4: MusicBrainz ID of selected object # @argument $5: Path to decoration file - info "call to $*" shift playback "$@" exit 0 diff --git a/src/sh/cache.sh b/src/sh/cache.sh index f1c9a2b..7a7581a 100644 --- a/src/sh/cache.sh +++ b/src/sh/cache.sh @@ -258,7 +258,7 @@ cache_rm_artist() { d="$CACHEDIR/$TYPE_ARTIST/$(__radix "$1")/" [ "$d" ] || return 1 [ -d "$d" ] || return 1 - info "removing $d" + info "Removing $d from cache" rm -rf "$d" } @@ -275,7 +275,7 @@ cache_rm_releasegroup() { d="$CACHEDIR/$TYPE_RELEASEGROUP/$(__radix "$1")/" [ "$d" ] || return 1 [ -d "$d" ] || return 1 - info "removing $d" + info "Removing $d from cache" rm -rf "$d" } @@ -292,6 +292,6 @@ cache_rm_release() { d="$CACHEDIR/$TYPE_RELEASE/$(__radix "$1")/" [ "$d" ] || return 1 [ -d "$d" ] || return 1 - info "removing $d" + info "Removing $d from cache" rm -rf "$d" } diff --git a/src/sh/mb.sh b/src/sh/mb.sh index bf9becc..34efa80 100644 --- a/src/sh/mb.sh +++ b/src/sh/mb.sh @@ -210,7 +210,6 @@ mb_search_async() { touch "$LOCKFILE" sleep 1 if [ "$view" = "$VIEW_SEARCH_ARTIST" ]; then - info "search artist. results: $RESULTS" api_mb_search_artist "$FZF_QUERY" | $JQ '.artists[] | [ .id, diff --git a/src/sh/playback.sh b/src/sh/playback.sh index bc1f9db..af397d3 100644 --- a/src/sh/playback.sh +++ b/src/sh/playback.sh @@ -99,7 +99,6 @@ __generate_playlist() { # pressed is stored in the environment variable FZF_KEY and is resolved to # the playback command through the method `__playback_cmd_from_key`. playback() { - info "call to playback: $*" view=${1:-} mbid_current="${2:-}" mbid="${3:-}" @@ -108,9 +107,44 @@ playback() { case "$pbcmd" in "$PLAYBACK_CMD_PLAY") [ "$path" ] || exit 0 - info "play pressed" case "$view" in - "$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") info "not implemented" ;; + "$VIEW_SEARCH_ARTIST" | "$VIEW_LIST_ARTISTS") + list_releasegroups "$mbid" | + while IFS= read -r rgline; do + rgmbid="$(echo "$rgline" | cut -d "$(printf '\t')" -f 4)" + rgpath="$(echo "$rgline" | cut -d "$(printf '\t')" -f 5)" + [ "$rgpath" ] || continue + [ "${queue:-}" ] || queue="" + export queue + list_releases "$rgmbid" | + while IFS= read -r line; do + rmbid="$(echo "$line" | cut -d "$(printf '\t')" -f 4)" + rpath="$(echo "$line" | cut -d "$(printf '\t')" -f 5)" + [ "$rpath" ] || continue + if [ ! "$queue" ]; then + __generate_playlist "$rmbid" "$rpath" | mpv_play_list >/dev/null + queue=1 + else + __generate_playlist "$rmbid" "$rpath" | mpv_queue_list >/dev/null + fi + done + queue=1 + done + ;; + "$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS") + list_releases "$mbid" | + while IFS= read -r line; do + rmbid="$(echo "$line" | cut -d "$(printf '\t')" -f 4)" + rpath="$(echo "$line" | cut -d "$(printf '\t')" -f 5)" + [ "$rpath" ] || continue + if [ ! "${queue:-}" ]; then + __generate_playlist "$rmbid" "$rpath" | mpv_play_list >/dev/null + queue=1 + else + __generate_playlist "$rmbid" "$rpath" | mpv_queue_list >/dev/null + fi + done + ;; "$VIEW_RELEASEGROUP") __generate_playlist "$mbid" "$path" | mpv_play_list >/dev/null ;; "$VIEW_RELEASE") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_play_list >/dev/null ;; "$VIEW_PLAYLIST") mpv_play_index $((FZF_POS - 1)) >/dev/null ;; @@ -119,7 +153,30 @@ playback() { "$PLAYBACK_CMD_QUEUE") [ "$path" ] || exit 0 case "$view" in - "$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") info "not implemented" ;; + "$VIEW_SEARCH_ARTIST" | "$VIEW_LIST_ARTISTS") + list_releasegroups "$mbid" | + while IFS= read -r rgline; do + rgmbid="$(echo "$rgline" | cut -d "$(printf '\t')" -f 4)" + rgpath="$(echo "$rgline" | cut -d "$(printf '\t')" -f 5)" + [ "$rgpath" ] || continue + list_releases "$rgmbid" | + while IFS= read -r line; do + rmbid="$(echo "$line" | cut -d "$(printf '\t')" -f 4)" + rpath="$(echo "$line" | cut -d "$(printf '\t')" -f 5)" + [ "$rpath" ] || continue + __generate_playlist "$rmbid" "$rpath" | mpv_queue_list >/dev/null + done + done + ;; + "$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS") + list_releases "$mbid" | + while IFS= read -r line; do + rmbid="$(echo "$line" | cut -d "$(printf '\t')" -f 4)" + rpath="$(echo "$line" | cut -d "$(printf '\t')" -f 5)" + [ "$rpath" ] || continue + __generate_playlist "$rmbid" "$rpath" | mpv_queue_list >/dev/null + done + ;; "$VIEW_RELEASEGROUP") __generate_playlist "$mbid" "$path" | mpv_queue_list >/dev/null ;; "$VIEW_RELEASE") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_list >/dev/null ;; "$VIEW_PLAYLIST") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_list >/dev/null ;; @@ -128,7 +185,30 @@ playback() { "$PLAYBACK_CMD_QUEUE_NEXT") [ "$path" ] || exit 0 case "$view" in - "$VIEW_ARTIST" | "$VIEW_SEARCH_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ARTISTS" | "$VIEW_LIST_ALBUMS") info "not implemented" ;; + "$VIEW_SEARCH_ARTIST" | "$VIEW_LIST_ARTISTS") + list_releasegroups "$mbid" | + while IFS= read -r rgline; do + rgmbid="$(echo "$rgline" | cut -d "$(printf '\t')" -f 4)" + rgpath="$(echo "$rgline" | cut -d "$(printf '\t')" -f 5)" + [ "$rgpath" ] || continue + list_releases "$rgmbid" | + while IFS= read -r line; do + rmbid="$(echo "$line" | cut -d "$(printf '\t')" -f 4)" + rpath="$(echo "$line" | cut -d "$(printf '\t')" -f 5)" + [ "$rpath" ] || continue + __generate_playlist "$rmbid" "$rpath" | mpv_queue_next_list >/dev/null + done + done + ;; + "$VIEW_ARTIST" | "$VIEW_SEARCH_ALBUM" | "$VIEW_LIST_ALBUMS") + list_releases "$mbid" | + while IFS= read -r line; do + rmbid="$(echo "$line" | cut -d "$(printf '\t')" -f 4)" + rpath="$(echo "$line" | cut -d "$(printf '\t')" -f 5)" + [ "$rpath" ] || continue + __generate_playlist "$rmbid" "$rpath" | mpv_queue_next_list >/dev/null + done + ;; "$VIEW_RELEASEGROUP") __generate_playlist "$mbid" "$path" | mpv_queue_next_list >/dev/null ;; "$VIEW_RELEASE") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_next_list >/dev/null ;; "$VIEW_PLAYLIST") __generate_playlist "$mbid_current" "$path" "$mbid" | mpv_queue_next_list >/dev/null ;;