修复因路径导致无法下载的问题;解决Settings被占用无法读取的问题;修复只下载音频失败的问题;默认的aria的文件预分配改为none;新增“解析后自动下载已解析视频”设置;批量下载时过滤UGC、其他季或花絮内容

pull/409/head
leiurayer 3 years ago
parent 6fd1b6d4c9
commit 06a4a57183

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

@ -24,7 +24,7 @@ namespace DownKyi.Core.FFmpeg
} }
if (video2 == null || !File.Exists(video2)) if (video2 == null || !File.Exists(video2))
{ {
param = $"-y -i \"{video1}\" -acodec copy -f aac \"{destVideo}\""; param = $"-y -i \"{video1}\" -acodec copy \"{destVideo}\"";
} }
if (!File.Exists(video1) && !File.Exists(video2)) { return false; } if (!File.Exists(video1) && !File.Exists(video2)) { return false; }

@ -9,6 +9,7 @@
public AllowStatus IsListenClipboard { get; set; } = AllowStatus.NONE; public AllowStatus IsListenClipboard { get; set; } = AllowStatus.NONE;
public AllowStatus IsAutoParseVideo { get; set; } = AllowStatus.NONE; public AllowStatus IsAutoParseVideo { get; set; } = AllowStatus.NONE;
public ParseScope ParseScope { get; set; } = ParseScope.NOT_SET; public ParseScope ParseScope { get; set; } = ParseScope.NOT_SET;
public AllowStatus IsAutoDownloadAll { get; set; } = AllowStatus.NONE;
public DownloadFinishedSort DownloadFinishedSort { get; set; } = DownloadFinishedSort.NOT_SET; public DownloadFinishedSort DownloadFinishedSort { get; set; } = DownloadFinishedSort.NOT_SET;
} }
} }

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

@ -14,6 +14,9 @@
// 默认的视频解析项 // 默认的视频解析项
private readonly ParseScope parseScope = ParseScope.NONE; private readonly ParseScope parseScope = ParseScope.NONE;
// 解析后自动下载解析视频
private readonly AllowStatus isAutoDownloadAll = AllowStatus.NO;
// 下载完成列表排序 // 下载完成列表排序
private readonly DownloadFinishedSort finishedSort = DownloadFinishedSort.DOWNLOAD; private readonly DownloadFinishedSort finishedSort = DownloadFinishedSort.DOWNLOAD;
@ -125,6 +128,33 @@
return SetSettings(); return SetSettings();
} }
/// <summary>
/// 解析后是否自动下载解析视频
/// </summary>
/// <returns></returns>
public AllowStatus IsAutoDownloadAll()
{
appSettings = GetSettings();
if (appSettings.Basic.IsAutoDownloadAll == AllowStatus.NONE)
{
// 第一次获取,先设置默认值
IsAutoDownloadAll(isAutoDownloadAll);
return isAutoDownloadAll;
}
return appSettings.Basic.IsAutoDownloadAll;
}
/// <summary>
/// 解析后是否自动下载解析视频
/// </summary>
/// <param name="isAutoDownloadAll"></param>
/// <returns></returns>
public bool IsAutoDownloadAll(AllowStatus isAutoDownloadAll)
{
appSettings.Basic.IsAutoDownloadAll = isAutoDownloadAll;
return SetSettings();
}
/// <summary> /// <summary>
/// 获取下载完成列表排序 /// 获取下载完成列表排序
/// </summary> /// </summary>

