From 711bbb02a4b5a1f693eb6cc5ffc2ca2fb1c1bc4b Mon Sep 17 00:00:00 2001 From: nilaoda Date: Thu, 1 Jun 2023 22:52:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=A4=9APeriod=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Extractor/DASHExtractor2.cs | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs index 7e0cd2b..4f54059 100644 --- a/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs +++ b/src/N_m3u8DL-RE.Parser/Extractor/DASHExtractor2.cs @@ -456,17 +456,26 @@ namespace N_m3u8DL_RE.Parser.Extractor } else { - //点播,这种情况作为新的part出现 - var startIndex = streamList[_index].Playlist!.MediaParts.Last().MediaSegments.Last().Index + 1; - var enumerator = streamSpec.Playlist.MediaParts[0].MediaSegments.GetEnumerator(); - while (enumerator.MoveNext()) + //点播,这种情况如果URL不同则作为新的part出现,否则仅把时间加起来 + var url1 = streamList[_index].Playlist!.MediaParts.Last().MediaSegments.Last().Url; + var url2 = streamSpec.Playlist.MediaParts[0].MediaSegments.LastOrDefault()?.Url; + if (url1 != url2) { - enumerator.Current.Index += startIndex; + var startIndex = streamList[_index].Playlist!.MediaParts.Last().MediaSegments.Last().Index + 1; + var enumerator = streamSpec.Playlist.MediaParts[0].MediaSegments.GetEnumerator(); + while (enumerator.MoveNext()) + { + enumerator.Current.Index += startIndex; + } + streamList[_index].Playlist!.MediaParts.Add(new MediaPart() + { + MediaSegments = streamSpec.Playlist.MediaParts[0].MediaSegments + }); } - streamList[_index].Playlist!.MediaParts.Add(new MediaPart() + else { - MediaSegments = streamSpec.Playlist.MediaParts[0].MediaSegments - }); + streamList[_index].Playlist!.MediaParts.Last().MediaSegments.Last().Duration += streamSpec.Playlist.MediaParts[0].MediaSegments.Sum(x => x.Duration); + } } } else