From: Antoine Jacquet Date: Mon, 12 Mar 2007 23:00:00 +0000 (+0100) Subject: version 0.38 (by Jonny Bijlsma) X-Git-Tag: v0.38 X-Git-Url: http://royale.zerezo.com/git/?p=FAPG;a=commitdiff_plain;h=389b0b695d6dd0e98f3ad67a47d6f6e48ed1b62e;hp=57a557c838aebd9b7fbd1344f6fcb86b7d5da7fd version 0.38 (by Jonny Bijlsma) * added .txx output (to work with iRiver T-series) --- diff --git a/CHANGELOG b/CHANGELOG index 315463f..333e53c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,8 @@ Change log file for FAPG +version 0.38 (2007-03-13) (by Jonny Bijlsma) + * added .txx output (to work with iRiver T-series) + version 0.37 (2007-03-07) * added a --stdin option to act as a filter (read filenames and directories from input) * trim spaces in artist/title when guessing from filename diff --git a/README b/README index f180f76..621983d 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -FAPG 0.37 (Fast Audio Playlist Generator) +FAPG 0.38 (Fast Audio Playlist Generator) site: http://royale.zerezo.com/fapg/ mail: royale@zerezo.com @@ -7,7 +7,7 @@ make make install usage: -fapg [-b|--backslash] [-d|--debug] [-f|--format=m3u|pls|html|rss|pla] [-g|--genre=#:#:...] [-o|--output=/path/to/file.m3u] [-p|--prefix=/the/prefix] [-r|--recursive] [-w|--windows] [-x|--exclude=#:#:...] [-c|--command=] [-s|--stdin] /path/to/mp3/dir1 [/path/to/mp3/dir2 ...] +fapg [-b|--backslash] [-d|--debug] [-f|--format=m3u|pls|html|rss|pla|txx] [-g|--genre=#:#:...] [-o|--output=/path/to/file.m3u] [-p|--prefix=/the/prefix] [-r|--recursive] [-w|--windows] [-x|--exclude=#:#:...] [-c|--command=] [-s|--stdin] /path/to/mp3/dir1 [/path/to/mp3/dir2 ...] - backslash : replace the '/' with '\' in Unix path. - debug : display useful messages if the program fails ;) - format : choose which format of playlist you want to generate (default is m3u). diff --git a/fapg.1 b/fapg.1 index 955eb52..c025865 100644 --- a/fapg.1 +++ b/fapg.1 @@ -32,7 +32,7 @@ formats. Replace the '/' with '\' in Unix path. .IP -d|--debug Display useful messages if the program fails ;) -.IP -f|--format=m3u|pls|html|rss|pla +.IP -f|--format=m3u|pls|html|rss|pla|txx Choose which format of playlist you want to generate (default is m3u). .IP -g|--genre=#:#:... Choose which genres (numerical values only) will be included in the generated playlist (default is all). diff --git a/fapg.c b/fapg.c index ea50917..a72d4e7 100644 --- a/fapg.c +++ b/fapg.c @@ -38,7 +38,7 @@ #include #include "genres.h" -#define VERSION "0.37" +#define VERSION "0.38" #define MP3_BASE 1024 #define OGG_BASE 1024*10 #define MAX 1024*200 /* 200ko for ID3 with JPEG images in it */ @@ -218,7 +218,7 @@ unsigned char *iso2web[256] = { void usage() { fprintf(stderr, - "Usage >> fapg [-b|--backslash] [-d|--debug] [-f|--format=m3u|pls|html|rss|pla] [-g|--genre=#:#:...] [-n|--nohardlink] [-o|--output=/path/to/file.m3u] [-p|--prefix=/the/prefix] [-r|--recursive] [-w|--windows] [-c|--command=] [-x|--exclude=#:#:...] [-s|--stdin] /path/to/mp3/dir1 [/path/to/mp3/dir2 ...]\n"); + "Usage >> fapg [-b|--backslash] [-d|--debug] [-f|--format=m3u|pls|html|rss|pla|txx] [-g|--genre=#:#:...] [-n|--nohardlink] [-o|--output=/path/to/file.m3u] [-p|--prefix=/the/prefix] [-r|--recursive] [-w|--windows] [-c|--command=] [-x|--exclude=#:#:...] [-s|--stdin] /path/to/mp3/dir1 [/path/to/mp3/dir2 ...]\n"); exit(1); } @@ -267,6 +267,122 @@ void myputstr(const char *c) } } +void txxputheader(const char *c) +{ + int cnt = 0; + + while(*c != 0) { + myputchar(*c); + cnt++; + c++; + } + + while(cnt < 512) { + putchar('\0'); + cnt++; + } +} + +void txxputnameoffset(const char *c) +{ + int pos = 0; + int cnt = 0; + char b; + unsigned char *prefx; + + prefx = prefix; + + if(*prefx != 0) { + while(*prefx != 0) { + if(*prefx == '/') { + pos = cnt; + } + cnt++; + prefx++; + } + + cnt--; // skip the leading dot of the filepath + } + + while(*c != 0) { + if(*c == '/') { + pos = cnt; + } + cnt++; + c++; + } + + pos += 2; + + b = (pos & 0xFF00) >> 8; + putchar(b); + b = (pos & 0x00FF); + putchar(b); +} + +void txxputstr(const char *c) +{ + int cnt = 0; + int pos; + unsigned char *prefx; + + txxputnameoffset(c); + + prefx = prefix; + fprintf(stderr, "prefix: '%s'\n", prefx); + + if(*prefx != 0) { + while(*prefx != 0) { + myputchar('\0'); + cnt++; + + if(*prefx == '/') + putchar(separator); + else + myputchar(*prefx); + cnt++; + + prefx++; + } + + c++; // skip the leading dot + } + + while(*c != 0) { + myputchar('\0'); + cnt++; + + if(*c == '/') + putchar(separator); + else + myputchar(*c); + cnt++; + + c++; + } + + while(cnt < 510) { + myputchar('\0'); + cnt++; + } +} + +void txxputcounter(int c) +{ + int b; + + rewind(stdout); + + b = (c & 0xFF000000) >> 24; + putchar(b); + b = (c & 0x00FF0000) >> 16; + putchar(b); + b = (c & 0x0000FF00) >> 8; + putchar(b); + b = (c & 0x000000FF); + putchar(b); +} + /* remove spaces at beginning and end of string */ void trim(char *c) { @@ -423,6 +539,8 @@ void parse_options(int argc, char **argv) format = 3; else if(strcmp(optarg, "pla") == 0) format = 4; + else if(strcmp(optarg, "txx") == 0) + format = 5; else usage(); break; @@ -1076,6 +1194,9 @@ void parse_file(unsigned char *newpath) myplaputstr(newpath); myplaputstr(eol); break; + case 5: //t-series playlist + txxputstr(newpath); + break; } } } @@ -1177,6 +1298,11 @@ int main(int argc, char **argv) eol = "\r\n"; myplaputstr("PLP PLAYLIST\r\nVERSION 1.20\r\n\r\n"); } + break; + case 5: + { + txxputheader(" iriver UMS PLA"); + } } if(fromstdin) { unsigned char path[PATH_MAX]; @@ -1204,6 +1330,9 @@ int main(int argc, char **argv) case 3: printf(" %s%s", eol, eol); break; + case 5: + txxputcounter(counter); + break; } if(genrelist) free(genrelist);