diff --git a/src/N_m3u8DL-RE.Common/Enum/RoleType.cs b/src/N_m3u8DL-RE.Common/Enum/RoleType.cs index 4dbd1cf..6e92b4a 100644 --- a/src/N_m3u8DL-RE.Common/Enum/RoleType.cs +++ b/src/N_m3u8DL-RE.Common/Enum/RoleType.cs @@ -11,4 +11,5 @@ public enum RoleType Description = 6, Sign = 7, Metadata = 8, + ForcedSubtitle = 9 } \ No newline at end of file diff --git a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs index 2501867..df8f2d4 100644 --- a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs +++ b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs @@ -178,8 +178,8 @@ internal partial class DASHExtractor2 : IExtractor var role = representation.Elements().FirstOrDefault(e => e.Name.LocalName == "Role") ?? adaptationSet.Elements().FirstOrDefault(e => e.Name.LocalName == "Role"); if (role != null) { - var v = role.Attribute("value")?.Value; - if (Enum.TryParse(v, true, out RoleType roleType)) + var roleValue = role.Attribute("value")?.Value; + if (Enum.TryParse(roleValue, true, out RoleType roleType)) { streamSpec.Role = roleType; @@ -190,6 +190,21 @@ internal partial class DASHExtractor2 : IExtractor streamSpec.Extension = "ttml"; } } + else if (roleValue != null && roleValue.Contains('-')) + { + roleValue = roleValue.Replace("-", ""); + if (Enum.TryParse(roleValue, true, out RoleType roleType_)) + { + streamSpec.Role = roleType_; + + if (roleType_ == RoleType.ForcedSubtitle) + { + streamSpec.MediaType = MediaType.SUBTITLES; // or maybe MediaType.CLOSED_CAPTIONS? + if (mType != null && mType.Contains("ttml")) + streamSpec.Extension = "ttml"; + } + } + } } streamSpec.Playlist.IsLive = isLive; // 设置刷新间隔 timeShiftBufferDepth / 2