list release groups

This commit is contained in:
2025-07-21 21:10:10 +02:00
parent 8a3e5144cf
commit c40768c973
7 changed files with 181 additions and 19 deletions

57
src/awk/releases.awk Normal file
View File

@@ -0,0 +1,57 @@
BEGIN {
OFS="\t"
year[0] = 0; del year[0]
title[0] = 0; del title[0]
type[0] = 0; del type[0]
id[0] = 0; del id[0]
score[0] = 0; del score[0]
}
function get_score(rgdt, rgti, dt, ti, qy, res) {
res = 0
if (rgdt == dt)
res = res + 5
if (rgti == ti)
res = res + 5
if (qy == "normal" || qy == "unknown")
res = res + 1
if (qy == "high")
res = res + 2
return res
}
{
gsub("&", "\\\\&")
rgmi = $1 # Release Group ID
rgty = $2 # Release Group Type
rgdt = substr($3, 1, 4) + 0 # Release Group Year
rgti = $4 # Release Group Title
mi = $5 # MusicBrainz Release ID
qy = $6 # Release Quality
dt = substr($7, 1, 4) + 0 # Release Year
ti = $8 # Release Title
s = get_score(rgdt, rgti, dt, ti, qy)
if (score[rgmi] < s) {
score[rgmi] = s
year[rgmi] = dt
title[rgmi] = ti
type[rgmi] = rgty
id[rgmi] = mi
}
}
END {
for (rgmi in id) {
if (type[rgmi] == "Single")
line = format_single
else if (type[rgmi] == "Album")
line = format_album
else if (type[rgmi] == "EP")
line = format_ep
else
line = format_album
sub("<<year>>", dt, line)
sub("<<title>>", ti, line)
print mi, line
}
}