mkplist: add -s option to enable "simple" sort (thanks qwx)

This commit is contained in:
Sigrid Solveig Haflínudóttir 2021-10-28 15:20:13 +00:00
parent a84f3ef581
commit 18521fc8c6
2 changed files with 32 additions and 8 deletions

View file

@ -3,6 +3,9 @@
mkplist, zuke \- graphical music player
.SH SYNOPSIS
.B audio/mkplist
[
.B -s
]
.I directory/file/URL [...]
.br
.B audio/zuke
@ -16,11 +19,15 @@ mkplist, zuke \- graphical music player
.PP
.I Zuke
is a graphical music player that reads a playlist from standard input
and presents an interface to play music. Playlists are generated
by
and presents an interface to play music.
.PP
Playlists are generated by
.IR mkplist ,
which accepts files, directories, and URLs as its arguments,
and writes the resulting playlist to standard output.
and writes the resulting playlist to standard output. Option
.B -s
enables "simple" sorting of the entries of the playlist, where only
full paths are compared.
.PP
Formats supported by
.I zuke

View file

@ -19,6 +19,7 @@ static Meta *all;
static int numall;
static int firstiscomposer;
static int keepfirstartist;
static int simplesort;
static char *fmts[] =
{
@ -281,6 +282,9 @@ cmpmeta(void *a_, void *b_)
a = a_;
b = b_;
if(simplesort)
return cistrcmp(a->path, b->path);
ae = utfrrune(a->path, '/');
be = utfrrune(b->path, '/');
if(ae != nil && be != nil && (x = cistrncmp(a->path, b->path, MAX(ae-a->path, be-b->path))) != 0) /* different path */
@ -313,21 +317,34 @@ cmpmeta(void *a_, void *b_)
return cistrcmp(a->path, b->path);
}
static void
usage(void)
{
fprint(2, "usage: %s [-s] directory/file/URL [...] > noise.plist\n", argv0);
exits("usage");
}
void
main(int argc, char **argv)
{
char *dir, wd[4096];
int i;
if(argc < 2){
fprint(2, "usage: mkplist DIR [DIR2 ...] > noise.plist\n");
exits("usage");
}
ARGBEGIN{
case 's':
simplesort = 1;
break;
default:
usage();
}ARGEND
if(argc < 1)
usage();
getwd(wd, sizeof(wd));
Binit(&out, 1, OWRITE);
for(i = 1; i < argc; i++){
for(i = 0; i < argc; i++){
if(strncmp(argv[i], "http://", 7) == 0 || strncmp(argv[i], "https://", 8) == 0){
if((curr = newmeta()) == nil)
sysfatal("no memory");