@ -1,4 +1,5 @@
using DownKyi.Core.FileName; using DownKyi.Core.FileName;
using DownKyi.Core.Settings.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
@ -28,6 +29,9 @@ namespace DownKyi.Core.Settings
// 是否使用默认下载目录,如果是,则每次点击下载选中项时不再询问下载目录 // 是否使用默认下载目录,如果是,则每次点击下载选中项时不再询问下载目录
private readonly AllowStatus isUseSaveVideoRootPath = AllowStatus.NO; private readonly AllowStatus isUseSaveVideoRootPath = AllowStatus.NO;
// 下载内容
private readonly VideoContentSettings videoContent = new VideoContentSettings();
// 文件命名格式 // 文件命名格式
private readonly List<FileNamePart> fileNameParts = new List<FileNamePart> private readonly List<FileNamePart> fileNameParts = new List<FileNamePart>
{ {
@ -236,6 +240,33 @@ namespace DownKyi.Core.Settings
return SetSettings(); 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>
/// 获取文件命名格式 /// 获取文件命名格式
/// </summary> /// </summary>

@ -57,9 +57,11 @@ namespace DownKyi.Core.Settings
{ {
try try
{ {
StreamReader streamReader = File.OpenText(settingsName); FileStream fileStream = new FileStream(settingsName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
StreamReader streamReader = new StreamReader(fileStream, System.Text.Encoding.UTF8);
string jsonWordTemplate = streamReader.ReadToEnd(); string jsonWordTemplate = streamReader.ReadToEnd();
streamReader.Close(); streamReader.Close();
fileStream.Close();
#if DEBUG #if DEBUG
#else #else

@ -180,6 +180,7 @@
<system:String x:Key="ListenClipboard">监听剪贴板</system:String> <system:String x:Key="ListenClipboard">监听剪贴板</system:String>
<system:String x:Key="VideoAutoParse">视频自动解析</system:String> <system:String x:Key="VideoAutoParse">视频自动解析</system:String>
<system:String x:Key="VideoParseScope">视频解析范围:</system:String> <system:String x:Key="VideoParseScope">视频解析范围:</system:String>
<system:String x:Key="AutoDownloadAll">解析后自动下载已解析视频</system:String>
<system:String x:Key="Network">网络</system:String> <system:String x:Key="Network">网络</system:String>
<system:String x:Key="AriaServerPort">Aria服务器端口</system:String> <system:String x:Key="AriaServerPort">Aria服务器端口</system:String>
@ -298,6 +299,7 @@
<system:String x:Key="Browse">浏览</system:String> <system:String x:Key="Browse">浏览</system:String>
<system:String x:Key="HardDiskFreeSpace">盘剩余空间:</system:String> <system:String x:Key="HardDiskFreeSpace">盘剩余空间:</system:String>
<system:String x:Key="DownloadContent">下载内容:</system:String> <system:String x:Key="DownloadContent">下载内容:</system:String>
<system:String x:Key="DownloadContent2">下载内容</system:String>
<system:String x:Key="DownloadAll">所有</system:String> <system:String x:Key="DownloadAll">所有</system:String>
<system:String x:Key="DownloadAudio">音频</system:String> <system:String x:Key="DownloadAudio">音频</system:String>
<system:String x:Key="DownloadVideo">视频</system:String> <system:String x:Key="DownloadVideo">视频</system:String>

@ -138,11 +138,9 @@ namespace DownKyi.Services
/// 获取视频章节与剧集 /// 获取视频章节与剧集
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<VideoSection> GetVideoSections() public List<VideoSection> GetVideoSections(bool noUgc = false)
{ {
if (bangumiSeason == null) { return null; } if (bangumiSeason == null) { return null; }
if (bangumiSeason.Section == null) { return null; }
if (bangumiSeason.Section.Count == 0) { return null; }
List<VideoSection> videoSections = new List<VideoSection> List<VideoSection> videoSections = new List<VideoSection>
{ {
@ -155,6 +153,15 @@ namespace DownKyi.Services
} }
}; };
// 不需要其他季或花絮内容
if (noUgc)
{
return videoSections;
}
if (bangumiSeason.Section == null) { return null; }
if (bangumiSeason.Section.Count == 0) { return null; }
foreach (BangumiSection section in bangumiSeason.Section) foreach (BangumiSection section in bangumiSeason.Section)
{ {
List<VideoPage> pages = new List<VideoPage>(); List<VideoPage> pages = new List<VideoPage>();

@ -106,7 +106,7 @@ namespace DownKyi.Services
/// 获取视频章节与剧集 /// 获取视频章节与剧集
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<VideoSection> GetVideoSections() public List<VideoSection> GetVideoSections(bool noUgc = false)
{ {
return null; return null;
} }

@ -103,7 +103,7 @@ namespace DownKyi.Services.Download
return; return;
} }
videoSections = videoInfoService.GetVideoSections(); videoSections = videoInfoService.GetVideoSections(true);
if (videoSections == null) if (videoSections == null)
{ {
LogManager.Debug(Tag, "videoSections is not exist."); LogManager.Debug(Tag, "videoSections is not exist.");
@ -196,7 +196,7 @@ namespace DownKyi.Services.Download
return directory; return directory;
} }
public int AddToDownload(IEventAggregator eventAggregator, string directory) public int AddToDownload(IEventAggregator eventAggregator, string directory, bool isAll = false)
{ {
if (directory == null || directory == string.Empty) { return -1; } if (directory == null || directory == string.Empty) { return -1; }
if (videoSections == null) { return -1; } if (videoSections == null) { return -1; }
@ -212,7 +212,7 @@ namespace DownKyi.Services.Download
foreach (VideoPage page in section.VideoPages) foreach (VideoPage page in section.VideoPages)
{ {
// 只下载选中项,跳过未选中项 // 只下载选中项,跳过未选中项
if (!page.IsSelected) { continue; } if (!isAll && !page.IsSelected) { continue; }
// 没有解析的也跳过 // 没有解析的也跳过
if (page.PlayUrl == null) { continue; } if (page.PlayUrl == null) { continue; }

@ -7,7 +7,7 @@ namespace DownKyi.Services
{ {
VideoInfoView GetVideoView(); VideoInfoView GetVideoView();
List<VideoSection> GetVideoSections(); List<VideoSection> GetVideoSections(bool noUgc);
List<VideoPage> GetVideoPages(); List<VideoPage> GetVideoPages();

@ -114,15 +114,30 @@ namespace DownKyi.Services
/// 获取视频章节与剧集 /// 获取视频章节与剧集
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public List<VideoSection> GetVideoSections() public List<VideoSection> GetVideoSections(bool noUgc = false)
{ {
if (videoView == null) { return null; } if (videoView == null) { return null; }
List<VideoSection> videoSections = new List<VideoSection>();
// 不需要ugc内容
if (noUgc)
{
videoSections.Add(new VideoSection
{
Id = 0,
Title = "default",
IsSelected = true,
VideoPages = GetVideoPages()
});
return videoSections;
}
if (videoView.UgcSeason == null) { return null; } if (videoView.UgcSeason == null) { return null; }
if (videoView.UgcSeason.Sections == null) { return null; } if (videoView.UgcSeason.Sections == null) { return null; }
if (videoView.UgcSeason.Sections.Count == 0) { return null; } if (videoView.UgcSeason.Sections.Count == 0) { return null; }
List<VideoSection> videoSections = new List<VideoSection>();
foreach (UgcSection section in videoView.UgcSeason.Sections) foreach (UgcSection section in videoView.UgcSeason.Sections)
{ {
List<ViewModels.PageViewModels.VideoPage> pages = new List<ViewModels.PageViewModels.VideoPage>(); List<ViewModels.PageViewModels.VideoPage> pages = new List<ViewModels.PageViewModels.VideoPage>();

@ -1,4 +1,5 @@
using DownKyi.Core.Settings; using DownKyi.Core.Settings;
using DownKyi.Core.Settings.Models;
using DownKyi.Core.Utils; using DownKyi.Core.Utils;
using DownKyi.Events; using DownKyi.Events;
using DownKyi.Images; using DownKyi.Images;
@ -136,14 +137,23 @@ namespace DownKyi.ViewModels.Dialogs
FolderIcon = NormalIcon.Instance().Folder; FolderIcon = NormalIcon.Instance().Folder;
FolderIcon.Fill = DictionaryResource.GetColor("ColorPrimary"); FolderIcon.Fill = DictionaryResource.GetColor("ColorPrimary");
DownloadAll = true; // 下载内容
DownloadAudio = true; VideoContentSettings videoContent = SettingsManager.GetInstance().GetVideoContent();
DownloadVideo = true;
DownloadDanmaku = true;
DownloadSubtitle = true;
DownloadCover = true;
#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(); DirectoryList = SettingsManager.GetInstance().GetHistoryVideoRootPaths();
@ -156,6 +166,9 @@ namespace DownKyi.ViewModels.Dialogs
// 是否使用默认下载目录 // 是否使用默认下载目录
IsDefaultDownloadDirectory = SettingsManager.GetInstance().IsUseSaveVideoRootPath() == AllowStatus.YES; IsDefaultDownloadDirectory = SettingsManager.GetInstance().IsUseSaveVideoRootPath() == AllowStatus.YES;
#endregion
} }
#region 命令申明 #region 命令申明
@ -213,6 +226,8 @@ namespace DownKyi.ViewModels.Dialogs
DownloadSubtitle = false; DownloadSubtitle = false;
DownloadCover = false; DownloadCover = false;
} }
SetVideoContent();
} }
// 音频选择事件 // 音频选择事件
@ -227,13 +242,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadAudio) if (!DownloadAudio)
{ {
DownloadAll = false; DownloadAll = false;
return;
} }
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{ {
DownloadAll = true; DownloadAll = true;
} }
SetVideoContent();
} }
// 视频选择事件 // 视频选择事件
@ -248,13 +264,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadVideo) if (!DownloadVideo)
{ {
DownloadAll = false; DownloadAll = false;
return;
} }
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{ {
DownloadAll = true; DownloadAll = true;
} }
SetVideoContent();
} }
// 弹幕选择事件 // 弹幕选择事件
@ -269,13 +286,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadDanmaku) if (!DownloadDanmaku)
{ {
DownloadAll = false; DownloadAll = false;
return;
} }
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{ {
DownloadAll = true; DownloadAll = true;
} }
SetVideoContent();
} }
// 字幕选择事件 // 字幕选择事件
@ -290,13 +308,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadSubtitle) if (!DownloadSubtitle)
{ {
DownloadAll = false; DownloadAll = false;
return;
} }
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{ {
DownloadAll = true; DownloadAll = true;
} }
SetVideoContent();
} }
// 封面选择事件 // 封面选择事件
@ -311,13 +330,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadCover) if (!DownloadCover)
{ {
DownloadAll = false; DownloadAll = false;
return;
} }
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover) if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{ {
DownloadAll = true; DownloadAll = true;
} }
SetVideoContent();
} }
// 确认下载事件 // 确认下载事件
@ -370,6 +390,23 @@ namespace DownKyi.ViewModels.Dialogs
#endregion #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>
/// 设置下载路径 /// 设置下载路径
/// </summary> /// </summary>

