hook for recording play

This commit is contained in:
2025-08-24 22:46:34 +02:00
parent f93b85b55e
commit a48a92ca58
6 changed files with 45 additions and 20 deletions

View File

@@ -11,11 +11,10 @@ BEGIN {
{
gsub("&", "\\\\&")
name = $2 == "Group" ? format_group : format_person
if (local_artists[$1])
name = format_local name
l = local_artists[$1] ? format_local : ""
if ($4)
name = name " " format_disambiguation
sub("<<disambiguation>>", $4, name)
sub("<<name>>", $3, name)
print name, $1
print l, name, $1
}

View File

@@ -1,5 +1,13 @@
BEGIN { OFS="\t" }
BEGIN {
OFS="\t"
local_recordings[0] = 0
delete local_recordings[0]
if (file_local_recordings) {
while ((getline < file_local_recordings) == 1)
local_recordings[$1] = $2
close(file_local_recordings)
}
}
{
gsub("&", "\\\\&")
id = $1
@@ -27,6 +35,7 @@ BEGIN { OFS="\t" }
sub("<<title>>", title, line)
sub("<<artist>>", artist, line)
sub("<<duration>>", dur, line)
l = local_recordings[id] ? format_local : ""
sortk = med" "nr
print sortk, line, id
print sortk, l, line, id ":" local_recordings[id]
}

View File

@@ -20,8 +20,7 @@ BEGIN {
title = $5
artistcredit = $6
line_release = artist == artistcredit ? format_release : format_release_w_artist
if (local_releasegroups[$1])
line_release = format_local line_release
l = local_releasegroups[$1] ? format_local : ""
switch (type) {
case "Single": line_type=format_single; break
case "Album": line_type=format_album; break
@@ -59,5 +58,5 @@ BEGIN {
line_year = year ? format_year : ""
sub("<<year>>", year, line_year)
sortk = year ? year : 0
print sortk, line_type, line_release, line_year, line_sectype, id
print sortk, l, line_type, line_release, line_year, line_sectype, id
}

View File

@@ -52,7 +52,6 @@ BEGIN {
sub("<<artist>>", artist, line)
sub("<<country>>", country, line)
sortk = year ? year : 0
if (local_releases[id])
line = format_local line
print sortk, line, id ":" local_releases[id]
l = local_releases[id] ? format_local : ""
print sortk, l, line, id ":" local_releases[id]
}

View File

@@ -71,6 +71,11 @@ if [ "${MUSICDIR:-}" ]; then
echo "Playing release $2" >>/tmp/foo
exit 0
fi
if [ "${1:-}" = "--play-recording" ]; then
echo "Playing recording $2" >>/tmp/foo
exit 0
fi
fi
if [ "${1:-}" = "--internal-preview-artist" ]; then
@@ -83,7 +88,8 @@ if [ "${1:-}" = "--internal-reload" ]; then
while [ -f "$LOCKFILE" ]; do
sleep 1
done
cat "$RESULTS"
column -t -s "$(printf '\t')" "$RESULTS" |
sed 's| \+\([0-9a-f-]\+\)$|\t\1|'
exit 0
fi
@@ -256,6 +262,12 @@ if [ "${1:-}" = "--internal-list-releases" ]; then
fi
if [ "${1:-}" = "--internal-list-recordings" ]; then
deco="$(grep "$2" "$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"
fi
mb_release "$2" |
$JQ -r '.media[] |
.position as $pos |
@@ -270,12 +282,17 @@ if [ "${1:-}" = "--internal-list-recordings" ]; then
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 1,2,5 |
sed 's| \+\([0-9a-f-]\+\)$|\t\1|'
column -t -s "$(printf '\t')" -R 2,3,6 |
sed 's| \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2|'
if [ -f "$rectmp" ]; then
rm -f "$rectmp"
fi
exit 0
fi
@@ -485,6 +502,8 @@ while true; do
--accept-nth="{2}" \
--with-nth="{1}" \
--expect="ctrl-h,ctrl-a" \
--bind="enter:execute-silent:$0 --play-recording {3}" \
--bind="focus:transform:[ {3} ] && echo \"rebind:enter\" || echo \"unbind:enter\"" \
--bind="alt-b:execute-silent:xdg-open 'https://musicbrainz.org/track/{r2}' &" \
--bind="ctrl-d:half-page-down,ctrl-u:half-page-up"
)

View File

@@ -10,7 +10,7 @@ CDESC="\033[38;5;254m"
CLIFE="\033[38;5;251m"
OFF="\033[m"
FORMAT_LOCAL="${FORMAT_LOCAL:-"\033[1m\033[48;5;88m"}"
FORMAT_LOCAL="${FORMAT_LOCAL:-"🔆"}"
# Prompts
SEARCH_PROMPT=${SEARCH_PROMPT:-"🔎 〉"}