修复可能存在的Index异常问题

This commit is contained in:
nilaoda 2022-12-12 01:41:30 +08:00
parent 04de21e594
commit 85d1572392
1 changed files with 16 additions and 1 deletions

View File

@ -741,7 +741,22 @@ namespace N_m3u8DL_RE.DownloadManager
if (index > -1) if (index > -1)
{ {
streamSpec.Playlist!.MediaParts[0].MediaSegments = streamSpec.Playlist!.MediaParts[0].MediaSegments.Skip(index + 1).ToList(); //修正Index
var list = streamSpec.Playlist!.MediaParts[0].MediaSegments.Skip(index + 1).ToList();
if (list.Count > 0)
{
var newMin = list.Min(s => s.Index);
var oldMax = streamSpec.Playlist!.MediaParts[0].MediaSegments.Max(s => s.Index);
if (newMin < oldMax)
{
var offset = oldMax - newMin + 1;
foreach (var item in list)
{
item.Index += offset;
}
}
}
streamSpec.Playlist!.MediaParts[0].MediaSegments = list;
} }
} }