@ -67,6 +67,13 @@ namespace DownKyi.ViewModels.Settings
set { SetProperty(ref selectedParseScope, value); } set { SetProperty(ref selectedParseScope, value); }
} }
private bool autoDownloadAll;
public bool AutoDownloadAll
{
get => autoDownloadAll;
set => SetProperty(ref autoDownloadAll, value);
}
#endregion #endregion
public ViewBasicViewModel(IEventAggregator eventAggregator) : base(eventAggregator) public ViewBasicViewModel(IEventAggregator eventAggregator) : base(eventAggregator)
@ -113,6 +120,10 @@ namespace DownKyi.ViewModels.Settings
ParseScope parseScope = SettingsManager.GetInstance().GetParseScope(); ParseScope parseScope = SettingsManager.GetInstance().GetParseScope();
SelectedParseScope = ParseScopes.FirstOrDefault(t => { return t.ParseScope == parseScope; }); SelectedParseScope = ParseScopes.FirstOrDefault(t => { return t.ParseScope == parseScope; });
// 解析后是否自动下载解析视频
AllowStatus isAutoDownloadAll = SettingsManager.GetInstance().IsAutoDownloadAll();
AutoDownloadAll = isAutoDownloadAll == AllowStatus.YES;
isOnNavigatedTo = false; isOnNavigatedTo = false;
} }
@ -193,6 +204,21 @@ namespace DownKyi.ViewModels.Settings
PublishTip(isSucceed); PublishTip(isSucceed);
} }
// 解析后是否自动下载解析视频
private DelegateCommand autoDownloadAllCommand;
public DelegateCommand AutoDownloadAllCommand => autoDownloadAllCommand ?? (autoDownloadAllCommand = new DelegateCommand(ExecuteAutoDownloadAllCommand));
/// <summary>
/// 解析后是否自动下载解析视频
/// </summary>
private void ExecuteAutoDownloadAllCommand()
{
AllowStatus isAutoDownloadAll = AutoDownloadAll ? AllowStatus.YES : AllowStatus.NO;
bool isSucceed = SettingsManager.GetInstance().IsAutoDownloadAll(isAutoDownloadAll);
PublishTip(isSucceed);
}
#endregion #endregion
/// <summary> /// <summary>

