From a3579fbb2870dde7fcc24b7cd6536a99ea39bf38 Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Wed, 24 May 2023 23:02:43 +0800
Subject: [PATCH 1/9] =?UTF-8?q?=E6=94=AF=E6=8C=81wbi=E5=8F=A3=E4=BB=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/DownKyi.Core/BiliApi/Sign/WbiSign.cs | 120 ++++++++++++++++++
.../Users/Models/UserInfoForNavigation.cs | 13 ++
src/DownKyi.Core/BiliApi/Users/UserInfo.cs | 11 +-
src/DownKyi.Core/BiliApi/Users/UserSpace.cs | 15 ++-
src/DownKyi.Core/DownKyi.Core.csproj | 1 +
.../Settings/Models/UserInfoSettings.cs | 3 +
src/DownKyi/Languages/Default.xaml | 2 +-
.../Services/Download/DownloadService.cs | 3 +-
src/DownKyi/ViewModels/ViewIndexViewModel.cs | 64 ++++++----
9 files changed, 202 insertions(+), 30 deletions(-)
create mode 100644 src/DownKyi.Core/BiliApi/Sign/WbiSign.cs
diff --git a/src/DownKyi.Core/BiliApi/Sign/WbiSign.cs b/src/DownKyi.Core/BiliApi/Sign/WbiSign.cs
new file mode 100644
index 0000000..4d584dc
--- /dev/null
+++ b/src/DownKyi.Core/BiliApi/Sign/WbiSign.cs
@@ -0,0 +1,120 @@
+using DownKyi.Core.Settings;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Security.Cryptography;
+using System.Text;
+using System.Text.RegularExpressions;
+
+namespace DownKyi.Core.BiliApi.Sign
+{
+ public static class WbiSign
+ {
+
+ ///
+ /// 打乱重排实时口令
+ ///
+ ///
+ ///
+ private static string GetMixinKey(string origin)
+ {
+ int[] mixinKeyEncTab = new int[]
+ {
+ 46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 58, 3, 45, 35, 27, 43, 5, 49,
+ 33, 9, 42, 19, 29, 28, 14, 39,12, 38, 41, 13, 37, 48, 7, 16, 24, 55, 40,
+ 61, 26, 17, 0, 1, 60, 51, 30, 4, 22, 25, 54, 21, 56, 59, 6, 63, 57, 62, 11,
+ 36, 20, 34, 44, 52
+ };
+
+ var temp = new StringBuilder();
+ foreach (var i in mixinKeyEncTab)
+ {
+ temp.Append(origin[i]);
+ }
+ return temp.ToString().Substring(0, 32);
+ }
+
+ ///
+ /// 将字典参数转为字符串
+ ///
+ ///
+ ///
+ public static string ParametersToQuery(Dictionary parameters)
+ {
+ var keys = parameters.Keys.ToList();
+ var queryList = new List();
+ foreach (var item in keys)
+ {
+ var value = parameters[item];
+ queryList.Add($"{item}={value}");
+ }
+ return string.Join("&", queryList);
+ }
+
+ ///
+ /// Wbi签名,返回所有参数字典
+ ///
+ ///
+ ///
+ public static Dictionary EncodeWbi(Dictionary parameters)
+ {
+ return EncodeWbi(parameters, GetKey().Item1, GetKey().Item2);
+ }
+
+ ///
+ /// Wbi签名,返回所有参数字典
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static Dictionary EncodeWbi(Dictionary parameters, string imgKey, string subKey)
+ {
+ var mixinKey = GetMixinKey(imgKey + subKey);
+
+ var chrFilter = new Regex("[!'()*]");
+
+ var newParameters = new Dictionary
+ {
+ { "wts", (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds }
+ };
+
+ foreach (var para in parameters)
+ {
+ var key = para.Key;
+ var value = para.Value.ToString();
+
+ var encodedValue = chrFilter.Replace(value, "");
+
+ newParameters.Add(Uri.EscapeDataString(key), Uri.EscapeDataString(encodedValue));
+ }
+
+ var keys = newParameters.Keys.ToList();
+ keys.Sort();
+
+ var queryList = new List();
+ foreach (var item in keys)
+ {
+ var value = newParameters[item];
+ queryList.Add($"{item}={value}");
+ }
+
+ var queryString = string.Join("&", queryList);
+ var md5Hasher = MD5.Create();
+ var hashStr = queryString + mixinKey;
+ var hashedQueryString = md5Hasher.ComputeHash(Encoding.UTF8.GetBytes(hashStr));
+ var wbiSign = BitConverter.ToString(hashedQueryString).Replace("-", "").ToLower();
+
+ newParameters.Add("w_rid", wbiSign);
+ return newParameters;
+ }
+
+ public static Tuple GetKey()
+ {
+ var user = SettingsManager.GetInstance().GetUserInfo();
+
+ return new Tuple(user.ImgKey, user.SubKey);
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/src/DownKyi.Core/BiliApi/Users/Models/UserInfoForNavigation.cs b/src/DownKyi.Core/BiliApi/Users/Models/UserInfoForNavigation.cs
index 0801dd3..d1256dc 100644
--- a/src/DownKyi.Core/BiliApi/Users/Models/UserInfoForNavigation.cs
+++ b/src/DownKyi.Core/BiliApi/Users/Models/UserInfoForNavigation.cs
@@ -53,6 +53,9 @@ namespace DownKyi.Core.BiliApi.Users.Models
//public int vip_theme_type { get; set; }
[JsonProperty("wallet")]
public UserInfoWallet Wallet { get; set; }
+
+ [JsonProperty("wbi_img")]
+ public Wbi Wbi { get; set; }
}
//public class NavDataLevelInfo
@@ -105,4 +108,14 @@ namespace DownKyi.Core.BiliApi.Users.Models
[JsonProperty("mid")]
public long Mid { get; set; }
}
+
+ [JsonObject]
+ public class Wbi
+ {
+ [JsonProperty("img_url")]
+ public string ImgUrl { get; set; }
+ [JsonProperty("sub_url")]
+ public string SubUrl { get; set; }
+ }
+
}
diff --git a/src/DownKyi.Core/BiliApi/Users/UserInfo.cs b/src/DownKyi.Core/BiliApi/Users/UserInfo.cs
index 175f1e3..d6d1a21 100644
--- a/src/DownKyi.Core/BiliApi/Users/UserInfo.cs
+++ b/src/DownKyi.Core/BiliApi/Users/UserInfo.cs
@@ -1,7 +1,9 @@
-using DownKyi.Core.BiliApi.Users.Models;
+using DownKyi.Core.BiliApi.Sign;
+using DownKyi.Core.BiliApi.Users.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
+using System.Collections.Generic;
namespace DownKyi.Core.BiliApi.Users
{
@@ -43,7 +45,12 @@ namespace DownKyi.Core.BiliApi.Users
///
public static UserInfoForSpace GetUserInfoForSpace(long mid)
{
- string url = $"https://api.bilibili.com/x/space/wbi/acc/info?mid={mid}";
+ var parameters = new Dictionary
+ {
+ { "mid", mid }
+ };
+ string query = WbiSign.ParametersToQuery(WbiSign.EncodeWbi(parameters));
+ string url = $"https://api.bilibili.com/x/space/wbi/acc/info?{query}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
diff --git a/src/DownKyi.Core/BiliApi/Users/UserSpace.cs b/src/DownKyi.Core/BiliApi/Users/UserSpace.cs
index c76af60..4072cf1 100644
--- a/src/DownKyi.Core/BiliApi/Users/UserSpace.cs
+++ b/src/DownKyi.Core/BiliApi/Users/UserSpace.cs
@@ -1,4 +1,5 @@
-using DownKyi.Core.BiliApi.Users.Models;
+using DownKyi.Core.BiliApi.Sign;
+using DownKyi.Core.BiliApi.Users.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@@ -114,7 +115,17 @@ namespace DownKyi.Core.BiliApi.Users
///
public static SpacePublicationList GetPublication(long mid, int pn, int ps, long tid = 0, PublicationOrder order = PublicationOrder.PUBDATE, string keyword = "")
{
- string url = $"https://api.bilibili.com/x/space/wbi/arc/search?mid={mid}&pn={pn}&ps={ps}&order={order.ToString("G").ToLower()}&tid={tid}&keyword={keyword}";
+ var parameters = new Dictionary
+ {
+ { "mid", mid },
+ { "pn", pn },
+ { "ps", ps },
+ { "order", order.ToString("G").ToLower() },
+ { "tid", tid },
+ { "keyword", keyword },
+ };
+ string query = WbiSign.ParametersToQuery(WbiSign.EncodeWbi(parameters));
+ string url = $"https://api.bilibili.com/x/space/wbi/arc/search?{query}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
diff --git a/src/DownKyi.Core/DownKyi.Core.csproj b/src/DownKyi.Core/DownKyi.Core.csproj
index c919ea6..2a9a3fb 100644
--- a/src/DownKyi.Core/DownKyi.Core.csproj
+++ b/src/DownKyi.Core/DownKyi.Core.csproj
@@ -186,6 +186,7 @@
+
diff --git a/src/DownKyi.Core/Settings/Models/UserInfoSettings.cs b/src/DownKyi.Core/Settings/Models/UserInfoSettings.cs
index 774b7ec..63debc7 100644
--- a/src/DownKyi.Core/Settings/Models/UserInfoSettings.cs
+++ b/src/DownKyi.Core/Settings/Models/UserInfoSettings.cs
@@ -6,5 +6,8 @@
public string Name { get; set; }
public bool IsLogin { get; set; } // 是否登录
public bool IsVip { get; set; } // 是否为大会员,未登录时为false
+
+ public string ImgKey { get; set; }
+ public string SubKey { get; set; }
}
}
diff --git a/src/DownKyi/Languages/Default.xaml b/src/DownKyi/Languages/Default.xaml
index b6ca780..19cebae 100644
--- a/src/DownKyi/Languages/Default.xaml
+++ b/src/DownKyi/Languages/Default.xaml
@@ -200,7 +200,7 @@
启用https(若下载器提示SSL错误,则关闭此项)
UserAgent:
选择下载器(重启生效):
- 内建下载器(测试)
+ 内建下载器
Aria2下载器
自定义Aria2下载器
Aria服务器地址:
diff --git a/src/DownKyi/Services/Download/DownloadService.cs b/src/DownKyi/Services/Download/DownloadService.cs
index acea7a1..c6297bc 100644
--- a/src/DownKyi/Services/Download/DownloadService.cs
+++ b/src/DownKyi/Services/Download/DownloadService.cs
@@ -20,14 +20,13 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using System.Windows;
namespace DownKyi.Services.Download
{
public abstract class DownloadService
{
protected string Tag = "DownloadService";
- protected TaskbarIcon _notifyIcon;
+ protected TaskbarIcon _notifyIcon;
protected IDialogService dialogService;
protected ObservableCollection downloadingList;
protected ObservableCollection downloadedList;
diff --git a/src/DownKyi/ViewModels/ViewIndexViewModel.cs b/src/DownKyi/ViewModels/ViewIndexViewModel.cs
index 9eaeb10..37aff24 100644
--- a/src/DownKyi/ViewModels/ViewIndexViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewIndexViewModel.cs
@@ -1,4 +1,5 @@
using DownKyi.Core.BiliApi.Users;
+using DownKyi.Core.BiliApi.Users.Models;
using DownKyi.Core.Logging;
using DownKyi.Core.Settings;
using DownKyi.Core.Settings.Models;
@@ -12,6 +13,7 @@ using Prism.Regions;
using Prism.Services.Dialogs;
using System;
using System.IO;
+using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
@@ -227,6 +229,36 @@ namespace DownKyi.ViewModels
InputText = string.Empty;
}
+ private UserInfoForNavigation GetUserInfo()
+ {
+ // 获取用户信息
+ var userInfo = UserInfo.GetUserInfoForNavigation();
+ if (userInfo != null)
+ {
+ SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
+ {
+ Mid = userInfo.Mid,
+ Name = userInfo.Name,
+ IsLogin = userInfo.IsLogin,
+ IsVip = userInfo.VipStatus == 1,
+ ImgKey = userInfo.Wbi.ImgUrl.Split('/').ToList().Last().Split('.')[0],
+ SubKey = userInfo.Wbi.SubUrl.Split('/').ToList().Last().Split('.')[0],
+ });
+ }
+ else
+ {
+ SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
+ {
+ Mid = -1,
+ Name = "",
+ IsLogin = false,
+ IsVip = false,
+ });
+ }
+
+ return userInfo;
+ }
+
///
/// 更新用户登录信息
///
@@ -248,27 +280,7 @@ namespace DownKyi.ViewModels
await Task.Run(new Action(() =>
{
// 获取用户信息
- var userInfo = UserInfo.GetUserInfoForNavigation();
- if (userInfo != null)
- {
- SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
- {
- Mid = userInfo.Mid,
- Name = userInfo.Name,
- IsLogin = userInfo.IsLogin,
- IsVip = userInfo.VipStatus == 1
- });
- }
- else
- {
- SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
- {
- Mid = -1,
- Name = "",
- IsLogin = false,
- IsVip = false
- });
- }
+ var userInfo = GetUserInfo();
PropertyChangeAsync(new Action(() =>
{
@@ -318,21 +330,27 @@ namespace DownKyi.ViewModels
{
return;
}
+
// 启动
if (parameter == "start")
{
UpdateUserInfo();
}
// 从登录页面返回
- if (parameter == "login")
+ else if (parameter == "login")
{
UpdateUserInfo();
}
// 注销
- if (parameter == "logout")
+ else if (parameter == "logout")
{
UpdateUserInfo();
}
+ // 其他情况只更新设置的用户信息,不更新UI
+ else
+ {
+ GetUserInfo();
+ }
}
From 35ca6a3442ea3d9835cf0fad1a83fc6d281fda2c Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Wed, 24 May 2023 23:03:05 +0800
Subject: [PATCH 2/9] =?UTF-8?q?=E5=8F=91=E5=B8=83v1.5.9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
CHANGELOG.md | 5 +++++
src/DownKyi.Core/Properties/AssemblyInfo.cs | 4 ++--
src/DownKyi/Models/AppInfo.cs | 2 +-
src/DownKyi/Properties/AssemblyInfo.cs | 4 ++--
4 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4347771..54dd1c7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,10 @@
# 更新日志
+## `2023/05/24` v1.5.9
+
+* [新增] 下载完成系统提示。
+* [修复] UP主个人空间访问。
+
## `2023/04/30` v1.5.8
* [新增] 视频详情页搜索功能。
diff --git a/src/DownKyi.Core/Properties/AssemblyInfo.cs b/src/DownKyi.Core/Properties/AssemblyInfo.cs
index 3c2f21e..6d3cbf8 100644
--- a/src/DownKyi.Core/Properties/AssemblyInfo.cs
+++ b/src/DownKyi.Core/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("2.1.8.0")]
-[assembly: AssemblyFileVersion("2.1.8.0")]
+[assembly: AssemblyVersion("2.1.9.0")]
+[assembly: AssemblyFileVersion("2.1.9.0")]
diff --git a/src/DownKyi/Models/AppInfo.cs b/src/DownKyi/Models/AppInfo.cs
index 9d92d36..b6535c2 100644
--- a/src/DownKyi/Models/AppInfo.cs
+++ b/src/DownKyi/Models/AppInfo.cs
@@ -11,7 +11,7 @@ namespace DownKyi.Models
const int a = 1;
const int b = 5;
- const int c = 8;
+ const int c = 9;
public AppInfo()
{
diff --git a/src/DownKyi/Properties/AssemblyInfo.cs b/src/DownKyi/Properties/AssemblyInfo.cs
index cbd7d78..1a199a7 100644
--- a/src/DownKyi/Properties/AssemblyInfo.cs
+++ b/src/DownKyi/Properties/AssemblyInfo.cs
@@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.5.8.0")]
-[assembly: AssemblyFileVersion("1.5.8.0")]
+[assembly: AssemblyVersion("1.5.9.0")]
+[assembly: AssemblyFileVersion("1.5.9.0")]
From 9da37a7f2853ffeb9fe09965ef908a47df77d6a1 Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Wed, 24 May 2023 23:48:50 +0800
Subject: [PATCH 3/9] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=9C=AA=E7=99=BB?=
=?UTF-8?q?=E5=BD=95=E6=97=B6=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8=E8=8E=B7?=
=?UTF-8?q?=E5=8F=96wbi=E5=8F=A3=E4=BB=A4=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/DownKyi.Core/BiliApi/Users/UserInfo.cs | 3 +-
src/DownKyi/ViewModels/ViewIndexViewModel.cs | 110 ++++++++++---------
2 files changed, 60 insertions(+), 53 deletions(-)
diff --git a/src/DownKyi.Core/BiliApi/Users/UserInfo.cs b/src/DownKyi.Core/BiliApi/Users/UserInfo.cs
index d6d1a21..cafdbb8 100644
--- a/src/DownKyi.Core/BiliApi/Users/UserInfo.cs
+++ b/src/DownKyi.Core/BiliApi/Users/UserInfo.cs
@@ -27,8 +27,7 @@ namespace DownKyi.Core.BiliApi.Users
UserInfoForNavigationOrigin userInfo = JsonConvert.DeserializeObject(response);
if (userInfo == null || userInfo.Data == null) { return null; }
- if (userInfo.Data.IsLogin) { return userInfo.Data; }
- else { return null; }
+ return userInfo.Data;
}
catch (Exception e)
{
diff --git a/src/DownKyi/ViewModels/ViewIndexViewModel.cs b/src/DownKyi/ViewModels/ViewIndexViewModel.cs
index 37aff24..b78e5c5 100644
--- a/src/DownKyi/ViewModels/ViewIndexViewModel.cs
+++ b/src/DownKyi/ViewModels/ViewIndexViewModel.cs
@@ -229,45 +229,59 @@ namespace DownKyi.ViewModels
InputText = string.Empty;
}
- private UserInfoForNavigation GetUserInfo()
+ private async Task GetUserInfo()
{
- // 获取用户信息
- var userInfo = UserInfo.GetUserInfoForNavigation();
- if (userInfo != null)
+ UserInfoForNavigation userInfo = null;
+ await Task.Run(new Action(() =>
{
- SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
+ // 获取用户信息
+ userInfo = UserInfo.GetUserInfoForNavigation();
+ if (userInfo != null)
{
- Mid = userInfo.Mid,
- Name = userInfo.Name,
- IsLogin = userInfo.IsLogin,
- IsVip = userInfo.VipStatus == 1,
- ImgKey = userInfo.Wbi.ImgUrl.Split('/').ToList().Last().Split('.')[0],
- SubKey = userInfo.Wbi.SubUrl.Split('/').ToList().Last().Split('.')[0],
- });
- }
- else
- {
- SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
+ SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
+ {
+ Mid = userInfo.Mid,
+ Name = userInfo.Name,
+ IsLogin = userInfo.IsLogin,
+ IsVip = userInfo.VipStatus == 1,
+ ImgKey = userInfo.Wbi.ImgUrl.Split('/').ToList().Last().Split('.')[0],
+ SubKey = userInfo.Wbi.SubUrl.Split('/').ToList().Last().Split('.')[0],
+ });
+ }
+ else
{
- Mid = -1,
- Name = "",
- IsLogin = false,
- IsVip = false,
- });
- }
+ SettingsManager.GetInstance().SetUserInfo(new UserInfoSettings
+ {
+ Mid = -1,
+ Name = "",
+ IsLogin = false,
+ IsVip = false,
+ });
+ }
+ }));
return userInfo;
}
///
/// 更新用户登录信息
///
- private async void UpdateUserInfo()
+ private async void UpdateUserInfo(bool isBackgroud = false)
{
try
{
+ if (isBackgroud)
+ {
+ // 获取用户信息
+ await GetUserInfo();
+ return;
+ }
+
LoginPanelVisibility = Visibility.Hidden;
+ // 获取用户信息
+ var userInfo = await GetUserInfo();
+
// 检查本地是否存在login文件,没有则说明未登录
if (!File.Exists(StorageManager.GetLogin()))
{
@@ -277,34 +291,26 @@ namespace DownKyi.ViewModels
return;
}
- await Task.Run(new Action(() =>
- {
- // 获取用户信息
- var userInfo = GetUserInfo();
+ LoginPanelVisibility = Visibility.Visible;
- PropertyChangeAsync(new Action(() =>
+ if (userInfo != null)
+ {
+ if (userInfo.Face != null)
+ {
+ Header = new StorageHeader().GetHeaderThumbnail(userInfo.Mid, userInfo.Name, userInfo.Face, 36, 36);
+ }
+ else
{
- LoginPanelVisibility = Visibility.Visible;
-
- if (userInfo != null)
- {
- if (userInfo.Face != null)
- {
- Header = new StorageHeader().GetHeaderThumbnail(userInfo.Mid, userInfo.Name, userInfo.Face, 36, 36);
- }
- else
- {
- Header = new BitmapImage(new Uri("pack://application:,,,/Resources/default_header.jpg"));
- }
- UserName = userInfo.Name;
- }
- else
- {
- Header = new BitmapImage(new Uri("pack://application:,,,/Resources/default_header.jpg"));
- UserName = null;
- }
- }));
- }));
+ Header = new BitmapImage(new Uri("pack://application:,,,/Resources/default_header.jpg"));
+ }
+ UserName = userInfo.Name;
+ }
+ else
+ {
+ Header = new BitmapImage(new Uri("pack://application:,,,/Resources/default_header.jpg"));
+ UserName = null;
+ }
+
}
catch (Exception e)
{
@@ -328,6 +334,8 @@ namespace DownKyi.ViewModels
string parameter = navigationContext.Parameters.GetValue("Parameter");
if (parameter == null)
{
+ // 其他情况只更新设置的用户信息,不更新UI
+ UpdateUserInfo(true);
return;
}
@@ -346,10 +354,10 @@ namespace DownKyi.ViewModels
{
UpdateUserInfo();
}
- // 其他情况只更新设置的用户信息,不更新UI
else
{
- GetUserInfo();
+ // 其他情况只更新设置的用户信息,不更新UI
+ UpdateUserInfo(true);
}
}
From 1a80a16d19c1bc829690847267e2f384fcea869b Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Fri, 26 May 2023 18:22:54 +0800
Subject: [PATCH 4/9] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=A7=86=E9=A2=91?=
=?UTF-8?q?=E6=B5=81API=E6=94=AF=E6=8C=81wbi?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../BiliApi/VideoStream/VideoStream.cs | 39 ++++++++++++++++---
1 file changed, 33 insertions(+), 6 deletions(-)
diff --git a/src/DownKyi.Core/BiliApi/VideoStream/VideoStream.cs b/src/DownKyi.Core/BiliApi/VideoStream/VideoStream.cs
index 5764fcd..80c6109 100644
--- a/src/DownKyi.Core/BiliApi/VideoStream/VideoStream.cs
+++ b/src/DownKyi.Core/BiliApi/VideoStream/VideoStream.cs
@@ -1,4 +1,5 @@
using DownKyi.Core.BiliApi.Models.Json;
+using DownKyi.Core.BiliApi.Sign;
using DownKyi.Core.BiliApi.VideoStream.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
@@ -19,7 +20,14 @@ namespace DownKyi.Core.BiliApi.VideoStream
///
public static PlayerV2 PlayerV2(long avid, string bvid, long cid)
{
- string url = $"https://api.bilibili.com/x/player/v2?cid={cid}&aid={avid}&bvid={bvid}";
+ var parameters = new Dictionary
+ {
+ { "avid", avid },
+ { "bvid", bvid },
+ { "cid", cid },
+ };
+ string query = WbiSign.ParametersToQuery(WbiSign.EncodeWbi(parameters));
+ string url = $"https://api.bilibili.com/x/player/wbi/v2?{query}";
string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
@@ -93,11 +101,30 @@ namespace DownKyi.Core.BiliApi.VideoStream
///
public static PlayUrl GetVideoPlayUrl(long avid, string bvid, long cid, int quality = 125)
{
- string baseUrl = $"https://api.bilibili.com/x/player/playurl?cid={cid}&qn={quality}&fourk=1&fnver=0&fnval=4048";
- string url;
- if (bvid != null) { url = $"{baseUrl}&bvid={bvid}"; }
- else if (avid > -1) { url = $"{baseUrl}&aid={avid}"; }
- else { return null; }
+ var parameters = new Dictionary
+ {
+ { "fourk", 1 },
+ { "fnver", 0 },
+ { "fnval", 4048 },
+ { "cid", cid },
+ { "qn", quality },
+ };
+
+ if (bvid != null)
+ {
+ parameters.Add("bvid", bvid);
+ }
+ else if (avid > -1)
+ {
+ parameters.Add("aid", avid);
+ }
+ else
+ {
+ return null;
+ }
+
+ string query = WbiSign.ParametersToQuery(WbiSign.EncodeWbi(parameters));
+ string url = $"https://api.bilibili.com/x/player/wbi/playurl?{query}";
return GetPlayUrl(url);
}
From daabbb58d99bf68ba0bc4be4e4325fde42719a50 Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Fri, 26 May 2023 18:23:09 +0800
Subject: [PATCH 5/9] =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=AF=A6=E7=BB=86?=
=?UTF-8?q?=E4=BF=A1=E6=81=AFAPI=E6=94=AF=E6=8C=81wbi?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/DownKyi.Core/BiliApi/Video/VideoInfo.cs | 25 +++++++++++++++------
1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/src/DownKyi.Core/BiliApi/Video/VideoInfo.cs b/src/DownKyi.Core/BiliApi/Video/VideoInfo.cs
index ed65ced..5744ccb 100644
--- a/src/DownKyi.Core/BiliApi/Video/VideoInfo.cs
+++ b/src/DownKyi.Core/BiliApi/Video/VideoInfo.cs
@@ -1,4 +1,5 @@
-using DownKyi.Core.BiliApi.Video.Models;
+using DownKyi.Core.BiliApi.Sign;
+using DownKyi.Core.BiliApi.Video.Models;
using DownKyi.Core.Logging;
using Newtonsoft.Json;
using System;
@@ -17,13 +18,23 @@ namespace DownKyi.Core.BiliApi.Video
public static VideoView VideoViewInfo(string bvid = null, long aid = -1)
{
// https://api.bilibili.com/x/web-interface/view/detail?bvid=BV1Sg411F7cb&aid=969147110&need_operation_card=1&web_rm_repeat=1&need_elec=1&out_referer=https%3A%2F%2Fspace.bilibili.com%2F42018135%2Ffavlist%3Ffid%3D94341835
- string baseUrl = "https://api.bilibili.com/x/web-interface/view";
- string referer = "https://www.bilibili.com";
- string url;
- if (bvid != null) { url = $"{baseUrl}?bvid={bvid}"; }
- else if (aid > -1) { url = $"{baseUrl}?aid={aid}"; }
- else { return null; }
+ var parameters = new Dictionary();
+ if (bvid != null)
+ {
+ parameters.Add("bvid", bvid);
+ }
+ else if (aid > -1)
+ {
+ parameters.Add("aid", aid);
+ }
+ else
+ {
+ return null;
+ }
+ string query = WbiSign.ParametersToQuery(WbiSign.EncodeWbi(parameters));
+ string url = $"https://api.bilibili.com/x/web-interface/wbi/view?{query}";
+ string referer = "https://www.bilibili.com";
string response = WebClient.RequestWeb(url, referer);
try
From 6221dd504e411a67dcb8f31732dc609fc48a0434 Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Mon, 10 Jul 2023 23:13:17 +0800
Subject: [PATCH 6/9] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BB=BB=E5=8A=A1?=
=?UTF-8?q?=E6=A0=8F=E5=9B=BE=E6=A0=87?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/DownKyi/Services/Download/DownloadService.cs | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/DownKyi/Services/Download/DownloadService.cs b/src/DownKyi/Services/Download/DownloadService.cs
index c6297bc..8e569b7 100644
--- a/src/DownKyi/Services/Download/DownloadService.cs
+++ b/src/DownKyi/Services/Download/DownloadService.cs
@@ -20,6 +20,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using System.Windows.Media.Imaging;
namespace DownKyi.Services.Download
{
@@ -804,6 +805,8 @@ namespace DownKyi.Services.Download
tokenSource = new CancellationTokenSource();
cancellationToken = tokenSource.Token;
_notifyIcon = new TaskbarIcon();
+ _notifyIcon.IconSource = new BitmapImage(new Uri("pack://application:,,,/Resources/favicon.ico"));
+
workTask = Task.Run(DoWork);
}
From 11538b6efa73633f194ea142c8ccad2627a131d2 Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Mon, 10 Jul 2023 23:13:43 +0800
Subject: [PATCH 7/9] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E5=BC=B9=E5=87=BA=E6=A1=86=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/DownKyi/Services/AlertService.cs | 5 +++--
src/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs | 2 +-
src/DownKyi/ViewModels/DownloadManager/DownloadingItem.cs | 2 +-
3 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/DownKyi/Services/AlertService.cs b/src/DownKyi/Services/AlertService.cs
index 4b46ecf..910842d 100644
--- a/src/DownKyi/Services/AlertService.cs
+++ b/src/DownKyi/Services/AlertService.cs
@@ -31,12 +31,13 @@ namespace DownKyi.Services
/// 显示一个警告弹窗
///
///
+ ///
///
- public ButtonResult ShowWarning(string message)
+ public ButtonResult ShowWarning(string message, int buttonNumber = 1)
{
VectorImage image = SystemIcon.Instance().Warning;
string title = DictionaryResource.GetString("Warning");
- return ShowMessage(image, title, message, 1);
+ return ShowMessage(image, title, message, buttonNumber);
}
///
diff --git a/src/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs b/src/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
index 7ddde0b..244459c 100644
--- a/src/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
+++ b/src/DownKyi/ViewModels/DownloadManager/DownloadedItem.cs
@@ -155,7 +155,7 @@ namespace DownKyi.ViewModels.DownloadManager
private void ExecuteRemoveVideoCommand()
{
AlertService alertService = new AlertService(DialogService);
- ButtonResult result = alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"));
+ ButtonResult result = alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"), 2);
if (result != ButtonResult.OK)
{
return;
diff --git a/src/DownKyi/ViewModels/DownloadManager/DownloadingItem.cs b/src/DownKyi/ViewModels/DownloadManager/DownloadingItem.cs
index 0f090eb..7e54bf2 100644
--- a/src/DownKyi/ViewModels/DownloadManager/DownloadingItem.cs
+++ b/src/DownKyi/ViewModels/DownloadManager/DownloadingItem.cs
@@ -218,7 +218,7 @@ namespace DownKyi.ViewModels.DownloadManager
private void ExecuteDeleteCommand()
{
AlertService alertService = new AlertService(DialogService);
- ButtonResult result = alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"));
+ ButtonResult result = alertService.ShowWarning(DictionaryResource.GetString("ConfirmDelete"), 2);
if (result != ButtonResult.OK)
{
return;
From d15175f62993631aea7a24cd622201c72d90432e Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Thu, 13 Jul 2023 23:11:29 +0800
Subject: [PATCH 8/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=96=87=E4=BB=B6?=
=?UTF-8?q?=E5=90=8D=E5=AF=BC=E8=87=B4=E7=9A=84=E9=97=AA=E9=80=80=E9=97=AE?=
=?UTF-8?q?=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/DownKyi.Core/Utils/Format.cs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/DownKyi.Core/Utils/Format.cs b/src/DownKyi.Core/Utils/Format.cs
index fcde0f6..14653ef 100644
--- a/src/DownKyi.Core/Utils/Format.cs
+++ b/src/DownKyi.Core/Utils/Format.cs
@@ -198,6 +198,12 @@ namespace DownKyi.Core.Utils
// 控制字符
destName = Regex.Replace(destName, @"\p{C}+", string.Empty);
+ // 如果只有空白字符、dot符
+ if (destName == " " || destName == ".")
+ {
+ return "[empty title]";
+ }
+
// 移除前导和尾部的空白字符、dot符
int i, j;
for (i = 0; i < destName.Length; i++)
From 333173749473b49dc0ca5b36d40962c7f8bfa271 Mon Sep 17 00:00:00 2001
From: leiurayer <1432593898@qq.com>
Date: Fri, 28 Jul 2023 00:07:23 +0800
Subject: [PATCH 9/9] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A8=8B=E5=BA=8F?=
=?UTF-8?q?=E5=8F=8D=E5=A4=8D=E8=AF=BB=E5=8F=96=E8=AE=BE=E7=BD=AE=E6=96=87?=
=?UTF-8?q?=E4=BB=B6=E7=9A=84=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/DownKyi.Core/Settings/SettingsManager.cs | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/src/DownKyi.Core/Settings/SettingsManager.cs b/src/DownKyi.Core/Settings/SettingsManager.cs
index f6d19b0..44a16bc 100644
--- a/src/DownKyi.Core/Settings/SettingsManager.cs
+++ b/src/DownKyi.Core/Settings/SettingsManager.cs
@@ -55,13 +55,23 @@ namespace DownKyi.Core.Settings
///
private AppSettings GetSettings()
{
+ if (appSettings != null) { return appSettings; }
+
try
{
- 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();
+ //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();
+ string jsonWordTemplate = string.Empty;
+ using (var stream = new FileStream(settingsName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite | FileShare.Delete))
+ {
+ using (var reader = new StreamReader(stream, System.Text.Encoding.UTF8))
+ {
+ jsonWordTemplate = reader.ReadToEnd();
+ }
+ }
#if DEBUG
#else