aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basic_curses.c10
-rw-r--r--regex.c28
2 files changed, 36 insertions, 2 deletions
diff --git a/basic_curses.c b/basic_curses.c
index ce6a338..51bef2b 100644
--- a/basic_curses.c
+++ b/basic_curses.c
@@ -27,10 +27,14 @@ void printfc(char* fstrc, int max_length, ...) {
}else
attrset( COLOR_PAIR(fstrc[i+1]-'0') | A_NORMAL);
}else{
+#ifdef DEBUG
fprintf(stderr,"%c isn't a color, skipping", fstrc[i+1]);
+#endif
}
}else{
+#ifdef DEBUG
fprintf(stderr,"end of line by '$', expect a color after '$'");
+#endif
return;
}
i+=2;
@@ -41,7 +45,9 @@ void printfc(char* fstrc, int max_length, ...) {
char format[10] = "%";
while(j < 9 && !strchr("diouxXeEfFgGaAcsp%", format[j] = fstrc[i+j]) );
if( j == 9 ) {
+#ifdef DEBUG
fprintf(stderr,"format too long %s...",format);
+#endif
return;
}
if( strchr("di", format[j] ) ) {
@@ -104,10 +110,14 @@ void printc(char* fstrc, int max_length) {
}else
attrset( COLOR_PAIR(fstrc[i+1]-'0') | A_NORMAL);
}else{
+#ifdef DEBUG
fprintf(stderr,"%c isn't a color, skipping", fstrc[i+1]);
+#endif
}
}else{
+#ifdef DEBUG
fprintf(stderr,"end of line by '$', expect a color after '$'");
+#endif
return;
}
i+=2;
diff --git a/regex.c b/regex.c
index b7f19aa..0b01347 100644
--- a/regex.c
+++ b/regex.c
@@ -101,11 +101,19 @@ void regexSelection(menuC* menu, const char* msg) {
}
}
}
+/*
+ * Example regex :
+ *
+ * ^([a-Z0-9 ]+) - ([^\[]+)\[([0-9]+)\]/atn
+ * (Daft Punk) - Something about us[11].mp3
+
+ */
void regexXtract(itemC* it, const char* msg) {
- char* tmp = strrchr( msg , '/' );
- if( !msg || !*msg || !tmp) {
+ if( !msg || !*msg) {
return;
}
+ char* tmp = strrchr( msg , '/' );
+ if( !tmp ) return;
char *regexS = malloc(tmp-msg+1);
@@ -118,9 +126,13 @@ void regexXtract(itemC* it, const char* msg) {
int nbR = strlen(tmp);
tab = malloc( sizeof *tab * (nbR+1));
if( match_regex(regexS, line, tab, nbR ) ) {
+#ifdef DEBUG
fprintf(stderr, "Hello");
+#endif
for(int i = 0 ; i < nbR ; i++) {
+#ifdef DEBUG
fprintf(stderr, "<<%s>>\n", tab[i]);
+#endif
switch(tmp[i]) {
case 't':
taglib_tag_set_title(it->info.tag, tab[i]);
@@ -132,8 +144,20 @@ void regexXtract(itemC* it, const char* msg) {
taglib_tag_set_album(it->info.tag, tab[i]);
break;
case 'y':
+ {
+ unsigned int t = 0;
+ int r = sscanf(tab[i], "%u", &t);
+ if( r == 1)
+ taglib_tag_set_year(it->info.tag, t);
break;
+ }
case 'n':
+ {
+ unsigned int t = 0;
+ int r = sscanf(tab[i], "%u", &t);
+ if( r == 1)
+ taglib_tag_set_track(it->info.tag, t);
+ }
break;
case 'g':
taglib_tag_set_genre(it->info.tag, tab[i]);