show playlist (buggy)

This commit is contained in:
2025-08-28 15:16:00 +02:00
parent f2383c3803
commit 8bfa2d7483
5 changed files with 76 additions and 48 deletions

View File

@@ -37,6 +37,7 @@ BEGIN {
sub("<<artist>>", artist, line) sub("<<artist>>", artist, line)
sub("<<duration>>", dur, line) sub("<<duration>>", dur, line)
l = local_recordings[id] ? format_local : "" l = local_recordings[id] ? format_local : ""
c = id == current_id ? format_current : ""
sortk = med" "nr sortk = med" "nr
print sortk, l, line, parentid, id ":" local_recordings[id] print sortk, l, c, line, parentid, id ":" local_recordings[id]
} }

View File

@@ -246,13 +246,10 @@ if [ "${1:-}" = "--fzf-key" ]; then
[ "$path" ] || exit 0 [ "$path" ] || exit 0
case "$mode" in case "$mode" in
"$MODE_RELEASEGROUP") "$MODE_RELEASEGROUP")
tmplist=$(mktemp) generate_playlist "$mbid" "$path" | mpv_play_list >/dev/null
generate_playlist "$mbid" "$path" >"$tmplist"
mpv_play_list "$tmplist" >/dev/null
rm -f "$tmplist"
;; ;;
"$MODE_RELEASE") "$MODE_RELEASE")
mpv_play_file "$path" >/dev/null generate_playlist "$parentmbid" "$path" "$mbid" | mpv_play_list >/dev/null
;; ;;
esac esac
;; ;;
@@ -262,13 +259,10 @@ if [ "${1:-}" = "--fzf-key" ]; then
[ "$path" ] || exit 0 [ "$path" ] || exit 0
case "$mode" in case "$mode" in
"$MODE_RELEASEGROUP") "$MODE_RELEASEGROUP")
tmplist=$(mktemp) generate_playlist "$mbid" "$path" | mpv_queue_list >/dev/null
generate_playlist "$mbid" "$path" >"$tmplist"
mpv_queue_list "$tmplist" >/dev/null
rm -f "$tmplist"
;; ;;
"$MODE_RELEASE") "$MODE_RELEASE")
mpv_play_file "$path" >/dev/null generate_playlist "$parentmbid" "$path" "$mbid" | mpv_queue_list >/dev/null
;; ;;
esac esac
;; ;;
@@ -563,6 +557,24 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
"$MODE_PLAYLIST") "$MODE_PLAYLIST")
count=$(mpv_playlist_count) count=$(mpv_playlist_count)
foo "Playlist: count=$count" foo "Playlist: count=$count"
list_playlist |
$FZF \
--reverse \
--no-sort \
--border=double \
--border-label=" Playlist " \
--no-input \
--margin="2%,10%" \
--bind="$KEYS_HALFPAGE_DOWN,$KEYS_HALFPAGE_UP,\
$KEYS_BROWSE,\
$KEYS_OUT,\
$KEYS_SELECT_ARTIST,\
$KEYS_PLAY,$KEYS_QUEUE,\
$KEYS_PLAY,$KEYS_QUEUE,$KEYS_TOGGLE_PLAY_PAUSE,\
$KEYS_PLAY_NEXT,$KEYS_PLAY_PREV,\
$KEYS_SEEK_FORWARD,$KEYS_SEEK_BACKWARD:transform:$0 --fzf-key {2} {3} {4}" \
--delimiter="\t" \
--with-nth="{1}" >/dev/null
# --bind="$KEYS_HALFPAGE_DOWN,$KEYS_HALFPAGE_UP,\ # --bind="$KEYS_HALFPAGE_DOWN,$KEYS_HALFPAGE_UP,\
#$KEYS_BROWSE,\ #$KEYS_BROWSE,\
#$KEYS_IN,$KEYS_OUT,\ #$KEYS_IN,$KEYS_OUT,\

View File

