show playlist (buggy)
This commit is contained in:
@@ -120,7 +120,7 @@ list_recordings() {
|
||||
"$AWK_RECORDINGS" |
|
||||
sort -k1,1n -k2,2g |
|
||||
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|'
|
||||
if [ "${rectmp:-}" ] && [ -f "$rectmp" ]; then
|
||||
rm -f "$rectmp"
|
||||
@@ -144,9 +144,10 @@ list_local_releases() {
|
||||
|
||||
# Generate playlist from MB release ID and path to decoration
|
||||
# @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)
|
||||
generate_playlist() {
|
||||
foo "generate_playlist: releaseid(1)=$1; path(2)=$2; trackid(3)=$3"
|
||||
printf "#EXTM3U\n"
|
||||
dir="$(dirname "$2")"
|
||||
mb_release "$1" |
|
||||
@@ -159,10 +160,13 @@ generate_playlist() {
|
||||
if ($tid == "") then . else map(select(.id == $tid)) end |
|
||||
map({
|
||||
t: [
|
||||
.title,
|
||||
(."artist-credit" | map([.name, .joinphrase] | join("")) | join("")),
|
||||
$rid,
|
||||
.id,
|
||||
$rid
|
||||
$pos,
|
||||
.number,
|
||||
.length,
|
||||
.title,
|
||||
(."artist-credit" | map([.name, .joinphrase] | join("")) | join(""))
|
||||
] | join("\t"),
|
||||
length: (.length / 1000 | round | tostring),
|
||||
$pos,
|
||||
@@ -193,26 +197,33 @@ list_artists_from_json() {
|
||||
# Generate playlist view
|
||||
list_playlist() {
|
||||
count=$(mpv_playlist_count)
|
||||
# mb_release "$1" |
|
||||
# $JQ -r '.media[] |
|
||||
# .position as $pos |
|
||||
# .tracks[] | [
|
||||
# .id,
|
||||
# $pos,
|
||||
# .number,
|
||||
# .length,
|
||||
# .recording.title,
|
||||
# (.recording."artist-credit" | map([.name, .joinphrase] | join("")) | join(""))
|
||||
# ] |
|
||||
# join("\t")' |
|
||||
# awk \
|
||||
# -F "\t" \
|
||||
# -v file_local_recordings="${rectmp:-}" \
|
||||
# -v format="$REC_FORMAT" \
|
||||
# -v format_local="$FORMAT_LOCAL" \
|
||||
# "$AWK_RECORDINGS" |
|
||||
# sort -k1,1n -k2,2g |
|
||||
# cut -d "$(printf '\t')" -f 2- |
|
||||
# column -t -s "$(printf '\t')" -R 2,3,6 |
|
||||
# sed 's| \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2|'
|
||||
[ "$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"
|
||||
done
|
||||
mpvtmp=$(mktemp)
|
||||
# Get playlist information from mpv
|
||||
__mpv_get "$mpvquery" | grep '.' >"$mpvtmp"
|
||||
# Get MusicBrainz Track ID of current recording
|
||||
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"
|
||||
# Get list
|
||||
foo "current_id=$current_id"
|
||||
foo "rectmp=$(cat "$rectmp")"
|
||||
cut -d "$(printf '\t')" -f 2- "$mpvtmp" |
|
||||
awk \
|
||||
-F "\t" \
|
||||
-v file_local_recordings="${rectmp:-}" \
|
||||
-v format="$REC_FORMAT_NO_NUMBER" \
|
||||
-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"
|
||||
}
|
||||
|
@@ -11,6 +11,8 @@ __mpv_command_with_args2() {
|
||||
}
|
||||
|
||||
__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'
|
||||
}
|
||||
|
||||
@@ -32,20 +34,20 @@ mpv_start() {
|
||||
$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_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_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() {
|
||||
|
@@ -12,6 +12,7 @@ OFF="\033[m"
|
||||
|
||||
FORMAT_LOCAL="${FORMAT_LOCAL:-"🔆"}"
|
||||
export FORMAT_LOCAL
|
||||
FORMAT_CURRENT="${FORMAT_CURRENT:-"👉"}"
|
||||
|
||||
# Prompts
|
||||
SEARCH_PROMPT=${SEARCH_PROMPT:-"🔎 〉"}
|
||||
@@ -74,3 +75,4 @@ RV_ARTIST="${FAINT}by ${CARTIST}<<artist>>$OFF"
|
||||
|
||||
# Recording view
|
||||
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"
|
||||
|
Reference in New Issue
Block a user