diff --git a/src/awk/recordings.awk b/src/awk/recordings.awk index 4cf58aa..09bb224 100644 --- a/src/awk/recordings.awk +++ b/src/awk/recordings.awk @@ -19,12 +19,13 @@ # The input to this awk program is a sequence of lines containing the following fields: # Field 1: The MusicBrainz ID of the release this track belongs to # Field 2: MusicBrainz ID of this track -# Field 3: Medium number of this track within the release -# Field 4: Track number of this track within the medium -# Field 5: Duration of this track in miliseconds -# Field 6: Title of this track -# Field 7: Artist of this track -# Field 8: Path to decoratoin file of this release +# Field 3: Number of media of theis release +# Field 4: Medium number of this track within the release +# Field 5: Track number of this track within the medium +# Field 6: Duration of this track in miliseconds +# Field 7: Title of this track +# Field 8: Artist of this track +# Field 9: Path to decoratoin file of this release # # The output is a sequence of tab-delimited lines containing the following fields: # Field 1: Sort value (to sort the track within the release) @@ -47,12 +48,13 @@ BEGIN { { parentid = $1 id = $2 - med = $3 - nr = $4 - dur = $5 - title = $6 - artist = $7 - deco = local_recordings[id] ? $8 : "" + medtot = $3 + med = $4 + nr = $5 + dur = $6 + title = $7 + artist = $8 + deco = local_recordings[id] ? $9 : "" gsub("&", "\\\\&", title) gsub("&", "\\\\&", artist) # Parse duration @@ -69,7 +71,10 @@ BEGIN { dur = "??:??" } line = format - sub("<>", med, line) + if (medtot == 1) + sub("<>", "", line) + else + sub("<>", med, line) sub("<>", nr, line) sub("<>", title, line) sub("<<artist>>", artist, line) diff --git a/src/sh/lists.sh b/src/sh/lists.sh index 652e2bc..aa0e2fa 100644 --- a/src/sh/lists.sh +++ b/src/sh/lists.sh @@ -99,20 +99,78 @@ list_releases() { # # argument $1: MusicBrainz release ID list_recordings() { + info "list recordings.." deco="$(grep "$1" "$LOCALDATA_RELEASES" | cut -d "$(printf '\t')" -f 2)" + info "deco=$deco" if [ "$deco" ]; then rectmp=$(mktemp) $JQ '.tracks | keys | join("\n")' "$deco" >"$rectmp" + info "rectmp=$rectmp" + info "$(cat "$rectmp")" fi - mb_release "$1" | - $JQ \ - --arg rid "$1" \ - --arg deco "$deco" \ - '.media[] | + info "going to awk..." + info "$( + mb_release "$1" | + $JQ \ + --arg rid "$1" \ + --arg deco "$deco" \ + '.media | + length as $l | + .[] | .position as $pos | .tracks[] | [ $rid, .id, + $l, + $pos, + .number, + .length, + .recording.title, + (.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join("")), + $deco + ] | + join("\t")' + )" + info "$( + mb_release "$1" | + $JQ \ + --arg rid "$1" \ + --arg deco "$deco" \ + '.media | + length as $l | + .[] | + .position as $pos | + .tracks[] | [ + $rid, + .id, + $l, + $pos, + .number, + .length, + .recording.title, + (.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join("")), + $deco + ] | + join("\t")' | + awk \ + -F "\t" \ + -v file_local_recordings="${rectmp:-}" \ + -v format="$REC_FORMAT" \ + -v format_local="$FORMAT_LOCAL" \ + "$AWK_RECORDINGS" + )" + mb_release "$1" | + $JQ \ + --arg rid "$1" \ + --arg deco "$deco" \ + '.media | + length as $l | + .[] | + .position as $pos | + .tracks[] | [ + $rid, + .id, + $l, $pos, .number, .length, diff --git a/src/sh/playback.sh b/src/sh/playback.sh index 8d76803..0fc50e6 100644 --- a/src/sh/playback.sh +++ b/src/sh/playback.sh @@ -60,7 +60,9 @@ __generate_playlist() { '$decofile[].tracks as $filenames | . | .id as $rid | - .media[] | + .media | + length as $l | + .[] | .position as $pos | .tracks | if ($tid == "") then . else map(select(.id == $tid)) end | @@ -68,6 +70,7 @@ __generate_playlist() { t: [ $rid, .id, + $l, $pos, .number, .length,