From 3bb4c4cb0c9e9eb15aa4794b80b79788e73aa87f Mon Sep 17 00:00:00 2001 From: nilaoda Date: Thu, 1 Jun 2023 22:19:08 +0800 Subject: [PATCH] fix #179 --- .../Extractor/DASHExtractor2.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs index 31f1d71..7e0cd2b 100644 --- a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs +++ b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; @@ -151,7 +152,7 @@ namespace N_m3u8DL_RE.Parser.Extractor streamSpec.GroupId = representation.Attribute("id")?.Value; streamSpec.Bandwidth = Convert.ToInt32(bandwidth?.Value ?? "0"); streamSpec.Codecs = representation.Attribute("codecs")?.Value ?? adaptationSet.Attribute("codecs")?.Value; - streamSpec.Language = representation.Attribute("lang")?.Value ?? adaptationSet.Attribute("lang")?.Value; + streamSpec.Language = FilterLanguage(representation.Attribute("lang")?.Value ?? adaptationSet.Attribute("lang")?.Value); streamSpec.FrameRate = frameRate ?? GetFrameRate(representation); streamSpec.Resolution = representation.Attribute("width")?.Value != null ? $"{representation.Attribute("width")?.Value}x{representation.Attribute("height")?.Value}" : null; streamSpec.Url = MpdUrl; @@ -511,6 +512,18 @@ namespace N_m3u8DL_RE.Parser.Extractor return streamList; } + /// + /// 如果有非法字符 返回und + /// + /// + /// + private string? FilterLanguage(string? v) + { + if (v == null) return null; + if (Regex.IsMatch(v, "^[\\w_\\-\\d]+$")) return v; + return "und"; + } + public async Task RefreshPlayListAsync(List streamSpecs) { if (streamSpecs.Count == 0) return;