@@ -120,7 +120,7 @@ list_recordings() {
"$AWK_RECORDINGS" | "$AWK_RECORDINGS" |
sort -k1,1n -k2,2g | sort -k1,1n -k2,2g |
cut -d "$(printf '\t')" -f 2- | cut -d "$(printf '\t')" -f 2- |
column -t -s "$(printf '\t')" -R 2,3,6 | column -t -s "$(printf '\t')" -R 3,4,7 |
sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2\t\3|' sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2\t\3|'
if [ "${rectmp:-}" ] && [ -f "$rectmp" ]; then if [ "${rectmp:-}" ] && [ -f "$rectmp" ]; then
rm -f "$rectmp" rm -f "$rectmp"
@@ -144,9 +144,10 @@ list_local_releases() {
# Generate playlist from MB release ID and path to decoration # Generate playlist from MB release ID and path to decoration
# @argument $1: MusicBrainz Release ID # @argument $1: MusicBrainz Release ID
# @argument $2: Path to decoration file # @argument $2: Path to decoration file / path to audio file
# @argument $3: MusicBrainz Track ID to select (optional) # @argument $3: MusicBrainz Track ID to select (optional)
generate_playlist() { generate_playlist() {
foo "generate_playlist: releaseid(1)=$1; path(2)=$2; trackid(3)=$3"
printf "#EXTM3U\n" printf "#EXTM3U\n"
dir="$(dirname "$2")" dir="$(dirname "$2")"
mb_release "$1" | mb_release "$1" |
@@ -159,10 +160,13 @@ generate_playlist() {
if ($tid == "") then . else map(select(.id == $tid)) end | if ($tid == "") then . else map(select(.id == $tid)) end |
map({ map({
t: [ t: [
.title, $rid,
(."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
.id, .id,
$rid $pos,
.number,
.length,
.title,
(."artist-credit" | map([.name, .joinphrase] | join("")) | join(""))
] | join("\t"), ] | join("\t"),
length: (.length / 1000 | round | tostring), length: (.length / 1000 | round | tostring),
$pos, $pos,
@@ -193,26 +197,33 @@ list_artists_from_json() {
# Generate playlist view # Generate playlist view
list_playlist() { list_playlist() {
count=$(mpv_playlist_count) count=$(mpv_playlist_count)
# mb_release "$1" | [ "$count" -eq 0 ] && return 0
# $JQ -r '.media[] | mpvquery=""
# .position as $pos | for i in $(seq 0 $((count - 1))); do
# .tracks[] | [ mpvquery="$mpvquery\${playlist/$i/current}\t\${playlist/$i/title}\t\${playlist/$i/filename}\n"
# .id, done
# $pos, mpvtmp=$(mktemp)
# .number, # Get playlist information from mpv
# .length, __mpv_get "$mpvquery" | grep '.' >"$mpvtmp"
# .recording.title, # Get MusicBrainz Track ID of current recording
# (.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join("")) current_id=$(grep "^yes" "$mpvtmp" | cut -d "$(printf '\t')" -f 3)
# ] | # Get file to be used in file_local_recordings
# join("\t")' | rectmp=$(mktemp)
# awk \ cut -d "$(printf '\t')" -f 3,9 "$mpvtmp" >"$rectmp"
# -F "\t" \ # Get list
# -v file_local_recordings="${rectmp:-}" \ foo "current_id=$current_id"
# -v format="$REC_FORMAT" \ foo "rectmp=$(cat "$rectmp")"
# -v format_local="$FORMAT_LOCAL" \ cut -d "$(printf '\t')" -f 2- "$mpvtmp" |
# "$AWK_RECORDINGS" | awk \
# sort -k1,1n -k2,2g | -F "\t" \
# cut -d "$(printf '\t')" -f 2- | -v file_local_recordings="${rectmp:-}" \
# column -t -s "$(printf '\t')" -R 2,3,6 | -v format="$REC_FORMAT_NO_NUMBER" \
# sed 's| \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2|' -v format_current="$FORMAT_CURRENT" \
-v current_id="$current_id" \
"$AWK_RECORDINGS" |
sort -k1,1n -k2,2g |
cut -d "$(printf '\t')" -f 2- |
column -t -s "$(printf '\t')" -R 5 |
sed 's| \+\([0-9a-f-]\+\) \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2\t\3|'
rm -f "$rectmp" "$mpvtmp"
} }

View File

@@ -11,6 +11,8 @@ __mpv_command_with_args2() {
} }
__mpv_get() { __mpv_get() {
foo "__mpv_get argument=$1"
foo "__mpv_get answer=$(__mpv_command_with_arg "expand-text" "$1" | $JQ -C)"
__mpv_command_with_arg "expand-text" "$1" | $JQ -r '.data' __mpv_command_with_arg "expand-text" "$1" | $JQ -r '.data'
} }
@@ -32,20 +34,20 @@ mpv_start() {
$MPV --no-config --no-terminal --input-ipc-server="$MPV_SOCKET" --idle --no-osc --no-input-default-bindings & $MPV --no-config --no-terminal --input-ipc-server="$MPV_SOCKET" --idle --no-osc --no-input-default-bindings &
} }
mpv_play_file() {
__mpv_command_with_arg "loadfile" "$1"
}
mpv_queue_file() {
__mpv_command_with_args2 "loadfile" "$1" "append-play"
}
mpv_play_list() { mpv_play_list() {
__mpv_command_with_arg "loadlist" "$1" t=$(mktemp)
cat >"$t"
foo "$(cat "$t")"
__mpv_command_with_arg "loadlist" "$t"
rm -f "$t"
} }
mpv_queue_list() { mpv_queue_list() {
__mpv_command_with_arg "loadlist" "$1" "append-play" t=$(mktemp)
cat >"$t"
foo "$(cat "$t")"
__mpv_command_with_arg "loadlist" "$t" "append-play"
rm -f "$t"
} }
mpv_next() { mpv_next() {

View File

@@ -12,6 +12,7 @@ OFF="\033[m"
FORMAT_LOCAL="${FORMAT_LOCAL:-"🔆"}" FORMAT_LOCAL="${FORMAT_LOCAL:-"🔆"}"
export FORMAT_LOCAL export FORMAT_LOCAL
FORMAT_CURRENT="${FORMAT_CURRENT:-"👉"}"
# Prompts # Prompts
SEARCH_PROMPT=${SEARCH_PROMPT:-"🔎 〉"} SEARCH_PROMPT=${SEARCH_PROMPT:-"🔎 〉"}
@@ -74,3 +75,4 @@ RV_ARTIST="${FAINT}by ${CARTIST}<<artist>>$OFF"
# Recording view # Recording view
REC_FORMAT="${CNOTE}${FAINT}<<med>>\t${CNOTE}<<nr>>$OFF\t${CTITLE}<<title>>\t${CARTIST}<<artist>>\t${CXXX}<<duration>>$OFF" REC_FORMAT="${CNOTE}${FAINT}<<med>>\t${CNOTE}<<nr>>$OFF\t${CTITLE}<<title>>\t${CARTIST}<<artist>>\t${CXXX}<<duration>>$OFF"
REC_FORMAT_NO_NUMBER="${CTITLE}<<title>>\t${CARTIST}<<artist>>\t${CXXX}<<duration>>$OFF"