bugfix: single file play
This commit is contained in:
@@ -4,7 +4,7 @@ BEGIN {
|
||||
delete local_recordings[0]
|
||||
if (file_local_recordings) {
|
||||
while ((getline < file_local_recordings) == 1)
|
||||
local_recordings[$1] = $2
|
||||
local_recordings[$1] = 1
|
||||
close(file_local_recordings)
|
||||
}
|
||||
}
|
||||
@@ -17,6 +17,7 @@ BEGIN {
|
||||
dur = $5
|
||||
title = $6
|
||||
artist = $7
|
||||
deco = local_recordings[id] ? $8 : ""
|
||||
# Parse duration
|
||||
if (dur) {
|
||||
dur = int(dur / 1000)
|
||||
@@ -39,5 +40,5 @@ BEGIN {
|
||||
l = local_recordings[id] ? format_local : ""
|
||||
c = id == current_id ? format_current : ""
|
||||
sortk = med" "nr
|
||||
print sortk, l, c, line, parentid, id ":" local_recordings[id]
|
||||
print sortk, l, c, line, parentid, id ":" deco
|
||||
}
|
||||
|
@@ -555,8 +555,6 @@ $KEYS_FILTER_LOCAL:transform:$0 --fzf-key {2} {3} {4}" \
|
||||
printf "%s#%s" "$MODE_ARTIST" "$sel" >"$MODEFILE"
|
||||
;;
|
||||
"$MODE_PLAYLIST")
|
||||
count=$(mpv_playlist_count)
|
||||
foo "Playlist: count=$count"
|
||||
list_playlist |
|
||||
$FZF \
|
||||
--reverse \
|
||||
|
@@ -95,12 +95,14 @@ 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[] |
|
||||
$JQ -r \
|
||||
--arg rid "$1" \
|
||||
--arg deco "$deco" \
|
||||
'.media[] |
|
||||
.position as $pos |
|
||||
.tracks[] | [
|
||||
$rid,
|
||||
@@ -109,7 +111,8 @@ list_recordings() {
|
||||
.number,
|
||||
.length,
|
||||
.recording.title,
|
||||
(.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join(""))
|
||||
(.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
|
||||
$deco
|
||||
] |
|
||||
join("\t")' |
|
||||
awk \
|
||||
@@ -144,14 +147,18 @@ 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 |
|
||||
$JQ -r \
|
||||
--slurpfile decofile "$2" \
|
||||
--arg base "$dir" \
|
||||
--arg deco "$2" \
|
||||
--arg tid "${3:-}" \
|
||||
'$decofile[].tracks as $filenames |
|
||||
. |
|
||||
.id as $rid |
|
||||
.media[] |
|
||||
@@ -166,7 +173,8 @@ generate_playlist() {
|
||||
.number,
|
||||
.length,
|
||||
.title,
|
||||
(."artist-credit" | map([.name, .joinphrase] | join("")) | join(""))
|
||||
(."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
|
||||
$deco
|
||||
] | join("\t"),
|
||||
length: (.length / 1000 | round | tostring),
|
||||
$pos,
|
||||
@@ -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