发布v1.5.0-alpha3

pull/253/head v1.5.0-alpha3
leiurayer 3 years ago
parent cf41095725
commit 0caa3a6629

@ -1,5 +1,10 @@
# 更新日志 # 更新日志
* `2022/03/12` v1.5.0-alpha3
1. [修复] 当用户性别为保密时,程序闪退的问题。
2. [修复] 批量下载UP主视频时程序偶尔闪退的问题。
3. [修复] 其他已知问题。
* `2022/03/07` v1.5.0-alpha2 * `2022/03/07` v1.5.0-alpha2
1. [优化] 重构程序架构,解决一些已知问题。 1. [优化] 重构程序架构,解决一些已知问题。
2. [优化] 界面UI的显示与操作。 2. [优化] 界面UI的显示与操作。

@ -9,16 +9,14 @@
[全部更新日志](CHANGELOG.md) [全部更新日志](CHANGELOG.md)
* `2022/03/07` v1.5.0-alpha2 * `2022/03/12` v1.5.0-alpha3
1. [优化] 重构程序架构,解决一些已知问题。 1. [修复] 当用户性别为保密时,程序闪退的问题。
2. [优化] 界面UI的显示与操作。 2. [修复] 批量下载UP主视频时程序偶尔闪退的问题。
3. [新增] 文件命名格式avid、bvid、cid、UP主信息、视频发布时间。 3. [修复] 其他已知问题。
4. [修复] 视频音质列表导致的闪退问题。
5. [修复] 图片下载导致的闪退问题。
## 下载 ## 下载
- [哔哩下载姬最新版](https://github.com/FlySelfLog/downkyi/releases/download/v1.5.0-alpha2/DownKyi-1.5.0-alpha2.zip) - [哔哩下载姬最新版](https://github.com/FlySelfLog/downkyi/releases/download/v1.5.0-alpha3/DownKyi-1.5.0-alpha3.zip)
- [下载页面](https://github.com/FlySelfLog/downkyi/releases) - [下载页面](https://github.com/FlySelfLog/downkyi/releases)

@ -7,6 +7,6 @@
public VideoSettings Video { get; set; } = new VideoSettings(); public VideoSettings Video { get; set; } = new VideoSettings();
public DanmakuSettings Danmaku { get; set; } = new DanmakuSettings(); public DanmakuSettings Danmaku { get; set; } = new DanmakuSettings();
public AboutSettings About { get; set; } = new AboutSettings(); public AboutSettings About { get; set; } = new AboutSettings();
public UserInfoSettings UserInfo { get; set; } public UserInfoSettings UserInfo { get; set; } = new UserInfoSettings();
} }
} }

