Files
fuzic/src/awk/releasegroups.awk

63 lines
1.9 KiB
Awk

BEGIN {
OFS="\t"
local_releasegroups[0] = 0
delete local_releasegroups[0]
if (file_local_releasegroups) {
while ((getline < file_local_releasegroups) == 1)
local_releasegroups[$1] = 1
close(file_local_releasegroups)
}
}
{
line_type=""
line_sectype=""
line_year=""
gsub("&", "\\\\&")
id = $1
type = $2
sectype = $3
year = substr($4, 1, 4) + 0
title = $5
artistcredit = $6
line_release = artist == artistcredit ? format_release : format_release_w_artist
l = local_releasegroups[$1] ? format_local : ""
switch (type) {
case "Single": line_type=format_single; break
case "Album": line_type=format_album; break
case "EP": line_type=format_ep; break
case "Broadcast": line_type=format_broadcast; break
case "Other": line_type=format_other; break
default: line_type=""
}
split(sectype, a, ";")
for (i in a) {
t=""
switch (a[i]) {
case "Compilation": t=format_compilation; break
case "Soundtrack": t=format_soundtrack; break
case "Spokenword": t=format_spokenword; break
case "Interview": t=format_interview; break
case "Audiobook": t=format_audiobook; break
case "Audio drama": t=format_audiodrama; break
case "Live": t=format_live; break
case "Remix": t=format_remix; break
case "DJ-mix": t=format_djmix; break
case "Mixtape/Street": t=format_mixtape; break
case "Demo": t=format_demo; break
case "Field recording": t=fieldrec; break
}
if (t)
line_sectype=line_sectype ? line_sectype ", " t : t
}
if (sectype) {
line_type = sprintf(format_has_secondary, line_type)
line_sectype = sprintf(format_secondary, line_sectype)
}
sub("<<title>>", title, line_release)
sub("<<artist>>", artistcredit, line_release)
line_year = year ? format_year : ""
sub("<<year>>", year, line_year)
sortk = year ? year : 0
print sortk, l, line_type, line_release, line_year, line_sectype, id
}