@ -144,7 +144,7 @@ namespace DownKyi.ViewModels.Settings
// 弹幕字体 // 弹幕字体
string danmakuFont = SettingsManager.GetInstance().GetDanmakuFontName(); string danmakuFont = SettingsManager.GetInstance().GetDanmakuFontName();
if (Fonts.Contains(danmakuFont)) if (danmakuFont != null && Fonts.Contains(danmakuFont))
{ {
// 只有系统中存在当前设置的字体,才能显示 // 只有系统中存在当前设置的字体,才能显示
SelectedFont = danmakuFont; SelectedFont = danmakuFont;

@ -1,6 +1,7 @@
using DownKyi.Core.BiliApi.BiliUtils; using DownKyi.Core.BiliApi.BiliUtils;
using DownKyi.Core.FileName; using DownKyi.Core.FileName;
using DownKyi.Core.Settings; using DownKyi.Core.Settings;
using DownKyi.Core.Settings.Models;
using DownKyi.Events; using DownKyi.Events;
using DownKyi.Utils; using DownKyi.Utils;
using Prism.Commands; using Prism.Commands;
@ -84,6 +85,48 @@ namespace DownKyi.ViewModels.Settings
set => SetProperty(ref saveVideoDirectory, value); set => SetProperty(ref saveVideoDirectory, value);
} }
private bool downloadAll;
public bool DownloadAll
{
get { return downloadAll; }
set { SetProperty(ref downloadAll, value); }
}
private bool downloadAudio;
public bool DownloadAudio
{
get { return downloadAudio; }
set { SetProperty(ref downloadAudio, value); }
}
private bool downloadVideo;
public bool DownloadVideo
{
get { return downloadVideo; }
set { SetProperty(ref downloadVideo, value); }
}
private bool downloadDanmaku;
public bool DownloadDanmaku
{
get { return downloadDanmaku; }
set { SetProperty(ref downloadDanmaku, value); }
}
private bool downloadSubtitle;
public bool DownloadSubtitle
{
get { return downloadSubtitle; }
set { SetProperty(ref downloadSubtitle, value); }
}
private bool downloadCover;
public bool DownloadCover
{
get { return downloadCover; }
set { SetProperty(ref downloadCover, value); }
}
private ObservableCollection<DisplayFileNamePart> selectedFileName; private ObservableCollection<DisplayFileNamePart> selectedFileName;
public ObservableCollection<DisplayFileNamePart> SelectedFileName public ObservableCollection<DisplayFileNamePart> SelectedFileName
{ {
@ -195,6 +238,24 @@ namespace DownKyi.ViewModels.Settings
// 默认下载目录 // 默认下载目录
SaveVideoDirectory = SettingsManager.GetInstance().GetSaveVideoRootPath(); SaveVideoDirectory = SettingsManager.GetInstance().GetSaveVideoRootPath();
// 下载内容
VideoContentSettings videoContent = SettingsManager.GetInstance().GetVideoContent();
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;
}
// 文件命名格式 // 文件命名格式
List<FileNamePart> fileNameParts = SettingsManager.GetInstance().GetFileNameParts(); List<FileNamePart> fileNameParts = SettingsManager.GetInstance().GetFileNameParts();
SelectedFileName.Clear(); SelectedFileName.Clear();
@ -311,6 +372,145 @@ namespace DownKyi.ViewModels.Settings
} }
} }
// 所有内容选择事件
private DelegateCommand downloadAllCommand;
public DelegateCommand DownloadAllCommand => downloadAllCommand ?? (downloadAllCommand = new DelegateCommand(ExecuteDownloadAllCommand));
/// <summary>
/// 所有内容选择事件
/// </summary>
private void ExecuteDownloadAllCommand()
{
if (DownloadAll)
{
DownloadAudio = true;
DownloadVideo = true;
DownloadDanmaku = true;
DownloadSubtitle = true;
DownloadCover = true;
}
else
{
DownloadAudio = false;
DownloadVideo = false;
DownloadDanmaku = false;
DownloadSubtitle = false;
DownloadCover = false;
}
SetVideoContent();
}
// 音频选择事件
private DelegateCommand downloadAudioCommand;
public DelegateCommand DownloadAudioCommand => downloadAudioCommand ?? (downloadAudioCommand = new DelegateCommand(ExecuteDownloadAudioCommand));
/// <summary>
/// 音频选择事件
/// </summary>
private void ExecuteDownloadAudioCommand()
{
if (!DownloadAudio)
{
DownloadAll = false;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 视频选择事件
private DelegateCommand downloadVideoCommand;
public DelegateCommand DownloadVideoCommand => downloadVideoCommand ?? (downloadVideoCommand = new DelegateCommand(ExecuteDownloadVideoCommand));
/// <summary>
/// 视频选择事件
/// </summary>
private void ExecuteDownloadVideoCommand()
{
if (!DownloadVideo)
{
DownloadAll = false;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 弹幕选择事件
private DelegateCommand downloadDanmakuCommand;
public DelegateCommand DownloadDanmakuCommand => downloadDanmakuCommand ?? (downloadDanmakuCommand = new DelegateCommand(ExecuteDownloadDanmakuCommand));
/// <summary>
/// 弹幕选择事件
/// </summary>
private void ExecuteDownloadDanmakuCommand()
{
if (!DownloadDanmaku)
{
DownloadAll = false;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 字幕选择事件
private DelegateCommand downloadSubtitleCommand;
public DelegateCommand DownloadSubtitleCommand => downloadSubtitleCommand ?? (downloadSubtitleCommand = new DelegateCommand(ExecuteDownloadSubtitleCommand));
/// <summary>
/// 字幕选择事件
/// </summary>
private void ExecuteDownloadSubtitleCommand()
{
if (!DownloadSubtitle)
{
DownloadAll = false;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 封面选择事件
private DelegateCommand downloadCoverCommand;
public DelegateCommand DownloadCoverCommand => downloadCoverCommand ?? (downloadCoverCommand = new DelegateCommand(ExecuteDownloadCoverCommand));
/// <summary>
/// 封面选择事件
/// </summary>
private void ExecuteDownloadCoverCommand()
{
if (!DownloadCover)
{
DownloadAll = false;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 选中文件名字段点击事件 // 选中文件名字段点击事件
private DelegateCommand<object> selectedFileNameCommand; private DelegateCommand<object> selectedFileNameCommand;
public DelegateCommand<object> SelectedFileNameCommand => selectedFileNameCommand ?? (selectedFileNameCommand = new DelegateCommand<object>(ExecuteSelectedFileNameCommand)); public DelegateCommand<object> SelectedFileNameCommand => selectedFileNameCommand ?? (selectedFileNameCommand = new DelegateCommand<object>(ExecuteSelectedFileNameCommand));
@ -460,21 +660,21 @@ namespace DownKyi.ViewModels.Settings
} }
/// <summary> /// <summary>
/// 发送需要显示的tip /// 保存下载视频内容到设置
/// </summary> /// </summary>
/// <param name="isSucceed"></param> private void SetVideoContent()
private void PublishTip(bool isSucceed)
{ {
if (isOnNavigatedTo) { return; } VideoContentSettings videoContent = new VideoContentSettings
if (isSucceed)
{
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
}
else
{ {
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed")); DownloadAudio = DownloadAudio,
} DownloadVideo = DownloadVideo,
DownloadDanmaku = DownloadDanmaku,
DownloadSubtitle = DownloadSubtitle,
DownloadCover = DownloadCover
};
bool isSucceed = SettingsManager.GetInstance().SetVideoContent(videoContent);
PublishTip(isSucceed);
} }
/// <summary> /// <summary>
@ -544,5 +744,23 @@ namespace DownKyi.ViewModels.Settings
return display; return display;
} }
/// <summary>
/// 发送需要显示的tip
/// </summary>
/// <param name="isSucceed"></param>
private void PublishTip(bool isSucceed)
{
if (isOnNavigatedTo) { return; }
if (isSucceed)
{
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
}
else
{
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingFailed"));
}
}
} }
} }

@ -480,6 +480,13 @@ namespace DownKyi.ViewModels
} }
LoadingVisibility = Visibility.Collapsed; LoadingVisibility = Visibility.Collapsed;
// 解析后是否自动下载解析视频
AllowStatus isAutoDownloadAll = SettingsManager.GetInstance().IsAutoDownloadAll();
if (parseScope != ParseScope.NONE && isAutoDownloadAll == AllowStatus.YES)
{
AddToDownload(true);
}
} }
/// <summary> /// <summary>
@ -498,56 +505,57 @@ namespace DownKyi.ViewModels
/// <summary> /// <summary>
/// 添加到下载列表事件 /// 添加到下载列表事件
/// </summary> /// </summary>
private async void ExecuteAddToDownloadCommand() private void ExecuteAddToDownloadCommand()
{ {
AddToDownloadService addToDownloadService = null; AddToDownload(false);
// 视频 //AddToDownloadService addToDownloadService = null;
if (ParseEntrance.IsAvUrl(input) || ParseEntrance.IsBvUrl(input)) //// 视频
{ //if (ParseEntrance.IsAvUrl(input) || ParseEntrance.IsBvUrl(input))
addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO); //{
} // addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
// 番剧(电影、电视剧) //}
else if (ParseEntrance.IsBangumiSeasonUrl(input) || ParseEntrance.IsBangumiEpisodeUrl(input) || ParseEntrance.IsBangumiMediaUrl(input)) //// 番剧(电影、电视剧)
{ //else if (ParseEntrance.IsBangumiSeasonUrl(input) || ParseEntrance.IsBangumiEpisodeUrl(input) || ParseEntrance.IsBangumiMediaUrl(input))
addToDownloadService = new AddToDownloadService(PlayStreamType.BANGUMI); //{
} // addToDownloadService = new AddToDownloadService(PlayStreamType.BANGUMI);
// 课程 //}
else if (ParseEntrance.IsCheeseSeasonUrl(input) || ParseEntrance.IsCheeseEpisodeUrl(input)) //// 课程
{ //else if (ParseEntrance.IsCheeseSeasonUrl(input) || ParseEntrance.IsCheeseEpisodeUrl(input))
addToDownloadService = new AddToDownloadService(PlayStreamType.CHEESE); //{
} // addToDownloadService = new AddToDownloadService(PlayStreamType.CHEESE);
else //}
{ //else
return; //{
} // return;
//}
// 选择文件夹
string directory = addToDownloadService.SetDirectory(dialogService); //// 选择文件夹
//string directory = addToDownloadService.SetDirectory(dialogService);
// 视频计数
int i = 0; //// 视频计数
await Task.Run(() => //int i = 0;
{ //await Task.Run(() =>
// 传递video对象 //{
addToDownloadService.GetVideo(VideoInfoView, VideoSections.ToList()); // // 传递video对象
// 下载 // addToDownloadService.GetVideo(VideoInfoView, VideoSections.ToList());
i = addToDownloadService.AddToDownload(eventAggregator, directory); // // 下载
}); // i = addToDownloadService.AddToDownload(eventAggregator, directory);
//});
if (directory == null)
{ //if (directory == null)
return; //{
} // return;
//}
// 通知用户添加到下载列表的结果
if (i <= 0) //// 通知用户添加到下载列表的结果
{ //if (i <= 0)
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); //{
} // eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
else //}
{ //else
eventAggregator.GetEvent<MessageEvent>().Publish($"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}"); //{
} // eventAggregator.GetEvent<MessageEvent>().Publish($"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
//}
} }
/// <summary> /// <summary>
@ -627,7 +635,7 @@ namespace DownKyi.ViewModels
NoDataVisibility = Visibility.Collapsed; NoDataVisibility = Visibility.Collapsed;
} }
List<VideoSection> videoSections = videoInfoService.GetVideoSections(); List<VideoSection> videoSections = videoInfoService.GetVideoSections(false);
if (videoSections == null) if (videoSections == null)
{ {
LogManager.Debug(Tag, "videoSections is not exist."); LogManager.Debug(Tag, "videoSections is not exist.");
@ -663,6 +671,62 @@ namespace DownKyi.ViewModels
videoInfoService.GetVideoStream(videoPage); videoInfoService.GetVideoStream(videoPage);
} }
/// <summary>
/// 添加到下载列表事件
/// </summary>
private async void AddToDownload(bool isAll)
{
AddToDownloadService addToDownloadService = null;
// 视频
if (ParseEntrance.IsAvUrl(input) || ParseEntrance.IsBvUrl(input))
{
addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
}
// 番剧(电影、电视剧)
else if (ParseEntrance.IsBangumiSeasonUrl(input) || ParseEntrance.IsBangumiEpisodeUrl(input) || ParseEntrance.IsBangumiMediaUrl(input))
{
addToDownloadService = new AddToDownloadService(PlayStreamType.BANGUMI);
}
// 课程
else if (ParseEntrance.IsCheeseSeasonUrl(input) || ParseEntrance.IsCheeseEpisodeUrl(input))
{
addToDownloadService = new AddToDownloadService(PlayStreamType.CHEESE);
}
else
{
return;
}
// 选择文件夹
string directory = addToDownloadService.SetDirectory(dialogService);
// 视频计数
int i = 0;
await Task.Run(() =>
{
// 传递video对象
addToDownloadService.GetVideo(VideoInfoView, VideoSections.ToList());
// 下载
i = addToDownloadService.AddToDownload(eventAggregator, directory, isAll);
});
if (directory == null)
{
return;
}
// 通知用户添加到下载列表的结果
if (i <= 0)
{
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
}
else
{
eventAggregator.GetEvent<MessageEvent>().Publish($"{DictionaryResource.GetString("TipAddDownloadingFinished1")}{i}{DictionaryResource.GetString("TipAddDownloadingFinished2")}");
}
}
#endregion #endregion
/// <summary> /// <summary>