@ -82,16 +82,16 @@ namespace DownKyi.Core.Settings
/// <returns></returns> /// <returns></returns>
private bool SetSettings() private bool SetSettings()
{ {
string json = JsonConvert.SerializeObject(appSettings); try
{
string json = JsonConvert.SerializeObject(appSettings);
#if DEBUG #if DEBUG
#else #else
// 加密字符串 // 加密字符串
json = Encryptor.EncryptString(json, password); json = Encryptor.EncryptString(json, password);
#endif #endif
try
{
File.WriteAllText(settingsName, json); File.WriteAllText(settingsName, json);
return true; return true;
} }

@ -7,9 +7,14 @@ namespace DownKyi.Core.Storage.Database
public class CoverDb public class CoverDb
{ {
private const string key = "b5018ecc-09d1-4da2-aa49-4625e41e623e"; private const string key = "b5018ecc-09d1-4da2-aa49-4625e41e623e";
private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetCoverIndex(), key);
private readonly string tableName = "cover"; private readonly string tableName = "cover";
#if DEBUG
private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetCoverIndex().Replace(".db", "_debug.db"));
#else
private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetCoverIndex(), key);
#endif
public CoverDb() public CoverDb()
{ {
CreateTable(); CreateTable();
@ -103,21 +108,30 @@ namespace DownKyi.Core.Storage.Database
{ {
List<Cover> covers = new List<Cover>(); List<Cover> covers = new List<Cover>();
dbHelper.ExecuteQuery(sql, reader => try
{ {
while (reader.Read()) dbHelper.ExecuteQuery(sql, reader =>
{ {
Cover cover = new Cover while (reader.Read())
{ {
Avid = (long)reader["avid"], Cover cover = new Cover
Bvid = (string)reader["bvid"], {
Cid = (long)reader["cid"], Avid = (long)reader["avid"],
Url = (string)reader["url"], Bvid = (string)reader["bvid"],
Md5 = (string)reader["md5"] Cid = (long)reader["cid"],
}; Url = (string)reader["url"],
covers.Add(cover); Md5 = (string)reader["md5"]
} };
}); covers.Add(cover);
}
});
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("Query()发生异常: {0}", e);
LogManager.Error($"{tableName}", e);
}
return covers; return covers;
} }

@ -14,7 +14,7 @@ namespace DownKyi.Core.Storage.Database.Download
protected string tableName = "download"; protected string tableName = "download";
#if DEBUG #if DEBUG
private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetDownload().Replace(".db","_debug.db")); private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetDownload().Replace(".db", "_debug.db"));
#else #else
private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetDownload(), key); private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetDownload(), key);
#endif #endif
@ -33,25 +33,25 @@ namespace DownKyi.Core.Storage.Database.Download
/// <param name="obj"></param> /// <param name="obj"></param>
public void Insert(string uuid, object obj) public void Insert(string uuid, object obj)
{ {
// 定义一个流 try
Stream stream = new MemoryStream(); {
// 定义一个格式化器 // 定义一个流
BinaryFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream();
// 序列化 // 定义一个格式化器
formatter.Serialize(stream, obj); BinaryFormatter formatter = new BinaryFormatter();
// 序列化
formatter.Serialize(stream, obj);
byte[] array = null; byte[] array = null;
array = new byte[stream.Length]; array = new byte[stream.Length];
//将二进制流写入数组 //将二进制流写入数组
stream.Position = 0; stream.Position = 0;
stream.Read(array, 0, (int)stream.Length); stream.Read(array, 0, (int)stream.Length);
//关闭流 //关闭流
stream.Close(); stream.Close();
try
{
string sql = $"insert into {tableName}(id, data) values (@id, @data)"; string sql = $"insert into {tableName}(id, data) values (@id, @data)";
dbHelper.ExecuteNonQuery(sql, new Action<SQLiteParameterCollection>((para) => dbHelper.ExecuteNonQuery(sql, new Action<SQLiteParameterCollection>((para) =>
{ {
@ -86,25 +86,25 @@ namespace DownKyi.Core.Storage.Database.Download
public void Update(string uuid, object obj) public void Update(string uuid, object obj)
{ {
// 定义一个流 try
Stream stream = new MemoryStream(); {
// 定义一个格式化器 // 定义一个流
BinaryFormatter formatter = new BinaryFormatter(); Stream stream = new MemoryStream();
// 序列化 // 定义一个格式化器
formatter.Serialize(stream, obj); BinaryFormatter formatter = new BinaryFormatter();
// 序列化
formatter.Serialize(stream, obj);
byte[] array = null; byte[] array = null;
array = new byte[stream.Length]; array = new byte[stream.Length];
//将二进制流写入数组 //将二进制流写入数组
stream.Position = 0; stream.Position = 0;
stream.Read(array, 0, (int)stream.Length); stream.Read(array, 0, (int)stream.Length);
//关闭流 //关闭流
stream.Close(); stream.Close();
try
{
string sql = $"update {tableName} set data=@data where id glob @id"; string sql = $"update {tableName} set data=@data where id glob @id";
dbHelper.ExecuteNonQuery(sql, new Action<SQLiteParameterCollection>((para) => dbHelper.ExecuteNonQuery(sql, new Action<SQLiteParameterCollection>((para) =>
{ {
@ -160,22 +160,31 @@ namespace DownKyi.Core.Storage.Database.Download
{ {
Dictionary<string, object> objects = new Dictionary<string, object>(); Dictionary<string, object> objects = new Dictionary<string, object>();
dbHelper.ExecuteQuery(sql, reader => try
{ {
while (reader.Read()) dbHelper.ExecuteQuery(sql, reader =>
{ {
// 读取字节数组 while (reader.Read())
byte[] array = (byte[])reader["data"]; {
// 定义一个流 // 读取字节数组
MemoryStream stream = new MemoryStream(array); byte[] array = (byte[])reader["data"];
//定义一个格式化器 // 定义一个流
BinaryFormatter formatter = new BinaryFormatter(); MemoryStream stream = new MemoryStream(array);
// 反序列化 //定义一个格式化器
object obj = formatter.Deserialize(stream); BinaryFormatter formatter = new BinaryFormatter();
// 反序列化
objects.Add((string)reader["id"], obj); object obj = formatter.Deserialize(stream);
}
}); objects.Add((string)reader["id"], obj);
}
});
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("Query()发生异常: {0}", e);
LogManager.Error($"{tableName}", e);
}
return objects; return objects;
} }

@ -7,9 +7,14 @@ namespace DownKyi.Core.Storage.Database
public class HeaderDb public class HeaderDb
{ {
private const string key = "7c1f1f40-7cdf-4d11-ad28-f0137a3c5308"; private const string key = "7c1f1f40-7cdf-4d11-ad28-f0137a3c5308";
private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetHeaderIndex(), key);
private readonly string tableName = "header"; private readonly string tableName = "header";
#if DEBUG
private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetHeaderIndex().Replace(".db", "_debug.db"));
#else
private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetHeaderIndex(), key);
#endif
public HeaderDb() public HeaderDb()
{ {
CreateTable(); CreateTable();
@ -90,20 +95,29 @@ namespace DownKyi.Core.Storage.Database
{ {
List<Header> headers = new List<Header>(); List<Header> headers = new List<Header>();
dbHelper.ExecuteQuery(sql, reader => try
{ {
while (reader.Read()) dbHelper.ExecuteQuery(sql, reader =>
{ {
Header header = new Header while (reader.Read())
{ {
Mid = (long)reader["mid"], Header header = new Header
Name = (string)reader["name"], {
Url = (string)reader["url"], Mid = (long)reader["mid"],
Md5 = (string)reader["md5"] Name = (string)reader["name"],
}; Url = (string)reader["url"],
headers.Add(header); Md5 = (string)reader["md5"]
} };
}); headers.Add(header);
}
});
}
catch (Exception e)
{
Utils.Debugging.Console.PrintLine("Query()发生异常: {0}", e);
LogManager.Error($"{tableName}", e);
}
return headers; return headers;
} }

@ -1,4 +1,6 @@
using System.IO; using DownKyi.Core.Logging;
using System;
using System.IO;
namespace DownKyi.Core.Utils namespace DownKyi.Core.Utils
{ {
@ -11,17 +13,26 @@ namespace DownKyi.Core.Utils
/// <returns></returns> /// <returns></returns>
public static long GetHardDiskSpace(string hardDiskName) public static long GetHardDiskSpace(string hardDiskName)
{ {
long totalSize = new long(); long totalSize = 0;
hardDiskName = $"{hardDiskName}:\\";
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives) try
{ {
if (drive.Name == hardDiskName) hardDiskName = $"{hardDiskName}:\\";
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{ {
totalSize = drive.TotalSize; if (drive.Name == hardDiskName)
{
totalSize = drive.TotalSize;
}
} }
} }
catch (Exception e)
{
Debugging.Console.PrintLine("GetHardDiskSpace()发生异常: {0}", e);
LogManager.Error("HardDisk", e);
}
return totalSize; return totalSize;
} }
@ -33,17 +44,25 @@ namespace DownKyi.Core.Utils
/// <returns></returns> /// <returns></returns>
public static long GetHardDiskFreeSpace(string hardDiskName) public static long GetHardDiskFreeSpace(string hardDiskName)
{ {
long freeSpace = new long(); long freeSpace = 0;
hardDiskName = $"{hardDiskName}:\\"; try
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{ {
if (drive.Name == hardDiskName) hardDiskName = $"{hardDiskName}:\\";
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo drive in drives)
{ {
freeSpace = drive.TotalFreeSpace; if (drive.Name == hardDiskName)
{
freeSpace = drive.TotalFreeSpace;
}
} }
} }
catch (Exception e)
{
Debugging.Console.PrintLine("GetHardDiskFreeSpace()发生异常: {0}", e);
LogManager.Error("HardDisk", e);
}
return freeSpace; return freeSpace;
} }

@ -3,12 +3,12 @@
public class AppInfo public class AppInfo
{ {
public string Name { get; } = "哔哩下载姬"; public string Name { get; } = "哔哩下载姬";
public int VersionCode { get; } = 501; public int VersionCode { get; } = 502;
#if DEBUG #if DEBUG
public string VersionName { get; } = "1.5.0-alpha2 Debug"; public string VersionName { get; } = "1.5.0-alpha3 Debug";
#else #else
public string VersionName { get; } = "1.5.0-alpha2"; public string VersionName { get; } = "1.5.0-alpha3";
#endif #endif
} }

@ -173,6 +173,32 @@ namespace DownKyi.Services
Name = name, Name = name,
Duration = "N/A" Duration = "N/A"
}; };
// UP主信息
if (bangumiSeason.UpInfo != null)
{
page.Owner = new Core.BiliApi.Models.VideoOwner
{
Name = bangumiSeason.UpInfo.Name,
Face = bangumiSeason.UpInfo.Avatar,
Mid = bangumiSeason.UpInfo.Mid,
};
}
else
{
page.Owner = new Core.BiliApi.Models.VideoOwner
{
Name = "",
Face = "",
Mid = -1,
};
}
// 视频发布时间
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
DateTime dateTime = startTime.AddSeconds(episode.PubTime);
page.PublishTime = dateTime.ToString("yyyy-MM-dd");
pages.Add(page); pages.Add(page);
} }

@ -185,7 +185,7 @@ namespace DownKyi.Services.Download
// 下载设置dialog中如果点击取消或者关闭窗口 // 下载设置dialog中如果点击取消或者关闭窗口
// 会返回空字符串, // 会返回空字符串,
// 这时直接退出 // 这时直接退出
if (directory == string.Empty) { return null; } if (directory == null || directory == string.Empty) { return null; }
// 文件夹不存在则创建 // 文件夹不存在则创建
if (!Directory.Exists(directory)) if (!Directory.Exists(directory))
@ -207,6 +207,8 @@ namespace DownKyi.Services.Download
// 添加到下载 // 添加到下载
foreach (VideoSection section in videoSections) foreach (VideoSection section in videoSections)
{ {
if (section.VideoPages == null) { continue; }
foreach (VideoPage page in section.VideoPages) foreach (VideoPage page in section.VideoPages)
{ {
// 只下载选中项,跳过未选中项 // 只下载选中项,跳过未选中项
@ -338,49 +340,49 @@ namespace DownKyi.Services.Download
break; break;
} }
// 如果不存在,直接添加到下载列表
DownloadBase downloadBase = new DownloadBase
{
Bvid = page.Bvid,
Avid = page.Avid,
Cid = page.Cid,
EpisodeId = page.EpisodeId,
CoverUrl = videoInfoView.CoverUrl,
PageCoverUrl = page.FirstFrame,
ZoneId = zoneId,
FilePath = filePath,
Order = page.Order,
MainTitle = videoInfoView.Title,
Name = page.Name,
Duration = page.Duration,
VideoCodecName = page.VideoQuality.SelectedVideoCodec,
Resolution = new Quality { Name = page.VideoQuality.QualityFormat, Id = page.VideoQuality.Quality },
AudioCodec = Constant.GetAudioQualities().FirstOrDefault(t => { return t.Name == page.AudioQualityFormat; }),
};
Downloading downloading = new Downloading
{
PlayStreamType = playStreamType,
DownloadStatus = DownloadStatus.NOT_STARTED,
};
// 需要下载的内容
downloadBase.NeedDownloadContent["downloadAudio"] = downloadAudio;
downloadBase.NeedDownloadContent["downloadVideo"] = downloadVideo;
downloadBase.NeedDownloadContent["downloadDanmaku"] = downloadDanmaku;
downloadBase.NeedDownloadContent["downloadSubtitle"] = downloadSubtitle;
downloadBase.NeedDownloadContent["downloadCover"] = downloadCover;
DownloadingItem downloadingItem = new DownloadingItem
{
DownloadBase = downloadBase,
Downloading = downloading,
PlayUrl = page.PlayUrl,
};
// 添加到下载列表 // 添加到下载列表
App.PropertyChangeAsync(new Action(() => App.PropertyChangeAsync(new Action(() =>
{ {
// 如果不存在,直接添加到下载列表
DownloadBase downloadBase = new DownloadBase
{
Bvid = page.Bvid,
Avid = page.Avid,
Cid = page.Cid,
EpisodeId = page.EpisodeId,
CoverUrl = videoInfoView.CoverUrl,
PageCoverUrl = page.FirstFrame,
ZoneId = zoneId,
FilePath = filePath,
Order = page.Order,
MainTitle = videoInfoView.Title,
Name = page.Name,
Duration = page.Duration,
VideoCodecName = page.VideoQuality.SelectedVideoCodec,
Resolution = new Quality { Name = page.VideoQuality.QualityFormat, Id = page.VideoQuality.Quality },
AudioCodec = Constant.GetAudioQualities().FirstOrDefault(t => { return t.Name == page.AudioQualityFormat; }),
};
Downloading downloading = new Downloading
{
PlayStreamType = playStreamType,
DownloadStatus = DownloadStatus.NOT_STARTED,
};
// 需要下载的内容
downloadBase.NeedDownloadContent["downloadAudio"] = downloadAudio;
downloadBase.NeedDownloadContent["downloadVideo"] = downloadVideo;
downloadBase.NeedDownloadContent["downloadDanmaku"] = downloadDanmaku;
downloadBase.NeedDownloadContent["downloadSubtitle"] = downloadSubtitle;
downloadBase.NeedDownloadContent["downloadCover"] = downloadCover;
DownloadingItem downloadingItem = new DownloadingItem
{
DownloadBase = downloadBase,
Downloading = downloading,
PlayUrl = page.PlayUrl,
};
App.DownloadingList.Add(downloadingItem); App.DownloadingList.Add(downloadingItem);
Thread.Sleep(10); Thread.Sleep(10);
})); }));

@ -138,6 +138,28 @@ namespace DownKyi.Services
Name = episode.Title, Name = episode.Title,
Duration = "N/A" Duration = "N/A"
}; };
// UP主信息
page.Owner = videoView.Owner;
if (page.Owner == null)
{
page.Owner = new Core.BiliApi.Models.VideoOwner
{
Name = "",
Face = "",
Mid = -1,
};
}
// 视频发布时间
DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)); // 当地时区
DateTime dateTime = startTime.AddSeconds(videoView.Pubdate);
page.PublishTime = dateTime.ToString("yyyy-MM-dd");
// 这里的发布时间有问题,
// 如果是合集,也会执行这里,
// 但是发布时间是入口视频的,不是所有视频的
// TODO 修复
pages.Add(page); pages.Add(page);
} }

@ -56,7 +56,7 @@ namespace DownKyi.ViewModels.Dialogs
{ {
SetProperty(ref directory, value); SetProperty(ref directory, value);
if (directory != string.Empty) if (directory != null && directory != string.Empty)
{ {
DriveName = directory.Substring(0, 1).ToUpper(); DriveName = directory.Substring(0, 1).ToUpper();
DriveNameFreeSpace = Format.FormatFileSize(HardDisk.GetHardDiskFreeSpace(DriveName)); DriveNameFreeSpace = Format.FormatFileSize(HardDisk.GetHardDiskFreeSpace(DriveName));
@ -381,7 +381,7 @@ namespace DownKyi.ViewModels.Dialogs
// 弹出选择下载目录的窗口 // 弹出选择下载目录的窗口
path = DialogUtils.SetDownloadDirectory(); path = DialogUtils.SetDownloadDirectory();
if (path == null || path == "") if (path == null || path == string.Empty)
{ {
return null; return null;
} }

@ -276,7 +276,7 @@ namespace DownKyi.ViewModels
} }
// 通知用户添加到下载列表的结果 // 通知用户添加到下载列表的结果
if (i == 0) if (i <= 0)
{ {
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
} }

@ -329,7 +329,7 @@ namespace DownKyi.ViewModels
} }
// 通知用户添加到下载列表的结果 // 通知用户添加到下载列表的结果
if (i == 0) if (i <= 0)
{ {
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
} }

@ -358,7 +358,7 @@ namespace DownKyi.ViewModels
} }
// 通知用户添加到下载列表的结果 // 通知用户添加到下载列表的结果
if (i == 0) if (i <= 0)
{ {
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
} }

@ -272,7 +272,7 @@ namespace DownKyi.ViewModels
} }
// 通知用户添加到下载列表的结果 // 通知用户添加到下载列表的结果
if (i == 0) if (i <= 0)
{ {
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
} }

@ -526,7 +526,7 @@ namespace DownKyi.ViewModels
StorageHeader storageHeader = new StorageHeader(); StorageHeader storageHeader = new StorageHeader();
Header = storageHeader.GetHeaderThumbnail(headerUri, 64, 64); Header = storageHeader.GetHeaderThumbnail(headerUri, 64, 64);
// 性别 // 性别
Sex = new BitmapImage(sexUri); Sex = sexUri == null ? null : new BitmapImage(sexUri);
// 等级 // 等级
Level = new BitmapImage(levelUri); Level = new BitmapImage(levelUri);

@ -258,7 +258,7 @@ namespace DownKyi.ViewModels
} }
// 通知用户添加到下载列表的结果 // 通知用户添加到下载列表的结果
if (i == 0) if (i <= 0)
{ {
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
} }

@ -279,7 +279,7 @@ namespace DownKyi.ViewModels
} }
// 通知用户添加到下载列表的结果 // 通知用户添加到下载列表的结果
if (i == 0) if (i <= 0)
{ {
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
} }

@ -313,7 +313,7 @@ namespace DownKyi.ViewModels
} }
// 通知用户添加到下载列表的结果 // 通知用户添加到下载列表的结果
if (i == 0) if (i <= 0)
{ {
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
} }

@ -29,6 +29,9 @@ namespace DownKyi.ViewModels
private readonly IDialogService dialogService; private readonly IDialogService dialogService;
// 保存输入字符串,避免被用户修改
private string input;
#region 页面属性申明 #region 页面属性申明
private VectorImage arrowBack; private VectorImage arrowBack;
@ -184,8 +187,10 @@ namespace DownKyi.ViewModels
LogManager.Debug(Tag, $"InputText: {InputText}"); LogManager.Debug(Tag, $"InputText: {InputText}");
input = InputText;
// 更新页面 // 更新页面
UnityUpdateView(UpdateView, InputText, null); UnityUpdateView(UpdateView, input, null);
// 是否自动解析视频 // 是否自动解析视频
if (SettingsManager.GetInstance().IsAutoParseVideo() == AllowStatus.YES) if (SettingsManager.GetInstance().IsAutoParseVideo() == AllowStatus.YES)
@ -362,7 +367,7 @@ namespace DownKyi.ViewModels
{ {
LogManager.Debug(Tag, $"Video Page: {videoPage.Cid}"); LogManager.Debug(Tag, $"Video Page: {videoPage.Cid}");
UnityUpdateView(ParseVideo, null, videoPage); UnityUpdateView(ParseVideo, input, videoPage);
}); });
} }
catch (Exception e) catch (Exception e)
@ -430,12 +435,10 @@ namespace DownKyi.ViewModels
{ {
foreach (VideoPage page in section.VideoPages) foreach (VideoPage page in section.VideoPages)
{ {
//VideoPage videoPage = section.VideoPages.FirstOrDefault(t => t == page);
if (page.IsSelected) if (page.IsSelected)
{ {
// 执行解析任务 // 执行解析任务
UnityUpdateView(ParseVideo, null, page); UnityUpdateView(ParseVideo, input, page);
} }
} }
} }
@ -447,10 +450,8 @@ namespace DownKyi.ViewModels
{ {
foreach (VideoPage page in section.VideoPages) foreach (VideoPage page in section.VideoPages)
{ {
//VideoPage videoPage = section.VideoPages.FirstOrDefault(t => t == page);
// 执行解析任务 // 执行解析任务
UnityUpdateView(ParseVideo, null, page); UnityUpdateView(ParseVideo, input, page);
} }
} }
} }
@ -460,10 +461,8 @@ namespace DownKyi.ViewModels
{ {
foreach (VideoPage page in section.VideoPages) foreach (VideoPage page in section.VideoPages)
{ {
//VideoPage videoPage = section.VideoPages.FirstOrDefault(t => t == page);
// 执行解析任务 // 执行解析任务
UnityUpdateView(ParseVideo, null, page); UnityUpdateView(ParseVideo, input, page);
} }
} }
break; break;
@ -503,20 +502,24 @@ namespace DownKyi.ViewModels
{ {
AddToDownloadService addToDownloadService = null; AddToDownloadService addToDownloadService = null;
// 视频 // 视频
if (ParseEntrance.IsAvUrl(InputText) || ParseEntrance.IsBvUrl(InputText)) if (ParseEntrance.IsAvUrl(input) || ParseEntrance.IsBvUrl(input))
{ {
addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO); addToDownloadService = new AddToDownloadService(PlayStreamType.VIDEO);
} }
// 番剧(电影、电视剧) // 番剧(电影、电视剧)
if (ParseEntrance.IsBangumiSeasonUrl(InputText) || ParseEntrance.IsBangumiEpisodeUrl(InputText) || ParseEntrance.IsBangumiMediaUrl(InputText)) else if (ParseEntrance.IsBangumiSeasonUrl(input) || ParseEntrance.IsBangumiEpisodeUrl(input) || ParseEntrance.IsBangumiMediaUrl(input))
{ {
addToDownloadService = new AddToDownloadService(PlayStreamType.BANGUMI); addToDownloadService = new AddToDownloadService(PlayStreamType.BANGUMI);
} }
// 课程 // 课程
if (ParseEntrance.IsCheeseSeasonUrl(InputText) || ParseEntrance.IsCheeseEpisodeUrl(InputText)) else if (ParseEntrance.IsCheeseSeasonUrl(input) || ParseEntrance.IsCheeseEpisodeUrl(input))
{ {
addToDownloadService = new AddToDownloadService(PlayStreamType.CHEESE); addToDownloadService = new AddToDownloadService(PlayStreamType.CHEESE);
} }
else
{
return;
}
// 选择文件夹 // 选择文件夹
string directory = addToDownloadService.SetDirectory(dialogService); string directory = addToDownloadService.SetDirectory(dialogService);
@ -531,8 +534,13 @@ namespace DownKyi.ViewModels
i = addToDownloadService.AddToDownload(eventAggregator, directory); i = addToDownloadService.AddToDownload(eventAggregator, directory);
}); });
if (directory == null)
{
return;
}
// 通知用户添加到下载列表的结果 // 通知用户添加到下载列表的结果
if (i == 0) if (i <= 0)
{ {
eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero")); eventAggregator.GetEvent<MessageEvent>().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
} }
@ -578,19 +586,19 @@ namespace DownKyi.ViewModels
private void UnityUpdateView(Action<IInfoService, VideoPage> action, string input, VideoPage page) private void UnityUpdateView(Action<IInfoService, VideoPage> action, string input, VideoPage page)
{ {
// 视频 // 视频
if (ParseEntrance.IsAvUrl(InputText) || ParseEntrance.IsBvUrl(InputText)) if (ParseEntrance.IsAvUrl(input) || ParseEntrance.IsBvUrl(input))
{ {
action(new VideoInfoService(input), page); action(new VideoInfoService(input), page);
} }
// 番剧(电影、电视剧) // 番剧(电影、电视剧)
if (ParseEntrance.IsBangumiSeasonUrl(InputText) || ParseEntrance.IsBangumiEpisodeUrl(InputText) || ParseEntrance.IsBangumiMediaUrl(InputText)) if (ParseEntrance.IsBangumiSeasonUrl(input) || ParseEntrance.IsBangumiEpisodeUrl(input) || ParseEntrance.IsBangumiMediaUrl(input))
{ {
action(new BangumiInfoService(input), page); action(new BangumiInfoService(input), page);
} }
// 课程 // 课程
if (ParseEntrance.IsCheeseSeasonUrl(InputText) || ParseEntrance.IsCheeseEpisodeUrl(InputText)) if (ParseEntrance.IsCheeseSeasonUrl(input) || ParseEntrance.IsCheeseEpisodeUrl(input))
{ {
action(new CheeseInfoService(input), page); action(new CheeseInfoService(input), page);
} }

Loading…
Cancel
Save