保存下载视频内容到设置

croire 3 years ago
parent e64d27dc0a
commit 74a9450680

@ -271,6 +271,7 @@
<Compile Include="Logging\LogLevel.cs" />
<Compile Include="Logging\LogManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings\Models\VideoContentSettings.cs" />
<Compile Include="Settings\ParseScope.cs" />
<Compile Include="Settings\SettingsManager.Video.cs" />
<Compile Include="Settings\SettingsManager.Basic.cs" />

@ -0,0 +1,11 @@
namespace DownKyi.Core.Settings.Models
{
public class VideoContentSettings
{
public bool DownloadAudio { get; set; } = true;
public bool DownloadVideo { get; set; } = true;
public bool DownloadDanmaku { get; set; } = true;
public bool DownloadSubtitle { get; set; } = true;
public bool DownloadCover { get; set; } = true;
}
}

@ -15,6 +15,7 @@ namespace DownKyi.Core.Settings.Models
public string SaveVideoRootPath { get; set; } = null; // 视频保存路径
public List<string> HistoryVideoRootPaths { get; set; } = null; // 历史视频保存路径
public AllowStatus IsUseSaveVideoRootPath { get; set; } = AllowStatus.NONE; // 是否使用默认视频保存路径
public VideoContentSettings VideoContent { get; set; } = null; // 下载内容
public List<FileNamePart> FileNameParts { get; set; } = null; // 文件命名格式
public string FileNamePartTimeFormat { get; set; } = null; // 文件命名中的时间格式
}

@ -1,4 +1,5 @@
using DownKyi.Core.FileName;
using DownKyi.Core.Settings.Models;
using System;
using System.Collections.Generic;
using System.IO;
@ -28,6 +29,9 @@ namespace DownKyi.Core.Settings
// 是否使用默认下载目录,如果是,则每次点击下载选中项时不再询问下载目录
private readonly AllowStatus isUseSaveVideoRootPath = AllowStatus.NO;
// 下载内容
private readonly VideoContentSettings videoContent = new VideoContentSettings();
// 文件命名格式
private readonly List<FileNamePart> fileNameParts = new List<FileNamePart>
{
@ -236,6 +240,33 @@ namespace DownKyi.Core.Settings
return SetSettings();
}
/// <summary>
/// 获取下载内容
/// </summary>
/// <returns></returns>
public VideoContentSettings GetVideoContent()
{
appSettings = GetSettings();
if (appSettings.Video.VideoContent == null)
{
// 第一次获取,先设置默认值
SetVideoContent(videoContent);
return videoContent;
}
return appSettings.Video.VideoContent;
}
/// <summary>
/// 设置下载内容
/// </summary>
/// <param name="videoContent"></param>
/// <returns></returns>
public bool SetVideoContent(VideoContentSettings videoContent)
{
appSettings.Video.VideoContent = videoContent;
return SetSettings();
}
/// <summary>
/// 获取文件命名格式
/// </summary>

@ -1,4 +1,5 @@
using DownKyi.Core.Settings;
using DownKyi.Core.Settings.Models;
using DownKyi.Core.Utils;
using DownKyi.Events;
using DownKyi.Images;
@ -136,14 +137,23 @@ namespace DownKyi.ViewModels.Dialogs
FolderIcon = NormalIcon.Instance().Folder;
FolderIcon.Fill = DictionaryResource.GetColor("ColorPrimary");
DownloadAll = true;
DownloadAudio = true;
DownloadVideo = true;
DownloadDanmaku = true;
DownloadSubtitle = true;
DownloadCover = true;
// 下载内容
VideoContentSettings videoContent = SettingsManager.GetInstance().GetVideoContent();
#endregion
DownloadAudio = videoContent.DownloadAudio;
DownloadVideo = videoContent.DownloadVideo;
DownloadDanmaku = videoContent.DownloadDanmaku;
DownloadSubtitle = videoContent.DownloadSubtitle;
DownloadCover = videoContent.DownloadCover;
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
else
{
DownloadAll = false;
}
// 历史下载目录
DirectoryList = SettingsManager.GetInstance().GetHistoryVideoRootPaths();
@ -156,6 +166,9 @@ namespace DownKyi.ViewModels.Dialogs
// 是否使用默认下载目录
IsDefaultDownloadDirectory = SettingsManager.GetInstance().IsUseSaveVideoRootPath() == AllowStatus.YES;
#endregion
}
#region 命令申明
@ -213,6 +226,8 @@ namespace DownKyi.ViewModels.Dialogs
DownloadSubtitle = false;
DownloadCover = false;
}
SetVideoContent();
}
// 音频选择事件
@ -234,6 +249,8 @@ namespace DownKyi.ViewModels.Dialogs
{
DownloadAll = true;
}
SetVideoContent();
}
// 视频选择事件
@ -255,6 +272,8 @@ namespace DownKyi.ViewModels.Dialogs
{
DownloadAll = true;
}
SetVideoContent();
}
// 弹幕选择事件
@ -276,6 +295,8 @@ namespace DownKyi.ViewModels.Dialogs
{
DownloadAll = true;
}
SetVideoContent();
}
// 字幕选择事件
@ -297,6 +318,8 @@ namespace DownKyi.ViewModels.Dialogs
{
DownloadAll = true;
}
SetVideoContent();
}
// 封面选择事件
@ -318,6 +341,8 @@ namespace DownKyi.ViewModels.Dialogs
{
DownloadAll = true;
}
SetVideoContent();
}
// 确认下载事件
@ -370,6 +395,23 @@ namespace DownKyi.ViewModels.Dialogs
#endregion
/// <summary>
/// 保存下载视频内容到设置
/// </summary>
private void SetVideoContent()
{
VideoContentSettings videoContent = new VideoContentSettings
{
DownloadAudio = DownloadAudio,
DownloadVideo = DownloadVideo,
DownloadDanmaku = DownloadDanmaku,
DownloadSubtitle = DownloadSubtitle,
DownloadCover = DownloadCover
};
SettingsManager.GetInstance().SetVideoContent(videoContent);
}
/// <summary>
/// 设置下载路径
/// </summary>

Loading…
Cancel
Save