diff --git a/DownKyi.Core/BiliApi/Zone/VideoZone.cs b/DownKyi.Core/BiliApi/Zone/VideoZone.cs index 9474086..038a120 100644 --- a/DownKyi.Core/BiliApi/Zone/VideoZone.cs +++ b/DownKyi.Core/BiliApi/Zone/VideoZone.cs @@ -20,7 +20,7 @@ namespace DownKyi.Core.BiliApi.Zone return that; } - public List GetZone() + public List GetZones() { return zones; } diff --git a/DownKyi.Core/Utils/Format.cs b/DownKyi.Core/Utils/Format.cs index 49ad0e7..c3a611c 100644 --- a/DownKyi.Core/Utils/Format.cs +++ b/DownKyi.Core/Utils/Format.cs @@ -122,15 +122,15 @@ namespace DownKyi.Core.Utils } else if (speed < 1024) { - formatSpeed = speed.ToString("#.##") + "B/s"; + formatSpeed = string.Format("{0:F2}", speed) + "B/s"; } else if (speed < 1024 * 1024) { - formatSpeed = (speed / 1024).ToString("#.##") + "KB/s"; + formatSpeed = string.Format("{0:F2}", speed / 1024) + "KB/s"; } else { - formatSpeed = (speed / 1024 / 1024).ToString("#.##") + "MB/s"; + formatSpeed = string.Format("{0:F2}", speed / 1024 / 1024) + "MB/s"; } return formatSpeed; } diff --git a/DownKyi/Models/DownloadingItem.cs b/DownKyi/Models/DownloadingItem.cs index 94a15d9..acde187 100644 --- a/DownKyi/Models/DownloadingItem.cs +++ b/DownKyi/Models/DownloadingItem.cs @@ -1,5 +1,4 @@ -using DownKyi.Core.Aria2cNet.Client; -using DownKyi.Core.BiliApi.VideoStream.Models; +using DownKyi.Core.BiliApi.VideoStream.Models; using DownKyi.Images; using DownKyi.Utils; using Prism.Commands; diff --git a/DownKyi/Services/Download/AriaDownloadService.cs b/DownKyi/Services/Download/AriaDownloadService.cs index f2d9e4e..abcf28a 100644 --- a/DownKyi/Services/Download/AriaDownloadService.cs +++ b/DownKyi/Services/Download/AriaDownloadService.cs @@ -153,6 +153,10 @@ namespace DownKyi.Services.Download // 更新状态显示 downloading.DownloadStatusTitle = DictionaryResource.GetString("WhileDownloading"); downloading.DownloadContent = DictionaryResource.GetString("DownloadingCover"); + // 下载大小 + downloading.DownloadingFileSize = string.Empty; + // 下载速度 + downloading.SpeedDisplay = string.Empty; // 查询、保存封面 StorageCover storageCover = new StorageCover(); @@ -198,6 +202,10 @@ namespace DownKyi.Services.Download // 更新状态显示 downloading.DownloadStatusTitle = DictionaryResource.GetString("WhileDownloading"); downloading.DownloadContent = DictionaryResource.GetString("DownloadingDanmaku"); + // 下载大小 + downloading.DownloadingFileSize = string.Empty; + // 下载速度 + downloading.SpeedDisplay = string.Empty; string title = $"{downloading.Name}"; string assFile = $"{downloading.FilePath}.ass"; @@ -217,7 +225,7 @@ namespace DownKyi.Services.Download //} // 字幕配置 - var subtitleConfig = new Config + Config subtitleConfig = new Config { Title = title, ScreenWidth = screenWidth, @@ -250,6 +258,10 @@ namespace DownKyi.Services.Download // 更新状态显示 downloading.DownloadStatusTitle = DictionaryResource.GetString("WhileDownloading"); downloading.DownloadContent = DictionaryResource.GetString("DownloadingSubtitle"); + // 下载大小 + downloading.DownloadingFileSize = string.Empty; + // 下载速度 + downloading.SpeedDisplay = string.Empty; List srtFiles = new List(); @@ -293,6 +305,10 @@ namespace DownKyi.Services.Download // 更新状态显示 downloading.DownloadStatusTitle = DictionaryResource.GetString("MixedFlow"); downloading.DownloadContent = DictionaryResource.GetString("DownloadingVideo"); + // 下载大小 + downloading.DownloadingFileSize = string.Empty; + // 下载速度 + downloading.SpeedDisplay = string.Empty; string finalFile = $"{downloading.FilePath}.mp4"; if (videoUid == null) @@ -326,6 +342,10 @@ namespace DownKyi.Services.Download // 更新状态显示 downloading.DownloadStatusTitle = DictionaryResource.GetString("Parsing"); downloading.DownloadContent = string.Empty; + // 下载大小 + downloading.DownloadingFileSize = string.Empty; + // 下载速度 + downloading.SpeedDisplay = string.Empty; if (downloading.PlayUrl != null && downloading.DownloadStatus == DownloadStatus.NOT_STARTED) { @@ -654,6 +674,9 @@ namespace DownKyi.Services.Download /// private DownloadResult DownloadByAria(DownloadingItem downloading, List urls, string path, string localFileName) { + // path已斜杠结尾,去掉斜杠 + path = path.TrimEnd('/').TrimEnd('\\'); + AriaSendOption option = new AriaSendOption { //HttpProxy = $"http://{Settings.GetAriaHttpProxy()}:{Settings.GetAriaHttpProxyListenPort()}", @@ -691,6 +714,8 @@ namespace DownKyi.Services.Download { case DownloadStatus.PAUSE: Task ariaPause = AriaClient.PauseAsync(downloading.Gid); + // 通知UI,并阻塞当前线程 + Pause(downloading); break; case DownloadStatus.DOWNLOADING: Task ariaUnpause = AriaClient.UnpauseAsync(downloading.Gid); @@ -712,8 +737,7 @@ namespace DownKyi.Services.Download } // 根据进度判断本次是否需要更新UI - // TODO 小于多少需要测试 - if (percent - video.Progress < 0.01) { return; } + if (Math.Abs(percent - video.Progress) < 0.01) { return; } // 下载进度 video.Progress = percent; @@ -729,7 +753,6 @@ namespace DownKyi.Services.Download { video.MaxSpeed = speed; } - } private void AriaDownloadFinish(bool isSuccess, string downloadPath, string gid, string msg) diff --git a/DownKyi/Services/VideoInfoService.cs b/DownKyi/Services/VideoInfoService.cs index 2cf5f81..a807aaa 100644 --- a/DownKyi/Services/VideoInfoService.cs +++ b/DownKyi/Services/VideoInfoService.cs @@ -162,7 +162,7 @@ namespace DownKyi.Services // 分区 string videoZone = string.Empty; - var zoneList = Core.BiliApi.Zone.VideoZone.Instance().GetZone(); + var zoneList = Core.BiliApi.Zone.VideoZone.Instance().GetZones(); var zone = zoneList.Find(it => it.Id == videoView.Tid); if (zone != null) { diff --git a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs index dfb6892..271b7ae 100644 --- a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs +++ b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs @@ -585,11 +585,31 @@ namespace DownKyi.ViewModels } } + // 视频分区 + int zoneId = -1; + List zoneList = VideoZone.Instance().GetZones(); + ZoneAttr zone = zoneList.Find(it => it.Id == VideoInfoView.TypeId); + if (zone != null) + { + ZoneAttr zoneParent = zoneList.Find(it => it.Id == zone.ParentId); + if (zoneParent != null) + { + zoneId = zoneParent.Id; + } + } + + // 如果只有一个视频章节,则不在命名中出现 + string sectionName = string.Empty; + if (VideoSections.Count > 1) + { + sectionName = section.Title; + } + // 文件路径 List fileNameParts = SettingsManager.GetInstance().GetFileNameParts(); FileName fileName = FileName.Builder(fileNameParts) .SetOrder(page.Order) - .SetSection(Format.FormatFileName(section.Title)) + .SetSection(Format.FormatFileName(sectionName)) .SetMainTitle(Format.FormatFileName(VideoInfoView.Title)) .SetPageTitle(Format.FormatFileName(page.Name)) .SetVideoZone(VideoInfoView.VideoZone.Split('>')[0]) @@ -644,7 +664,7 @@ namespace DownKyi.ViewModels EpisodeId = page.EpisodeId, CoverUrl = page.FirstFrame, - ZoneImage = (DrawingImage)Application.Current.Resources[VideoZoneIcon.Instance().GetZoneImageKey(VideoInfoView.TypeId)], + ZoneImage = (DrawingImage)Application.Current.Resources[VideoZoneIcon.Instance().GetZoneImageKey(zoneId)], Order = page.Order, MainTitle = VideoInfoView.Title, diff --git a/DownKyi/Views/DownloadManager/ViewDownloading.xaml b/DownKyi/Views/DownloadManager/ViewDownloading.xaml index b13f441..b766407 100644 --- a/DownKyi/Views/DownloadManager/ViewDownloading.xaml +++ b/DownKyi/Views/DownloadManager/ViewDownloading.xaml @@ -15,7 +15,7 @@ - +