bugfix: single file play
This commit is contained in:
@@ -95,23 +95,26 @@ list_releases() {
|
||||
list_recordings() {
|
||||
deco="$(grep "$1" "$LOCALDATA_RELEASES" | cut -d "$(printf '\t')" -f 2)"
|
||||
if [ "$deco" ]; then
|
||||
base="$(dirname "$deco")"
|
||||
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
|
||||
mb_release "$1" |
|
||||
$JQ -r --arg rid "$1" '.media[] |
|
||||
.position as $pos |
|
||||
.tracks[] | [
|
||||
$rid,
|
||||
.id,
|
||||
$pos,
|
||||
.number,
|
||||
.length,
|
||||
.recording.title,
|
||||
(.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join(""))
|
||||
] |
|
||||
join("\t")' |
|
||||
$JQ -r \
|
||||
--arg rid "$1" \
|
||||
--arg deco "$deco" \
|
||||
'.media[] |
|
||||
.position as $pos |
|
||||
.tracks[] | [
|
||||
$rid,
|
||||
.id,
|
||||
$pos,
|
||||
.number,
|
||||
.length,
|
||||
.recording.title,
|
||||
(.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
|
||||
$deco
|
||||
] |
|
||||
join("\t")' |
|
||||
awk \
|
||||
-F "\t" \
|
||||
-v file_local_recordings="${rectmp:-}" \
|
||||
@@ -144,38 +147,43 @@ list_local_releases() {
|
||||
|
||||
# Generate playlist from MB release ID and path to decoration
|
||||
# @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)
|
||||
generate_playlist() {
|
||||
foo "generate_playlist: releaseid(1)=$1; path(2)=$2; trackid(3)=$3"
|
||||
printf "#EXTM3U\n"
|
||||
dir="$(dirname "$2")"
|
||||
mb_release "$1" |
|
||||
$JQ -r --slurpfile deco "$2" --arg base "$dir" --arg tid "${3:-}" '$deco[].tracks as $filenames |
|
||||
. |
|
||||
.id as $rid |
|
||||
.media[] |
|
||||
.position as $pos |
|
||||
.tracks |
|
||||
if ($tid == "") then . else map(select(.id == $tid)) end |
|
||||
map({
|
||||
t: [
|
||||
$rid,
|
||||
.id,
|
||||
$pos,
|
||||
.number,
|
||||
.length,
|
||||
.title,
|
||||
(."artist-credit" | map([.name, .joinphrase] | join("")) | join(""))
|
||||
] | join("\t"),
|
||||
length: (.length / 1000 | round | tostring),
|
||||
$pos,
|
||||
number: .number,
|
||||
file: $filenames[.id]
|
||||
}) |
|
||||
map(if(.number | type == "string" and test("^[0-9]+$")) then .number |= tonumber else . end) |
|
||||
sort_by([.pos, .number]) |
|
||||
map("#EXTINF:" + .length + "," + .t + "\n" + $base + "/" + .file)[]'
|
||||
$JQ -r \
|
||||
--slurpfile decofile "$2" \
|
||||
--arg base "$dir" \
|
||||
--arg deco "$2" \
|
||||
--arg tid "${3:-}" \
|
||||
'$decofile[].tracks as $filenames |
|
||||
. |
|
||||
.id as $rid |
|
||||
.media[] |
|
||||
.position as $pos |
|
||||
.tracks |
|
||||
if ($tid == "") then . else map(select(.id == $tid)) end |
|
||||
map({
|
||||
t: [
|
||||
$rid,
|
||||
.id,
|
||||
$pos,
|
||||
.number,
|
||||
.length,
|
||||
.title,
|
||||
(."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
|
||||
$deco
|
||||
] | join("\t"),
|
||||
length: (.length / 1000 | round | tostring),
|
||||
$pos,
|
||||
number: .number,
|
||||
file: $filenames[.id]
|
||||
}) |
|
||||
map(if(.number | type == "string" and test("^[0-9]+$")) then .number |= tonumber else . end) |
|
||||
sort_by([.pos, .number]) |
|
||||
map("#EXTINF:" + .length + "," + .t + "\n" + $base + "/" + .file)[]'
|
||||
}
|
||||
|
||||
# Generate artist list from JSON
|
||||
@@ -200,7 +208,7 @@ list_playlist() {
|
||||
[ "$count" -eq 0 ] && return 0
|
||||
mpvquery=""
|
||||
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
|
||||
mpvtmp=$(mktemp)
|
||||
# Get playlist information from mpv
|
||||
@@ -209,10 +217,8 @@ list_playlist() {
|
||||
current_id=$(grep "^yes" "$mpvtmp" | cut -d "$(printf '\t')" -f 3)
|
||||
# Get file to be used in file_local_recordings
|
||||
rectmp=$(mktemp)
|
||||
cut -d "$(printf '\t')" -f 3,9 "$mpvtmp" >"$rectmp"
|
||||
cut -d "$(printf '\t')" -f 3 "$mpvtmp" >"$rectmp"
|
||||
# Get list
|
||||
foo "current_id=$current_id"
|
||||
foo "rectmp=$(cat "$rectmp")"
|
||||
cut -d "$(printf '\t')" -f 2- "$mpvtmp" |
|
||||
awk \
|
||||
-F "\t" \
|
||||
|
Reference in New Issue
Block a user