Skip to content

Commit

Permalink
发布v1.5.0-alpha3
Browse files Browse the repository at this point in the history
  • Loading branch information
leiurayer committed Mar 11, 2022
1 parent cf41095 commit 0caa3a6
Show file tree
Hide file tree
Showing 22 changed files with 286 additions and 169 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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的显示与操作。
Expand Down
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion src/DownKyi.Core/Settings/Models/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ public class AppSettings
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();
}
}
10 changes: 5 additions & 5 deletions src/DownKyi.Core/Settings/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ private AppSettings GetSettings()
/// <returns></returns>
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;
}
Expand Down
40 changes: 27 additions & 13 deletions src/DownKyi.Core/Storage/Database/CoverDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -103,21 +108,30 @@ private List<Cover> Query(string sql)
{
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"],
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;
}

Expand Down
99 changes: 54 additions & 45 deletions src/DownKyi.Core/Storage/Database/Download/DownloadDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DownloadDb
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
Expand All @@ -33,25 +33,25 @@ public void Close()
/// <param name="obj"></param>
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<SQLiteParameterCollection>((para) =>
{
Expand Down Expand Up @@ -86,25 +86,25 @@ public void Delete(string uuid)

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<SQLiteParameterCollection>((para) =>
{
Expand Down Expand Up @@ -160,22 +160,31 @@ private Dictionary<string, object> Query(string sql)
{
Dictionary<string, object> objects = new Dictionary<string, object>();

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;
}

Expand Down
38 changes: 26 additions & 12 deletions src/DownKyi.Core/Storage/Database/HeaderDb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -90,20 +95,29 @@ private List<Header> Query(string sql)
{
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"],
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;
}

Expand Down
47 changes: 33 additions & 14 deletions src/DownKyi.Core/Utils/HardDisk.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.IO;
using DownKyi.Core.Logging;
using System;
using System.IO;

namespace DownKyi.Core.Utils
{
Expand All @@ -11,17 +13,26 @@ public static class HardDisk
/// <returns></returns>
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;
}
Expand All @@ -33,17 +44,25 @@ public static long GetHardDiskSpace(string hardDiskName)
/// <returns></returns>
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;
}
Expand Down
Loading

0 comments on commit 0caa3a6

Please sign in to comment.