修复因路径导致无法下载的问题;解决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\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" />

@ -24,7 +24,7 @@ namespace DownKyi.Core.FFmpeg
}
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; }

@ -9,6 +9,7 @@
public AllowStatus IsListenClipboard { get; set; } = AllowStatus.NONE;
public AllowStatus IsAutoParseVideo { get; set; } = AllowStatus.NONE;
public ParseScope ParseScope { get; set; } = ParseScope.NOT_SET;
public AllowStatus IsAutoDownloadAll { get; set; } = AllowStatus.NONE;
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 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; // 文件命名中的时间格式
}

@ -14,6 +14,9 @@
// 默认的视频解析项
private readonly ParseScope parseScope = ParseScope.NONE;
// 解析后自动下载解析视频
private readonly AllowStatus isAutoDownloadAll = AllowStatus.NO;
// 下载完成列表排序
private readonly DownloadFinishedSort finishedSort = DownloadFinishedSort.DOWNLOAD;
@ -125,6 +128,33 @@
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>

@ -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>

@ -57,9 +57,11 @@ namespace DownKyi.Core.Settings
{
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();
streamReader.Close();
fileStream.Close();
#if DEBUG
#else

@ -180,6 +180,7 @@
<system:String x:Key="ListenClipboard">监听剪贴板</system:String>
<system:String x:Key="VideoAutoParse">视频自动解析</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="AriaServerPort">Aria服务器端口</system:String>
@ -298,6 +299,7 @@
<system:String x:Key="Browse">浏览</system:String>
<system:String x:Key="HardDiskFreeSpace">盘剩余空间:</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="DownloadAudio">音频</system:String>
<system:String x:Key="DownloadVideo">视频</system:String>

@ -138,11 +138,9 @@ namespace DownKyi.Services
/// 获取视频章节与剧集
/// </summary>
/// <returns></returns>
public List<VideoSection> GetVideoSections()
public List<VideoSection> GetVideoSections(bool noUgc = false)
{
if (bangumiSeason == null) { return null; }
if (bangumiSeason.Section == null) { return null; }
if (bangumiSeason.Section.Count == 0) { return null; }
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)
{
List<VideoPage> pages = new List<VideoPage>();

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

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

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

@ -114,15 +114,30 @@ namespace DownKyi.Services
/// 获取视频章节与剧集
/// </summary>
/// <returns></returns>
public List<VideoSection> GetVideoSections()
public List<VideoSection> GetVideoSections(bool noUgc = false)
{
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.Sections == null) { return null; }
if (videoView.UgcSeason.Sections.Count == 0) { return null; }
List<VideoSection> videoSections = new List<VideoSection>();
foreach (UgcSection section in videoView.UgcSeason.Sections)
{
List<ViewModels.PageViewModels.VideoPage> pages = new List<ViewModels.PageViewModels.VideoPage>();

@ -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();
}
// 音频选择事件
@ -227,13 +242,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadAudio)
{
DownloadAll = false;
return;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 视频选择事件
@ -248,13 +264,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadVideo)
{
DownloadAll = false;
return;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 弹幕选择事件
@ -269,13 +286,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadDanmaku)
{
DownloadAll = false;
return;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 字幕选择事件
@ -290,13 +308,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadSubtitle)
{
DownloadAll = false;
return;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 封面选择事件
@ -311,13 +330,14 @@ namespace DownKyi.ViewModels.Dialogs
if (!DownloadCover)
{
DownloadAll = false;
return;
}
if (DownloadAudio && DownloadVideo && DownloadDanmaku && DownloadSubtitle && DownloadCover)
{
DownloadAll = true;
}
SetVideoContent();
}
// 确认下载事件
@ -370,6 +390,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>

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

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

@ -1,6 +1,7 @@
using DownKyi.Core.BiliApi.BiliUtils;
using DownKyi.Core.FileName;
using DownKyi.Core.Settings;
using DownKyi.Core.Settings.Models;
using DownKyi.Events;
using DownKyi.Utils;
using Prism.Commands;
@ -84,6 +85,48 @@ namespace DownKyi.ViewModels.Settings
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;
public ObservableCollection<DisplayFileNamePart> SelectedFileName
{
@ -195,6 +238,24 @@ namespace DownKyi.ViewModels.Settings
// 默认下载目录
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();
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;
public DelegateCommand<object> SelectedFileNameCommand => selectedFileNameCommand ?? (selectedFileNameCommand = new DelegateCommand<object>(ExecuteSelectedFileNameCommand));
@ -460,21 +660,21 @@ namespace DownKyi.ViewModels.Settings
}
/// <summary>
/// 发送需要显示的tip
/// 保存下载视频内容到设置
/// </summary>
/// <param name="isSucceed"></param>
private void PublishTip(bool isSucceed)
private void SetVideoContent()
{
if (isOnNavigatedTo) { return; }
if (isSucceed)
{
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipSettingUpdated"));
}
else
VideoContentSettings videoContent = new VideoContentSettings
{
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>
@ -544,5 +744,23 @@ namespace DownKyi.ViewModels.Settings
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;
// 解析后是否自动下载解析视频
AllowStatus isAutoDownloadAll = SettingsManager.GetInstance().IsAutoDownloadAll();
if (parseScope != ParseScope.NONE && isAutoDownloadAll == AllowStatus.YES)
{
AddToDownload(true);
}
}
/// <summary>
@ -498,56 +505,57 @@ namespace DownKyi.ViewModels
/// <summary>
/// 添加到下载列表事件
/// </summary>
private async void ExecuteAddToDownloadCommand()
{
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);
});
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")}");
}
private void ExecuteAddToDownloadCommand()
{
AddToDownload(false);
//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);
//});
//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")}");
//}
}
/// <summary>
@ -627,7 +635,7 @@ namespace DownKyi.ViewModels
NoDataVisibility = Visibility.Collapsed;
}
List<VideoSection> videoSections = videoInfoService.GetVideoSections();
List<VideoSection> videoSections = videoInfoService.GetVideoSections(false);
if (videoSections == null)
{
LogManager.Debug(Tag, "videoSections is not exist.");
@ -663,6 +671,62 @@ namespace DownKyi.ViewModels
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
/// <summary>

@ -63,7 +63,6 @@
Background="{DynamicResource BrushBorder}" />
<CheckBox
Grid.Column="0"
Margin="0,20,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
@ -74,7 +73,6 @@
Style="{StaticResource CheckBoxStyle}" />
<CheckBox
Grid.Column="0"
Margin="0,20,0,0"
HorizontalAlignment="Left"
VerticalAlignment="Top"
@ -105,6 +103,16 @@
</ComboBox>
</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>
</ScrollViewer>

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

@ -151,6 +151,63 @@
</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
Margin="0,20,0,0"
Padding="10,10"

Loading…
Cancel
Save