mkplist: add -s option to enable "simple" sort (thanks qwx)
This commit is contained in:
parent
a84f3ef581
commit
18521fc8c6
2 changed files with 32 additions and 8 deletions
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue