summaryrefslogtreecommitdiffstats
path: root/common/tags.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-29 22:51:18 +0100
committerwm4 <wm4@nowhere>2014-12-29 22:51:18 +0100
commit8048374a5c1eb3af80aa057dcfd20deed39447c8 (patch)
tree311150ab89f3362a1203da1fd39d47b9dcd58d36 /common/tags.c
parent6618e5d69ab2f1eef70769e46f4129d13bd7ff29 (diff)
downloadmpv-8048374a5c1eb3af80aa057dcfd20deed39447c8.tar.bz2
mpv-8048374a5c1eb3af80aa057dcfd20deed39447c8.tar.xz
player: filter tags, add --display-tags option
This attempts to increase user-friendliness by excluding useless tags. It should be especially helpful with mp4 files, because the FFmpeg mp4 demuxer adds tons of completely useless information to the metadata. Fixes #1403.
Diffstat (limited to 'common/tags.c')
-rw-r--r--common/tags.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/common/tags.c b/common/tags.c
index bc9d98ea2f..c38d002243 100644
--- a/common/tags.c
+++ b/common/tags.c
@@ -74,6 +74,25 @@ struct mp_tags *mp_tags_dup(void *tparent, struct mp_tags *tags)
return new;
}
+// Return a copy of the tags, but containing only keys in list. Also forces
+// the order and casing of the keys (for cosmetic reasons).
+// The special key "all" matches all keys.
+struct mp_tags *mp_tags_filtered(void *tparent, struct mp_tags *tags, char **list)
+{
+ struct mp_tags *new = talloc_zero(tparent, struct mp_tags);
+ for (int n = 0; list && list[n]; n++) {
+ char *key = list[n];
+ if (strcasecmp(key, "all") == 0) {
+ talloc_free(new);
+ return mp_tags_dup(tparent, tags);
+ }
+ char *value = mp_tags_get_str(tags, key);
+ if (value)
+ mp_tags_set_str(new, key, value);
+ }
+ return new;
+}
+
void mp_tags_merge(struct mp_tags *tags, struct mp_tags *src)
{
for (int n = 0; n < src->num_keys; n++)