diff --git a/NEWS b/NEWS index 085779e..a4656d1 100644 --- a/NEWS +++ b/NEWS @@ -12,6 +12,8 @@ Changes in 0.5.6, released on 2009-08-31: and operation will continue until 100 subsequent errors. Based on an idea from dhorton. (Ticket #1585) + - [NEW] New command line option -s: Make ezstream function as a line- + based shuffling utility. * src/playlist.c: - [MISC] Consider no output from a playlist program to be equivalent to an empty line, indicating that the end of the playlist is reached. diff --git a/doc/ezstream.1.in.in b/doc/ezstream.1.in.in index b7b5f57..3e57418 100644 --- a/doc/ezstream.1.in.in +++ b/doc/ezstream.1.in.in @@ -27,6 +27,11 @@ .Op Fl hnqVv .Fl c Ar configfile .Ek +.Nm +.Bk -words +.Fl s +.Op Ar playlist +.Ek .Sh DESCRIPTION The .Nm @@ -44,7 +49,6 @@ reading from standard input, and can be used from the command line. .It Fl c Ar configfile Use the XML configuration in .Ar configfile . -.Pq Mandatory. .It Fl h Print a summary of available command line parameters with short descriptions and exit. @@ -53,6 +57,18 @@ Normalize metadata strings by removing excess whitespaces. .It Fl q Be more quiet. Suppress the output that external programs send to standard error. +.It Fl s Op Ar playlist +Run +.Nm +as a line-based shuffling utility. +If no +.Ar playlist +argument is given, a list of media file names is read from standard input +instead of an input file. +After successfully reading the entire list, it is shuffled and printed to +standard output, and +.Nm +will exit. .It Fl V Print the .Nm diff --git a/src/ezstream.c b/src/ezstream.c index 34938c3..fa9387b 100644 --- a/src/ezstream.c +++ b/src/ezstream.c @@ -51,6 +51,7 @@ char *__progname; int nFlag; int qFlag; +int sFlag; int vFlag; int metadataFromProgram; @@ -1073,6 +1074,7 @@ void usage(void) { printf("usage: %s [-hnqVv] -c configfile\n", __progname); + printf(" %s -s [playlist]\n", __progname); } void @@ -1083,6 +1085,8 @@ usageHelp(void) printf(" -h display this additional help and exit\n"); printf(" -n normalize metadata strings\n"); printf(" -q suppress STDERR output from external en-/decoders\n"); + printf(" -s [playlist] read lines from playlist (or STDIN), shuffle and print them to\n"); + printf(" STDOUT, then exit\n"); printf(" -V print the version number and exit\n"); printf(" -v verbose output (use twice for more effect)\n"); printf("\n"); @@ -1120,7 +1124,7 @@ main(int argc, char *argv[]) qFlag = 0; vFlag = 0; - while ((c = local_getopt(argc, argv, "c:hnqVv")) != -1) { + while ((c = local_getopt(argc, argv, "c:hnqsVv")) != -1) { switch (c) { case 'c': if (configFile != NULL) { @@ -1140,6 +1144,9 @@ main(int argc, char *argv[]) case 'q': qFlag = 1; break; + case 's': + sFlag = 1; + break; case 'V': printf("%s\n", PACKAGE_STRING); return (ez_shutdown(0)); @@ -1156,6 +1163,35 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + if (sFlag) { + playlist_t *pl; + const char *entry; + + switch (argc) { + case 0: + pl = playlist_read(NULL); + if (pl == NULL) + return (ez_shutdown(1)); + break; + case 1: + pl = playlist_read(argv[0]); + if (pl == NULL) + return (ez_shutdown(1)); + break; + default: + printf("Error: Too many arguments.\n"); + return (ez_shutdown(2)); + } + + playlist_shuffle(pl); + while ((entry = playlist_get_next(pl)) != NULL) + printf("%s\n", entry); + + playlist_free(&pl); + + return (ez_shutdown(0)); + } + if (configFile == NULL) { printf("You must supply a config file with the -c argument.\n"); usage();