Files
fuzic/src/awk/recordings.awk

43 lines
884 B
Awk

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("&", "\\\\&")
parentid = $1
id = $2
med = $3
nr = $4
dur = $5
title = $6
artist = $7
# Parse duration
if (dur) {
dur = int(dur / 1000)
dh = int(dur / 3600)
dur = dur % 3600
dm = int(dur / 60)
ds = dur % 60
if (ds <= 9)
ds = "0"ds
dur = dh ? dh":"dm":"ds : dm":"ds
} else {
dur = "??:??"
}
line = format
sub("<<med>>", med, line)
sub("<<nr>>", nr, line)
sub("<<title>>", title, line)
sub("<<artist>>", artist, line)
sub("<<duration>>", dur, line)
l = local_recordings[id] ? format_local : ""
sortk = med" "nr
print sortk, l, line, parentid, id ":" local_recordings[id]
}