diff options
author | Stefano Gottardo <gottardo.stefano.83@gmail.com> | 2024-07-22 18:36:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-22 18:36:33 +0200 |
commit | 3e8215d6414df5e5d3b375e717bb830ec8edf658 (patch) | |
tree | e1e6459ecf368a05f5aa625bb31709e93b60d1a3 | |
parent | bac5652f5f3a28392a1fd05416ce7029c6a2c6b9 (diff) | |
parent | 28ad55736c4e410df7dd998a41adf2f03965917b (diff) |
Merge pull request #25455 from CastagnaIT/ass_detect_omega
[backport][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); } |