Don't give confusing errors about WEBVTT when there are errors in a Subrip file ...
authorCarl Hetherington <cth@carlh.net>
Tue, 6 Feb 2024 10:33:12 +0000 (11:33 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 7 Feb 2024 00:04:51 +0000 (01:04 +0100)
cscript
src/lib/string_text_file.cc

diff --git a/cscript b/cscript
index 4131617412ed016f03b1cf5ccedb27b8d2c0d68e..6c43e05b635ad028180e1f28964f10f550ba30ba 100644 (file)
--- a/cscript
+++ b/cscript
@@ -508,7 +508,7 @@ def dependencies(target, options):
         deps = []
 
     deps.append(('libdcp', 'v1.8.94'))
-    deps.append(('libsub', 'v1.6.46'))
+    deps.append(('libsub', 'v1.6.47'))
     deps.append(('leqm-nrt', '30dcaea1373ac62fba050e02ce5b0c1085797a23'))
     deps.append(('rtaudio', 'f619b76'))
     # We get our OpenSSL libraries from the environment, but we
index 348ccd1d5e7fe95c90b0687963acb576ce6d29bc..9b43b35a6fe8fda9ba38e290c068944b5ec6649d 100644 (file)
@@ -25,6 +25,7 @@
 #include "string_text_file_content.h"
 #include <dcp/file.h>
 #include <sub/collect.h>
+#include <sub/exceptions.h>
 #include <sub/ssa_reader.h>
 #include <sub/stl_binary_reader.h>
 #include <sub/subrip_reader.h>
@@ -105,9 +106,14 @@ StringTextFile::StringTextFile (shared_ptr<const StringTextFileContent> content)
                if (ext == ".srt") {
                        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()));
+                       } 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()));