diff --git a/BiliCommenter/BiliCommenter.csproj b/BiliCommenter/BiliCommenter.csproj
index e3cb8c6..340635d 100644
--- a/BiliCommenter/BiliCommenter.csproj
+++ b/BiliCommenter/BiliCommenter.csproj
@@ -4,7 +4,8 @@
WinExe
netcoreapp3.0
true
- 0.2.4.0
+ 0.2.5.0
+ logo.ico
@@ -12,10 +13,15 @@
+
-
+
+
+
+
+
diff --git a/BiliCommenter/MainWindow.xaml b/BiliCommenter/MainWindow.xaml
index 38c11a1..bc2ee57 100644
--- a/BiliCommenter/MainWindow.xaml
+++ b/BiliCommenter/MainWindow.xaml
@@ -6,7 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BiliCommenter"
mc:Ignorable="d"
- Title="Bilibili Commenter" Height="600" Width="1000">
+ Title="Bilibili Commenter" Height="600" Width="1000" ResizeMode="NoResize">
@@ -81,8 +81,8 @@
-
-
+
+
@@ -98,7 +98,7 @@
-
+
@@ -151,19 +151,19 @@
mahCtrls:TextBoxHelper.IsWaitingForData="True"
mahCtrls:TextBoxHelper.UseFloatingWatermark="True"
mahCtrls:TextBoxHelper.Watermark="Password"
- Style="{StaticResource MahApps.Styles.PasswordBox.ButtonRevealed}"
+ Style="{StaticResource MahApps.Styles.PasswordBox.Button.Revealed}"
KeyDown="PasswordBox_KeyDown"/>
@@ -181,9 +181,9 @@
-
-
-
+
+
+
-
+
diff --git a/BiliCommenter/MainWindow.xaml.cs b/BiliCommenter/MainWindow.xaml.cs
index 2a23cef..1972572 100644
--- a/BiliCommenter/MainWindow.xaml.cs
+++ b/BiliCommenter/MainWindow.xaml.cs
@@ -14,6 +14,7 @@
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
+using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;
namespace BiliCommenter
@@ -87,6 +88,10 @@ public void Initialize()
if (Settings.Default.IsInheritTasks)
ReadTasks();
+ // Init caches
+ if (!Directory.Exists("cache"))
+ Directory.CreateDirectory("cache");
+
#region Read log-in informations
Thread freshThread = new Thread(async () =>
{
@@ -121,20 +126,21 @@ public void Initialize()
{
// Get the list of the emojis.
var allEmojis = await Common.GetEmojisAsync();
+ var checkedEmojis = await Common.CheckCacheAsync(allEmojis);
- for (int i = 0; i < allEmojis.Data.Count; i++)
+ for (int i = 0; i < checkedEmojis.Count; i++)
{
- var emojiPack = allEmojis.Data[i];
+ var emojiPack = checkedEmojis[i];
// These part of code is a piece of s**t, but works :).
this.Invoke(() =>
{
var item = new TabItem();
- item.Header = emojiPack.Pname;
+ item.Header = emojiPack.PackName;
StackPanel panel = new StackPanel { Orientation = Orientation.Vertical, HorizontalAlignment = HorizontalAlignment.Center };
StackPanel stack = null;
- for (int j = 0; j < emojiPack.Emojis.Count; j++)
+ for (int j = 0; j < emojiPack.CheckedEmojis.Count; j++)
{
- var emoji = emojiPack.Emojis[j];
+ var emoji = emojiPack.CheckedEmojis[j];
if (j % 9 == 0)
{
stack = new StackPanel { Orientation = Orientation.Horizontal };
@@ -146,9 +152,9 @@ public void Initialize()
Height = 75,
Content = new Image
{
- Width = 70,
- Height = 70,
- Source = CreateBI(emoji.Url),
+ Width = 64,
+ Height = 64,
+ Source = CreateBI(emoji.ImagePath),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center
},
@@ -193,8 +199,8 @@ private void ChangeLogStatusFlyouts(object sender, RoutedEventArgs e)
}
private void ChangeSettingFlyout(object sender, RoutedEventArgs e)
{
- IsSaveAccessKey.IsChecked = Settings.Default.IsSaveAccessKey;
- IsInheritTasks.IsChecked = Settings.Default.IsInheritTasks;
+ IsSaveAccessKey.IsOn = Settings.Default.IsSaveAccessKey;
+ IsInheritTasks.IsOn = Settings.Default.IsInheritTasks;
SettingsFlyout.IsOpen = !SettingsFlyout.IsOpen;
}
private void TextBox_GotFocus(object sender, RoutedEventArgs e)
@@ -220,7 +226,7 @@ private void LoginButton_Click(object sender, RoutedEventArgs e)
Thread loginThread = new Thread(async () =>
{
// we should handle the exceptions that made it fail to login in the future version.
- await Auth.LoginV3(username, password);
+ await Auth.Login(username, password);
if (Settings.Default.IsSaveAccessKey)
{
Settings.Default.AccessKey = Account.AccessKey;
@@ -306,24 +312,43 @@ private void MessageTextBox_TextChanged(object sender, TextChangedEventArgs e)
}
private void EmojiButton_Click(object sender, RoutedEventArgs e)
{
- EmojiFlyout.IsOpen = !EmojiFlyout.IsOpen;
- if (EmojiFlyout.IsOpen)
+ if (!EmojiFlyout.IsOpen)
{
- int delta = 40;
- for (int i = 0; i < 400 / delta; i++)
- Height += delta;
+ DoubleAnimation da = new DoubleAnimation(600, 1000, TimeSpan.FromSeconds(0.1));
+ BeginAnimation(HeightProperty, da);
+ Thread th = new Thread(() =>
+ {
+ Thread.Sleep(100);
+
+ this.Invoke(() =>
+ {
+ EmojiFlyout.IsOpen = !EmojiFlyout.IsOpen;
+ });
+ });
+ th.Start();
}
else
{
- Thread th = new Thread(() => {
- Thread.Sleep(500);
- int delta = 40;
- for (int i = 0; i < 400 / delta; i++)
- this.Invoke(() => Height -= delta);
+ EmojiFlyout.IsOpen = !EmojiFlyout.IsOpen;
+ Thread th = new Thread(() =>
+ {
+ Thread.Sleep(100);
+
+ this.Invoke(() =>
+ {
+ DoubleAnimation da = new DoubleAnimation(1000, 600, new Duration(TimeSpan.FromSeconds(0.2)));
+ CircleEase ease = new CircleEase();
+ ease.EasingMode = EasingMode.EaseIn;
+ da.EasingFunction = ease;
+
+ BeginAnimation(HeightProperty, da);
+ });
});
th.Start();
}
}
+
+
private void AddOrUpdate(object sender, RoutedEventArgs e)
{
if(TaskPair.ContainsKey(BangumiListBox.SelectedItem as string))
@@ -410,8 +435,8 @@ private void ReadTasks()
}
private void UpdateSettings(object sender, RoutedEventArgs e)
{
- Settings.Default.IsSaveAccessKey = IsSaveAccessKey.IsChecked == true;
- Settings.Default.IsInheritTasks = IsInheritTasks.IsChecked == true;
+ Settings.Default.IsSaveAccessKey = IsSaveAccessKey.IsOn == true;
+ Settings.Default.IsInheritTasks = IsInheritTasks.IsOn == true;
Settings.Default.Save();
}
}
diff --git a/BiliCommenter/WelcomeWindow.xaml b/BiliCommenter/WelcomeWindow.xaml
index 81443fc..e549526 100644
--- a/BiliCommenter/WelcomeWindow.xaml
+++ b/BiliCommenter/WelcomeWindow.xaml
@@ -7,6 +7,6 @@
mc:Ignorable="d"
Title="WelcomeWindow" Height="512" Width="512" WindowStyle="None" AllowsTransparency="True" Background="#00FFFFFF">
-
+
diff --git a/BiliCore/API/Auth.cs b/BiliCore/API/Auth.cs
index 5836b53..c629792 100644
--- a/BiliCore/API/Auth.cs
+++ b/BiliCore/API/Auth.cs
@@ -5,6 +5,8 @@
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Security;
using System;
+using System.Collections.Generic;
+using System.Net;
using System.Net.Http;
using System.Security.Cryptography;
using System.Text;
@@ -52,19 +54,19 @@ public static async Task LoginFromAccessKey(string accesskey)
await Account.FreshStatusAsync();
if (Account.AccessKey != "") await FreshSSO();
}
- public static async Task LoginV3(string username, string password, string captcha = "")
+ public static async Task Login(string username, string password)
{
string url = "https://passport.bilibili.com/api/v3/oauth2/login";
- string data = $"appkey={Common.AppKey}&build={Common.Build}&mobi_app=android&password={Uri.EscapeDataString(await EncryptPassword(password))}&platform=android&ts={Common.TimeSpan}&username={Uri.EscapeDataString(username)}";
- if (data != "")
- {
- data += "&captcha=" + captcha;
- }
+ var pwd = Uri.EscapeDataString(await EncryptPassword(password));
+
+ string data = $"username={Uri.EscapeDataString(username)}&password={pwd}&gee_type=10&appkey={Common.AppKey}&mobi_app=android&platform=android&ts={Common.TimeSpan}";
data += "&sign=" + Common.GetSign(data);
using (HttpClient hc = new HttpClient())
{
- hc.DefaultRequestHeaders.Referrer = new Uri("https://www.bilibili.com");
- var response = await hc.PostAsync(url, new StringContent(data, Encoding.UTF8, "application/x-www-form-urlencoded"));
+ hc.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 BiliDroid/5.44.2 (bbcallen@gmail.com)");
+ hc.DefaultRequestHeaders.Add("referer", "https://www.bilibili.com/");
+ var response = await hc.PostAsync(url, new StringContent(data,Encoding.UTF8, "application/x-www-form-urlencoded"));
+
var result = await response.Content.ReadAsStringAsync();
var model = JsonConvert.DeserializeObject(result);
Account.AccessKey = model.data.token_info.access_token;
@@ -72,26 +74,7 @@ public static async Task LoginV3(string username, string password, string captch
await FreshSSO();
}
}
- public static async Task LoginV2(string username, string password, string captcha = "")
- {
- string url = "https://passport.bilibili.com/api/oauth2/login";
- string data = $"appkey={Common.AppKey}&build={Common.Build}&mobi_app=android&password={Uri.EscapeDataString(await EncryptPassword(password))}&platform=android&ts={Common.TimeSpan}&username={Uri.EscapeDataString(username)}";
- if (data != "")
- {
- data += "&captcha=" + captcha;
- }
- data += "&sign=" + Common.GetSign(data);
- using (HttpClient hc = new HttpClient())
- {
- hc.DefaultRequestHeaders.Referrer = new Uri("https://www.bilibili.com");
- var response = await hc.PostAsync(url, new StringContent(data, Encoding.UTF8, "application/x-www-form-urlencoded"));
- var result = await response.Content.ReadAsStringAsync();
- var model = JsonConvert.DeserializeObject(result);
- Account.AccessKey = model.data.access_token;
- Account.AuthResultCode = model.code;
- await FreshSSO();
- }
- }
+
public static async Task FreshSSO()
{
var url = $"https://api.kaaass.net/biliapi/user/sso?access_key={Account.AccessKey}";
diff --git a/BiliCore/API/Common.cs b/BiliCore/API/Common.cs
index d19199a..946ea26 100644
--- a/BiliCore/API/Common.cs
+++ b/BiliCore/API/Common.cs
@@ -1,8 +1,11 @@
using BiliCommenter.Models;
+using BiliCore.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
+using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
@@ -16,9 +19,11 @@ public static long TimeSpan
get { return Convert.ToInt64((DateTime.Now - new DateTime(1970, 1, 1, 8, 0, 0, 0)).TotalSeconds); }
}
- public const string AppKey = "1d8b6e7d45233436";
- public const string AppSecret = "560c52ccd288fed045859ed18bffd973";
- public const string Build = "5290000";
+ public const string AppKey = "4409e2ce8ffd12b8";
+ public const string AppSecret = "59b43e04ad6965f34319062b478f83dd";
+ public const string Build = "5370000";
+
+
public static string GetSign(string url)
{
@@ -36,6 +41,7 @@ public static string GetSign(string url)
result = MD5.GetMd5String(stringBuilder.ToString()).ToLower();
return result;
}
+
public static async Task GetEmojisAsync()
{
using (var client = new HttpClient())
@@ -45,5 +51,36 @@ public static async Task GetEmojisAsync()
return JsonConvert.DeserializeObject(context);
}
}
+
+ public static async Task> CheckCacheAsync(EmojisModel emojis)
+ {
+ List list = new List();
+ for (int i = 0; i < emojis.Data.Count; i++)
+ {
+ var emojiPack = emojis.Data[i];
+ var checkedEmojiPack = new CheckedEmojiPack();
+
+ checkedEmojiPack.PackName = emojiPack.Pname;
+
+ for (int j = 0; j < emojiPack.Emojis.Count; j++)
+ {
+ var emoji = emojiPack.Emojis[j];
+ var checkedEmoji = new CheckedEmojiPack.CheckedEmoji();
+ var url = emoji.Url;
+ var fileName = url.Split('/').Last();
+ var filePath = Path.Combine("cache", fileName);
+ if (!File.Exists(filePath))
+ {
+ WebClient wc = new WebClient();
+ await wc.DownloadFileTaskAsync(new Uri(url), filePath);
+ }
+ checkedEmoji.Name = emoji.Name;
+ checkedEmoji.ImagePath = "pack://siteoforigin:,,,/cache/" + fileName;
+ checkedEmojiPack.CheckedEmojis.Add(checkedEmoji);
+ }
+ list.Add(checkedEmojiPack);
+ }
+ return list;
+ }
}
}
diff --git a/BiliCore/BiliCore.csproj b/BiliCore/BiliCore.csproj
index 7514faf..0afe046 100644
--- a/BiliCore/BiliCore.csproj
+++ b/BiliCore/BiliCore.csproj
@@ -2,9 +2,9 @@
netstandard2.0
- 0.2.4.0
- 0.2.4.0
- 0.2.4.0
+ 0.2.5.0
+ 0.2.5.0
+ 0.2.5.0
diff --git a/BiliCore/Models/CheckedEmojiPack.cs b/BiliCore/Models/CheckedEmojiPack.cs
new file mode 100644
index 0000000..555e37e
--- /dev/null
+++ b/BiliCore/Models/CheckedEmojiPack.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace BiliCore.Models
+{
+
+ public class CheckedEmojiPack
+ {
+ public class CheckedEmoji
+ {
+ public string Name { get; set; }
+ public string ImagePath { get; set; }
+ }
+ public List CheckedEmojis = new List();
+ public string PackName { get; set; }
+ }
+}