hook for recording play
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
BEGIN {
|
BEGIN {
|
||||||
OFS="\t"
|
OFS="\t"
|
||||||
local_artists[0] = 0
|
local_artists[0] = 0
|
||||||
delete local_artists[0]
|
delete local_artists[0]
|
||||||
@@ -8,14 +8,13 @@ BEGIN {
|
|||||||
close(file_local_artists)
|
close(file_local_artists)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
gsub("&", "\\\\&")
|
gsub("&", "\\\\&")
|
||||||
name = $2 == "Group" ? format_group : format_person
|
name = $2 == "Group" ? format_group : format_person
|
||||||
if (local_artists[$1])
|
l = local_artists[$1] ? format_local : ""
|
||||||
name = format_local name
|
|
||||||
if ($4)
|
if ($4)
|
||||||
name = name " " format_disambiguation
|
name = name " " format_disambiguation
|
||||||
sub("<<disambiguation>>", $4, name)
|
sub("<<disambiguation>>", $4, name)
|
||||||
sub("<<name>>", $3, name)
|
sub("<<name>>", $3, name)
|
||||||
print name, $1
|
print l, name, $1
|
||||||
}
|
}
|
||||||
|
@@ -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("&", "\\\\&")
|
gsub("&", "\\\\&")
|
||||||
id = $1
|
id = $1
|
||||||
@@ -27,6 +35,7 @@ BEGIN { OFS="\t" }
|
|||||||
sub("<<title>>", title, line)
|
sub("<<title>>", title, line)
|
||||||
sub("<<artist>>", artist, line)
|
sub("<<artist>>", artist, line)
|
||||||
sub("<<duration>>", dur, line)
|
sub("<<duration>>", dur, line)
|
||||||
|
l = local_recordings[id] ? format_local : ""
|
||||||
sortk = med" "nr
|
sortk = med" "nr
|
||||||
print sortk, line, id
|
print sortk, l, line, id ":" local_recordings[id]
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
BEGIN {
|
BEGIN {
|
||||||
OFS="\t"
|
OFS="\t"
|
||||||
local_releasegroups[0] = 0
|
local_releasegroups[0] = 0
|
||||||
delete local_releasegroups[0]
|
delete local_releasegroups[0]
|
||||||
@@ -20,8 +20,7 @@ BEGIN {
|
|||||||
title = $5
|
title = $5
|
||||||
artistcredit = $6
|
artistcredit = $6
|
||||||
line_release = artist == artistcredit ? format_release : format_release_w_artist
|
line_release = artist == artistcredit ? format_release : format_release_w_artist
|
||||||
if (local_releasegroups[$1])
|
l = local_releasegroups[$1] ? format_local : ""
|
||||||
line_release = format_local line_release
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case "Single": line_type=format_single; break
|
case "Single": line_type=format_single; break
|
||||||
case "Album": line_type=format_album; break
|
case "Album": line_type=format_album; break
|
||||||
@@ -59,5 +58,5 @@ BEGIN {
|
|||||||
line_year = year ? format_year : ""
|
line_year = year ? format_year : ""
|
||||||
sub("<<year>>", year, line_year)
|
sub("<<year>>", year, line_year)
|
||||||
sortk = year ? year : 0
|
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
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
BEGIN {
|
BEGIN {
|
||||||
OFS="\t"
|
OFS="\t"
|
||||||
local_releases[0] = 0
|
local_releases[0] = 0
|
||||||
delete local_releases[0]
|
delete local_releases[0]
|
||||||
@@ -52,7 +52,6 @@ BEGIN {
|
|||||||
sub("<<artist>>", artist, line)
|
sub("<<artist>>", artist, line)
|
||||||
sub("<<country>>", country, line)
|
sub("<<country>>", country, line)
|
||||||
sortk = year ? year : 0
|
sortk = year ? year : 0
|
||||||
if (local_releases[id])
|
l = local_releases[id] ? format_local : ""
|
||||||
line = format_local line
|
print sortk, l, line, id ":" local_releases[id]
|
||||||
print sortk, line, id ":" local_releases[id]
|
|
||||||
}
|
}
|
||||||
|
25
src/main.sh
25
src/main.sh
@@ -71,6 +71,11 @@ if [ "${MUSICDIR:-}" ]; then
|
|||||||
echo "Playing release $2" >>/tmp/foo
|
echo "Playing release $2" >>/tmp/foo
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "${1:-}" = "--play-recording" ]; then
|
||||||
|
echo "Playing recording $2" >>/tmp/foo
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--internal-preview-artist" ]; then
|
if [ "${1:-}" = "--internal-preview-artist" ]; then
|
||||||
@@ -83,7 +88,8 @@ if [ "${1:-}" = "--internal-reload" ]; then
|
|||||||
while [ -f "$LOCKFILE" ]; do
|
while [ -f "$LOCKFILE" ]; do
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
cat "$RESULTS"
|
column -t -s "$(printf '\t')" "$RESULTS" |
|
||||||
|
sed 's| \+\([0-9a-f-]\+\)$|\t\1|'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -256,6 +262,12 @@ if [ "${1:-}" = "--internal-list-releases" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${1:-}" = "--internal-list-recordings" ]; then
|
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" |
|
mb_release "$2" |
|
||||||
$JQ -r '.media[] |
|
$JQ -r '.media[] |
|
||||||
.position as $pos |
|
.position as $pos |
|
||||||
@@ -270,12 +282,17 @@ if [ "${1:-}" = "--internal-list-recordings" ]; then
|
|||||||
join("\t")' |
|
join("\t")' |
|
||||||
awk \
|
awk \
|
||||||
-F "\t" \
|
-F "\t" \
|
||||||
|
-v file_local_recordings="${rectmp:-}" \
|
||||||
-v format="$REC_FORMAT" \
|
-v format="$REC_FORMAT" \
|
||||||
|
-v format_local="$FORMAT_LOCAL" \
|
||||||
"$AWK_RECORDINGS" |
|
"$AWK_RECORDINGS" |
|
||||||
sort -k1,1n -k2,2g |
|
sort -k1,1n -k2,2g |
|
||||||
cut -d "$(printf '\t')" -f 2- |
|
cut -d "$(printf '\t')" -f 2- |
|
||||||
column -t -s "$(printf '\t')" -R 1,2,5 |
|
column -t -s "$(printf '\t')" -R 2,3,6 |
|
||||||
sed 's| \+\([0-9a-f-]\+\)$|\t\1|'
|
sed 's| \+\([0-9a-f-]\+\):\(.*$\)$|\t\1\t\2|'
|
||||||
|
if [ -f "$rectmp" ]; then
|
||||||
|
rm -f "$rectmp"
|
||||||
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -485,6 +502,8 @@ while true; do
|
|||||||
--accept-nth="{2}" \
|
--accept-nth="{2}" \
|
||||||
--with-nth="{1}" \
|
--with-nth="{1}" \
|
||||||
--expect="ctrl-h,ctrl-a" \
|
--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="alt-b:execute-silent:xdg-open 'https://musicbrainz.org/track/{r2}' &" \
|
||||||
--bind="ctrl-d:half-page-down,ctrl-u:half-page-up"
|
--bind="ctrl-d:half-page-down,ctrl-u:half-page-up"
|
||||||
)
|
)
|
||||||
|
@@ -10,7 +10,7 @@ CDESC="\033[38;5;254m"
|
|||||||
CLIFE="\033[38;5;251m"
|
CLIFE="\033[38;5;251m"
|
||||||
OFF="\033[m"
|
OFF="\033[m"
|
||||||
|
|
||||||
FORMAT_LOCAL="${FORMAT_LOCAL:-"\033[1m\033[48;5;88m"}"
|
FORMAT_LOCAL="${FORMAT_LOCAL:-"🔆"}"
|
||||||
|
|
||||||
# Prompts
|
# Prompts
|
||||||
SEARCH_PROMPT=${SEARCH_PROMPT:-"🔎 〉"}
|
SEARCH_PROMPT=${SEARCH_PROMPT:-"🔎 〉"}
|
||||||
|
Reference in New Issue
Block a user