From 951749bd0ff8db9c34f4e333144ef6bd13daf8c9 Mon Sep 17 00:00:00 2001
From: croire <1432593898@qq.com>
Date: Sun, 30 Apr 2023 16:39:12 +0800
Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E5=88=97=E8=A1=A8=E5=A2=9E?=
=?UTF-8?q?=E5=8A=A0=E4=BA=86=E4=B8=80=E4=B8=AA=E6=90=9C=E7=B4=A2=E6=A1=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
DownKyi/Languages/Default.xaml | 2 +
DownKyi/Languages/en_US.xaml | 4 +-
DownKyi/Languages/zh_CN.xaml | 2 +
DownKyi/Languages/zh_TW.xaml | 2 +
.../DownloadManager/DownloadedItem.cs | 21 ++++++-
DownKyi/ViewModels/ViewSettingsViewModel.cs | 1 +
.../ViewModels/ViewVideoDetailViewModel.cs | 62 ++++++++++++++++++-
DownKyi/Views/ViewVideoDetail.xaml | 32 +++++++++-
8 files changed, 119 insertions(+), 7 deletions(-)
diff --git a/DownKyi/Languages/Default.xaml b/DownKyi/Languages/Default.xaml
index 20846ed..02ba237 100644
--- a/DownKyi/Languages/Default.xaml
+++ b/DownKyi/Languages/Default.xaml
@@ -135,6 +135,8 @@
视频编码
全选
+ 搜索
+ 搜索视频名称
解析
解析视频
下载选中项
diff --git a/DownKyi/Languages/en_US.xaml b/DownKyi/Languages/en_US.xaml
index d952741..988a3fb 100644
--- a/DownKyi/Languages/en_US.xaml
+++ b/DownKyi/Languages/en_US.xaml
@@ -56,7 +56,9 @@
音质
画质
视频编码
-
+
+ 搜索
+ 搜索视频名称
全选
解析
解析视频
diff --git a/DownKyi/Languages/zh_CN.xaml b/DownKyi/Languages/zh_CN.xaml
index 28994d8..0beb9b6 100644
--- a/DownKyi/Languages/zh_CN.xaml
+++ b/DownKyi/Languages/zh_CN.xaml
@@ -58,6 +58,8 @@
画质
视频编码
+ 搜索
+ 搜索视频名称
全选
解析
解析视频
diff --git a/DownKyi/Languages/zh_TW.xaml b/DownKyi/Languages/zh_TW.xaml
index 28994d8..0beb9b6 100644
--- a/DownKyi/Languages/zh_TW.xaml
+++ b/DownKyi/Languages/zh_TW.xaml
@@ -58,6 +58,8 @@
画质
视频编码
+ 搜索
+ 搜索视频名称
全选
解析
解析视频
diff --git a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
index 8bb6518..7ddde0b 100644
--- a/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
+++ b/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
@@ -5,6 +5,7 @@ using DownKyi.Utils;
using Prism.Commands;
using Prism.Services.Dialogs;
using System.IO;
+using System.Linq;
namespace DownKyi.ViewModels.DownloadManager
{
@@ -91,8 +92,24 @@ namespace DownKyi.ViewModels.DownloadManager
private void ExecuteOpenFolderCommand()
{
if (DownloadBase == null) { return; }
-
- string videoPath = $"{DownloadBase.FilePath}.mp4";
+ //TODO:这里不光有mp4视频文件,也可能存在音频文件、字幕,或者其他文件类型
+ //fix bug:Issues #709
+ //这里根据需要下载的类型判断,具体对应的文件后缀名
+ var downLoadContents = DownloadBase.NeedDownloadContent.Where(e => e.Value == true).Select(e => e.Key);
+ string fileSuffix = string.Empty;
+ if (downLoadContents.Contains("downloadVideo"))
+ {
+ fileSuffix = ".mp4";
+ }
+ else if (downLoadContents.Contains("downloadAudio"))
+ {
+ fileSuffix = ".aac";
+ }
+ else if (downLoadContents.Contains("downloadCover"))
+ {
+ fileSuffix = ".jpg";
+ }
+ string videoPath = $"{DownloadBase.FilePath}{fileSuffix}";
FileInfo fileInfo = new FileInfo(videoPath);
if (File.Exists(fileInfo.FullName))
{
diff --git a/DownKyi/ViewModels/ViewSettingsViewModel.cs b/DownKyi/ViewModels/ViewSettingsViewModel.cs
index d1d9812..882aea5 100644
--- a/DownKyi/ViewModels/ViewSettingsViewModel.cs
+++ b/DownKyi/ViewModels/ViewSettingsViewModel.cs
@@ -41,6 +41,7 @@ namespace DownKyi.ViewModels
#endregion
+
public ViewSettingsViewModel(IRegionManager regionManager, IEventAggregator eventAggregator) : base(eventAggregator)
{
this.regionManager = regionManager;
diff --git a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
index 5d7551b..d8c8ee0 100644
--- a/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
+++ b/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
@@ -10,6 +10,7 @@ using DownKyi.Services.Download;
using DownKyi.Utils;
using DownKyi.ViewModels.Dialogs;
using DownKyi.ViewModels.PageViewModels;
+using Newtonsoft.Json;
using Prism.Commands;
using Prism.Events;
using Prism.Regions;
@@ -17,7 +18,9 @@ using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.IO;
using System.Linq;
+using System.Runtime.Serialization.Formatters.Binary;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
@@ -46,7 +49,13 @@ namespace DownKyi.ViewModels
get => inputText;
set => SetProperty(ref inputText, value);
}
+ private string inputSearchText;
+ public string InputSearchText
+ {
+ get => inputSearchText;
+ set => SetProperty(ref inputSearchText, value);
+ }
private GifImage loading;
public GifImage Loading
{
@@ -81,7 +90,7 @@ namespace DownKyi.ViewModels
get => videoSections;
set => SetProperty(ref videoSections, value);
}
-
+ public ObservableCollection CaCheVideoSections { get; set; }
private bool isSelectAll;
public bool IsSelectAll
{
@@ -125,7 +134,7 @@ namespace DownKyi.ViewModels
DownloadManage.Fill = DictionaryResource.GetColor("ColorPrimary");
VideoSections = new ObservableCollection();
-
+ CaCheVideoSections = new ObservableCollection();
#endregion
}
@@ -172,6 +181,41 @@ namespace DownKyi.ViewModels
private DelegateCommand inputCommand;
public DelegateCommand InputCommand => inputCommand ?? (inputCommand = new DelegateCommand(ExecuteInputCommand, CanExecuteInputCommand));
+
+ private DelegateCommand inputSearchCommand;
+
+ public DelegateCommand InputSearchCommand => inputSearchCommand ?? (inputSearchCommand = new DelegateCommand(ExcuteInputSearchCommand));
+ ///
+ /// 搜索视频输入时间
+ ///
+ private async void ExcuteInputSearchCommand() {
+ await Task.Run(() =>
+ {
+ if (InputSearchText == null || InputSearchText == string.Empty)
+ {
+ foreach (VideoSection section in VideoSections) {
+ var cache= CaCheVideoSections.FirstOrDefault(e=>e.Id==section.Id);
+ if (cache!=null)
+ {
+ section.VideoPages=cache.VideoPages;
+ }
+ }
+ }
+ else
+ {
+ foreach (VideoSection section in VideoSections)
+ {
+ var cache = CaCheVideoSections.FirstOrDefault(e => e.Id == section.Id);
+ if (cache != null)
+ {
+ var pages = cache.VideoPages.Where(e => e.Name.Contains(InputSearchText)).ToList();
+ section.VideoPages = pages;
+ }
+
+ }
+ }
+ });
+ }
///
/// 处理输入事件
///
@@ -582,6 +626,7 @@ namespace DownKyi.ViewModels
NoDataVisibility = Visibility.Collapsed;
VideoSections.Clear();
+ CaCheVideoSections.Clear();
}
///
@@ -642,6 +687,7 @@ namespace DownKyi.ViewModels
PropertyChangeAsync(new Action(() =>
{
VideoSections.Clear();
+ CaCheVideoSections.Clear();
}));
// 添加新数据
@@ -660,17 +706,27 @@ namespace DownKyi.ViewModels
IsSelected = true,
VideoPages = pages
});
+ CaCheVideoSections.Add(new VideoSection
+ {
+ Id = 0,
+ Title = "default",
+ IsSelected = true,
+ VideoPages = pages
+ });
}));
}
else
{
+ //这里如果浅拷贝会导致用于查询的CaCheVideoSections数据变化,所以这样处理
+ var videoSectionsStr = JsonConvert.SerializeObject(videoSections);
+ var videoSectionsData = JsonConvert.DeserializeObject>(videoSectionsStr);
PropertyChangeAsync(new Action(() =>
{
VideoSections.AddRange(videoSections);
+ CaCheVideoSections.AddRange(videoSectionsData);
}));
}
}
-
///
/// 解析视频流
///
diff --git a/DownKyi/Views/ViewVideoDetail.xaml b/DownKyi/Views/ViewVideoDetail.xaml
index 0c62303..422fa33 100644
--- a/DownKyi/Views/ViewVideoDetail.xaml
+++ b/DownKyi/Views/ViewVideoDetail.xaml
@@ -694,7 +694,36 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+