diff options
author | CastagnaIT <gottardo.stefano.83@gmail.com> | 2024-07-08 07:49:45 +0200 |
---|---|---|
committer | CastagnaIT <gottardo.stefano.83@gmail.com> | 2024-07-08 16:50:34 +0200 |
commit | 28ad55736c4e410df7dd998a41adf2f03965917b (patch) | |
tree | 129d9e420c2da1b20cef0810ec1d12ccfcf1a093 | |
parent | 6186114acf4354697317b64d4a75f72eebf353dc (diff) |
[DVDFactorySubtitle] Improved ASS format detection
-rw-r--r-- | xbmc/cores/VideoPlayer/DVDSubtitles/DVDFactorySubtitle.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDFactorySubtitle.cpp b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDFactorySubtitle.cpp index 51270337c6..6f922cd02f 100644 --- a/xbmc/cores/VideoPlayer/DVDSubtitles/DVDFactorySubtitle.cpp +++ b/xbmc/cores/VideoPlayer/DVDSubtitles/DVDFactorySubtitle.cpp @@ -20,6 +20,12 @@ #include <cstring> #include <memory> +#include <regex> + +namespace +{ +constexpr const char* ASS_SCRIPT_TYPE_RE = "^ScriptType:\\s*v4\\.00\\+?"; +} CDVDSubtitleParser* CDVDFactorySubtitle::CreateParser(std::string& strFile) { @@ -32,6 +38,8 @@ CDVDSubtitleParser* CDVDFactorySubtitle::CreateParser(std::string& strFile) return nullptr; } + const std::regex reAssScriptType{ASS_SCRIPT_TYPE_RE}; + for (int t = 0; t < 256; t++) { if (pStream->ReadLine(line)) @@ -55,10 +63,9 @@ CDVDSubtitleParser* CDVDFactorySubtitle::CreateParser(std::string& strFile) return new CDVDSubtitleParserVplayer(std::move(pStream), strFile); } else if (!StringUtils::CompareNoCase(line, "!: This is a Sub Station Alpha v", 32) || - !StringUtils::CompareNoCase(line, "ScriptType: v4.00", 17) || - !StringUtils::CompareNoCase(line, "Dialogue: Marked", 16) || - !StringUtils::CompareNoCase(line, "Dialogue: ", 10) || - !StringUtils::CompareNoCase(line, "[Events]", 8)) + std::regex_match(line, reAssScriptType) || + !StringUtils::CompareNoCase(line, "[Events]", 8) || + !StringUtils::CompareNoCase(line, "Dialogue:", 9)) { return new CDVDSubtitleParserSSA(std::move(pStream), strFile); } |