From 0caa3a66296ab66e179631a323b80fdcb95684de Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Sat, 12 Mar 2022 02:34:33 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E5=B8=83v1.5.0-alpha3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 5 +
README.md | 12 +--
.../Settings/Models/AppSettings.cs | 2 +-
src/DownKyi.Core/Settings/SettingsManager.cs | 10 +-
src/DownKyi.Core/Storage/Database/CoverDb.cs | 40 +++++---
.../Storage/Database/Download/DownloadDb.cs | 99 ++++++++++---------
src/DownKyi.Core/Storage/Database/HeaderDb.cs | 38 ++++---
src/DownKyi.Core/Utils/HardDisk.cs | 47 ++++++---
src/DownKyi/Models/AppInfo.cs | 6 +-
src/DownKyi/Services/BangumiInfoService.cs | 26 +++++
.../Services/Download/AddToDownloadService.cs | 84 ++++++++--------
src/DownKyi/Services/VideoInfoService.cs | 22 +++++
.../Dialogs/ViewDownloadSetterViewModel.cs | 4 +-
.../ViewModels/ViewChannelViewModel.cs | 2 +-
.../ViewMyBangumiFollowViewModel.cs | 2 +-
.../ViewModels/ViewMyFavoritesViewModel.cs | 2 +-
.../ViewModels/ViewMyHistoryViewModel.cs | 2 +-
.../ViewModels/ViewMySpaceViewModel.cs | 2 +-
.../ViewModels/ViewMyToViewVideoViewModel.cs | 2 +-
.../ViewPublicFavoritesViewModel.cs | 2 +-
.../ViewModels/ViewPublicationViewModel.cs | 2 +-
.../ViewModels/ViewVideoDetailViewModel.cs | 44 +++++----
22 files changed, 286 insertions(+), 169 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ef9e1da..80cceed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# 更新日志
+* `2022/03/12` v1.5.0-alpha3
+ 1. [修复] 当用户性别为保密时,程序闪退的问题。
+ 2. [修复] 批量下载UP主视频时,程序偶尔闪退的问题。
+ 3. [修复] 其他已知问题。
+
* `2022/03/07` v1.5.0-alpha2
1. [优化] 重构程序架构,解决一些已知问题。
2. [优化] 界面UI的显示与操作。
diff --git a/README.md b/README.md
index 1e67aff..d831891 100644
--- a/README.md
+++ b/README.md
@@ -9,16 +9,14 @@
[全部更新日志](CHANGELOG.md)
-* `2022/03/07` v1.5.0-alpha2
- 1. [优化] 重构程序架构,解决一些已知问题。
- 2. [优化] 界面UI的显示与操作。
- 3. [新增] 文件命名格式:avid、bvid、cid、UP主信息、视频发布时间。
- 4. [修复] 视频音质列表导致的闪退问题。
- 5. [修复] 图片下载导致的闪退问题。
+* `2022/03/12` v1.5.0-alpha3
+ 1. [修复] 当用户性别为保密时,程序闪退的问题。
+ 2. [修复] 批量下载UP主视频时,程序偶尔闪退的问题。
+ 3. [修复] 其他已知问题。
## 下载
-- [哔哩下载姬最新版](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)
diff --git a/src/DownKyi.Core/Settings/Models/AppSettings.cs b/src/DownKyi.Core/Settings/Models/AppSettings.cs
index 6285a91..197dbe4 100644
--- a/src/DownKyi.Core/Settings/Models/AppSettings.cs
+++ b/src/DownKyi.Core/Settings/Models/AppSettings.cs
@@ -7,6 +7,6 @@
public VideoSettings Video { get; set; } = new VideoSettings();
public DanmakuSettings Danmaku { get; set; } = new DanmakuSettings();
public AboutSettings About { get; set; } = new AboutSettings();
- public UserInfoSettings UserInfo { get; set; }
+ public UserInfoSettings UserInfo { get; set; } = new UserInfoSettings();
}
}
diff --git a/src/DownKyi.Core/Settings/SettingsManager.cs b/src/DownKyi.Core/Settings/SettingsManager.cs
index cbed751..a5da781 100644
--- a/src/DownKyi.Core/Settings/SettingsManager.cs
+++ b/src/DownKyi.Core/Settings/SettingsManager.cs
@@ -82,16 +82,16 @@ namespace DownKyi.Core.Settings
///
private bool SetSettings()
{
- string json = JsonConvert.SerializeObject(appSettings);
+ try
+ {
+ string json = JsonConvert.SerializeObject(appSettings);
#if DEBUG
#else
- // 加密字符串
- json = Encryptor.EncryptString(json, password);
+ // 加密字符串
+ json = Encryptor.EncryptString(json, password);
#endif
- try
- {
File.WriteAllText(settingsName, json);
return true;
}
diff --git a/src/DownKyi.Core/Storage/Database/CoverDb.cs b/src/DownKyi.Core/Storage/Database/CoverDb.cs
index 8bca281..9576116 100644
--- a/src/DownKyi.Core/Storage/Database/CoverDb.cs
+++ b/src/DownKyi.Core/Storage/Database/CoverDb.cs
@@ -7,9 +7,14 @@ namespace DownKyi.Core.Storage.Database
public class CoverDb
{
private const string key = "b5018ecc-09d1-4da2-aa49-4625e41e623e";
- private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetCoverIndex(), key);
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()
{
CreateTable();
@@ -103,21 +108,30 @@ namespace DownKyi.Core.Storage.Database
{
List covers = new List();
- dbHelper.ExecuteQuery(sql, reader =>
+ try
{
- while (reader.Read())
+ dbHelper.ExecuteQuery(sql, reader =>
{
- Cover cover = new Cover
+ while (reader.Read())
{
- Avid = (long)reader["avid"],
- Bvid = (string)reader["bvid"],
- Cid = (long)reader["cid"],
- Url = (string)reader["url"],
- Md5 = (string)reader["md5"]
- };
- covers.Add(cover);
- }
- });
+ Cover cover = new Cover
+ {
+ Avid = (long)reader["avid"],
+ Bvid = (string)reader["bvid"],
+ Cid = (long)reader["cid"],
+ Url = (string)reader["url"],
+ Md5 = (string)reader["md5"]
+ };
+ covers.Add(cover);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ Utils.Debugging.Console.PrintLine("Query()发生异常: {0}", e);
+ LogManager.Error($"{tableName}", e);
+ }
+
return covers;
}
diff --git a/src/DownKyi.Core/Storage/Database/Download/DownloadDb.cs b/src/DownKyi.Core/Storage/Database/Download/DownloadDb.cs
index 7d1b0c5..f32c9c9 100644
--- a/src/DownKyi.Core/Storage/Database/Download/DownloadDb.cs
+++ b/src/DownKyi.Core/Storage/Database/Download/DownloadDb.cs
@@ -14,7 +14,7 @@ namespace DownKyi.Core.Storage.Database.Download
protected string tableName = "download";
#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
private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetDownload(), key);
#endif
@@ -33,25 +33,25 @@ namespace DownKyi.Core.Storage.Database.Download
///
public void Insert(string uuid, object obj)
{
- // 定义一个流
- Stream stream = new MemoryStream();
- // 定义一个格式化器
- BinaryFormatter formatter = new BinaryFormatter();
- // 序列化
- formatter.Serialize(stream, obj);
+ try
+ {
+ // 定义一个流
+ Stream stream = new MemoryStream();
+ // 定义一个格式化器
+ BinaryFormatter formatter = new BinaryFormatter();
+ // 序列化
+ formatter.Serialize(stream, obj);
- byte[] array = null;
- array = new byte[stream.Length];
+ byte[] array = null;
+ array = new byte[stream.Length];
- //将二进制流写入数组
- stream.Position = 0;
- stream.Read(array, 0, (int)stream.Length);
+ //将二进制流写入数组
+ stream.Position = 0;
+ stream.Read(array, 0, (int)stream.Length);
- //关闭流
- stream.Close();
+ //关闭流
+ stream.Close();
- try
- {
string sql = $"insert into {tableName}(id, data) values (@id, @data)";
dbHelper.ExecuteNonQuery(sql, new Action((para) =>
{
@@ -86,25 +86,25 @@ namespace DownKyi.Core.Storage.Database.Download
public void Update(string uuid, object obj)
{
- // 定义一个流
- Stream stream = new MemoryStream();
- // 定义一个格式化器
- BinaryFormatter formatter = new BinaryFormatter();
- // 序列化
- formatter.Serialize(stream, obj);
+ try
+ {
+ // 定义一个流
+ Stream stream = new MemoryStream();
+ // 定义一个格式化器
+ BinaryFormatter formatter = new BinaryFormatter();
+ // 序列化
+ formatter.Serialize(stream, obj);
- byte[] array = null;
- array = new byte[stream.Length];
+ byte[] array = null;
+ array = new byte[stream.Length];
- //将二进制流写入数组
- stream.Position = 0;
- stream.Read(array, 0, (int)stream.Length);
+ //将二进制流写入数组
+ stream.Position = 0;
+ stream.Read(array, 0, (int)stream.Length);
- //关闭流
- stream.Close();
+ //关闭流
+ stream.Close();
- try
- {
string sql = $"update {tableName} set data=@data where id glob @id";
dbHelper.ExecuteNonQuery(sql, new Action((para) =>
{
@@ -160,22 +160,31 @@ namespace DownKyi.Core.Storage.Database.Download
{
Dictionary objects = new Dictionary();
- dbHelper.ExecuteQuery(sql, reader =>
+ try
{
- while (reader.Read())
+ dbHelper.ExecuteQuery(sql, reader =>
{
- // 读取字节数组
- byte[] array = (byte[])reader["data"];
- // 定义一个流
- MemoryStream stream = new MemoryStream(array);
- //定义一个格式化器
- BinaryFormatter formatter = new BinaryFormatter();
- // 反序列化
- object obj = formatter.Deserialize(stream);
-
- objects.Add((string)reader["id"], obj);
- }
- });
+ while (reader.Read())
+ {
+ // 读取字节数组
+ byte[] array = (byte[])reader["data"];
+ // 定义一个流
+ MemoryStream stream = new MemoryStream(array);
+ //定义一个格式化器
+ BinaryFormatter formatter = new BinaryFormatter();
+ // 反序列化
+ 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;
}
diff --git a/src/DownKyi.Core/Storage/Database/HeaderDb.cs b/src/DownKyi.Core/Storage/Database/HeaderDb.cs
index d1d11c2..28f9a48 100644
--- a/src/DownKyi.Core/Storage/Database/HeaderDb.cs
+++ b/src/DownKyi.Core/Storage/Database/HeaderDb.cs
@@ -7,9 +7,14 @@ namespace DownKyi.Core.Storage.Database
public class HeaderDb
{
private const string key = "7c1f1f40-7cdf-4d11-ad28-f0137a3c5308";
- private readonly DbHelper dbHelper = new DbHelper(StorageManager.GetHeaderIndex(), key);
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()
{
CreateTable();
@@ -90,20 +95,29 @@ namespace DownKyi.Core.Storage.Database
{
List headers = new List();
- dbHelper.ExecuteQuery(sql, reader =>
+ try
{
- while (reader.Read())
+ dbHelper.ExecuteQuery(sql, reader =>
{
- Header header = new Header
+ while (reader.Read())
{
- Mid = (long)reader["mid"],
- Name = (string)reader["name"],
- Url = (string)reader["url"],
- Md5 = (string)reader["md5"]
- };
- headers.Add(header);
- }
- });
+ Header header = new Header
+ {
+ Mid = (long)reader["mid"],
+ Name = (string)reader["name"],
+ Url = (string)reader["url"],
+ Md5 = (string)reader["md5"]
+ };
+ headers.Add(header);
+ }
+ });
+ }
+ catch (Exception e)
+ {
+ Utils.Debugging.Console.PrintLine("Query()发生异常: {0}", e);
+ LogManager.Error($"{tableName}", e);
+ }
+
return headers;
}
diff --git a/src/DownKyi.Core/Utils/HardDisk.cs b/src/DownKyi.Core/Utils/HardDisk.cs
index 046384d..9427ad1 100644
--- a/src/DownKyi.Core/Utils/HardDisk.cs
+++ b/src/DownKyi.Core/Utils/HardDisk.cs
@@ -1,4 +1,6 @@
-using System.IO;
+using DownKyi.Core.Logging;
+using System;
+using System.IO;
namespace DownKyi.Core.Utils
{
@@ -11,17 +13,26 @@ namespace DownKyi.Core.Utils
///
public static long GetHardDiskSpace(string hardDiskName)
{
- long totalSize = new long();
- hardDiskName = $"{hardDiskName}:\\";
- DriveInfo[] drives = DriveInfo.GetDrives();
+ long totalSize = 0;
- 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;
}
@@ -33,17 +44,25 @@ namespace DownKyi.Core.Utils
///
public static long GetHardDiskFreeSpace(string hardDiskName)
{
- long freeSpace = new long();
- hardDiskName = $"{hardDiskName}:\\";
- DriveInfo[] drives = DriveInfo.GetDrives();
-
- foreach (DriveInfo drive in drives)
+ long freeSpace = 0;
+ try
{
- 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;
}
diff --git a/src/DownKyi/Models/AppInfo.cs b/src/DownKyi/Models/AppInfo.cs
index c2ec5e5..c523818 100644
--- a/src/DownKyi/Models/AppInfo.cs
+++ b/src/DownKyi/Models/AppInfo.cs
@@ -3,12 +3,12 @@
public class AppInfo
{
public string Name { get; } = "哔哩下载姬";
- public int VersionCode { get; } = 501;
+ public int VersionCode { get; } = 502;
#if DEBUG
- public string VersionName { get; } = "1.5.0-alpha2 Debug";
+ public string VersionName { get; } = "1.5.0-alpha3 Debug";
#else
- public string VersionName { get; } = "1.5.0-alpha2";
+ public string VersionName { get; } = "1.5.0-alpha3";
#endif
}
diff --git a/src/DownKyi/Services/BangumiInfoService.cs b/src/DownKyi/Services/BangumiInfoService.cs
index a11443f..aebf31c 100644
--- a/src/DownKyi/Services/BangumiInfoService.cs
+++ b/src/DownKyi/Services/BangumiInfoService.cs
@@ -173,6 +173,32 @@ namespace DownKyi.Services
Name = name,
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);
}
diff --git a/src/DownKyi/Services/Download/AddToDownloadService.cs b/src/DownKyi/Services/Download/AddToDownloadService.cs
index f4b4ad3..f6d1273 100644
--- a/src/DownKyi/Services/Download/AddToDownloadService.cs
+++ b/src/DownKyi/Services/Download/AddToDownloadService.cs
@@ -185,7 +185,7 @@ namespace DownKyi.Services.Download
// 下载设置dialog中如果点击取消或者关闭窗口,
// 会返回空字符串,
// 这时直接退出
- if (directory == string.Empty) { return null; }
+ if (directory == null || directory == string.Empty) { return null; }
// 文件夹不存在则创建
if (!Directory.Exists(directory))
@@ -207,6 +207,8 @@ namespace DownKyi.Services.Download
// 添加到下载
foreach (VideoSection section in videoSections)
{
+ if (section.VideoPages == null) { continue; }
+
foreach (VideoPage page in section.VideoPages)
{
// 只下载选中项,跳过未选中项
@@ -338,49 +340,49 @@ namespace DownKyi.Services.Download
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(() =>
{
+ // 如果不存在,直接添加到下载列表
+ 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);
Thread.Sleep(10);
}));
diff --git a/src/DownKyi/Services/VideoInfoService.cs b/src/DownKyi/Services/VideoInfoService.cs
index bd927a3..bcb3561 100644
--- a/src/DownKyi/Services/VideoInfoService.cs
+++ b/src/DownKyi/Services/VideoInfoService.cs
@@ -138,6 +138,28 @@ namespace DownKyi.Services
Name = episode.Title,
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);
}
diff --git a/src/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs b/src/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs
index 6603ec7..c62b6aa 100644
--- a/src/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs
+++ b/src/DownKyi/ViewModels/Dialogs/ViewDownloadSetterViewModel.cs
@@ -56,7 +56,7 @@ namespace DownKyi.ViewModels.Dialogs
{
SetProperty(ref directory, value);
- if (directory != string.Empty)
+ if (directory != null && directory != string.Empty)
{
DriveName = directory.Substring(0, 1).ToUpper();
DriveNameFreeSpace = Format.FormatFileSize(HardDisk.GetHardDiskFreeSpace(DriveName));
@@ -381,7 +381,7 @@ namespace DownKyi.ViewModels.Dialogs
// 弹出选择下载目录的窗口
path = DialogUtils.SetDownloadDirectory();
- if (path == null || path == "")
+ if (path == null || path == string.Empty)
{
return null;
}
diff --git a/src/DownKyi/ViewModels/ViewChannelViewModel.cs b/src/DownKyi/ViewModels/ViewChannelViewModel.cs
index 4d5de5a..2bd5ec2 100644
--- a/src/DownKyi/ViewModels/ViewChannelViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewChannelViewModel.cs
@@ -276,7 +276,7 @@ namespace DownKyi.ViewModels
}
// 通知用户添加到下载列表的结果
- if (i == 0)
+ if (i <= 0)
{
eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
}
diff --git a/src/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs b/src/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs
index e082410..caa760e 100644
--- a/src/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewMyBangumiFollowViewModel.cs
@@ -329,7 +329,7 @@ namespace DownKyi.ViewModels
}
// 通知用户添加到下载列表的结果
- if (i == 0)
+ if (i <= 0)
{
eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
}
diff --git a/src/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs b/src/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs
index ce93ace..7e8e7bf 100644
--- a/src/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewMyFavoritesViewModel.cs
@@ -358,7 +358,7 @@ namespace DownKyi.ViewModels
}
// 通知用户添加到下载列表的结果
- if (i == 0)
+ if (i <= 0)
{
eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
}
diff --git a/src/DownKyi/ViewModels/ViewMyHistoryViewModel.cs b/src/DownKyi/ViewModels/ViewMyHistoryViewModel.cs
index 71dbe07..cafc2e3 100644
--- a/src/DownKyi/ViewModels/ViewMyHistoryViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewMyHistoryViewModel.cs
@@ -272,7 +272,7 @@ namespace DownKyi.ViewModels
}
// 通知用户添加到下载列表的结果
- if (i == 0)
+ if (i <= 0)
{
eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
}
diff --git a/src/DownKyi/ViewModels/ViewMySpaceViewModel.cs b/src/DownKyi/ViewModels/ViewMySpaceViewModel.cs
index eca6626..58d2f23 100644
--- a/src/DownKyi/ViewModels/ViewMySpaceViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewMySpaceViewModel.cs
@@ -526,7 +526,7 @@ namespace DownKyi.ViewModels
StorageHeader storageHeader = new StorageHeader();
Header = storageHeader.GetHeaderThumbnail(headerUri, 64, 64);
// 性别
- Sex = new BitmapImage(sexUri);
+ Sex = sexUri == null ? null : new BitmapImage(sexUri);
// 等级
Level = new BitmapImage(levelUri);
diff --git a/src/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs b/src/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs
index 6c8a13d..d55ab01 100644
--- a/src/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewMyToViewVideoViewModel.cs
@@ -258,7 +258,7 @@ namespace DownKyi.ViewModels
}
// 通知用户添加到下载列表的结果
- if (i == 0)
+ if (i <= 0)
{
eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
}
diff --git a/src/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs b/src/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs
index d5ca22f..2500437 100644
--- a/src/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewPublicFavoritesViewModel.cs
@@ -279,7 +279,7 @@ namespace DownKyi.ViewModels
}
// 通知用户添加到下载列表的结果
- if (i == 0)
+ if (i <= 0)
{
eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
}
diff --git a/src/DownKyi/ViewModels/ViewPublicationViewModel.cs b/src/DownKyi/ViewModels/ViewPublicationViewModel.cs
index 854004c..32047d7 100644
--- a/src/DownKyi/ViewModels/ViewPublicationViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewPublicationViewModel.cs
@@ -313,7 +313,7 @@ namespace DownKyi.ViewModels
}
// 通知用户添加到下载列表的结果
- if (i == 0)
+ if (i <= 0)
{
eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
}
diff --git a/src/DownKyi/ViewModels/ViewVideoDetailViewModel.cs b/src/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
index 15bf298..10b69c8 100644
--- a/src/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewVideoDetailViewModel.cs
@@ -29,6 +29,9 @@ namespace DownKyi.ViewModels
private readonly IDialogService dialogService;
+ // 保存输入字符串,避免被用户修改
+ private string input;
+
#region 页面属性申明
private VectorImage arrowBack;
@@ -184,8 +187,10 @@ namespace DownKyi.ViewModels
LogManager.Debug(Tag, $"InputText: {InputText}");
+ input = InputText;
+
// 更新页面
- UnityUpdateView(UpdateView, InputText, null);
+ UnityUpdateView(UpdateView, input, null);
// 是否自动解析视频
if (SettingsManager.GetInstance().IsAutoParseVideo() == AllowStatus.YES)
@@ -362,7 +367,7 @@ namespace DownKyi.ViewModels
{
LogManager.Debug(Tag, $"Video Page: {videoPage.Cid}");
- UnityUpdateView(ParseVideo, null, videoPage);
+ UnityUpdateView(ParseVideo, input, videoPage);
});
}
catch (Exception e)
@@ -430,12 +435,10 @@ namespace DownKyi.ViewModels
{
foreach (VideoPage page in section.VideoPages)
{
- //VideoPage videoPage = section.VideoPages.FirstOrDefault(t => t == page);
-
if (page.IsSelected)
{
// 执行解析任务
- UnityUpdateView(ParseVideo, null, page);
+ UnityUpdateView(ParseVideo, input, page);
}
}
}
@@ -447,10 +450,8 @@ namespace DownKyi.ViewModels
{
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)
{
- //VideoPage videoPage = section.VideoPages.FirstOrDefault(t => t == page);
-
// 执行解析任务
- UnityUpdateView(ParseVideo, null, page);
+ UnityUpdateView(ParseVideo, input, page);
}
}
break;
@@ -503,20 +502,24 @@ namespace DownKyi.ViewModels
{
AddToDownloadService addToDownloadService = null;
// 视频
- if (ParseEntrance.IsAvUrl(InputText) || ParseEntrance.IsBvUrl(InputText))
+ if (ParseEntrance.IsAvUrl(input) || ParseEntrance.IsBvUrl(input))
{
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);
}
// 课程
- if (ParseEntrance.IsCheeseSeasonUrl(InputText) || ParseEntrance.IsCheeseEpisodeUrl(InputText))
+ else if (ParseEntrance.IsCheeseSeasonUrl(input) || ParseEntrance.IsCheeseEpisodeUrl(input))
{
addToDownloadService = new AddToDownloadService(PlayStreamType.CHEESE);
}
+ else
+ {
+ return;
+ }
// 选择文件夹
string directory = addToDownloadService.SetDirectory(dialogService);
@@ -531,8 +534,13 @@ namespace DownKyi.ViewModels
i = addToDownloadService.AddToDownload(eventAggregator, directory);
});
+ if (directory == null)
+ {
+ return;
+ }
+
// 通知用户添加到下载列表的结果
- if (i == 0)
+ if (i <= 0)
{
eventAggregator.GetEvent().Publish(DictionaryResource.GetString("TipAddDownloadingZero"));
}
@@ -578,19 +586,19 @@ namespace DownKyi.ViewModels
private void UnityUpdateView(Action action, string input, VideoPage page)
{
// 视频
- if (ParseEntrance.IsAvUrl(InputText) || ParseEntrance.IsBvUrl(InputText))
+ if (ParseEntrance.IsAvUrl(input) || ParseEntrance.IsBvUrl(input))
{
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);
}
// 课程
- if (ParseEntrance.IsCheeseSeasonUrl(InputText) || ParseEntrance.IsCheeseEpisodeUrl(InputText))
+ if (ParseEntrance.IsCheeseSeasonUrl(input) || ParseEntrance.IsCheeseEpisodeUrl(input))
{
action(new CheeseInfoService(input), page);
}