bugfix: single file play

This commit is contained in:
2025-08-28 15:48:50 +02:00
parent 8bfa2d7483
commit 4a8f42cdd5
3 changed files with 54 additions and 49 deletions

View File

@@ -4,7 +4,7 @@ BEGIN {
delete local_recordings[0] delete local_recordings[0]
if (file_local_recordings) { if (file_local_recordings) {
while ((getline < file_local_recordings) == 1) while ((getline < file_local_recordings) == 1)
local_recordings[$1] = $2 local_recordings[$1] = 1
close(file_local_recordings) close(file_local_recordings)
} }
} }
@@ -17,6 +17,7 @@ BEGIN {
dur = $5 dur = $5
title = $6 title = $6
artist = $7 artist = $7
deco = local_recordings[id] ? $8 : ""
# Parse duration # Parse duration
if (dur) { if (dur) {
dur = int(dur / 1000) dur = int(dur / 1000)
@@ -39,5 +40,5 @@ BEGIN {
l = local_recordings[id] ? format_local : "" l = local_recordings[id] ? format_local : ""
c = id == current_id ? format_current : "" c = id == current_id ? format_current : ""
sortk = med" "nr sortk = med" "nr
print sortk, l, c, line, parentid, id ":" local_recordings[id] print sortk, l, c, line, parentid, id ":" deco
} }

View File

@@ -555,8 +555,6 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
printf "%s#%s" "$MODE_ARTIST" "$sel" >"$MODEFILE" printf "%s#%s" "$MODE_ARTIST" "$sel" >"$MODEFILE"
;; ;;
"$MODE_PLAYLIST") "$MODE_PLAYLIST")
count=$(mpv_playlist_count)
foo "Playlist: count=$count"
list_playlist | list_playlist |
$FZF \ $FZF \
--reverse \ --reverse \

View File

@@ -95,12 +95,14 @@ list_releases() {
list_recordings() { list_recordings() {
deco="$(grep "$1" "$LOCALDATA_RELEASES" | cut -d "$(printf '\t')" -f 2)" deco="$(grep "$1" "$LOCALDATA_RELEASES" | cut -d "$(printf '\t')" -f 2)"
if [ "$deco" ]; then if [ "$deco" ]; then
base="$(dirname "$deco")"
rectmp=$(mktemp) rectmp=$(mktemp)
$JQ -r --arg base "$base/" '.tracks | to_entries | map(.key + "\t" + $base + .value) | join("\n")' "$deco" >"$rectmp" $JQ -r '.tracks | keys | join("\n")' "$deco" >"$rectmp"
fi fi
mb_release "$1" | mb_release "$1" |
$JQ -r --arg rid "$1" '.media[] | $JQ -r \
--arg rid "$1" \
--arg deco "$deco" \
'.media[] |
.position as $pos | .position as $pos |
.tracks[] | [ .tracks[] | [
$rid, $rid,
@@ -109,7 +111,8 @@ list_recordings() {
.number, .number,
.length, .length,
.recording.title, .recording.title,
(.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join("")) (.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
$deco
] | ] |
join("\t")' | join("\t")' |
awk \ awk \
@@ -144,14 +147,18 @@ 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 / path to audio file # @argument $2: Path to decoration 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" |
$JQ -r --slurpfile deco "$2" --arg base "$dir" --arg tid "${3:-}" '$deco[].tracks as $filenames | $JQ -r \
--slurpfile decofile "$2" \
--arg base "$dir" \
--arg deco "$2" \
--arg tid "${3:-}" \
'$decofile[].tracks as $filenames |
. | . |
.id as $rid | .id as $rid |
.media[] | .media[] |
@@ -166,7 +173,8 @@ generate_playlist() {
.number, .number,
.length, .length,
.title, .title,
(."artist-credit" | map([.name, .joinphrase] | join("")) | join("")) (."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
$deco
] | join("\t"), ] | join("\t"),
length: (.length / 1000 | round | tostring), length: (.length / 1000 | round | tostring),
$pos, $pos,
@@ -200,7 +208,7 @@ list_playlist() {
[ "$count" -eq 0 ] && return 0 [ "$count" -eq 0 ] && return 0
mpvquery="" mpvquery=""
for i in $(seq 0 $((count - 1))); do for i in $(seq 0 $((count - 1))); do
mpvquery="$mpvquery\${playlist/$i/current}\t\${playlist/$i/title}\t\${playlist/$i/filename}\n" mpvquery="$mpvquery\${playlist/$i/current}\t\${playlist/$i/title}\n"
done done
mpvtmp=$(mktemp) mpvtmp=$(mktemp)
# Get playlist information from mpv # Get playlist information from mpv
@@ -209,10 +217,8 @@ list_playlist() {
current_id=$(grep "^yes" "$mpvtmp" | cut -d "$(printf '\t')" -f 3) current_id=$(grep "^yes" "$mpvtmp" | cut -d "$(printf '\t')" -f 3)
# Get file to be used in file_local_recordings # Get file to be used in file_local_recordings
rectmp=$(mktemp) rectmp=$(mktemp)
cut -d "$(printf '\t')" -f 3,9 "$mpvtmp" >"$rectmp" cut -d "$(printf '\t')" -f 3 "$mpvtmp" >"$rectmp"
# Get list # Get list
foo "current_id=$current_id"
foo "rectmp=$(cat "$rectmp")"
cut -d "$(printf '\t')" -f 2- "$mpvtmp" | cut -d "$(printf '\t')" -f 2- "$mpvtmp" |
awk \ awk \
-F "\t" \ -F "\t" \