Cope with WEBVTT files named with .srt extensions.
authorCarl Hetherington <cth@carlh.net>
Thu, 27 Apr 2023 22:13:20 +0000 (00:13 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 27 Apr 2023 22:13:20 +0000 (00:13 +0200)
src/lib/string_text_file.cc

index 869a2c96a832cf1044caff7e19463b674230aaa6..348ccd1d5e7fe95c90b0687963acb576ce6d29bc 100644 (file)
@@ -103,7 +103,12 @@ StringTextFile::StringTextFile (shared_ptr<const StringTextFileContent> content)
                ucnv_close (to_utf8);
 
                if (ext == ".srt") {
-                       reader.reset(new sub::SubripReader(utf8.get()));
+                       try {
+                               reader.reset(new sub::SubripReader(utf8.get()));
+                       } catch (...) {
+                               /* Sometimes files are have the .srt extension but are really WEBVTT */
+                               reader.reset(new sub::WebVTTReader(utf8.get()));
+                       }
                } else if (ext == ".ssa" || ext == ".ass") {
                        reader.reset(new sub::SSAReader(utf8.get()));
                } else if (ext == ".vtt") {