Cleanup: whitespace.
[dcpomatic.git] / src / lib / string_text_file.cc
index 76abe547f35045413e1a7b945f72a939d59ea72a..348ccd1d5e7fe95c90b0687963acb576ce6d29bc 100644 (file)
@@ -28,6 +28,7 @@
 #include <sub/ssa_reader.h>
 #include <sub/stl_binary_reader.h>
 #include <sub/subrip_reader.h>
+#include <sub/web_vtt_reader.h>
 #include <unicode/ucsdet.h>
 #include <unicode/ucnv.h>
 #include <iostream>
@@ -102,9 +103,16 @@ 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") {
+                       reader.reset(new sub::WebVTTReader(utf8.get()));
                }
        }