shithub: zuke

Download patch

ref: 242c59a09d4de8026aa6a865651f92c03c5e441c
parent: c2eaf5845f78e87c37c85447e4a0afc6443957fd
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Thu Dec 19 19:43:32 EST 2019

support more cover image naming variants

--- a/zuke.c
+++ b/zuke.c
@@ -60,6 +60,7 @@
 static int entering;
 static int colwidth[3];
 static int mincolwidth[3];
+static char *covers[] = {"folder", "cover", "Cover", "scans/CD", "Scans/Front", "Covers/Front"};
 
 #pragma varargck type "P" int
 static int
@@ -236,7 +237,7 @@
 static void
 coverload(void *player_)
 {
-	int p[2], pid, fd;
+	int p[2], pid, fd, i;
 	char *prog, *path, *s, tmp[32];
 	Meta *m;
 	Channel *ch;
@@ -263,14 +264,15 @@
 		if(path != nil && (s = utfrrune(path, '/')) != nil){
 			*s = 0;
 
-			if((s = smprint("%s/cover.jpg", path)) != nil && (fd = open(s, OREAD)) >= 0)
-				prog = "jpg";
-			free(s);
-			s = nil;
-
-			if(fd < 0 && (s = smprint("%s/cover.png", path)) != nil && (fd = open(s, OREAD)) >= 0)
-				prog = "png";
-			free(s);
+			for(i = 0; i < nelem(covers) && prog == nil; i++){
+				if((s = smprint("%s/%s.jpg", path, covers[i])) != nil && (fd = open(s, OREAD)) >= 0)
+					prog = "jpg";
+				free(s);
+				s = nil;
+				if(fd < 0 && (s = smprint("%s/%s.png", path, covers[i])) != nil && (fd = open(s, OREAD)) >= 0)
+					prog = "png";
+				free(s);
+			}
 		}
 		free(path);
 	}