改用url path

This commit is contained in:
nilaoda 2022-09-18 02:21:09 +08:00
parent a15412b9e4
commit 1192cba42e
1 changed files with 8 additions and 3 deletions

View File

@ -214,7 +214,7 @@ namespace N_m3u8DL_RE.DownloadManager
var seg = segments.First(); var seg = segments.First();
segments = segments.Skip(1); segments = segments.Skip(1);
//记录最新url //记录最新url
dic[name] = seg.Url; dic[name] = GetPath(seg.Url);
//获取文件名 //获取文件名
var filename = hls ? seg.Index.ToString(pad) : OtherUtil.GetFileNameFromInput(seg.Url, false); var filename = hls ? seg.Index.ToString(pad) : OtherUtil.GetFileNameFromInput(seg.Url, false);
var index = seg.Index; var index = seg.Index;
@ -286,7 +286,7 @@ namespace N_m3u8DL_RE.DownloadManager
//记录最新url //记录最新url
if (segments.Any()) if (segments.Any())
dic[name] = segments.Last().Url; dic[name] = GetPath(segments.Last().Url);
recodingDurDic[task.Id] += (int)segments.Sum(s => s.Duration); recodingDurDic[task.Id] += (int)segments.Sum(s => s.Duration);
@ -513,13 +513,18 @@ namespace N_m3u8DL_RE.DownloadManager
{ {
if (string.IsNullOrEmpty(lastUrl)) return; 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) if (index > -1)
{ {
streamSpec.Playlist!.MediaParts[0].MediaSegments = streamSpec.Playlist!.MediaParts[0].MediaSegments.Skip(index + 1).ToList(); 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<bool> StartRecordAsync() public async Task<bool> StartRecordAsync()
{ {
var takeLastCount = 15; var takeLastCount = 15;