diff options
author | Andreas Mair <amair.sob@googlemail.com> | 2015-10-21 08:30:33 +0200 |
---|---|---|
committer | Andreas Mair <amair.sob@googlemail.com> | 2015-10-21 08:30:33 +0200 |
commit | bea5973e0cffe983584484ad29f900044b003093 (patch) | |
tree | 281309f886d32c5f4566e226b69657c34388b55c | |
parent | 0366dcf604b067f1a0e5379f2125589fd19be269 (diff) | |
download | mpd-bea5973e0cffe983584484ad29f900044b003093.tar.gz mpd-bea5973e0cffe983584484ad29f900044b003093.tar.xz mpd-bea5973e0cffe983584484ad29f900044b003093.zip |
Filter out this extra data and leading zeroes in "track" and "disc" tags.
-rw-r--r-- | src/tag/TagHandler.cxx | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/tag/TagHandler.cxx b/src/tag/TagHandler.cxx index 9bbaae36a..bbd30877a 100644 --- a/src/tag/TagHandler.cxx +++ b/src/tag/TagHandler.cxx @@ -22,6 +22,9 @@ #include "TagBuilder.hxx" #include "util/ASCII.hxx" +#include <stdio.h> +#include <stdlib.h> + static void add_tag_duration(SongTime duration, void *ctx) { @@ -35,7 +38,17 @@ add_tag_tag(TagType type, const char *value, void *ctx) { TagBuilder &tag = *(TagBuilder *)ctx; - tag.AddItem(type, value); + if (type == TAG_TRACK || type == TAG_DISC) { + /* filter out this extra data and leading zeroes */ + char *end; + unsigned n = strtoul(value, &end, 10); + if (value != end) { + char s[21]; + if (snprintf(s, 21, "%u", n) >= 0) + tag.AddItem(type, s); + } + } else + tag.AddItem(type, value); } const struct tag_handler add_tag_handler = { |