Johannes Weißl
2011-04-04 14:57:18 UTC
---
Doc/cmus.txt | 5 +++--
expr.c | 12 +++++++++---
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/Doc/cmus.txt b/Doc/cmus.txt
index 83a0b78..119b40d 100644
--- a/Doc/cmus.txt
+++ b/Doc/cmus.txt
@@ -1086,7 +1086,7 @@ built-in filters. Also (and)-grouping is done implicitly.
@h2 Strings
@li long
-*filename*, *artist*, *album*, *title*, *genre*, *comment*
+*filename*, *artist*, *album*, *title*, *genre*, *comment*, *codec*
@br
Comparators: *=* and *!=* (not equal)
@@ -1098,7 +1098,8 @@ Comparators: none
@h2 Integers
@li long
-*discnumber*, *tracknumber*, *date* (year), *duration* (seconds)
+*discnumber*, *tracknumber*, *date* (year), *duration* (seconds),
+*bitrate*
@br
Comparators: *<*, *<=*, *=*, *>=*, *>*, *!=*
diff --git a/expr.c b/expr.c
index 6b52954..b184693 100644
--- a/expr.c
+++ b/expr.c
@@ -409,6 +409,8 @@ static const struct {
} builtin[] = {
{ "album", EXPR_STR },
{ "artist", EXPR_STR },
+ { "bitrate", EXPR_INT },
+ { "codec", EXPR_STR },
{ "comment", EXPR_STR },
{ "date", EXPR_INT },
{ "discnumber", EXPR_INT },
@@ -849,12 +851,14 @@ int expr_eval(struct expr *expr, struct track_info *ti)
val = ti->filename;
if (!using_utf8 && utf8_encode(val, charset, &uval) == 0)
val = uval;
+ } else if (strcmp(key, "codec") == 0) {
+ val = ti->codec;
} else {
val = keyvals_get_val(ti->comments, key);
- /* non-existing string tag equals to "" */
- if (!val)
- val = "";
}
+ /* non-existing string tag equals to "" */
+ if (!val)
+ val = "";
res = glob_match(&expr->estr.glob_head, val);
free(uval);
if (expr->estr.op == SOP_EQ)
@@ -870,6 +874,8 @@ int expr_eval(struct expr *expr, struct track_info *ti)
val = INT_MAX;
} else if (strcmp(key, "date") == 0) {
val = comments_get_date(ti->comments, key) / 10000;
+ } else if (strcmp(key, "bitrate") == 0) {
+ val = (ti->bitrate >= 0) ? (int) (ti->bitrate / 1000. + 0.5) : -1;
} else {
val = comments_get_int(ti->comments, key);
}
Doc/cmus.txt | 5 +++--
expr.c | 12 +++++++++---
2 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/Doc/cmus.txt b/Doc/cmus.txt
index 83a0b78..119b40d 100644
--- a/Doc/cmus.txt
+++ b/Doc/cmus.txt
@@ -1086,7 +1086,7 @@ built-in filters. Also (and)-grouping is done implicitly.
@h2 Strings
@li long
-*filename*, *artist*, *album*, *title*, *genre*, *comment*
+*filename*, *artist*, *album*, *title*, *genre*, *comment*, *codec*
@br
Comparators: *=* and *!=* (not equal)
@@ -1098,7 +1098,8 @@ Comparators: none
@h2 Integers
@li long
-*discnumber*, *tracknumber*, *date* (year), *duration* (seconds)
+*discnumber*, *tracknumber*, *date* (year), *duration* (seconds),
+*bitrate*
@br
Comparators: *<*, *<=*, *=*, *>=*, *>*, *!=*
diff --git a/expr.c b/expr.c
index 6b52954..b184693 100644
--- a/expr.c
+++ b/expr.c
@@ -409,6 +409,8 @@ static const struct {
} builtin[] = {
{ "album", EXPR_STR },
{ "artist", EXPR_STR },
+ { "bitrate", EXPR_INT },
+ { "codec", EXPR_STR },
{ "comment", EXPR_STR },
{ "date", EXPR_INT },
{ "discnumber", EXPR_INT },
@@ -849,12 +851,14 @@ int expr_eval(struct expr *expr, struct track_info *ti)
val = ti->filename;
if (!using_utf8 && utf8_encode(val, charset, &uval) == 0)
val = uval;
+ } else if (strcmp(key, "codec") == 0) {
+ val = ti->codec;
} else {
val = keyvals_get_val(ti->comments, key);
- /* non-existing string tag equals to "" */
- if (!val)
- val = "";
}
+ /* non-existing string tag equals to "" */
+ if (!val)
+ val = "";
res = glob_match(&expr->estr.glob_head, val);
free(uval);
if (expr->estr.op == SOP_EQ)
@@ -870,6 +874,8 @@ int expr_eval(struct expr *expr, struct track_info *ti)
val = INT_MAX;
} else if (strcmp(key, "date") == 0) {
val = comments_get_date(ti->comments, key) / 10000;
+ } else if (strcmp(key, "bitrate") == 0) {
+ val = (ti->bitrate >= 0) ? (int) (ti->bitrate / 1000. + 0.5) : -1;
} else {
val = comments_get_int(ti->comments, key);
}
--
1.7.4.1
1.7.4.1