X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fstring_text_file.cc;h=9b43b35a6fe8fda9ba38e290c068944b5ec6649d;hb=HEAD;hp=76abe547f35045413e1a7b945f72a939d59ea72a;hpb=2f1986a814403d690aedcbe8b7057878ebae76b0;p=dcpomatic.git diff --git a/src/lib/string_text_file.cc b/src/lib/string_text_file.cc index 76abe547f..9b43b35a6 100644 --- a/src/lib/string_text_file.cc +++ b/src/lib/string_text_file.cc @@ -25,9 +25,11 @@ #include "string_text_file_content.h" #include #include +#include #include #include #include +#include #include #include #include @@ -102,9 +104,21 @@ StringTextFile::StringTextFile (shared_ptr content) ucnv_close (to_utf8); if (ext == ".srt") { - reader.reset(new sub::SubripReader(utf8.get())); + try { + reader.reset(new sub::SubripReader(utf8.get())); + } catch (sub::SubripError& subrip_error) { + /* Sometimes files are have the .srt extension but are really WEBVTT... */ + try { + reader.reset(new sub::WebVTTReader(utf8.get())); + } catch (sub::WebVTTHeaderError&) { + /* ...but in this case there isn't even a WebVTT error */ + throw subrip_error; + } + } } else if (ext == ".ssa" || ext == ".ass") { reader.reset(new sub::SSAReader(utf8.get())); + } else if (ext == ".vtt") { + reader.reset(new sub::WebVTTReader(utf8.get())); } }