diff --git a/src/DownKyi.Core/DownKyi.Core.csproj b/src/DownKyi.Core/DownKyi.Core.csproj index cb85a1d..67ed5f0 100644 --- a/src/DownKyi.Core/DownKyi.Core.csproj +++ b/src/DownKyi.Core/DownKyi.Core.csproj @@ -308,6 +308,7 @@ + diff --git a/src/DownKyi.Core/FileName/FileName.cs b/src/DownKyi.Core/FileName/FileName.cs index 356a9e0..e16ce19 100644 --- a/src/DownKyi.Core/FileName/FileName.cs +++ b/src/DownKyi.Core/FileName/FileName.cs @@ -163,7 +163,7 @@ namespace DownKyi.Core.FileName path += videoPublishTime; break; case FileNamePart.AVID: - path += avid; + path += $"av{avid}"; break; case FileNamePart.BVID: path += bvid; diff --git a/src/DownKyi.Core/Settings/Models/BasicSettings.cs b/src/DownKyi.Core/Settings/Models/BasicSettings.cs index 43eea04..f04f7ee 100644 --- a/src/DownKyi.Core/Settings/Models/BasicSettings.cs +++ b/src/DownKyi.Core/Settings/Models/BasicSettings.cs @@ -11,5 +11,6 @@ public ParseScope ParseScope { get; set; } = ParseScope.NOT_SET; public AllowStatus IsAutoDownloadAll { get; set; } = AllowStatus.NONE; public DownloadFinishedSort DownloadFinishedSort { get; set; } = DownloadFinishedSort.NOT_SET; + public RepeatDownloadStrategy RepeatDownloadStrategy { get; set; } = RepeatDownloadStrategy.Ask; } } diff --git a/src/DownKyi.Core/Settings/RepeatDownloadStrategy.cs b/src/DownKyi.Core/Settings/RepeatDownloadStrategy.cs new file mode 100644 index 0000000..fdb2447 --- /dev/null +++ b/src/DownKyi.Core/Settings/RepeatDownloadStrategy.cs @@ -0,0 +1,9 @@ +namespace DownKyi.Core.Settings +{ + public enum RepeatDownloadStrategy + { + Ask, + ReDownload, + JumpOver + } +} \ No newline at end of file diff --git a/src/DownKyi.Core/Settings/SettingsManager.Basic.cs b/src/DownKyi.Core/Settings/SettingsManager.Basic.cs index ccf618f..3f84893 100644 --- a/src/DownKyi.Core/Settings/SettingsManager.Basic.cs +++ b/src/DownKyi.Core/Settings/SettingsManager.Basic.cs @@ -19,6 +19,9 @@ // 下载完成列表排序 private readonly DownloadFinishedSort finishedSort = DownloadFinishedSort.DOWNLOAD; + + // 重复下载策略 + private readonly RepeatDownloadStrategy _repeatDownloadStrategy = RepeatDownloadStrategy.Ask; /// /// 获取下载完成后的操作 @@ -182,5 +185,32 @@ return SetSettings(); } + /// + /// 获取重复下载策略 + /// + /// + public RepeatDownloadStrategy GetRepeatDownloadStrategy() + { + appSettings = GetSettings(); + if (appSettings.Basic.RepeatDownloadStrategy == RepeatDownloadStrategy.Ask) + { + // 第一次获取,先设置默认值 + SetRepeatDownloadStrategy(_repeatDownloadStrategy); + return _repeatDownloadStrategy; + } + + return appSettings.Basic.RepeatDownloadStrategy; + } + + /// + /// 设置重复下载策略 + /// + /// + /// + public bool SetRepeatDownloadStrategy(RepeatDownloadStrategy repeatDownloadStrategy) + { + appSettings.Basic.RepeatDownloadStrategy = repeatDownloadStrategy; + return SetSettings(); + } } } diff --git a/src/DownKyi/DownKyi.csproj b/src/DownKyi/DownKyi.csproj index a4b3f02..f88bef8 100644 --- a/src/DownKyi/DownKyi.csproj +++ b/src/DownKyi/DownKyi.csproj @@ -116,6 +116,7 @@ + diff --git a/src/DownKyi/Languages/Default.xaml b/src/DownKyi/Languages/Default.xaml index 566dfbb..8dba54b 100644 --- a/src/DownKyi/Languages/Default.xaml +++ b/src/DownKyi/Languages/Default.xaml @@ -195,6 +195,10 @@ 监听剪贴板 视频自动解析 视频解析范围: + 重复下载策略: + 每次询问 + 重新下载 + 跳过重复项 解析后自动下载已解析视频 网络 diff --git a/src/DownKyi/Models/RepeatDownloadStrategyDisplay.cs b/src/DownKyi/Models/RepeatDownloadStrategyDisplay.cs new file mode 100644 index 0000000..2ad85e9 --- /dev/null +++ b/src/DownKyi/Models/RepeatDownloadStrategyDisplay.cs @@ -0,0 +1,10 @@ +using DownKyi.Core.Settings; + +namespace DownKyi.Models +{ + public class RepeatDownloadStrategyDisplay + { + public string Name { get; set; } + public RepeatDownloadStrategy RepeatDownloadStrategy { get; set; } + } +} \ No newline at end of file diff --git a/src/DownKyi/Services/Download/AddToDownloadService.cs b/src/DownKyi/Services/Download/AddToDownloadService.cs index 8133af9..70affbe 100644 --- a/src/DownKyi/Services/Download/AddToDownloadService.cs +++ b/src/DownKyi/Services/Download/AddToDownloadService.cs @@ -279,21 +279,37 @@ namespace DownKyi.Services.Download { //eventAggregator.GetEvent().Publish($"{page.Name}{DictionaryResource.GetString("TipAlreadyToAddDownloaded")}"); //isDownloaded = true; - - AlertService alertService = new AlertService(dialogService); - ButtonResult result = alertService.ShowInfo(DictionaryResource.GetString("TipAlreadyToAddDownloaded2")); - if (result == ButtonResult.OK) + var repeatDownloadStrategy = SettingsManager.GetInstance().GetRepeatDownloadStrategy(); + switch (repeatDownloadStrategy) { - App.PropertyChangeAsync(() => + case RepeatDownloadStrategy.Ask: { - App.DownloadedList.Remove(item); - }); - - isDownloaded = false; - } - else - { - isDownloaded = true; + AlertService alertService = new AlertService(dialogService); + ButtonResult result = alertService.ShowInfo(DictionaryResource.GetString("TipAlreadyToAddDownloaded2")); + if (result == ButtonResult.OK) + { + App.PropertyChangeAsync(() => + { + App.DownloadedList.Remove(item); + }); + + isDownloaded = false; + } + else + { + isDownloaded = true; + } + break; + } + case RepeatDownloadStrategy.ReDownload: + isDownloaded = false; + break; + case RepeatDownloadStrategy.JumpOver: + isDownloaded = true; + break; + default: + isDownloaded = true; + break; } break; diff --git a/src/DownKyi/Services/VideoInfoService.cs b/src/DownKyi/Services/VideoInfoService.cs index ed9738b..2f9ce60 100644 --- a/src/DownKyi/Services/VideoInfoService.cs +++ b/src/DownKyi/Services/VideoInfoService.cs @@ -151,7 +151,7 @@ namespace DownKyi.Services Bvid = episode.Bvid, Cid = episode.Cid, EpisodeId = -1, - FirstFrame = episode.Page.FirstFrame, + FirstFrame = episode.Arc.Pic, Order = order, Name = episode.Title, Duration = "N/A" diff --git a/src/DownKyi/ViewModels/Settings/ViewBasicViewModel.cs b/src/DownKyi/ViewModels/Settings/ViewBasicViewModel.cs index 3f2ce2b..7610b20 100644 --- a/src/DownKyi/ViewModels/Settings/ViewBasicViewModel.cs +++ b/src/DownKyi/ViewModels/Settings/ViewBasicViewModel.cs @@ -73,6 +73,22 @@ namespace DownKyi.ViewModels.Settings get => autoDownloadAll; set => SetProperty(ref autoDownloadAll, value); } + + private List _repeatDownloadStrategy; + + public List RepeatDownloadStrategy + { + get => _repeatDownloadStrategy; + set => SetProperty(ref _repeatDownloadStrategy, value); + } + + private RepeatDownloadStrategyDisplay _selectedRepeatDownloadStrategy; + + public RepeatDownloadStrategyDisplay SelectedRepeatDownloadStrategy + { + get => _selectedRepeatDownloadStrategy; + set => SetProperty(ref _selectedRepeatDownloadStrategy, value); + } #endregion @@ -89,6 +105,14 @@ namespace DownKyi.ViewModels.Settings new ParseScopeDisplay{ Name = DictionaryResource.GetString("ParseCurrentSection"), ParseScope = ParseScope.CURRENT_SECTION }, new ParseScopeDisplay{ Name = DictionaryResource.GetString("ParseAll"), ParseScope = ParseScope.ALL } }; + + // 重复下载策略 + RepeatDownloadStrategy = new List + { + new RepeatDownloadStrategyDisplay { Name = DictionaryResource.GetString("RepeatDownloadAsk"), RepeatDownloadStrategy = Core.Settings.RepeatDownloadStrategy.Ask }, + new RepeatDownloadStrategyDisplay { Name = DictionaryResource.GetString("RepeatDownloadReDownload"), RepeatDownloadStrategy = Core.Settings.RepeatDownloadStrategy.ReDownload }, + new RepeatDownloadStrategyDisplay { Name = DictionaryResource.GetString("RepeatDownloadReJumpOver"), RepeatDownloadStrategy = Core.Settings.RepeatDownloadStrategy.JumpOver } + }; #endregion @@ -123,6 +147,10 @@ namespace DownKyi.ViewModels.Settings // 解析后是否自动下载解析视频 AllowStatus isAutoDownloadAll = SettingsManager.GetInstance().IsAutoDownloadAll(); AutoDownloadAll = isAutoDownloadAll == AllowStatus.YES; + + // 重复下载策略 + var repeatDownloadStrategy = SettingsManager.GetInstance().GetRepeatDownloadStrategy(); + SelectedRepeatDownloadStrategy = RepeatDownloadStrategy.FirstOrDefault(t => t.RepeatDownloadStrategy == repeatDownloadStrategy); isOnNavigatedTo = false; } @@ -218,6 +246,26 @@ namespace DownKyi.ViewModels.Settings bool isSucceed = SettingsManager.GetInstance().IsAutoDownloadAll(isAutoDownloadAll); PublishTip(isSucceed); } + + // 解析范围事件 + private DelegateCommand _repeatDownloadStrategyCommand; + + public DelegateCommand RepeatDownloadStrategyCommand => _repeatDownloadStrategyCommand ?? (_repeatDownloadStrategyCommand = new DelegateCommand(ExecuteRepeatDownloadStrategyCommand)); + + /// + /// 解析范围事件 + /// + /// + private void ExecuteRepeatDownloadStrategyCommand(object parameter) + { + if (!(parameter is RepeatDownloadStrategyDisplay repeatDownloadStrategy)) + { + return; + } + + var isSucceed = SettingsManager.GetInstance().SetRepeatDownloadStrategy(repeatDownloadStrategy.RepeatDownloadStrategy); + PublishTip(isSucceed); + } #endregion diff --git a/src/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs b/src/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs index eba6594..2d512f0 100644 --- a/src/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs +++ b/src/DownKyi/ViewModels/Settings/ViewNetworkViewModel.cs @@ -371,16 +371,19 @@ namespace DownKyi.ViewModels.Settings } // 设置UserAgent事件 - private DelegateCommand userAgentCommand; - public DelegateCommand UserAgentCommand => userAgentCommand ?? (userAgentCommand = new DelegateCommand(ExecuteUserAgentCommand)); + private DelegateCommand userAgentCommand; + public DelegateCommand UserAgentCommand => userAgentCommand ?? (userAgentCommand = new DelegateCommand(ExecuteUserAgentCommand)); /// /// 设置UserAgent事件 /// - private void ExecuteUserAgentCommand() + private void ExecuteUserAgentCommand(string ua) { - bool isSucceed = SettingsManager.GetInstance().SetUserAgent(UserAgent); - PublishTip(isSucceed); + if (ua != null) + { + bool isSucceed = SettingsManager.GetInstance().SetUserAgent(ua); + PublishTip(isSucceed); + } } // 下载器选择事件 diff --git a/src/DownKyi/Views/Settings/ViewBasic.xaml b/src/DownKyi/Views/Settings/ViewBasic.xaml index f6f6d57..e81493a 100644 --- a/src/DownKyi/Views/Settings/ViewBasic.xaml +++ b/src/DownKyi/Views/Settings/ViewBasic.xaml @@ -112,7 +112,27 @@ Foreground="{DynamicResource BrushTextDark}" IsChecked="{Binding AutoDownloadAll, Mode=TwoWay}" Style="{StaticResource CheckBoxStyle}" /> + + + + + + + + + + diff --git a/src/nuget.config b/src/nuget.config new file mode 100644 index 0000000..3357aef --- /dev/null +++ b/src/nuget.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file