From 1192cba42ed9704dac73ef82d80b6d26e86839c1 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Sun, 18 Sep 2022 02:21:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E7=94=A8url=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../DownloadManager/SimpleLiveRecordManager.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager.cs index 6b065db..8a6e4ea 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleLiveRecordManager.cs @@ -214,7 +214,7 @@ namespace N_m3u8DL_RE.DownloadManager var seg = segments.First(); segments = segments.Skip(1); //记录最新url - dic[name] = seg.Url; + dic[name] = GetPath(seg.Url); //获取文件名 var filename = hls ? seg.Index.ToString(pad) : OtherUtil.GetFileNameFromInput(seg.Url, false); var index = seg.Index; @@ -286,7 +286,7 @@ namespace N_m3u8DL_RE.DownloadManager //记录最新url if (segments.Any()) - dic[name] = segments.Last().Url; + dic[name] = GetPath(segments.Last().Url); recodingDurDic[task.Id] += (int)segments.Sum(s => s.Duration); @@ -513,13 +513,18 @@ namespace N_m3u8DL_RE.DownloadManager { if (string.IsNullOrEmpty(lastUrl)) return; - var index = streamSpec.Playlist!.MediaParts[0].MediaSegments.FindIndex(s => s.Url == lastUrl); + var index = streamSpec.Playlist!.MediaParts[0].MediaSegments.FindIndex(s => GetPath(s.Url) == lastUrl); if (index > -1) { streamSpec.Playlist!.MediaParts[0].MediaSegments = streamSpec.Playlist!.MediaParts[0].MediaSegments.Skip(index + 1).ToList(); } } + private string GetPath(string url) + { + return new Uri(url).GetLeftPart(UriPartial.Path); + } + public async Task StartRecordAsync() { var takeLastCount = 15;