@ -63,7 +63,6 @@
Background="{DynamicResource BrushBorder}" /> Background="{DynamicResource BrushBorder}" />
<CheckBox <CheckBox
Grid.Column="0"
Margin="0,20,0,0" Margin="0,20,0,0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
@ -74,7 +73,6 @@
Style="{StaticResource CheckBoxStyle}" /> Style="{StaticResource CheckBoxStyle}" />
<CheckBox <CheckBox
Grid.Column="0"
Margin="0,20,0,0" Margin="0,20,0,0"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
@ -105,6 +103,16 @@
</ComboBox> </ComboBox>
</StackPanel> </StackPanel>
<CheckBox
Margin="0,20,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Command="{Binding AutoDownloadAllCommand}"
Content="{DynamicResource AutoDownloadAll}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding AutoDownloadAll, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<StackPanel Margin="10" /> <StackPanel Margin="10" />
</StackPanel> </StackPanel>
</ScrollViewer> </ScrollViewer>

@ -19,8 +19,14 @@
<GroupBox <GroupBox
Margin="0,20,0,0" Margin="0,20,0,0"
Padding="20,5" Padding="20,5"
HorizontalAlignment="Left" HorizontalAlignment="Left">
Header="{DynamicResource FilterType}"> <GroupBox.Header>
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource FilterType}" />
</GroupBox.Header>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal"> <StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<CheckBox <CheckBox
Margin="0,0,0,0" Margin="0,0,0,0"
@ -30,14 +36,14 @@
IsChecked="{Binding TopFilter, Mode=TwoWay}" IsChecked="{Binding TopFilter, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" /> Style="{StaticResource CheckBoxStyle}" />
<CheckBox <CheckBox
Margin="20,0,0,0" Margin="40,0,0,0"
Command="{Binding BottomFilterCommand}" Command="{Binding BottomFilterCommand}"
Content="{DynamicResource BottomFilter}" Content="{DynamicResource BottomFilter}"
Foreground="{DynamicResource BrushTextDark}" Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding BottomFilter, Mode=TwoWay}" IsChecked="{Binding BottomFilter, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" /> Style="{StaticResource CheckBoxStyle}" />
<CheckBox <CheckBox
Margin="20,0,0,0" Margin="40,0,0,0"
Command="{Binding ScrollFilterCommand}" Command="{Binding ScrollFilterCommand}"
Content="{DynamicResource ScrollFilter}" Content="{DynamicResource ScrollFilter}"
Foreground="{DynamicResource BrushTextDark}" Foreground="{DynamicResource BrushTextDark}"

@ -151,6 +151,63 @@
</StackPanel> </StackPanel>
</StackPanel> </StackPanel>
<GroupBox
Margin="0,20,0,0"
Padding="10,10"
HorizontalAlignment="Stretch">
<GroupBox.Header>
<TextBlock
FontSize="12"
Foreground="{DynamicResource BrushTextDark}"
Text="{DynamicResource DownloadContent2}" />
</GroupBox.Header>
<StackPanel Margin="0,10,0,0" Orientation="Horizontal">
<CheckBox
Margin="0,0,0,0"
Command="{Binding DownloadAllCommand}"
Content="{DynamicResource DownloadAll}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadAll, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadAudioCommand}"
Content="{DynamicResource DownloadAudio}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadAudio, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadVideoCommand}"
Content="{DynamicResource DownloadVideo}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadVideo, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadDanmakuCommand}"
Content="{DynamicResource DownloadDanmaku}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadDanmaku, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadSubtitleCommand}"
Content="{DynamicResource DownloadSubtitle}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadSubtitle, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Margin="40,0,0,0"
Command="{Binding DownloadCoverCommand}"
Content="{DynamicResource DownloadCover}"
Foreground="{DynamicResource BrushTextDark}"
IsChecked="{Binding DownloadCover, Mode=TwoWay}"
Style="{StaticResource CheckBoxStyle}" />
</StackPanel>
</GroupBox>
<GroupBox <GroupBox
Margin="0,20,0,0" Margin="0,20,0,0"
Padding="10,10" Padding="10,10"

Loading…
Cancel
Save