From a023935c7c972245afe1f53389146180b07cddd9 Mon Sep 17 00:00:00 2001 From: croire <1432593898@qq.com> Date: Tue, 8 Mar 2022 12:30:49 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=B8=80=E4=BA=9B=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DownKyi.Core/Settings/Models/AppSettings.cs | 2 +- .../Services/Download/AddToDownloadService.cs | 82 ++++++++++--------- DownKyi/ViewModels/ViewChannelViewModel.cs | 2 +- .../ViewMyBangumiFollowViewModel.cs | 2 +- .../ViewModels/ViewMyFavoritesViewModel.cs | 2 +- DownKyi/ViewModels/ViewMyHistoryViewModel.cs | 2 +- .../ViewModels/ViewMyToViewVideoViewModel.cs | 2 +- .../ViewPublicFavoritesViewModel.cs | 2 +- .../ViewModels/ViewPublicationViewModel.cs | 2 +- 9 files changed, 50 insertions(+), 48 deletions(-) diff --git a/DownKyi.Core/Settings/Models/AppSettings.cs b/DownKyi.Core/Settings/Models/AppSettings.cs index 6285a91..197dbe4 100644 --- a/DownKyi.Core/Settings/Models/AppSettings.cs +++ b/DownKyi.Core/Settings/Models/AppSettings.cs @@ -7,6 +7,6 @@ public VideoSettings Video { get; set; } = new VideoSettings(); public DanmakuSettings Danmaku { get; set; } = new DanmakuSettings(); public AboutSettings About { get; set; } = new AboutSettings(); - public UserInfoSettings UserInfo { get; set; } + public UserInfoSettings UserInfo { get; set; } = new UserInfoSettings(); } } diff --git a/DownKyi/Services/Download/AddToDownloadService.cs b/DownKyi/Services/Download/AddToDownloadService.cs index f4b4ad3..13a3d4c 100644 --- a/DownKyi/Services/Download/AddToDownloadService.cs +++ b/DownKyi/Services/Download/AddToDownloadService.cs @@ -207,6 +207,8 @@ namespace DownKyi.Services.Download // 添加到下载 foreach (VideoSection section in videoSections) { + if (section.VideoPages == null) { continue; } + foreach (VideoPage page in section.VideoPages) { // 只下载选中项,跳过未选中项 @@ -338,49 +340,49 @@ namespace DownKyi.Services.Download break; } - // 如果不存在,直接添加到下载列表 - DownloadBase downloadBase = new DownloadBase - { - Bvid = page.Bvid, - Avid = page.Avid, - Cid = page.Cid, - EpisodeId = page.EpisodeId, - CoverUrl = videoInfoView.CoverUrl, - PageCoverUrl = page.FirstFrame, - ZoneId = zoneId, - FilePath = filePath, - - Order = page.Order, - MainTitle = videoInfoView.Title, - Name = page.Name, - Duration = page.Duration, - VideoCodecName = page.VideoQuality.SelectedVideoCodec, - Resolution = new Quality { Name = page.VideoQuality.QualityFormat, Id = page.VideoQuality.Quality }, - AudioCodec = Constant.GetAudioQualities().FirstOrDefault(t => { return t.Name == page.AudioQualityFormat; }), - }; - Downloading downloading = new Downloading - { - PlayStreamType = playStreamType, - DownloadStatus = DownloadStatus.NOT_STARTED, - }; - - // 需要下载的内容 - downloadBase.NeedDownloadContent["downloadAudio"] = downloadAudio; - downloadBase.NeedDownloadContent["downloadVideo"] = downloadVideo; - downloadBase.NeedDownloadContent["downloadDanmaku"] = downloadDanmaku; - downloadBase.NeedDownloadContent["downloadSubtitle"] = downloadSubtitle; - downloadBase.NeedDownloadContent["downloadCover"] = downloadCover; - - DownloadingItem downloadingItem = new DownloadingItem - { - DownloadBase = downloadBase, - Downloading = downloading, - PlayUrl = page.PlayUrl, - }; - // 添加到下载列表 App.PropertyChangeAsync(new Action(() => { + // 如果不存在,直接添加到下载列表 + DownloadBase downloadBase = new DownloadBase + { + Bvid = page.Bvid, + Avid = page.Avid, + Cid = page.Cid, + EpisodeId = page.EpisodeId, + CoverUrl = videoInfoView.CoverUrl, + PageCoverUrl = page.FirstFrame, + ZoneId = zoneId, + FilePath = filePath, + + Order = page.Order, + MainTitle = videoInfoView.Title, + Name = page.Name, + Duration = page.Duration, + VideoCodecName = page.VideoQuality.SelectedVideoCodec, + Resolution = new Quality { Name = page.VideoQuality.QualityFormat, Id = page.VideoQuality.Quality }, + AudioCodec = Constant.GetAudioQualities().FirstOrDefault(t => { return t.Name == page.AudioQualityFormat; }), + }; + Downloading downloading = new Downloading + { + PlayStreamType = playStreamType, + DownloadStatus = DownloadStatus.NOT_STARTED, + }; + + // 需要下载的内容 + downloadBase.NeedDownloadContent["downloadAudio"] = downloadAudio; + downloadBase.NeedDownloadContent["downloadVideo"] = downloadVideo; + downloadBase.NeedDownloadContent["downloadDanmaku"] = downloadDanmaku; + downloadBase.NeedDownloadContent["downloadSubtitle"] = downloadSubtitle; + downloadBase.NeedDownloadContent["downloadCover"] = downloadCover; + + DownloadingItem downloadingItem = new DownloadingItem + { + DownloadBase = downloadBase, + Downloading = downloading, + PlayUrl = page.PlayUrl, + }; + App.DownloadingList.Add(downloadingItem); Thread.Sleep(10); })); diff --git a/DownKyi/ViewModels/ViewChannelViewModel.cs b/DownKyi/ViewModels/ViewChannelViewModel.cs index 4d5de5a..2bd5ec2 100644 --- a/DownKyi/ViewModels/ViewChannelViewModel.cs +++ b/DownKyi/ViewModels/ViewChannelViewModel.cs @@ -276,7 +276,7 @@ namespace DownKyi.ViewModels } // 通知用户添加到下载列表的结果 - if (i == 0) + if (i <= 0) { eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } diff --git a/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs b/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs index e082410..caa760e 100644 --- a/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs +++ b/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs @@ -329,7 +329,7 @@ namespace DownKyi.ViewModels } // 通知用户添加到下载列表的结果 - if (i == 0) + if (i <= 0) { eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } diff --git a/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs b/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs index ce93ace..7e8e7bf 100644 --- a/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs +++ b/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs @@ -358,7 +358,7 @@ namespace DownKyi.ViewModels } // 通知用户添加到下载列表的结果 - if (i == 0) + if (i <= 0) { eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } diff --git a/DownKyi/ViewModels/ViewMyHistoryViewModel.cs b/DownKyi/ViewModels/ViewMyHistoryViewModel.cs index 71dbe07..cafc2e3 100644 --- a/DownKyi/ViewModels/ViewMyHistoryViewModel.cs +++ b/DownKyi/ViewModels/ViewMyHistoryViewModel.cs @@ -272,7 +272,7 @@ namespace DownKyi.ViewModels } // 通知用户添加到下载列表的结果 - if (i == 0) + if (i <= 0) { eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } diff --git a/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs b/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs index 6c8a13d..d55ab01 100644 --- a/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs +++ b/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs @@ -258,7 +258,7 @@ namespace DownKyi.ViewModels } // 通知用户添加到下载列表的结果 - if (i == 0) + if (i <= 0) { eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } diff --git a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs index d5ca22f..2500437 100644 --- a/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs @@ -279,7 +279,7 @@ namespace DownKyi.ViewModels } // 通知用户添加到下载列表的结果 - if (i == 0) + if (i <= 0) { eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); } diff --git a/DownKyi/ViewModels/ViewPublicationViewModel.cs b/DownKyi/ViewModels/ViewPublicationViewModel.cs index 854004c..32047d7 100644 --- a/DownKyi/ViewModels/ViewPublicationViewModel.cs +++ b/DownKyi/ViewModels/ViewPublicationViewModel.cs @@ -313,7 +313,7 @@ namespace DownKyi.ViewModels } // 通知用户添加到下载列表的结果 - if (i == 0) + if (i <= 0) { eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); }