ref: 41abe98ac77c8a3b54b86264f910f069484bae02
parent: bafc196c4b07261923d4f197659a26d0919cdeae
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Mon Feb 19 20:38:06 EST 2024
zuke: add "composer" tag support (column hidden by default)
--- a/sys/man/1/zuke
+++ b/sys/man/1/zuke
@@ -53,7 +53,7 @@
.TF "c"
.TP
.B A
-Artist
+Artist (displays composer if no artist has been set)
.TP
.B a
Album
@@ -60,6 +60,9 @@
.TP
.B b
File basename
+.TP
+.B C
+Composer
.TP
.B t
Title
--- a/sys/src/cmd/audio/zuke/mkplist.c
+++ b/sys/src/cmd/audio/zuke/mkplist.c
@@ -104,6 +104,10 @@
if(aux->album == nil)
aux->album = strdup(v);
break;
+ case Tcomposer:
+ if(aux->composer == nil)
+ aux->composer = strdup(v);
+ break;
case Ttitle:
if(aux->title == nil)
aux->title = strdup(v);
@@ -331,6 +335,11 @@
return x;
}
}
+ if(i == 0 && a->composer != nil || b->composer != nil){
+ if(a->composer == nil && a->composer != nil) return -1;
+ if(a->composer != nil && a->composer == nil) return 1;
+ if((x = cistrcmp(a->composer, b->composer)) != 0) return x;
+ }
if(a->date != nil || b->date != nil){
if(a->date == nil && b->date != nil) return -1;
@@ -428,8 +437,8 @@
recvul(cexit);
for(i = 0; i < ntracks; i++){
- if(tracks[i]->numartist < 1)
- fprint(2, "no artists: %s\n", tracks[i]->path);
+ if(tracks[i]->numartist < 1 && tracks[i]->composer == nil)
+ fprint(2, "no artists/composer: %s\n", tracks[i]->path);
if(tracks[i]->title == nil)
fprint(2, "no title: %s\n", tracks[i]->path);
printmeta(&out, tracks[i]);
--- a/sys/src/cmd/audio/zuke/plist.c
+++ b/sys/src/cmd/audio/zuke/plist.c
@@ -15,6 +15,8 @@
Bprint(b, "%c %s\n", Palbum, m->album);
if(m->title != nil)
Bprint(b, "%c %s\n", Ptitle, m->title);
+ if(m->composer != nil)
+ Bprint(b, "%c %s\n", Pcomposer, m->composer);
if(m->date != nil)
Bprint(b, "%c %s\n", Pdate, m->date);
if(m->track != nil)
--- a/sys/src/cmd/audio/zuke/plist.h
+++ b/sys/src/cmd/audio/zuke/plist.h
@@ -14,6 +14,7 @@
Palbum= 'a',
Partist= 'A',
Pbasename= 'b',
+ Pcomposer= 'C',
Pdate= 'd',
Pduration= 'D',
Pfilefmt= 'f',
@@ -37,6 +38,7 @@
{
char *artist[Maxartist];
char *album;
+ char *composer;
char *title;
char *date;
char *track;
--- a/sys/src/cmd/audio/zuke/zuke.c
+++ b/sys/src/cmd/audio/zuke/zuke.c
@@ -238,6 +238,7 @@
switch(c){
case Palbum: s = m->album; break;
case Partist: s = m->artist[0]; break;
+ case Pcomposer: s = m->composer; break;
case Pdate: s = m->date; break;
case Ptitle: s = (!colspath && (m->title == nil || *m->title == 0)) ? m->basename : m->title; break;
case Ptrack: snprint(tmp, sizeof(tmp), "%4s", m->track); s = m->track ? tmp : nil; break;
@@ -975,6 +976,8 @@
if(m->path != nil){
if(m->filefmt == nil)
m->filefmt = "";
+ if(m->numartist == 0 && m->composer != nil)
+ m->artist[m->numartist++] = m->composer;
pl->n++;
m++;
}
@@ -994,13 +997,14 @@
if(m->numartist < Maxartist)
m->artist[m->numartist++] = s;
break;
- case Pfilefmt: m->filefmt = s; break;
- case Palbum: m->album = s; break;
- case Pdate: m->date = s; break;
- case Ptitle: m->title = s; break;
- case Ptrack: m->track = s; break;
- case Prgtrack: m->rgtrack = atof(s); break;
- case Prgalbum: m->rgalbum = atof(s); break;
+ case Pcomposer: m->composer = s; break;
+ case Pfilefmt: m->filefmt = s; break;
+ case Palbum: m->album = s; break;
+ case Pdate: m->date = s; break;
+ case Ptitle: m->title = s; break;
+ case Ptrack: m->track = s; break;
+ case Prgtrack: m->rgtrack = atof(s); break;
+ case Prgalbum: m->rgalbum = atof(s); break;
case Ppath:
m->path = s;
m->basename = (b = utfrrune(s, '/')) == nil ? s : b+1;