diff --git a/src/N_m3u8DL-RE.Common/Entity/WebVttSub.cs b/src/N_m3u8DL-RE.Common/Entity/WebVttSub.cs index 9bcbfe9..3bff876 100644 --- a/src/N_m3u8DL-RE.Common/Entity/WebVttSub.cs +++ b/src/N_m3u8DL-RE.Common/Entity/WebVttSub.cs @@ -15,6 +15,8 @@ namespace N_m3u8DL_RE.Common.Entity private static partial Regex TSValueRegex(); [GeneratedRegex("\\s")] private static partial Regex SplitRegex(); + [GeneratedRegex("([\\s\\S]*?)<\\/c>")] + private static partial Regex VttClassRegex(); public List Cues { get; set; } = new List(); public long MpegtsTimestamp { get; set; } = 0L; @@ -88,7 +90,7 @@ namespace N_m3u8DL_RE.Common.Entity { StartTime = startTime, EndTime = endTime, - Payload = string.Join("", payload.Where(c => c != 8203)), //Remove Zero Width Space! + Payload = RemoveClassTag(string.Join("", payload.Where(c => c != 8203))), //Remove Zero Width Space! Settings = style }); payloads.Clear(); @@ -120,6 +122,15 @@ namespace N_m3u8DL_RE.Common.Entity return webSub; } + private static string RemoveClassTag(string text) + { + if (VttClassRegex().IsMatch(text)) + { + return VttClassRegex().Match(text).Groups[1].Value; + } + else return text; + } + /// /// 从另一个字幕中获取所有Cue,并加载此字幕中,且自动修正偏移 ///