shithub: zuke

Download patch

ref: 2b330da8ae103be1970421a4a97a5c263fc09177
parent: 238db3819fb5fecd884a487cb62abbf4fd22ba32
author: Sigrid Solveig Haflínudóttir <[email protected]>
date: Tue Dec 22 11:16:37 EST 2020

add -G argument to dump the playlist in a new format

--- a/README.md
+++ b/README.md
@@ -12,6 +12,12 @@
  * good metadata support
  * basic livestreams (ie IceCast) support
 
+## 2020/12/22
+
+New playlist format. Zuke still will load old format and you can convert to the new one like so:
+
+	audio/zuke -G <old.plist >new.plist
+
 ## Installing
 
 Install [libtags](https://git.sr.ht/~ft/libtags) first.
--- a/mkplist.c
+++ b/mkplist.c
@@ -222,29 +222,6 @@
 	return 0;
 }
 
-static void
-printmeta(Meta *m)
-{
-	int i;
-
-	Bprint(&out, "%c %s\n%c %s\n", Ppath, m->path, Pfilefmt, m->filefmt);
-	for(i = 0; i < m->numartist; i++)
-		Bprint(&out, "%c %s\n", Partist, m->artist[i]);
-	if(m->album != nil)
-		Bprint(&out, "%c %s\n", Palbum, m->album);
-	if(m->title != nil)
-		Bprint(&out, "%c %s\n", Ptitle, m->title);
-	if(m->date != nil)
-		Bprint(&out, "%c %s\n", Pdate, m->date);
-	if(m->track != nil)
-		Bprint(&out, "%c %s\n", Ptrack, m->track);
-	if(m->duration > 0)
-		Bprint(&out, "%c %llud\n", Pduration, m->duration);
-	if(m->imagesize > 0)
-		Bprint(&out, "%c %d %d %d %s\n", Pimage, m->imageoffset, m->imagesize, m->imagereader, m->imagefmt);
-	Bprint(&out, "\n");
-}
-
 static int
 cmpmeta(void *a_, void *b_)
 {
@@ -320,7 +297,7 @@
 			fprint(2, "no artists: %s\n", all[i].path);
 		if(all[i].title == nil)
 			fprint(2, "no title: %s\n", all[i].path);
-		printmeta(all+i);
+		printmeta(&out, all+i);
 	}
 	Bterm(&out);
 	fprint(2, "found %d tagged tracks\n", numall);
--- a/plist.h
+++ b/plist.h
@@ -46,3 +46,26 @@
 	int imagesize;
 	int imagereader; /* non-zero if a special reader required */
 };
+
+static void
+printmeta(Biobuf *b, Meta *m)
+{
+	int i;
+
+	Bprint(b, "%c %s\n%c %s\n", Ppath, m->path, Pfilefmt, m->filefmt);
+	for(i = 0; i < m->numartist; i++)
+		Bprint(b, "%c %s\n", Partist, m->artist[i]);
+	if(m->album != nil)
+		Bprint(b, "%c %s\n", Palbum, m->album);
+	if(m->title != nil)
+		Bprint(b, "%c %s\n", Ptitle, m->title);
+	if(m->date != nil)
+		Bprint(b, "%c %s\n", Pdate, m->date);
+	if(m->track != nil)
+		Bprint(b, "%c %s\n", Ptrack, m->track);
+	if(m->duration > 0)
+		Bprint(b, "%c %llud\n", Pduration, m->duration);
+	if(m->imagesize > 0)
+		Bprint(b, "%c %d %d %d %s\n", Pimage, m->imageoffset, m->imagesize, m->imagereader, m->imagefmt);
+	Bprint(b, "\n");
+}
--- a/zuke.c
+++ b/zuke.c
@@ -64,6 +64,7 @@
 static double seekoff; /* ms */
 static QLock audiolock;
 static int audioerr = 0;
+static Biobuf out;
 static char *covers[] = {"art", "folder", "cover", "Cover", "scans/CD", "Scans/Front", "Covers/Front"};
 
 static int Scrollwidth;
@@ -674,6 +675,15 @@
 }
 
 static void
+writeplist(void)
+{
+	int i;
+
+	for(i = 0; i < plnum; i++)
+		printmeta(&out, pl+i);
+}
+
+static void
 readplistnew(void)
 {
 	char *s, *e, *a[5];
@@ -979,7 +989,7 @@
 static void
 usage(void)
 {
-	fprint(2, "usage: %s [-s] [-c aAdDtTp]\n", argv0);
+	fprint(2, "usage: %s [-s] [-G] [-c aAdDtTp]\n", argv0);
 	sysfatal("usage");
 }
 
@@ -995,9 +1005,10 @@
 		{ nil, &key, CHANRCV },
 		{ nil, nil, CHANEND },
 	};
-	int n, scrolling, oldpcur, oldbuttons, pnew, shuffled, themetid;
+	int n, scrolling, oldpcur, oldbuttons, pnew, shuffled, themetid, nogui;
 
 	shuffled = 0;
+	nogui = 0;
 	ARGBEGIN{
 	case 'd':
 		debug++;
@@ -1010,6 +1021,9 @@
 		if(strlen(cols) >= nelem(colwidth))
 			sysfatal("max %d columns allowed", nelem(colwidth));
 		break;
+	case 'G':
+		nogui = 1;
+		break;
 	default:
 		usage();
 		break;
@@ -1019,6 +1033,13 @@
 	if(plnum < 1){
 		fprint(2, "empty playlist\n");
 		sysfatal("empty");
+	}
+
+	if(nogui){
+		Binit(&out, 1, OWRITE);
+		writeplist();
+		Bterm(&out);
+		threadexitsall(nil);
 	}
 
 	if(initdraw(nil, nil, "zuke") < 0)