summaryrefslogtreecommitdiffstats
path: root/sub/sd_ass.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-02-16 02:03:36 +0100
committerwm4 <wm4@nowhere>2020-02-16 02:07:24 +0100
commita4eb8f75c0644ce5cf7c0bcea6b3efd2a886027d (patch)
treefa028721887a4bc984a20c946c4ee95295677b7a /sub/sd_ass.c
parent0b35b4c91796fb020e13d955efd450021eb5eedb (diff)
downloadmpv-a4eb8f75c0644ce5cf7c0bcea6b3efd2a886027d.tar.bz2
mpv-a4eb8f75c0644ce5cf7c0bcea6b3efd2a886027d.tar.xz
sub: add an option to filter subtitles by regex
Works as ad-filter. I had some more plans, for example replacing matching text with different text, but for now it's dropping matches only. There's a big warning in the manpage that I might change semantics. For example, I might turn it into a primitive sed. In a sane world, you'd probably write a simple script that processes downloaded subtitles before giving them to mpv, and avoid all this complexity. But we don't live in a sane world, and the sooner you learn this, the happier you will be. (But I also want to run this on muxed subtitles.) This is pretty straightforward. We use POSIX regexes, which are readily available without additional pain or dependencies. This also means it's (apparently) not available on win32 (MinGW). The regex list is because I hate big monolithic regexes, and this makes it slightly better. Very superficially tested.
Diffstat (limited to 'sub/sd_ass.c')
-rw-r--r--sub/sd_ass.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/sub/sd_ass.c b/sub/sd_ass.c
index 2b0cf13127..40e5093d8e 100644
--- a/sub/sd_ass.c
+++ b/sub/sd_ass.c
@@ -65,6 +65,9 @@ static void fill_plaintext(struct sd *sd, double pts);
static const struct sd_filter_functions *const filters[] = {
// Note: list order defines filter order.
&sd_filter_sdh,
+#if HAVE_POSIX
+ &sd_filter_regex,
+#endif
NULL,
};