From 800b8d7aee3b4ab8402bd836254003cbd1bfd7ca Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Thu, 24 Oct 2024 20:21:04 +0800 Subject: [PATCH 1/7] =?UTF-8?q?#875=20=E4=BF=AE=E5=A4=8D=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E9=A1=B5=E8=AF=84=E8=AE=BA=E8=83=8C=E6=99=AF=E9=80=8F=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Pages/Home/UserDynamicPage.xaml | 1 + src/BiliLite.UWP/Themes/Dark.xaml | 1 + src/BiliLite.UWP/Themes/Light.xaml | 1 + 3 files changed, 3 insertions(+) diff --git a/src/BiliLite.UWP/Pages/Home/UserDynamicPage.xaml b/src/BiliLite.UWP/Pages/Home/UserDynamicPage.xaml index f39b3f2a..bdd468e6 100644 --- a/src/BiliLite.UWP/Pages/Home/UserDynamicPage.xaml +++ b/src/BiliLite.UWP/Pages/Home/UserDynamicPage.xaml @@ -198,6 +198,7 @@ VerticalAlignment="Stretch" Background="{ThemeResource HalfTransparentBackground}"> diff --git a/src/BiliLite.UWP/Themes/Dark.xaml b/src/BiliLite.UWP/Themes/Dark.xaml index d48b15ab..5fbc2da1 100644 --- a/src/BiliLite.UWP/Themes/Dark.xaml +++ b/src/BiliLite.UWP/Themes/Dark.xaml @@ -20,6 +20,7 @@ #FF808080 #FF282828 + #1a2031 Transparent diff --git a/src/BiliLite.UWP/Themes/Light.xaml b/src/BiliLite.UWP/Themes/Light.xaml index 47b9ede7..bdab7eef 100644 --- a/src/BiliLite.UWP/Themes/Light.xaml +++ b/src/BiliLite.UWP/Themes/Light.xaml @@ -20,6 +20,7 @@ #FF808080 #FFF9F9F9 + #eff4f9 Transparent From 6b0e54067dc874013dab8212d02a896a8d475e80 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Thu, 24 Oct 2024 20:21:42 +0800 Subject: [PATCH 2/7] =?UTF-8?q?#857=20=E5=AE=89=E8=A3=85=E6=95=99=E7=A8=8B?= =?UTF-8?q?=E8=A1=A5=E5=85=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- document/install-readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/document/install-readme.md b/document/install-readme.md index 4b6a29a8..ad9cf851 100644 --- a/document/install-readme.md +++ b/document/install-readme.md @@ -46,7 +46,7 @@ ![](./_img/check-ps1-permission-02.drawio.png) -3. 执行命令`Set-ExecutionPolicy -ExecutionPolicy RemoteSigned`并按Y键启用脚本执行权限 +3. 执行命令`Set-ExecutionPolicy -ExecutionPolicy RemoteSigned`并按Y键启用脚本执行权限, 如果执行命令后无任何输出表示执行成功可以进入下一步运行安装脚本 ### 运行安装脚本 From 281bb6174c6af2cf84b246389f5aa92ae7b2c373 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Thu, 24 Oct 2024 20:22:34 +0800 Subject: [PATCH 3/7] =?UTF-8?q?#876=20=E4=BF=AE=E5=A4=8D=E6=97=A0=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E5=9B=BE=E7=89=87=E5=8A=A8=E6=80=81=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UserDynamicItemV2DataTemplateSelector.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/BiliLite.UWP/Controls/DataTemplateSelectors/UserDynamicItemV2DataTemplateSelector.cs b/src/BiliLite.UWP/Controls/DataTemplateSelectors/UserDynamicItemV2DataTemplateSelector.cs index 6147bf51..0cfdf576 100644 --- a/src/BiliLite.UWP/Controls/DataTemplateSelectors/UserDynamicItemV2DataTemplateSelector.cs +++ b/src/BiliLite.UWP/Controls/DataTemplateSelectors/UserDynamicItemV2DataTemplateSelector.cs @@ -20,6 +20,7 @@ static UserDynamicItemV2DataTemplateSelector() { Constants.DynamicTypes.DRAW, (selector, model) => { + if (model.Dynamic == null) return selector.OtherTemplate; if (model.Dynamic.DynDraw.Items.Count == 1) { return selector.Draw1x1Template; From 9fbbb0929ded01b6ec0673dacb0b9a807c841da9 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Fri, 25 Oct 2024 12:09:54 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E7=A7=BB=E9=99=A4RestSharp=E4=BE=9D?= =?UTF-8?q?=E8=B5=96=EF=BC=9B=E5=A4=84=E7=90=86Simple.AES=E3=80=81System.D?= =?UTF-8?q?rawing.Common=E7=89=88=E6=9C=AC=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/BiliLite.UWP.csproj | 5 +- .../Extensions/ApiModelExtensions.cs | 3 +- src/BiliLite.UWP/Models/Common/Enumerates.cs | 9 +++ .../Models/Requests/Api/AccountApi.cs | 78 +++++++++---------- .../Models/Requests/Api/CommentApi.cs | 16 ++-- .../Models/Requests/Api/EmoteApi.cs | 5 +- .../Models/Requests/Api/GitApi.cs | 4 +- .../Models/Requests/Api/Home/AnimeAPI.cs | 8 +- .../Models/Requests/Api/Home/CinemaAPI.cs | 4 +- .../Models/Requests/Api/Home/HotApi.cs | 5 +- .../Models/Requests/Api/Home/LiveAPI.cs | 7 +- .../Models/Requests/Api/Home/RecommendAPI.cs | 9 ++- .../Models/Requests/Api/Live/LiveAreaAPI.cs | 7 +- .../Models/Requests/Api/Live/LiveCenterAPI.cs | 13 ++-- .../Requests/Api/Live/LiveRecommendAPI.cs | 5 +- .../Models/Requests/Api/Live/LiveRoomAPI.cs | 45 +++++------ .../Models/Requests/Api/PlayerAPI.cs | 24 +++--- .../Models/Requests/Api/RankAPI.cs | 7 +- .../Models/Requests/Api/RegionAPI.cs | 15 ++-- .../Models/Requests/Api/SearchAPI.cs | 19 ++--- .../Models/Requests/Api/SeasonApi.cs | 11 ++- .../Models/Requests/Api/SeasonIndexAPI.cs | 7 +- .../Models/Requests/Api/User/AtAPI.cs | 5 +- .../Models/Requests/Api/User/DynamicAPI.cs | 31 ++++---- .../Models/Requests/Api/User/FavoriteAPI.cs | 41 +++++----- .../Models/Requests/Api/User/FollowAPI.cs | 17 ++-- .../Models/Requests/Api/User/UserDetailAPI.cs | 29 +++---- .../Models/Requests/Api/User/WatchLaterAPI.cs | 13 ++-- .../Models/Requests/Api/VideoAPI.cs | 23 +++--- src/BiliLite.UWP/Models/Requests/ApiModel.cs | 3 +- .../SendDynamic/SendDynamicV2ViewModel.cs | 35 ++++----- .../User/SendDynamic/SendDynamicViewModel.cs | 34 ++++---- .../BiliLite.Win32Tools.csproj | 4 +- src/BiliLite.Win32Tools/packages.config | 2 +- 34 files changed, 276 insertions(+), 267 deletions(-) diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 1a433522..2b74db93 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -1540,10 +1540,7 @@ 1.4.3 - - 107.3.0 - - + 2.0.2 diff --git a/src/BiliLite.UWP/Extensions/ApiModelExtensions.cs b/src/BiliLite.UWP/Extensions/ApiModelExtensions.cs index ee85e329..0da00685 100644 --- a/src/BiliLite.UWP/Extensions/ApiModelExtensions.cs +++ b/src/BiliLite.UWP/Extensions/ApiModelExtensions.cs @@ -1,5 +1,6 @@ using System.Runtime.CompilerServices; using System.Threading.Tasks; +using BiliLite.Models.Common; using BiliLite.Models.Requests; using BiliLite.Models.Responses; using BiliLite.Services; @@ -18,7 +19,7 @@ public static class ApiModelExtensions public static async Task Request(this ApiModel api, [CallerMemberName] string methodName = null) { _logger.Trace($"¼ {methodName} {api.baseUrl}"); - if (api.method == RestSharp.Method.Get) + if (api.method == HttpMethods.Get) { if (api.need_redirect) { diff --git a/src/BiliLite.UWP/Models/Common/Enumerates.cs b/src/BiliLite.UWP/Models/Common/Enumerates.cs index ffc92e0a..5619ef65 100644 --- a/src/BiliLite.UWP/Models/Common/Enumerates.cs +++ b/src/BiliLite.UWP/Models/Common/Enumerates.cs @@ -11,6 +11,15 @@ public enum LogType Necessary, } + public enum HttpMethods + { + Get, + Post, + Put, + Patch, + Delete, + } + public enum LoginStatus { /// diff --git a/src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs b/src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs index 1e32f484..1ac1e683 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs @@ -24,7 +24,7 @@ public ApiModel GetKey() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://passport.bilibili.com/x/passport-login/web/key" }; return api; @@ -38,7 +38,7 @@ public ApiModel LoginV2(string username, string password, string captcha = "", A { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/api/oauth2/login", body = $"username={Uri.EscapeDataString(username)}&password={Uri.EscapeDataString(password)}{(captcha == "" ? "" : "&captcha=" + captcha)}&" + ApiHelper.MustParameter(appKey) }; @@ -54,7 +54,7 @@ public ApiModel LoginV3(string username, string password, ApiKeyInfo appKey) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/passport-login/oauth2/login", body = $"actionKey=appkey&channel=bili&device=phone&permission=ALL&subid=1&username={Uri.EscapeDataString(username)}&password={Uri.EscapeDataString(password)}&" + ApiHelper.MustParameter(appKey), headers = ApiHelper.MustHeader(appKey), @@ -71,7 +71,7 @@ public ApiModel Country() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://passport.bilibili.com/x/passport-login/country", parameter = ApiHelper.MustParameter(AppKey) }; @@ -83,7 +83,7 @@ public ApiModel SendSMS(string cid, string phone, string sessionId, ApiKeyInfo a { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/passport-login/sms/send", body = $"actionKey=appkey&cid={cid}&tel={phone}&login_session_id={sessionId}&" + ApiHelper.MustParameter(appKey), headers = ApiHelper.MustHeader(appKey), @@ -101,7 +101,7 @@ public ApiModel SendSMSWithCaptcha(string cid, string phone, string session_id, var buvid = ApiHelper.GetBuvid(); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/passport-login/sms/send", body = $"buvid={buvid}&actionKey=appkey&cid={cid}&tel={phone}&login_session_id={session_id}&gee_seccode={seccode}&gee_validate={validate}&gee_challenge={challenge}&recaptcha_token={recaptchaToken}&" + ApiHelper.MustParameter(appKey), headers = ApiHelper.MustHeader(appKey), @@ -114,7 +114,7 @@ public ApiModel SMSLogin(string cid, string phone, string code, string sessionId { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/passport-login/login/sms", body = $"actionKey=appkey&cid={cid}&tel={phone}&login_session_id={sessionId}&captcha_key={captchaKey}&code={code}&" + ApiHelper.MustParameter(appKey), headers = ApiHelper.MustHeader(appKey), @@ -132,7 +132,7 @@ public ApiModel SSO(string accessKey) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://passport.bilibili.com/api/login/sso", parameter = ApiHelper.MustParameter(AppKey, false) + $"&access_key={accessKey}", headers = ApiHelper.GetDefaultHeaders() @@ -149,7 +149,7 @@ public ApiModel Captcha() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://passport.bilibili.com/captcha", headers = ApiHelper.GetDefaultHeaders(), parameter = $"ts={TimeExtensions.GetTimestampS()}" @@ -165,7 +165,7 @@ public ApiModel GeetestCaptcha() { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/safecenter/captcha/pre" }; return api; @@ -179,7 +179,7 @@ public ApiModel FetchHideTel(string tmp_token) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.bilibili.com/x/safecenter/user/info", parameter = $"tmp_code={tmp_token}" }; @@ -194,7 +194,7 @@ public ApiModel SendVerifySMS(string tmp_token, string recaptcha_token, string g { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/safecenter/common/sms/send", body = $"sms_type=loginTelCheck&tmp_code={tmp_token}&recaptcha_token={recaptcha_token}&gee_challenge={gee_challenge}&gee_gt={gee_gt}&gee_validate={geetest_validate}&gee_seccode={geetest_seccode}" }; @@ -209,7 +209,7 @@ public ApiModel SubmitPwdLoginSMSCheck(string code, string tmp_token, string req { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/safecenter/login/tel/verify", body = $"type=loginTelCheck&code={code}&tmp_code={tmp_token}&request_id={request_id}&captcha_key={captcha_key}" }; @@ -224,7 +224,7 @@ public ApiModel PwdLoginExchangeCookie(string code) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/passport-login/web/exchange_cookie", body = $"code={code}" }; @@ -239,7 +239,7 @@ public ApiModel UserProfile() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://app.bilibili.com/x/v2/account/myinfo", parameter = ApiHelper.MustParameter(AppKey, true) }; @@ -256,7 +256,7 @@ public ApiModel MineProfile() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://app.bilibili.com/x/v2/account/mine", parameter = ApiHelper.MustParameter(AppKey, true) }; @@ -272,7 +272,7 @@ public ApiModel Space(string mid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "http://app.biliapi.net/x/v2/space", parameter = ApiHelper.MustParameter(AppKey, true) + $"&vmid={mid}" }; @@ -284,7 +284,7 @@ public ApiModel History(int pn = 1, int ps = 24) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/history", parameter = ApiHelper.MustParameter(AppKey, true) + $"&pn={pn}&ps={ps}" }; @@ -304,7 +304,7 @@ public ApiModel HistoryWbi(HistoryCursor cursor) } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/web-interface/history/cursor", parameter = $"max={cursor.Max}&view_at={cursor.ViewAt}&business=", need_cookie = true, @@ -317,7 +317,7 @@ public ApiModel SearchHistory(string keyword, int page) var kw = keyword.UrlEncode(); var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/web-goblin/history/search", parameter = $"pn={page}&ps=20&keyword={kw}&business=all", need_cookie = true, @@ -329,7 +329,7 @@ public ApiModel DelHistory(string id) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/history/delete", body = ApiHelper.MustParameter(AppKey, true) + $"&kid={id}" }; @@ -346,7 +346,7 @@ public ApiModel QRLoginAuthCodeTV(string local_id, ApiKeyInfo appkey) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/passport-tv-login/qrcode/auth_code", body = $"appkey={appkey.Appkey}&local_id={local_id}&ts={TimeExtensions.GetTimestampS()}&mobi_app=ios", headers = ApiHelper.MustHeader(appkey), @@ -364,7 +364,7 @@ public ApiModel QRLoginPollTV(string auth_code, string local_id, ApiKeyInfo appk { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/x/passport-tv-login/qrcode/poll", body = $"appkey={appkey.Appkey}&auth_code={auth_code}&local_id={local_id}&ts={TimeExtensions.GetTimestampS()}&mobi_app=ios", headers = ApiHelper.MustHeader(appkey), @@ -381,7 +381,7 @@ public ApiModel QRLoginAuthCode() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://passport.bilibili.com/x/passport-login/web/qrcode/generate", }; return api; @@ -396,7 +396,7 @@ public ApiModel QRLoginPoll(string auth_code) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://passport.bilibili.com/x/passport-login/web/qrcode/poll", parameter = $"qrcode_key={auth_code}" }; @@ -412,7 +412,7 @@ public ApiModel GetCookieToAccessKey(ApiKeyInfo appKey) var apiBody = "api=http://link.acg.tv/forum.php"; var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://passport.bilibili.com/login/app/third", parameter = $"appkey={appKey.Appkey}&{apiBody}", need_cookie = true, @@ -429,7 +429,7 @@ public ApiModel GetCookieToAccessKey(string url) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = url, need_cookie = true, need_redirect = true, @@ -445,7 +445,7 @@ public ApiModel GetOAuth2Info() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://passport.bilibili.com/api/oauth2/info", parameter = ApiHelper.MustParameter(AppKey) + "&access_token=" + SettingService.Account.AccessKey }; @@ -461,7 +461,7 @@ public ApiModel RefreshToken(ApiKeyInfo appKey) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://passport.bilibili.com/api/oauth2/refreshToken", body = ApiHelper.MustParameter(appKey) + $"&access_token={SettingService.Account.AccessKey}&refresh_token={SettingService.GetValue(SettingConstants.Account.REFRESH_KEY, "")}" }; @@ -478,7 +478,7 @@ public ApiModel CheckCookies() var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://passport.bilibili.com/x/passport-login/web/cookie/info", parameter = $"csrf={csrf}", need_cookie = true, @@ -494,7 +494,7 @@ public ApiModel RefreshCsrf(string correspondPath) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://www.bilibili.com/correspond/1/{correspondPath}", need_cookie = true, }; @@ -510,7 +510,7 @@ public ApiModel RefreshCookie(string refreshCsrf,string refreshToken) var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://passport.bilibili.com/x/passport-login/web/cookie/refresh", body = $"csrf={csrf}&refresh_csrf={refreshCsrf}&source=main_web&refresh_token={refreshToken}", need_cookie = true, @@ -527,7 +527,7 @@ public ApiModel ConfirmRefreshCookie(string refreshToken) var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://passport.bilibili.com/x/passport-login/web/confirm/refresh", body = $"csrf={csrf}&refresh_token={refreshToken}", need_cookie = true, @@ -539,7 +539,7 @@ public ApiModel Nav() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.bilibili.com/x/web-interface/nav" }; return api; @@ -549,7 +549,7 @@ public ApiModel Buvid() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.bilibili.com/x/web-frontend/getbuvid" }; return api; @@ -559,7 +559,7 @@ public ApiModel Buvid4() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.bilibili.com/x/frontend/finger/spi" }; return api; @@ -569,7 +569,7 @@ public ApiModel BNut() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://www.bilibili.com/", need_cookie = true, }; @@ -583,7 +583,7 @@ public ApiModel BiliTicket() var hexSign = ApiHelper.GetHMACSHA256("XgwSnGZ1p", $"ts{ts}"); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://api.bilibili.com/bapis/bilibili.api.ticket.v1.Ticket/GenWebTicket", parameter= $"key_id=ec02&hexsign={hexSign}&context[ts]={ts}&csrf={csrf}", need_cookie = true, @@ -596,7 +596,7 @@ public ApiModel CaptchaRegister(string voucher) var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://api.bilibili.com/x/gaia-vgate/v1/register", body = $"csrf={csrf}&v_voucher={voucher}", need_cookie = true, diff --git a/src/BiliLite.UWP/Models/Requests/Api/CommentApi.cs b/src/BiliLite.UWP/Models/Requests/Api/CommentApi.cs index fc9cd8fa..2bc10148 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/CommentApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/CommentApi.cs @@ -46,7 +46,7 @@ public ApiModel Comment(string oid, CommentSort sort, int pn, int type, int ps = { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/reply", parameter = $"oid={oid}&plat=2&pn={pn}&ps={ps}&sort={(int)sort}&type={type}", need_cookie = true, @@ -76,7 +76,7 @@ public ApiModel CommentV2(string oid, CommentSort sort, int pn, int type, int ps var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/reply/main", parameter = $"oid={oid}&ps={ps}&mode={mode}&type={type}&csrf={csrf}&pagination_str={paginationStr}", need_cookie = true, @@ -89,7 +89,7 @@ public ApiModel Reply(string oid, string root, int pn, int type, int ps = 30) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/reply/reply", parameter = $"oid={oid}&plat=2&pn={pn}&ps={ps}&root={root}&type={type}", need_cookie = true, @@ -103,7 +103,7 @@ public ApiModel Like(string oid, string root, int action, int type) var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/reply/action", body = $"&oid={oid}&rpid={root}&action={action}&type={type}&csrf={csrf}", need_cookie = true, @@ -117,7 +117,7 @@ public ApiModel ReplyComment(string oid, string root, string parent, string mess var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/reply/add", body = $"&oid={oid}&root={root}&parent={parent}&type={type}&message={message}&csrf={csrf}", need_cookie = true, @@ -131,7 +131,7 @@ public ApiModel DeleteComment(string oid, string rpid, int type) var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/reply/del", body = $"&oid={oid}&rpid={rpid}&type={type}&csrf={csrf}", need_cookie = true, @@ -145,7 +145,7 @@ public ApiModel AddComment(string oid, CommentType type, string message, List() { diff --git a/src/BiliLite.UWP/Models/Requests/Api/EmoteApi.cs b/src/BiliLite.UWP/Models/Requests/Api/EmoteApi.cs index fb854adb..8f4befa1 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/EmoteApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/EmoteApi.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api { @@ -21,7 +22,7 @@ public ApiModel UserEmote(EmoteBusiness business) var type = business.ToString(); var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/emote/user/panel/web", parameter = ApiHelper.MustParameter(AppKey) + $"&business={type}", headers = ApiHelper.GetAuroraHeaders(), diff --git a/src/BiliLite.UWP/Models/Requests/Api/GitApi.cs b/src/BiliLite.UWP/Models/Requests/Api/GitApi.cs index 4a6cdeb5..cc001cf2 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/GitApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/GitApi.cs @@ -17,7 +17,7 @@ public ApiModel CheckUpdate() updateJsonAddress = updateJsonAddress.Replace("\"", ""); // 解决取出的值有奇怪的转义符 var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{updateJsonAddress}/document/new_version.json", parameter = $"ts={TimeExtensions.GetTimestampS()}" }; @@ -32,7 +32,7 @@ public ApiModel FindMoreEntrance() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.GIT_RAW_URL}/document/entrance.json", parameter = $"ts={TimeExtensions.GetTimestampS()}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/Home/AnimeAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/Home/AnimeAPI.cs index ddd170e8..6526100a 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Home/AnimeAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Home/AnimeAPI.cs @@ -10,7 +10,7 @@ public ApiModel BangumiHome() var baseUrl = SettingService.GetValue(SettingConstants.Other.BILI_LITE_WEB_API_BASE_URL, ApiConstants.BILI_LITE_WEB_API_DEFAULT_BASE_URL); var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{baseUrl}api/anime/bangumi" }; return api; @@ -21,7 +21,7 @@ public ApiModel GuochuangHome() var baseUrl = SettingService.GetValue(SettingConstants.Other.BILI_LITE_WEB_API_BASE_URL, ApiConstants.BILI_LITE_WEB_API_DEFAULT_BASE_URL); var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{baseUrl}api/anime/guochuang" }; return api; @@ -32,7 +32,7 @@ public ApiModel Timeline(int type) var baseUrl = SettingService.GetValue(SettingConstants.Other.BILI_LITE_WEB_API_BASE_URL, ApiConstants.BILI_LITE_WEB_API_DEFAULT_BASE_URL); var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{baseUrl}api/anime/timeline", parameter = "type=" + type }; @@ -44,7 +44,7 @@ public ApiModel AnimeFallMore(int wid, long cursor = 0) var baseUrl = SettingService.GetValue(SettingConstants.Other.BILI_LITE_WEB_API_BASE_URL, ApiConstants.BILI_LITE_WEB_API_DEFAULT_BASE_URL); var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{baseUrl}api/anime/bangumiFalls", parameter = $"wid={wid}&cursor={cursor}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/Home/CinemaAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/Home/CinemaAPI.cs index b7d2e932..5c1747eb 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Home/CinemaAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Home/CinemaAPI.cs @@ -10,7 +10,7 @@ public ApiModel CinemaHome() var baseUrl = SettingService.GetValue(SettingConstants.Other.BILI_LITE_WEB_API_BASE_URL, ApiConstants.BILI_LITE_WEB_API_DEFAULT_BASE_URL); var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{baseUrl}api/cinema/home" }; return api; @@ -20,7 +20,7 @@ public ApiModel CinemaFallMore(int wid, long cursor = 0) var baseUrl = SettingService.GetValue(SettingConstants.Other.BILI_LITE_WEB_API_BASE_URL, ApiConstants.BILI_LITE_WEB_API_DEFAULT_BASE_URL); var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{baseUrl}api/cinema/falls", parameter = $"wid={wid}&cursor={cursor}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/Home/HotApi.cs b/src/BiliLite.UWP/Models/Requests/Api/Home/HotApi.cs index ca62e3ec..2e2d0ac7 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Home/HotApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Home/HotApi.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api.Home { @@ -8,7 +9,7 @@ public ApiModel Popular(string idx = "0", string last_param = "") { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/v2/show/popular/index", parameter = ApiHelper.MustParameter(AppKey, true) + $"&idx={idx}&last_param={last_param}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/Home/LiveAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/Home/LiveAPI.cs index 365a55e0..2cd93b3f 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Home/LiveAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Home/LiveAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api.Home { @@ -8,7 +9,7 @@ public ApiModel LiveHome() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.live.bilibili.com/xlive/app-interface/v2/index/getAllList", parameter = ApiHelper.MustParameter(AppKey, true) + "&device=android&rec_page=1&relation_page=1&scale=xxhdpi", }; @@ -21,7 +22,7 @@ public ApiModel LiveHomeItems() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.live.bilibili.com/xlive/web-interface/v1/index/getList", parameter = "platform=web" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/Home/RecommendAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/Home/RecommendAPI.cs index b47a811d..ee53a0cd 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Home/RecommendAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Home/RecommendAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api.Home { @@ -8,7 +9,7 @@ public ApiModel Recommend(string idx = "0") { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/v2/feed/index", parameter = ApiHelper.MustParameter(AppKey, true) + $"&flush=0&idx={idx}&login_event=2&network=wifi&open_event=&pull={(idx == "0").ToString().ToLower()}&qn=32&style=2", headers = ApiHelper.GetAuroraHeaders() @@ -21,7 +22,7 @@ public ApiModel Dislike(RecommondFeedbackParams feedbackParams) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.biliapi.net/x/feed/dislike", parameter = ApiHelper.MustParameter(AppKey, true) + $"&goto={feedbackParams.GoTo}&id={feedbackParams.Id}&mid={feedbackParams.Mid}&reason_id={feedbackParams.ReasonId}&rid={feedbackParams.Rid}&tag_id={feedbackParams.TagId}" @@ -33,7 +34,7 @@ public ApiModel Feedback(RecommondFeedbackParams feedbackParams) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.biliapi.net/x/feed/dislike", parameter = ApiHelper.MustParameter(AppKey, true) + $"&goto={feedbackParams.GoTo}&id={feedbackParams.Id}&mid={feedbackParams.Mid}&feedback_id={feedbackParams.ReasonId}&rid={feedbackParams.Rid}&tag_id={feedbackParams.TagId}" diff --git a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveAreaAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveAreaAPI.cs index d8a4390d..f5e9112d 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveAreaAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveAreaAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api.Live { @@ -8,7 +9,7 @@ public ApiModel LiveAreaList() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/room/v1/Area/getList", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&need_entrance=1&parent_id=0" }; @@ -20,7 +21,7 @@ public ApiModel LiveAreaRoomList(int area_id = 0, int parent_area_id = 0, int pa { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/room/v3/Area/getRoomList", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&area_id={area_id}&cate_id=0&parent_area_id={parent_area_id}&page={page}&page_size=36&sort_type={sort_type}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveCenterAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveCenterAPI.cs index 1f4c4adb..8fefdf48 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveCenterAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveCenterAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api.Live { @@ -8,7 +9,7 @@ public ApiModel FollowLive() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.live.bilibili.com/xlive/app-interface/v1/relation/liveAnchor", parameter = ApiHelper.MustParameter(AppKey, true) + "&qn=0&sortRule=0&filterRule=0", }; @@ -20,7 +21,7 @@ public ApiModel FollowUnLive(int page) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.live.bilibili.com/xlive/app-interface/v1/relation/unliveAnchor", parameter = ApiHelper.MustParameter(AppKey, true) + $"&page={page}&pagesize=30", }; @@ -32,7 +33,7 @@ public ApiModel History(int page) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://app.bilibili.com/x/v2/history/liveList", parameter = ApiHelper.MustParameter(AppKey, true) + $"&pn={page}&ps=20", }; @@ -44,7 +45,7 @@ public ApiModel SignInfo() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.live.bilibili.com/rc/v2/Sign/getSignInfo", parameter = ApiHelper.MustParameter(AppKey, true) + "&actionKey=appkey", }; @@ -56,7 +57,7 @@ public ApiModel DoSign() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/rc/v1/Sign/doSign", parameter = ApiHelper.MustParameter(AppKey, true) + "&actionKey=appkey" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRecommendAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRecommendAPI.cs index 85e967ef..564b912e 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRecommendAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRecommendAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api.Live { @@ -14,7 +15,7 @@ public ApiModel LiveRoomList(int page = 1, string sort_type = "online") { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/room/v3/Area/getRoomList", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&area_id=0&cate_id=0&parent_area_id=0&page={page}&page_size=36&sort_type={sort_type}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRoomAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRoomAPI.cs index 4a4e7456..bdff23e0 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRoomAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/Live/LiveRoomAPI.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; +using BiliLite.Models.Common; namespace BiliLite.Models.Requests.Api.Live { @@ -24,7 +25,7 @@ public ApiModel LiveRoomInfo(string roomid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/xlive/app-room/v1/index/getInfoByRoom", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&room_id={roomid}&device=android" }; @@ -39,7 +40,7 @@ public ApiModel MyWallet() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/pay/v2/Pay/myWallet", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey" }; @@ -55,7 +56,7 @@ public ApiModel LiveTitles() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/rc/v1/Title/getTitle", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey" }; @@ -71,7 +72,7 @@ public ApiModel GiftList(int area_v2_id, int area_v2_parent_id, int roomId) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/gift/v4/Live/giftConfig", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&area_v2_id={area_v2_id}&area_v2_parent_id={area_v2_parent_id}&roomid={roomId}" }; @@ -87,7 +88,7 @@ public ApiModel BagList(int roomId) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/xlive/app-room/v1/gift/bag_list", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&roomid={roomId}" }; @@ -103,7 +104,7 @@ public ApiModel RoomGifts(int area_v2_id, int area_v2_parent_id, int roomId) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/gift/v3/live/room_gift_list", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&area_v2_id={area_v2_id}&area_v2_parent_id={area_v2_parent_id}&roomid={roomId}" }; @@ -119,7 +120,7 @@ public ApiModel FreeSilverTime() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/mobile/freeSilverCurrentTask", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey" }; @@ -134,7 +135,7 @@ public ApiModel GetFreeSilver() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/mobile/freeSilverAward", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey" }; @@ -150,7 +151,7 @@ public ApiModel SendBagGift(long ruid, int giftId, int num, int bagId, int roomI { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://api.live.bilibili.com/xlive/revenue/v1/gift/sendBag", body = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey", need_cookie = true, @@ -168,7 +169,7 @@ public ApiModel SendGift(long ruid, int giftId, string coinType, int num, int ro { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://api.live.bilibili.com/xlive/revenue/v1/gift/send{char.ToUpper(coinType[0]) + coinType.Substring(1)}", body = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey", need_cookie = true, @@ -187,7 +188,7 @@ public ApiModel SendDanmu(string text, int roomId) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://api.live.bilibili.com/api/sendmsg", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey", }; @@ -204,7 +205,7 @@ public ApiModel AnchorProfile(long uid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/live_user/v1/card/card_up", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&uid={uid}", }; @@ -224,7 +225,7 @@ public ApiModel GuardList(long ruid, int roomId, int page) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/xlive/app-room/v1/guardTab/topList", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&page={page}&page_size=20&roomid={roomId}&ruid={ruid}", }; @@ -243,7 +244,7 @@ public ApiModel FansList(long ruid, int roomId, int page) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/rankdb/v2/RoomRank/mobileMedalRank", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&page={page}&roomid={roomId}&ruid={ruid}", }; @@ -264,7 +265,7 @@ public ApiModel RoomRankList(long ruid, int roomId, string rank_type, string swi { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/xlive/general-interface/v1/rank/queryContributionRank", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&room_id={roomId}&ruid={ruid}&type={rank_type}&switch={switch_type}", }; @@ -281,7 +282,7 @@ public ApiModel RoomLotteryInfo(int roomId) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/xlive/lottery-interface/v1/lottery/getLotteryInfo", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&roomid={roomId}", need_cookie = true, @@ -299,7 +300,7 @@ public ApiModel RoomSuperChat(int roomId) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/av/v1/SuperChat/getMessageList", parameter = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&room_id={roomId}", }; @@ -315,7 +316,7 @@ public ApiModel RoomEntryAction(int roomId) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://api.live.bilibili.com/room/v1/Room/room_entry_action", body = ApiHelper.MustParameter(AppKey, true) + $"&actionKey=appkey&room_id={roomId}", }; @@ -332,7 +333,7 @@ public ApiModel GetDanmuInfo(int roomId) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/xlive/web-room/v1/index/getDanmuInfo", parameter = $"?id={roomId}", need_cookie = true @@ -348,7 +349,7 @@ public ApiModel GetBuvid() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.bilibili.com/x/frontend/finger/spi", need_cookie = true }; @@ -366,7 +367,7 @@ public ApiModel JoinAnchorLottery(int roomId, int lottery_id, string buvid3, int var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://api.live.bilibili.com/xlive/lottery-interface/v1/Anchor/Join", body = $"room_id={roomId}&id={lottery_id}&platform=pc&csrf={csrf}", need_cookie = true, @@ -390,7 +391,7 @@ public ApiModel JoinRedPocketLottery(long uid, int room_id, long ruid, int lot_i var csrf = m_cookieService.GetCSRFToken(); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = "https://api.live.bilibili.com/xlive/lottery-interface/v1/popularityRedPocket/RedPocketDraw", parameter = $"csrf={csrf}", body = $"uid={uid}&room_id={room_id}&ruid={ruid}&lot_id={lot_id}&ts={TimeExtensions.GetTimestampS()}", diff --git a/src/BiliLite.UWP/Models/Requests/Api/PlayerAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/PlayerAPI.cs index 49768196..2e4966f4 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/PlayerAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/PlayerAPI.cs @@ -19,7 +19,7 @@ public ApiModel VideoPlayUrl(string aid, string cid, int qn, bool dash, bool pro } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{baseUrl}/x/player/playurl", parameter = $"avid={aid}&cid={cid}&qn={qn}&type=&otype=json&mid={(SettingService.Account.Logined ? SettingService.Account.Profile.mid.ToString() : "")}", need_cookie = true, @@ -42,7 +42,7 @@ public ApiModel SeasonPlayUrl(string aid, string cid, string ep_id, int qn, int } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{baseUrl}/pgc/player/web/playurl", parameter = $"appkey={AppKey.Appkey}&cid={cid}&ep_id={ep_id}&qn={qn}&type=&otype=json&module=bangumi&season_type={season_type}" }; @@ -68,7 +68,7 @@ public ApiModel SeasonAndroidPlayUrl(string aid, string cid, int qn, int season_ { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/player/web/playurl", parameter = $"appkey={AppKey.Appkey}&cid={cid}&qn={qn}&type=&otype=json&module=bangumi&season_type={season_type}" }; @@ -86,7 +86,7 @@ public ApiModel LivePlayUrl(string room_id, int qn = 0) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.live.bilibili.com/xlive/web-room/v2/index/getRoomPlayInfo", parameter = $"room_id={room_id}&qn={qn}&protocol=0,1&format=0,2&codec=0,1", //"cid={cid}&qn={qn}&platform=web" need_cookie = true @@ -106,7 +106,7 @@ public ApiModel InteractionEdgeInfo(string aid, int graph_version, int edge_id = { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/stein/edgeinfo_v2", parameter = ApiHelper.MustParameter(AppKey, true) + $"&aid={aid}&graph_version={graph_version}&edge_id={edge_id}" }; @@ -128,7 +128,7 @@ public ApiModel SeasonHistoryReport(string aid, string cid, int progress, int si { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/history/report", body = ApiHelper.MustParameter(AppKey, true) + $"&aid={aid}&cid={cid}&epid={epid}&sid={sid}&progress={progress}&realtime={progress}&sub_type=1&type={type}" }; @@ -151,7 +151,7 @@ public ApiModel SendDanmu(string aid, string cid, string color, string msg, int { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/dm/post", parameter = ApiHelper.MustParameter(AppKey, true) + $"&aid={aid}", body = $"msg={Uri.EscapeDataString(msg)}&mode={mode}&screen_state=1&color={color}&pool=0&progress={Convert.ToInt32(position * 1000)}&fontsize=25&rnd={TimeExtensions.GetTimestampS()}&from=7&oid={cid}&plat={plat}&type=1" @@ -170,7 +170,7 @@ public async Task GetPlayerInfo(string aid, string cid, string bvid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/player/wbi/v2", parameter = $"cid={cid}&aid={aid}&bvid={bvid}", need_cookie = true, @@ -189,7 +189,7 @@ public ApiModel GetPlayerOnline(string aid, string cid, string bvid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/player/online/total", parameter = $"cid={cid}&aid={aid}&bvid={bvid}", }; @@ -204,7 +204,7 @@ public ApiModel GetDanmuFilterWords() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/dm/filter/user", parameter = ApiHelper.MustParameter(AppKey, true) }; @@ -222,7 +222,7 @@ public ApiModel AddDanmuFilterWord(string word, int type) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/dm/filter/user/add", body = ApiHelper.MustParameter(AppKey, true) + $"&filter={Uri.EscapeDataString(word)}&type={type}" }; @@ -240,7 +240,7 @@ public ApiModel SegDanmaku(string oid, int segment_index) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"http://api.bilibili.com/x/v2/dm/list/seg.so", parameter = $"type=1&oid={oid}&segment_index={segment_index}&{ApiHelper.MustParameter(AppKey, true)}", }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/RankAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/RankAPI.cs index 4ef8f9e1..122cc8f3 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/RankAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/RankAPI.cs @@ -1,4 +1,5 @@ using System.Threading.Tasks; +using BiliLite.Models.Common; using BiliLite.Services; namespace BiliLite.Models.Requests.Api @@ -9,7 +10,7 @@ public class RankAPI //{ // var api = new ApiModel() // { - // method = RestSharp.Method.Get, + // method = HttpMethods.Get, // baseUrl = $"{ApiHelper.baseUrl}/api/rank/RankRegion" // }; // return api; @@ -24,7 +25,7 @@ public async Task Rank(int rid, string type) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/web-interface/ranking/v2", parameter = $"rid={rid}&type={type}", }; @@ -45,7 +46,7 @@ public ApiModel SeasonRank(int type) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/season/rank/list", parameter = $"season_type={type}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/RegionAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/RegionAPI.cs index 276dacf9..32ebea3a 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/RegionAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/RegionAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api { @@ -8,7 +9,7 @@ public ApiModel Regions() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/v2/region/index", parameter = ApiHelper.MustParameter(AppKey, true) }; @@ -20,7 +21,7 @@ public ApiModel RegionDynamic(int rid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/v2/region/dynamic", parameter = ApiHelper.MustParameter(AppKey, false) + $"&rid={rid}" }; @@ -31,7 +32,7 @@ public ApiModel RegionDynamic(int rid, string next_aid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.biliapi.net/x/v2/region/dynamic/list", parameter = ApiHelper.MustParameter(AppKey, false) + $"&rid={rid}&ctime={next_aid}&pull=false" }; @@ -44,7 +45,7 @@ public ApiModel RegionChildDynamic(int rid, int tag_id = 0) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.biliapi.net/x/v2/region/dynamic/child", parameter = ApiHelper.MustParameter(AppKey, false) + $"&rid={rid}&tag_id={tag_id}&pull=true" }; @@ -56,7 +57,7 @@ public ApiModel RegionChildDynamic(int rid, string next, int tag_id = 0) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/v2/region/dynamic/child/list", parameter = ApiHelper.MustParameter(AppKey, false) + $"&rid={rid}&tag_id={tag_id}&pull=false&ctime={next}" }; @@ -67,7 +68,7 @@ public ApiModel RegionChildList(int rid, string order, int page, int tag_id = 0) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.biliapi.net/x/v2/region/show/child/list", parameter = ApiHelper.MustParameter(AppKey, false) + $"&order={order}&pn={page}&ps=20&rid={rid}&tag_id={tag_id}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/SearchAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/SearchAPI.cs index 974a380f..49def992 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/SearchAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/SearchAPI.cs @@ -2,6 +2,7 @@ using BiliLite.Services; using System; using System.Collections.Generic; +using BiliLite.Models.Common; namespace BiliLite.Models.Requests.Api { @@ -21,7 +22,7 @@ public ApiModel Search(string keyword, string order = "", int duration = 0, int { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/v2/search", parameter = ApiHelper.MustParameter(AppKey, true) + "&fnval=16&fnver=0&force_host=0&fourk=1&from_source=app_search&highlight=0&is_org_query=0&qn=112&recommend=1" }; @@ -51,7 +52,7 @@ public ApiModel WebSearchVideo(string keyword, int pn = 1, string order = "", st } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, need_cookie = true, baseUrl = $"{baseUrl}/x/web-interface/search/type", parameter = $"context=&search_type=video&page={pn}&order={order}&keyword={Uri.EscapeDataString(keyword)}&duration={duration}&category_id=&tids_2=&__refresh__=true&tids={region}&highlight=1&single_column=0" @@ -72,7 +73,7 @@ public ApiModel WebSearchAnime(string keyword, int pn = 1, string area = "") } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, need_cookie = true, baseUrl = $"{baseUrl}/x/web-interface/search/type", parameter = $"context=&search_type=media_bangumi&page={pn}&order=&keyword={Uri.EscapeDataString(keyword)}&category_id=&__refresh__=true&highlight=1&single_column=0" @@ -93,7 +94,7 @@ public ApiModel WebSearchMovie(string keyword, int pn = 1, string area = "") } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, need_cookie = true, baseUrl = $"{baseUrl}/x/web-interface/search/type", parameter = $"context=&search_type=media_ft&page={pn}&order=&keyword={Uri.EscapeDataString(keyword)}&category_id=&__refresh__=true&highlight=1&single_column=0" @@ -114,7 +115,7 @@ public ApiModel WebSearchUser(string keyword, int pn = 1, string order = "&order } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, need_cookie = true, baseUrl = $"{baseUrl}/x/web-interface/search/type", parameter = $"context=&search_type=bili_user&page={pn}&keyword={Uri.EscapeDataString(keyword)}{order}{type}&__refresh__=true&changing=mid&highlight=1&single_column=0&category_id=" @@ -135,7 +136,7 @@ public ApiModel WebSearchLive(string keyword, int pn = 1, string area = "") } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, need_cookie = true, baseUrl = $"{baseUrl}/x/web-interface/search/type", parameter = $"context=&search_type=live&cover_type=user_cover&page={pn}&keyword={Uri.EscapeDataString(keyword)}&__refresh__=true&changing=mid&highlight=1&single_column=0" @@ -156,7 +157,7 @@ public ApiModel WebSearchArticle(string keyword, int pn = 1, string order = "tot } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, need_cookie = true, baseUrl = $"{baseUrl}/x/web-interface/search/type", parameter = $"context=&search_type=article&page={pn}&order={order}&keyword={Uri.EscapeDataString(keyword)}&category_id={region}&__refresh__=true&highlight=1&single_column=0" @@ -177,7 +178,7 @@ public ApiModel WebSearchTopic(string keyword, int pn = 1, string area = "") } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, need_cookie = true, baseUrl = $"{baseUrl}/x/web-interface/search/type", parameter = $"context=&search_type=topic&page={pn}&order=&keyword={Uri.EscapeDataString(keyword)}&category_id=&__refresh__=true&highlight=1&single_column=0" @@ -194,7 +195,7 @@ public ApiModel SearchSuggest(string content) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://s.search.bilibili.com/main/suggest", parameter = $"term={content}&main_ver=v1" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs index 15e9e370..809d6314 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/SeasonApi.cs @@ -1,7 +1,6 @@ using BiliLite.Services; using System; using BiliLite.Models.Common; -using Bilibili.App.View.V1; namespace BiliLite.Models.Requests.Api { @@ -20,7 +19,7 @@ public ApiModel Detail(string id, SeasonIdType type = SeasonIdType.SeasonId, boo var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{baseUrl}/pgc/view/v2/app/season", parameter = ApiHelper.MustParameter(AppKey, true), }; @@ -47,7 +46,7 @@ public ApiModel ShortReview(int media_id, string next = "", int sort = 0) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/review/short/list", parameter = $"media_id={media_id}&ps=20&sort={sort}&cursor={next}" }; @@ -66,7 +65,7 @@ public ApiModel LikeReview(int media_id, int review_id, ReviewType review_type = { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://bangumi.bilibili.com/review/api/like", body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&review_id={review_id}&review_type={(int)review_type}" }; @@ -82,7 +81,7 @@ public ApiModel DislikeReview(int media_id, int review_id, ReviewType review_typ { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://bangumi.bilibili.com/review/api/dislike", body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&review_id={review_id}&review_type={(int)review_type}" }; @@ -101,7 +100,7 @@ public ApiModel SendShortReview(int media_id, string content, bool share_feed, i { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://bangumi.bilibili.com/review/api/short/post", body = $"{ApiHelper.MustParameter(AppKey, true)}&media_id={media_id}&content={Uri.EscapeDataString(content)}&share_feed={(share_feed ? 1 : 0)}&score={score}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/SeasonIndexAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/SeasonIndexAPI.cs index 4ccca7ca..6f779611 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/SeasonIndexAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/SeasonIndexAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api { @@ -13,7 +14,7 @@ public ApiModel Condition(int season_type) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/season/index/condition",//$"https://bangumi.bilibili.com/media/api/search/v2/condition", parameter = ApiHelper.MustParameter(AppKey, false) + $"&season_type={season_type}&type=0" }; @@ -33,7 +34,7 @@ public ApiModel Result(int page, int season_type, string condition, int pagesize { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/season/index/result", parameter = ApiHelper.MustParameter(AppKey, false) + condition + $"&page={page}&pagesize={pagesize}&season_type={season_type}&type=0" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/User/AtAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/User/AtAPI.cs index bb80a816..5651b2ae 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/User/AtAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/User/AtAPI.cs @@ -1,5 +1,6 @@ using BiliLite.Services; using System; +using BiliLite.Models.Common; namespace BiliLite.Models.Requests.Api.User { @@ -9,7 +10,7 @@ public ApiModel RecommendAt(int page = 1, int pagesize = 20) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.vc.bilibili.com/dynamic_mix/v1/dynamic_mix/rcmd_at", parameter = ApiHelper.MustParameter(AppKey, true) + $"&need_attention=1&need_recent_at=1&page={page}&pagesize={pagesize}&teenagers_mode=0", }; @@ -21,7 +22,7 @@ public ApiModel SearchUser(string keyword, int page = 1, int pagesize = 20) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://app.bilibili.com/x/v2/search/user", parameter = ApiHelper.MustParameter(AppKey, true) + $"&keyword={Uri.EscapeDataString(keyword)}&order=totalrank&order_sort=0&pn={page}&ps={pagesize}", }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/User/DynamicAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/User/DynamicAPI.cs index d8e03522..e12e89a2 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/User/DynamicAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/User/DynamicAPI.cs @@ -1,5 +1,6 @@ using BiliLite.Services; using System; +using BiliLite.Models.Common; using BiliLite.Models.Common.UserDynamic; namespace BiliLite.Models.Requests.Api.User @@ -33,13 +34,13 @@ public ApiModel DyanmicNew(UserDynamicType type) } var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new", parameter = $"type_list={Uri.EscapeDataString(typeList)}&uid={SettingService.Account.UserID}", }; //var api = new ApiModel() //{ - // method = RestSharp.Method.Get, + // method = HttpMethods.Get, // baseUrl = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history", // parameter = $"host_uid={SettingService.Account.UserID}&visitor_uid={SettingService.Account.UserID}", //}; @@ -57,7 +58,7 @@ public ApiModel DynamicDetail(string id) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/get_dynamic_detail", parameter = $"dynamic_id={id}", }; @@ -75,7 +76,7 @@ public ApiModel DynamicRepost(string id, string offset = "") { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/repost_detail", parameter = $"dynamic_id={id}&offset={offset}", }; @@ -110,7 +111,7 @@ public ApiModel HistoryDynamic(string dynamic_id, UserDynamicType type) var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_history", parameter = $"offset_dynamic_id={dynamic_id}&type_list={Uri.EscapeDataString(typeList)}&uid={SettingService.Account.UserID}" };//使用Web的API @@ -127,7 +128,7 @@ public ApiModel SpaceHistory(string mid, string dynamic_id = "") { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/space_history", parameter = $"offset_dynamic_id={dynamic_id}&visitor_uid={SettingService.Account.UserID}&host_uid={mid}&need_top=1" }; @@ -144,7 +145,7 @@ public ApiModel SpaceHistoryV2(string mid, string offset = "") { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/space", parameter = $"offset={offset}&host_mid={mid}", need_cookie = true, @@ -162,7 +163,7 @@ public ApiModel Article(string updateBaseline,string type="article") { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.bilibili.com/x/polymer/web-dynamic/v1/feed/nav", parameter = $"type={type}&update_baseline={updateBaseline}", need_cookie = true, @@ -179,7 +180,7 @@ public ApiModel RecommendTopic() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://api.vc.bilibili.com/topic_svr/v1/topic_svr/get_rcmd_topic", parameter = ApiHelper.MustParameter(AppKey, true), }; @@ -196,7 +197,7 @@ public ApiModel CreateDynamicPhoto(string imgs, string content, string at_uids, { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create_draw", parameter = ApiHelper.MustParameter(AppKey, true), body = $"uid={SettingService.Account.UserID}&category=3&pictures={Uri.EscapeDataString(imgs)}&description={Uri.EscapeDataString(content)}&content={Uri.EscapeDataString(content)}&setting=%7B%22copy_forbidden%22%3A0%7D&at_uids={Uri.EscapeDataString(at_uids)}&at_control={Uri.EscapeDataString(at_control)}&extension=%7B%22emoji_type%22%3A1%7D" @@ -213,7 +214,7 @@ public ApiModel CreateDynamicText(string content, string at_uids, string at_cont { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/create", parameter = ApiHelper.MustParameter(AppKey, true), body = $"uid={SettingService.Account.UserID}&dynamic_id=0&type=4&content={Uri.EscapeDataString(content)}&setting=%7B%22copy_forbidden%22%3A0%7D&at_uids={Uri.EscapeDataString(at_uids)}&at_control={Uri.EscapeDataString(at_control)}&jumpfrom=110&extension=%7B%22emoji_type%22%3A1%7D" @@ -230,7 +231,7 @@ public ApiModel RepostDynamic(string dynamic_id, string content, string at_uids, { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://api.vc.bilibili.com/dynamic_repost/v1/dynamic_repost/repost", parameter = ApiHelper.MustParameter(AppKey, true), body = $"uid={SettingService.Account.UserID}&dynamic_id={dynamic_id}&content={Uri.EscapeDataString(content)}&at_uids={Uri.EscapeDataString(at_uids)}&at_control={Uri.EscapeDataString(at_control)}&extension=%7B%22emoji_type%22%3A1%7D" @@ -249,7 +250,7 @@ public ApiModel Like(string dynamic_id, int up) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://api.vc.bilibili.com/dynamic_like/v1/dynamic_like/thumb", body = ApiHelper.MustParameter(AppKey, true) + $"&dynamic_id={dynamic_id}&uid={SettingService.Account.UserID}&up={up}" }; @@ -265,7 +266,7 @@ public ApiModel Delete(string dynamic_id) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/rm_dynamic", body = ApiHelper.MustParameter(AppKey, true) + $"&dynamic_id={dynamic_id}" }; @@ -282,7 +283,7 @@ public ApiModel UploadImage() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.vc.bilibili.com/api/v1/drawImage/upload", parameter = ApiHelper.MustParameter(AppKey, true) }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/User/FavoriteAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/User/FavoriteAPI.cs index 57679c58..c9c3e80a 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/User/FavoriteAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/User/FavoriteAPI.cs @@ -1,6 +1,7 @@ using BiliLite.Services; using System; using System.Collections.Generic; +using BiliLite.Models.Common; namespace BiliLite.Models.Requests.Api.User { @@ -17,7 +18,7 @@ public ApiModel MyFavorite() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/space/v2", parameter = ApiHelper.MustParameter(AppKey, true) + $"&up_mid={SettingService.Account.UserID}" }; @@ -28,7 +29,7 @@ public ApiModel MyCreatedFavoriteList(int page) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/created/list", parameter = ApiHelper.MustParameter(AppKey, true) + $"&up_mid={SettingService.Account.UserID}&pn={page}&ps=20" }; @@ -43,7 +44,7 @@ public ApiModel MyCreatedFavorite(string aid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/medialist/gateway/base/created", parameter = ApiHelper.MustParameter(AppKey, true) + $"&rid={aid}&up_mid={SettingService.Account.UserID}&type=2&pn=1&ps=100" }; @@ -65,7 +66,7 @@ public ApiModel AddFavorite(List favIds, string avid) ids = Uri.EscapeDataString(ids.TrimEnd(',')); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/medialist/gateway/coll/resource/deal", body = ApiHelper.MustParameter(AppKey, true) + $"&add_media_ids={ids}&rid={avid}&type=2" }; @@ -93,7 +94,7 @@ public ApiModel UpdateFavorite(List addFavIds,List delFavIds, st delIds = Uri.EscapeDataString(delIds.TrimEnd(',')); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/medialist/gateway/coll/resource/deal", body = ApiHelper.MustParameter(AppKey, true) + $"&add_media_ids={addIds}&del_media_ids={delIds}&rid={avid}&type=2" }; @@ -109,7 +110,7 @@ public ApiModel CollectFavorite(string media_id) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/fav", body = ApiHelper.MustParameter(AppKey, true) + $"&media_id={media_id}" }; @@ -124,7 +125,7 @@ public ApiModel CacnelCollectFavorite(string media_id) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/unfav", body = ApiHelper.MustParameter(AppKey, true) + $"&media_id={media_id}" }; @@ -143,7 +144,7 @@ public ApiModel CreateFavorite(string title, string intro, bool isOpen) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/add", body = ApiHelper.MustParameter(AppKey, true) + $"&privacy={(isOpen ? 0 : 1)}&title={Uri.EscapeDataString(title)}&intro={Uri.EscapeDataString(intro)}" }; @@ -162,7 +163,7 @@ public ApiModel EditFavorite(string title, string intro, bool isOpen, string med { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/edit", body = ApiHelper.MustParameter(AppKey, true) + $"&privacy={(isOpen ? 0 : 1)}&title={Uri.EscapeDataString(title)}&intro={Uri.EscapeDataString(intro)}&media_id={media_id}" }; @@ -179,7 +180,7 @@ public ApiModel DelFavorite(string media_id) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/del", body = ApiHelper.MustParameter(AppKey, true) + $"&media_ids={media_id}" }; @@ -195,7 +196,7 @@ public ApiModel FavoriteInfo(string fid, string keyword, int page = 1) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/resource/list", parameter = $"media_id={fid}&mid={SettingService.Account.UserID}&keyword={Uri.EscapeDataString(keyword)}&pn={page}&ps=20&platform=web", need_cookie = true, @@ -207,7 +208,7 @@ public ApiModel FavoriteSeasonInfo(string season_id, string keyword, int page = { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/space/fav/season/list", parameter = ApiHelper.MustParameter(AppKey, true) + $"&season_id={season_id}&mid={SettingService.Account.UserID}&keyword={Uri.EscapeDataString(keyword)}&pn={page}&ps=20" }; @@ -229,7 +230,7 @@ public ApiModel Delete(string media_id, List video_ids) ids = Uri.EscapeDataString(ids.TrimEnd(',')); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/resource/batch-del", body = ApiHelper.MustParameter(AppKey, true) + $"&media_id={media_id}&resources={ids}" }; @@ -250,7 +251,7 @@ public ApiModel Copy(string src_media_id, string tar_media_id, List vide ids = Uri.EscapeDataString(ids.TrimEnd(',')); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/resource/copy", body = ApiHelper.MustParameter(AppKey, true) + $"&src_media_id={src_media_id}&tar_media_id={tar_media_id}&resources={ids}&mid={mid}" }; @@ -271,7 +272,7 @@ public ApiModel Move(string src_media_id, string tar_media_id, List vide ids = Uri.EscapeDataString(ids.TrimEnd(',')); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/resource/move", body = ApiHelper.MustParameter(AppKey, true) + $"&src_media_id={src_media_id}&tar_media_id={tar_media_id}&resources={ids}" }; @@ -286,7 +287,7 @@ public ApiModel Clean(string media_id) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/resource/clean", body = ApiHelper.MustParameter(AppKey, true) + $"&media_id={media_id}" }; @@ -299,7 +300,7 @@ public ApiModel Sort(List favIdList) var sort = string.Join(',', favIdList); var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/sort", body = ApiHelper.MustParameter(AppKey, true) + $"&sort={sort}" }; @@ -315,7 +316,7 @@ public ApiModel SortResource(string mediaId, string sourceId, string targetId) sort = string.IsNullOrEmpty(targetId) ? $"0:0:{sourceId}:2" : $"{targetId}:2:{sourceId}:2"; var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/resource/sort", body = ApiHelper.MustParameter(AppKey, true) + $"&media_id={mediaId}&sort={sort}" }; @@ -327,7 +328,7 @@ public ApiModel GetCollected(int page=1,int pageCount=20) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/collected/list", parameter = $"up_mid={SettingService.Account.UserID}&pn={page}&ps={pageCount}&platform=web", need_cookie = true, @@ -339,7 +340,7 @@ public ApiModel UnFavCollected(string seasonId) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/season/unfav", body = ApiHelper.MustParameter(AppKey, true) + $"&season_id={seasonId}" }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/User/FollowAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/User/FollowAPI.cs index f9ea4b53..c44f7313 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/User/FollowAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/User/FollowAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api.User { @@ -15,7 +16,7 @@ public ApiModel MyFollowBangumi(int page = 1, int status = 0, int pagesize = 20) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/app/follow/v2/bangumi", parameter = ApiHelper.MustParameter(AppKey, true) + $"&pn={page}&ps={pagesize}&status={status}", headers = ApiHelper.GetAuroraHeaders() @@ -34,7 +35,7 @@ public ApiModel MyFollowCinema(int page = 1, int status = 0, int pagesize = 20) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/app/follow/v2/cinema", parameter = ApiHelper.MustParameter(AppKey, true) + $"&pn={page}&ps={pagesize}&status={status}", }; @@ -49,7 +50,7 @@ public ApiModel FollowSeason(string season_id) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/app/follow/add", body = ApiHelper.MustParameter(AppKey, true) + $"&season_id={season_id}" }; @@ -64,7 +65,7 @@ public ApiModel CancelFollowSeason(string season_id) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/app/follow/del", body = ApiHelper.MustParameter(AppKey, true) + $"&season_id={season_id}" }; @@ -80,7 +81,7 @@ public ApiModel SetSeasonStatus(string season_id, int status) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/pgc/app/follow/status/update", body = ApiHelper.MustParameter(AppKey, true) + $"&season_id={season_id}&status={status}" }; @@ -99,7 +100,7 @@ public ApiModel Attention(string mid, string mode) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/modify", body = ApiHelper.MustParameter(AppKey, true) + $"&act={mode}&fid={mid}&re_src=32" }; @@ -116,7 +117,7 @@ public ApiModel GetAttention(string mid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation", parameter = $"fid={mid}", need_cookie = true diff --git a/src/BiliLite.UWP/Models/Requests/Api/User/UserDetailAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/User/UserDetailAPI.cs index a2850d0b..a0bd912d 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/User/UserDetailAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/User/UserDetailAPI.cs @@ -2,6 +2,7 @@ using System.Linq; using BiliLite.Services; using System.Threading.Tasks; +using BiliLite.Models.Common; using Microsoft.Extensions.DependencyInjection; namespace BiliLite.Models.Requests.Api.User @@ -24,7 +25,7 @@ public async Task UserInfo(string mid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/space/wbi/acc/info", parameter = $"mid={mid}", need_cookie = true @@ -41,7 +42,7 @@ public ApiModel Space(string mid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = "https://app.bilibili.com/x/v2/space", parameter = ApiHelper.MustParameter(AppKey, needAccesskey: true) + $"&vmid={mid}", }; @@ -57,7 +58,7 @@ public ApiModel UserStat(string mid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/stat", parameter = $"vmid={mid}", }; @@ -76,7 +77,7 @@ public async Task SubmitVideos(string mid, int page = 1, int pagesize { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/space/wbi/arc/search", parameter = $"mid={mid}&ps={pagesize}&tid={tid}&pn={page}&keyword={keyword}&order={order.ToString()}", need_cookie = true, @@ -89,7 +90,7 @@ public ApiModel SubmitVideosCursor(string mid, int pagesize = 30, SubmitVideoOrd { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/v2/space/archive/cursor", parameter = $"{ApiHelper.MustParameter(AppKey, true)}&vmid={mid}&ps={pagesize}&order={order.ToString()}&aid={cursor}", @@ -109,7 +110,7 @@ public ApiModel SubmitArticles(string mid, int page = 1, int pagesize = 30, Subm { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/space/article", parameter = $"mid={mid}&ps={pagesize}&pn={page}&sort={order.ToString()}", }; @@ -120,7 +121,7 @@ public ApiModel SubmitCollections(string mid, int pageNum) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/polymer/space/seasons_series_list_mobile", parameter = $"{ApiHelper.MustParameter(AppKey, true)}&mid={mid}&page_num={pageNum}&page_size=20", }; @@ -136,7 +137,7 @@ public ApiModel FollowingsTag() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/tags", parameter = ApiHelper.MustParameter(AppKey, true) }; @@ -152,7 +153,7 @@ public ApiModel FollowingTagUser(long targetUserId) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/tag/user", parameter = $"fid={targetUserId}&" + ApiHelper.MustParameter(AppKey, true) }; @@ -168,7 +169,7 @@ public ApiModel CreateFollowingTag(long tag) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/tag/create", body = $"tag={tag}&" + ApiHelper.MustParameter(AppKey, true) }; @@ -194,7 +195,7 @@ public ApiModel AddFollowingTagUsers(List targetUserIdList,List tagI var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/tags/addUsers", body = $"fids={fids}&tagids={tagids}&csrf={csrf}",// + ApiHelper.MustParameter(AppKey, true) need_cookie = true, @@ -214,7 +215,7 @@ public async Task Followings(string mid, int page = 1, int pagesize = { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/followings", parameter = $"vmid={mid}&ps={pagesize}&pn={page}&order=desc&order_type={(order == FollowingsOrder.attention ? "attention" : "")}", need_cookie = true, @@ -244,7 +245,7 @@ public ApiModel Followers(string mid, int page = 1, int pagesize = 30) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/followers", parameter = $"vmid={mid}&ps={pagesize}&pn={page}&order=desc", need_cookie = true, @@ -261,7 +262,7 @@ public ApiModel Favlist(string mid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v3/fav/folder/created/list-all", parameter = $"up_mid={mid}", }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/User/WatchLaterAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/User/WatchLaterAPI.cs index 5ca01f95..3f0581ec 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/User/WatchLaterAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/User/WatchLaterAPI.cs @@ -1,4 +1,5 @@ -using BiliLite.Services; +using BiliLite.Models.Common; +using BiliLite.Services; namespace BiliLite.Models.Requests.Api.User { @@ -8,7 +9,7 @@ public ApiModel Add(string aid) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/history/toview/add", body = ApiHelper.MustParameter(AppKey, true) + $"&aid={aid}" }; @@ -19,7 +20,7 @@ public ApiModel Watchlater() { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/history/toview", parameter = ApiHelper.MustParameter(AppKey, true) + $"&ps=100" }; @@ -30,7 +31,7 @@ public ApiModel Clear() { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/history/toview/clear", body = ApiHelper.MustParameter(AppKey, true) }; @@ -41,7 +42,7 @@ public ApiModel Del() { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/history/toview/del", body = ApiHelper.MustParameter(AppKey, true) + "&viewed=true" }; @@ -52,7 +53,7 @@ public ApiModel Del(string id) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/v2/history/toview/del", body = ApiHelper.MustParameter(AppKey, true) + "&aid=" + id }; diff --git a/src/BiliLite.UWP/Models/Requests/Api/VideoAPI.cs b/src/BiliLite.UWP/Models/Requests/Api/VideoAPI.cs index 2587cca3..d5d05075 100644 --- a/src/BiliLite.UWP/Models/Requests/Api/VideoAPI.cs +++ b/src/BiliLite.UWP/Models/Requests/Api/VideoAPI.cs @@ -1,5 +1,6 @@ using BiliLite.Services; using System; +using BiliLite.Models.Common; namespace BiliLite.Models.Requests.Api { @@ -9,7 +10,7 @@ public ApiModel Detail(string id, bool isbvid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/v2/view", parameter = ApiHelper.MustParameter(AppKey, true) + $"&{(isbvid ? "bvid=" : "aid=")}{id}&plat=0" }; @@ -21,7 +22,7 @@ public ApiModel DetailWebInterface(string id, bool isBvId) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.bilibili.com/x/web-interface/view", parameter = $"&{(isBvId ? "bvid=" : "aid=")}{id}", need_cookie = true, @@ -33,7 +34,7 @@ public ApiModel RelatesWebInterface(string id, bool isBvId) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.bilibili.com/x/web-interface/archive/related", parameter = $"&{(isBvId ? "bvid=" : "aid=")}{id}" }; @@ -44,7 +45,7 @@ public ApiModel DetailProxy(string id, bool isbvid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://app.bilibili.com/x/v2/view", parameter = ApiHelper.GetAccessParameter(AppKey) + $"&{(isbvid ? "bvid=" : "aid=")}{id}&plat=0" }; @@ -64,7 +65,7 @@ public ApiModel Like(string aid, int dislike, int like) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://app.bilibili.com/x/v2/view/like", body = ApiHelper.MustParameter(AppKey, true) + $"&aid={aid}&dislike={dislike}&from=7&like={like}" }; @@ -81,7 +82,7 @@ public ApiModel Dislike(string aid, int dislike, int like) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://app.biliapi.net/x/v2/view/dislike", body = ApiHelper.MustParameter(AppKey, true) + $"&aid={aid}&dislike={dislike}&from=7&like={like}" }; @@ -97,7 +98,7 @@ public ApiModel Triple(string aid) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://app.bilibili.com/x/v2/view/like/triple", body = ApiHelper.MustParameter(AppKey, true) + $"&aid={aid}" }; @@ -109,7 +110,7 @@ public ApiModel Coin(string aid, int num) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"https://app.biliapi.net/x/v2/view/coin/add", body = ApiHelper.MustParameter(AppKey, true) + $"&aid={aid}&multiply={num}&platform=android&select_like=0" }; @@ -127,7 +128,7 @@ public ApiModel Attention(string mid, string mode) { var api = new ApiModel() { - method = RestSharp.Method.Post, + method = HttpMethods.Post, baseUrl = $"{ApiHelper.API_BASE_URL}/x/relation/modify", body = ApiHelper.MustParameter(AppKey, true) + $"&act={mode}&fid={mid}&re_src=32" }; @@ -139,7 +140,7 @@ public ApiModel Tags(string aid) { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"{ApiHelper.API_BASE_URL}/x/tag/archive/tags", parameter = $"&aid={aid}", need_cookie = true, @@ -151,7 +152,7 @@ public ApiModel GetMediaList(string medisListId, string lastAid, int pagesize = { var api = new ApiModel() { - method = RestSharp.Method.Get, + method = HttpMethods.Get, baseUrl = $"https://api.bilibili.com/x/v2/medialist/resource/list", parameter = $"{ApiHelper.MustParameter(AppKey, true)}&type=1&biz_id={medisListId}&oid={lastAid}&otype=2&ps={pagesize}&direction=false&desc=true&sort_field=1&tid=0&with_current=false", diff --git a/src/BiliLite.UWP/Models/Requests/ApiModel.cs b/src/BiliLite.UWP/Models/Requests/ApiModel.cs index 01ed0228..bad0c078 100644 --- a/src/BiliLite.UWP/Models/Requests/ApiModel.cs +++ b/src/BiliLite.UWP/Models/Requests/ApiModel.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using BiliLite.Models.Common; namespace BiliLite.Models.Requests { @@ -7,7 +8,7 @@ public class ApiModel /// /// 请求方法 /// - public RestSharp.Method method { get; set; } + public HttpMethods method { get; set; } /// /// API地址 /// diff --git a/src/BiliLite.UWP/ViewModels/User/SendDynamic/SendDynamicV2ViewModel.cs b/src/BiliLite.UWP/ViewModels/User/SendDynamic/SendDynamicV2ViewModel.cs index 61c59fd6..0114ac54 100644 --- a/src/BiliLite.UWP/ViewModels/User/SendDynamic/SendDynamicV2ViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/User/SendDynamic/SendDynamicV2ViewModel.cs @@ -6,7 +6,6 @@ using System.Threading.Tasks; using Windows.Storage; using BiliLite.Extensions; -using BiliLite.Models; using BiliLite.Models.Common; using BiliLite.Models.Common.User.SendDynamic; using BiliLite.Models.Exceptions; @@ -18,7 +17,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PropertyChanged; -using RestSharp; +using BiliLite.Models.Common.UserDynamic; +using BiliLite.Models.Requests.Api; namespace BiliLite.ViewModels.User.SendDynamic { @@ -80,30 +80,21 @@ public async void UploadImage(StorageFile file) try { Uploading = true; - var api = m_dynamicApi.UploadImage(); - var fileStream = await file.OpenAsync(FileAccessMode.Read); var bytes = new byte[fileStream.Size]; await fileStream.ReadAsync(bytes.AsBuffer(), (uint)fileStream.Size, Windows.Storage.Streams.InputStreamOptions.None); - var client = new RestClient(api.url); - var request = new RestRequest(); - request.Method = Method.Post; - request.AddParameter("biz", "draw"); - request.AddParameter("category", "daily"); - request.AddFile("file_up", bytes, file.Name); - var response = await client.ExecuteAsync(request); - var content = response.Content; - - var result = JsonConvert.DeserializeObject>(content); - if (result.code == 0) + var fileInfo = new UploadFileInfo() { - result.data.ImageSize = (await file.GetBasicPropertiesAsync()).Size / 1024; - Images.Add(result.data); - } - else - { - Notify.ShowMessageToast(result.message); - } + Data = bytes, + FileName = file.Name, + }; + var api = new CommentApi().UploadDraw(fileInfo); + var result = await api.Request(); + if (!result.status) + throw new CustomizedErrorException(result.message); + var uploadDrawResult = await result.GetData(); + if (!uploadDrawResult.success) + throw new CustomizedErrorException(uploadDrawResult.message); } catch (Exception ex) { diff --git a/src/BiliLite.UWP/ViewModels/User/SendDynamic/SendDynamicViewModel.cs b/src/BiliLite.UWP/ViewModels/User/SendDynamic/SendDynamicViewModel.cs index 502598ae..21c29366 100644 --- a/src/BiliLite.UWP/ViewModels/User/SendDynamic/SendDynamicViewModel.cs +++ b/src/BiliLite.UWP/ViewModels/User/SendDynamic/SendDynamicViewModel.cs @@ -18,7 +18,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PropertyChanged; -using RestSharp; +using BiliLite.Models.Common.UserDynamic; +using BiliLite.Models.Requests.Api; namespace BiliLite.ViewModels.User.SendDynamic { @@ -80,30 +81,21 @@ public async void UploadImage(StorageFile file) try { Uploading = true; - var api = m_dynamicApi.UploadImage(); - var fileStream = await file.OpenAsync(FileAccessMode.Read); var bytes = new byte[fileStream.Size]; await fileStream.ReadAsync(bytes.AsBuffer(), (uint)fileStream.Size, Windows.Storage.Streams.InputStreamOptions.None); - var client = new RestClient(api.url); - var request = new RestRequest(); - request.Method = Method.Post; - request.AddParameter("biz", "draw"); - request.AddParameter("category", "daily"); - request.AddFile("file_up", bytes, file.Name); - var response = await client.ExecuteAsync(request); - var content = response.Content; - - var result = JsonConvert.DeserializeObject>(content); - if (result.code == 0) + var fileInfo = new UploadFileInfo() { - result.data.ImageSize = (await file.GetBasicPropertiesAsync()).Size / 1024; - Images.Add(result.data); - } - else - { - Notify.ShowMessageToast(result.message); - } + Data = bytes, + FileName = file.Name, + }; + var api = new CommentApi().UploadDraw(fileInfo); + var result = await api.Request(); + if (!result.status) + throw new CustomizedErrorException(result.message); + var uploadDrawResult = await result.GetData(); + if (!uploadDrawResult.success) + throw new CustomizedErrorException(uploadDrawResult.message); } catch (Exception ex) { diff --git a/src/BiliLite.Win32Tools/BiliLite.Win32Tools.csproj b/src/BiliLite.Win32Tools/BiliLite.Win32Tools.csproj index 2c17aab7..4c95cd5e 100644 --- a/src/BiliLite.Win32Tools/BiliLite.Win32Tools.csproj +++ b/src/BiliLite.Win32Tools/BiliLite.Win32Tools.csproj @@ -54,7 +54,7 @@ prompt 4 - + AnyCPU pdbonly true @@ -86,7 +86,7 @@ - ..\..\packages\System.Drawing.Common.5.0.2\lib\net461\System.Drawing.Common.dll + ..\..\packages\System.Drawing.Common.5.0.3\lib\net461\System.Drawing.Common.dll ..\..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll diff --git a/src/BiliLite.Win32Tools/packages.config b/src/BiliLite.Win32Tools/packages.config index ae18d497..39e4d786 100644 --- a/src/BiliLite.Win32Tools/packages.config +++ b/src/BiliLite.Win32Tools/packages.config @@ -5,7 +5,7 @@ - + From d98113af8f1051eeb8a764df98808a1f23f3a878 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 26 Oct 2024 10:51:08 +0800 Subject: [PATCH 5/7] =?UTF-8?q?#884=20=E4=BF=AE=E5=A4=8DWin10=E4=B8=8B?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=87=AA=E5=AE=9A=E4=B9=89=E6=96=B0=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E9=A1=B5=E8=83=8C=E6=99=AF=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/Extensions/FileExtensions.cs | 14 ++++++++++++++ src/BiliLite.UWP/Pages/NewPage.xaml.cs | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/BiliLite.UWP/Extensions/FileExtensions.cs b/src/BiliLite.UWP/Extensions/FileExtensions.cs index 9544f523..05e36550 100644 --- a/src/BiliLite.UWP/Extensions/FileExtensions.cs +++ b/src/BiliLite.UWP/Extensions/FileExtensions.cs @@ -23,5 +23,19 @@ public static async Task GetExportFile(string fileTypeChoiceKey, st var file = await savePicker.PickSaveFileAsync(); return file; } + + public static async Task CheckFileExist(this string path) + { + try + { + var file = await StorageFile.GetFileFromPathAsync(path); + return file != null; + } + catch (Exception) + { + // 如果文件不存在或者路径无效,将捕获异常 + return false; + } + } } } diff --git a/src/BiliLite.UWP/Pages/NewPage.xaml.cs b/src/BiliLite.UWP/Pages/NewPage.xaml.cs index 7ec045ca..52ced345 100644 --- a/src/BiliLite.UWP/Pages/NewPage.xaml.cs +++ b/src/BiliLite.UWP/Pages/NewPage.xaml.cs @@ -41,7 +41,7 @@ private async void SetBackground() } else { - if (!File.Exists(background)) + if (!await background.CheckFileExist()) { Notify.ShowMessageToast("背景图片不存在,请重新设置"); return; From 91344e3b2b91d3cedbc93ab1991a85e7cba02370 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Sat, 26 Oct 2024 11:48:37 +0800 Subject: [PATCH 6/7] 4.7.6 --- document/new_version.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/document/new_version.json b/document/new_version.json index d638c47f..af08b638 100644 --- a/document/new_version.json +++ b/document/new_version.json @@ -1,7 +1,7 @@ { - "version": "4.7.4", - "version_num": 40704, - "version_desc": "更新内容:\r\n\r\n- 新增自动跳过OP/ED功能,设置中开启 \r\n\r\n- 可选保存已下载视频数据到数据库 \r\n\r\n- 视频播放控件内新增章节看点列表 \r\n\r\n- 持续快进功能启用分档位快进 \r\n\r\n- 将外部合并视频帮助页移入内部,添加python批量合并脚本外链 \r\n\r\n- 更新证书 \r\n\r\n- sqlite数据库迁移更新 \r\n\r\n- 可设置优先播放器类型\r\n\r\n- 修复选集界面错误换行 \r\n\r\n- 捕获初始化下载视频错误 \r\n\r\n- 已下载番剧打开详情错误 \r\n\r\n\r\n\r\n\r\n 如果无法打开下载地址,请访问:https://github.com/ywmoyue/biliuwp-lite/releases", - "url": "https://github.com/ywmoyue/biliuwp-lite/releases", - "download_url": "https://github.com/ywmoyue/biliuwp-lite/releases" + "version": "4.7.6", + "version_num": 40706, + "version_desc": "更新内容:\r\n\r\n- 支持屏蔽彩色弹幕 \r\n\r\n- 完善快捷键自定义功能,新增快捷键行为:切换字幕开关 \r\n\r\n- 打开下载页时不重新加载下载项 \r\n\r\n- 打开图片时不再遮挡状态栏 \r\n\r\n- 全局mica半透明背景样式调整 \r\n\r\n- 去除多余的白色焦点边框 \r\n\r\n- 状态栏顶部拖拽窗口 \r\n\r\n- 修复sql脚本错误 \r\n\r\n- 修复FFmpegInterop播放器播放视频偶现播放中突然跳转视频 结尾或无声音 \r\n\r\n- 修复分区->番剧->连载动画页的港澳台番剧打开失败 \r\n\r\n- 安装教程补充 \r\n\r\n- 修复部分视频媒体流加载错误 \r\n\r\n- 修复UP主个人主页报错 \r\n\r\n- 开启使用下载索引设置项后下载视频无字幕 \r\n\r\n- 帮助页新增 Windows 11 24H2 杜比全景声无声说明 \r\n\r\n- 新标签页已设置背景图不存在时提示\r\n\r\n\r\n\r\n\r\n 如果无法打开下载地址,请访问:https://github.com/ywmoyue/biliuwp-lite/releases", + "url": "https://github.com/ywmoyue/biliuwp-lite/releases", + "download_url": "https://github.com/ywmoyue/biliuwp-lite/releases" } From c4152b28d8ab01844256a1b7f1133a5193385e1d Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Tue, 29 Oct 2024 20:20:25 +0800 Subject: [PATCH 7/7] =?UTF-8?q?#891=20=E5=88=9D=E6=AD=A5=E5=AE=9E=E7=8E=B0?= =?UTF-8?q?=E5=A4=96=E7=BD=AE=E6=8F=92=E4=BB=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/BiliLite.UWP/App.xaml.cs | 4 + src/BiliLite.UWP/BiliLite.UWP.csproj | 7 + .../Controls/PlayerControl.xaml.cs | 3 +- .../Controls/Settings/DevSettingsControl.xaml | 47 +++ .../Settings/DevSettingsControl.xaml.cs | 41 +++ .../Extensions/MapperExtensions.cs | 3 + .../Extensions/ViewModelExtensions.cs | 1 + .../Models/Common/SettingConstants.cs | 2 + src/BiliLite.UWP/Pages/BasePage.cs | 5 + src/BiliLite.UWP/Services/PluginService.cs | 337 ++++++++++++++++++ .../Services/ShortcutKeyService.cs | 6 + src/BiliLite.UWP/Startup.cs | 1 + .../Plugins/WebSocketPluginViewModel.cs | 27 ++ .../Settings/DevSettingsControlViewModel.cs | 39 ++ 14 files changed, 522 insertions(+), 1 deletion(-) create mode 100644 src/BiliLite.UWP/Services/PluginService.cs create mode 100644 src/BiliLite.UWP/ViewModels/Plugins/WebSocketPluginViewModel.cs create mode 100644 src/BiliLite.UWP/ViewModels/Settings/DevSettingsControlViewModel.cs diff --git a/src/BiliLite.UWP/App.xaml.cs b/src/BiliLite.UWP/App.xaml.cs index 6f370b92..39a9b173 100644 --- a/src/BiliLite.UWP/App.xaml.cs +++ b/src/BiliLite.UWP/App.xaml.cs @@ -206,6 +206,7 @@ private async void InitBili() App.Current.Resources["ImageCornerRadius"] = new CornerRadius(SettingService.GetValue(SettingConstants.UI.IMAGE_CORNER_RADIUS, 0)); await AppHelper.SetRegions(); await InitDb(); + try { var downloadService = ServiceProvider.GetRequiredService(); @@ -217,6 +218,9 @@ private async void InitBili() logger.Error("初始化加载下载视频错误", ex); } VideoPlayHistoryHelper.LoadABPlayHistories(true); + + var pluginService = ServiceProvider.GetRequiredService(); + await pluginService.Start(); } private async Task InitDb() diff --git a/src/BiliLite.UWP/BiliLite.UWP.csproj b/src/BiliLite.UWP/BiliLite.UWP.csproj index 2b74db93..3e49bb43 100644 --- a/src/BiliLite.UWP/BiliLite.UWP.csproj +++ b/src/BiliLite.UWP/BiliLite.UWP.csproj @@ -268,9 +268,11 @@ + + @@ -278,6 +280,7 @@ + @@ -1549,6 +1552,9 @@ 0.17.0 + + 0.15.2 + 1.26.0 @@ -1575,6 +1581,7 @@ + diff --git a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs index a1f2a02c..c47804c1 100644 --- a/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/PlayerControl.xaml.cs @@ -845,6 +845,7 @@ private async void DanmuTimer_Tick(object sender, object e) private void PositionTimer_Tick(object sender, object e) { + PluginCenter.BroadcastPosition(this, Player.Position); if (!m_autoSkipOpEdFlag) return; if (CurrentPlayItem == null) return; if (CurrentPlayItem.EpisodeSkip == null) return; @@ -1834,7 +1835,7 @@ double Brightness { _brightness = value; BrightnessShield.Opacity = value; - if(!lockBrightness) + if (!lockBrightness) SettingService.SetValue(SettingConstants.Player.PLAYER_BRIGHTNESS, _brightness); } } diff --git a/src/BiliLite.UWP/Controls/Settings/DevSettingsControl.xaml b/src/BiliLite.UWP/Controls/Settings/DevSettingsControl.xaml index ed02549f..2d8bf976 100644 --- a/src/BiliLite.UWP/Controls/Settings/DevSettingsControl.xaml +++ b/src/BiliLite.UWP/Controls/Settings/DevSettingsControl.xaml @@ -9,6 +9,7 @@ xmlns:controls1="using:Microsoft.UI.Xaml.Controls" xmlns:common="using:BiliLite.Models.Common" xmlns:font="using:FontAwesome5" + xmlns:plugins="using:BiliLite.ViewModels.Plugins" mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="400"> @@ -66,6 +67,12 @@ + + + + + + @@ -133,5 +140,45 @@ DisplayMemberPath="Name"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/BiliLite.UWP/Controls/Settings/DevSettingsControl.xaml.cs b/src/BiliLite.UWP/Controls/Settings/DevSettingsControl.xaml.cs index 9a139050..c500a79e 100644 --- a/src/BiliLite.UWP/Controls/Settings/DevSettingsControl.xaml.cs +++ b/src/BiliLite.UWP/Controls/Settings/DevSettingsControl.xaml.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.ObjectModel; using System.Threading.Tasks; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; @@ -7,6 +8,13 @@ using BiliLite.Services; using Microsoft.Extensions.DependencyInjection; using Windows.ApplicationModel.Core; +using BiliLite.ViewModels.Settings; +using Windows.Storage.Pickers; +using Windows.Storage; +using BiliLite.ViewModels.Plugins; +using Microsoft.Toolkit.Uwp.Helpers; +using Newtonsoft.Json; +using IMapper = AutoMapper.IMapper; //https://go.microsoft.com/fwlink/?LinkId=234236 上介绍了“用户控件”项模板 @@ -15,9 +23,17 @@ namespace BiliLite.Controls.Settings public sealed partial class DevSettingsControl : UserControl { private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + private readonly DevSettingsControlViewModel m_viewModel; + private readonly PluginService m_pluginService; + private readonly IMapper m_mapper; public DevSettingsControl() { + m_viewModel = App.ServiceProvider.GetRequiredService(); + m_mapper = App.ServiceProvider.GetRequiredService(); + m_pluginService = App.ServiceProvider.GetRequiredService(); + m_viewModel.Plugins = + m_mapper.Map>(m_pluginService.GetPlugins()); this.InitializeComponent(); LoadDev(); } @@ -217,5 +233,30 @@ private async void BtnMigrateDb_OnClick(object sender, RoutedEventArgs e) var migrateService = App.ServiceProvider.GetRequiredService(); await migrateService.ExcuteAllMigrationScripts(); } + + private async void BtnSettingPlugin_OnClick(object sender, RoutedEventArgs e) + { + await PluginsDialog.ShowAsync(); + } + + private async void BtnImportPluginInfo_OnClick(object sender, RoutedEventArgs e) + { + var filePicker = new FileOpenPicker(); + filePicker.FileTypeFilter.Add(".json"); + var file = await filePicker.PickSingleFileAsync(); + if (file == null) return; + using var openFile = await file.OpenAsync(FileAccessMode.Read); + var text = await openFile.ReadTextAsync(); + var plugin = JsonConvert.DeserializeObject(text); + await m_pluginService.AddPlugin(plugin); + m_viewModel.AddPlugin(m_mapper.Map(plugin)); + } + + private async void BtnDeletePlugin_OnClick(object sender, RoutedEventArgs e) + { + if (!(sender is Button { DataContext: WebSocketPluginViewModel plugin })) return; + await m_pluginService.RemovePlugin(plugin.Name); + m_viewModel.RemovePlugin(plugin); + } } } diff --git a/src/BiliLite.UWP/Extensions/MapperExtensions.cs b/src/BiliLite.UWP/Extensions/MapperExtensions.cs index 818faf46..8c7df82f 100644 --- a/src/BiliLite.UWP/Extensions/MapperExtensions.cs +++ b/src/BiliLite.UWP/Extensions/MapperExtensions.cs @@ -28,6 +28,7 @@ using BiliLite.ViewModels.Comment; using BiliLite.ViewModels.Download; using BiliLite.ViewModels.Home; +using BiliLite.ViewModels.Plugins; using BiliLite.ViewModels.Season; using BiliLite.ViewModels.Settings; using BiliLite.ViewModels.User; @@ -46,6 +47,8 @@ public static IServiceCollection AddMapper(this IServiceCollection services) { var mapper = new Mapper(new MapperConfiguration(expression => { + expression.CreateMap() + .ReverseMap(); expression.CreateMap() .ReverseMap(); expression.CreateMap() diff --git a/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs b/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs index 0af4875f..8cd58aa5 100644 --- a/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs +++ b/src/BiliLite.UWP/Extensions/ViewModelExtensions.cs @@ -51,6 +51,7 @@ public static IServiceCollection AddViewModels(this IServiceCollection services) services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); return services; } diff --git a/src/BiliLite.UWP/Models/Common/SettingConstants.cs b/src/BiliLite.UWP/Models/Common/SettingConstants.cs index e8390fa7..18e3cf0b 100644 --- a/src/BiliLite.UWP/Models/Common/SettingConstants.cs +++ b/src/BiliLite.UWP/Models/Common/SettingConstants.cs @@ -1063,6 +1063,8 @@ public class Other public const string DEFAULT_REQUEST_BUILD = "75900200"; public const string SQL_DB_VERSION = "SqlDbVersion"; + + public const string PLUGIN_LIST = "PluginList"; } } } diff --git a/src/BiliLite.UWP/Pages/BasePage.cs b/src/BiliLite.UWP/Pages/BasePage.cs index 7d35cab3..75f91e19 100644 --- a/src/BiliLite.UWP/Pages/BasePage.cs +++ b/src/BiliLite.UWP/Pages/BasePage.cs @@ -86,6 +86,11 @@ public void StopHighRateSpeedPlay() Player.StopHighRateSpeedPlay(); } + public void SetPosition(double position) + { + Player.SetPosition(position); + } + public void PositionBack() { Player.PositionBack(); diff --git a/src/BiliLite.UWP/Services/PluginService.cs b/src/BiliLite.UWP/Services/PluginService.cs new file mode 100644 index 00000000..762ee7a2 --- /dev/null +++ b/src/BiliLite.UWP/Services/PluginService.cs @@ -0,0 +1,337 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Flurl.Http; +using Windows.System; +using WebSocket4Net; +using System.Timers; +using Windows.UI.Core; +using Windows.UI.Xaml.Controls; +using BiliLite.Extensions; +using BiliLite.Models.Common; +using BiliLite.Pages; +using Microsoft.Extensions.DependencyInjection; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace BiliLite.Services +{ + public class PluginService + { + private readonly SettingSqlService m_settingSqlService; + private List m_plugins; + private static readonly ILogger _logger = GlobalLogger.FromCurrentType(); + + public PluginService(SettingSqlService settingSqlService) + { + m_settingSqlService = settingSqlService; + m_plugins = m_settingSqlService.GetValue(SettingConstants.Other.PLUGIN_LIST, new List()); + } + + public async Task Start() + { + foreach (var plugin in m_plugins) + { + await plugin.Start(); + } + } + + public async Task Stop() + { + foreach (var plugin in m_plugins) + { + await plugin.Stop(); + } + } + + public List GetPlugins() + { + return m_plugins; + } + + public async Task AddPlugin(WebSocketPlugin plugin) + { + var oldPlugin = m_plugins.FirstOrDefault(x => x.Name == plugin.Name); + if (oldPlugin != null) + { + await oldPlugin.Stop(); + + oldPlugin.CheckUrl = plugin.CheckUrl; + oldPlugin.WakeProto = plugin.WakeProto; + oldPlugin.WebSocketUrl = plugin.WebSocketUrl; + + try + { + await oldPlugin.Start(); + } + catch (Exception ex) + { + _logger.Error("更新插件失败", ex); + throw ex; + } + + m_settingSqlService.SetValue(SettingConstants.Other.PLUGIN_LIST, m_plugins); + return; + } + try + { + await plugin.Start(); + } + catch (Exception ex) + { + _logger.Error("添加插件失败", ex); + throw ex; + } + + m_plugins.Add(plugin); + m_settingSqlService.SetValue(SettingConstants.Other.PLUGIN_LIST, m_plugins); + } + + public async Task RemovePlugin(string name) + { + var plugin = m_plugins.FirstOrDefault(x => x.Name == name); + if (plugin == null) return; + await plugin.Stop(); + m_plugins.Remove(plugin); + } + } + + public class WebSocketPlugin + { + private WebSocket m_webSocket; + private bool m_autoReconnect = true; + private int m_retryCount = 0; + private Timer m_clearRetryTimer; + + public WebSocketPlugin() + { + m_clearRetryTimer = new Timer(5000); + m_clearRetryTimer.AutoReset = true; + m_clearRetryTimer.Elapsed += ClearRetryTimer_Elapsed; + } + + /// + /// 插件的唤醒协议, 例如 bilibili:// + /// + public string WakeProto { get; set; } + + /// + /// 连接插件的WebSocket地址 + /// + public string WebSocketUrl { get; set; } + + /// + /// 检查插件是否已启动的Http地址 + /// + public string CheckUrl { get; set; } + + /// + /// 插件名称 + /// + public string Name { get; set; } + + public async Task Start() + { + if (!await CheckIsEnable()) + { + await WakePlugin(); + } + await Connect(); + PluginCenter.BroadcastEvent += OnBroadcastEvent; + } + + public async Task Stop() + { + PluginCenter.BroadcastEvent -= OnBroadcastEvent; + await DisConnect(); + } + + private void OnBroadcastEvent(object sender,object msg) + { + // 将msg序列化为json字符串,通过ws发送出去 + var json = JsonConvert.SerializeObject(msg); + if (m_webSocket.State == WebSocketState.Open) + { + try + { + m_webSocket.Send(json); + } + catch (Exception ex) + { + // 处理发送消息时可能出现的异常 + Debug.WriteLine($"Error sending message: {ex.Message}"); + } + } + else + { + // WebSocket连接不是打开状态,可能需要重连或记录错误 + Debug.WriteLine("WebSocket is not in the Open state."); + } + } + + private async Task Connect() + { + m_webSocket = new WebSocket(WebSocketUrl); + m_webSocket.Opened += OnWebSocketOpened; + m_webSocket.Closed += OnWebSocketClosed; + m_webSocket.MessageReceived += OnWebSocketMessageReceived; + m_webSocket.Error += OnWebSocketError; + await OpenConnect(); + } + + private async Task OpenConnect() + { + try + { + await m_webSocket.OpenAsync(); + } + catch (Exception ex) + { + await RetryConnect(); + } + } + + private async Task DisConnect() + { + if (m_webSocket != null && m_webSocket.State == WebSocketState.Open) + { + m_webSocket.Opened -= OnWebSocketOpened; + m_webSocket.Closed -= OnWebSocketClosed; + m_webSocket.MessageReceived -= OnWebSocketMessageReceived; + m_webSocket.Error -= OnWebSocketError; + m_autoReconnect = false; + await m_webSocket.CloseAsync(); + m_webSocket = null; + } + } + + private void ClearRetryTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) + { + if (m_webSocket.State == WebSocketState.Open) + { + m_clearRetryTimer.Stop(); + m_retryCount = 0; + } + } + + private async Task RetryConnect() + { + var retryTime = 2000 * (m_retryCount); + + m_retryCount++; + m_clearRetryTimer.Start(); + + await Task.Delay(retryTime); + + await OpenConnect(); + } + + private void OnWebSocketOpened(object sender, EventArgs e) + { + // WebSocket 连接已打开 + } + + private async void OnWebSocketClosed(object sender, EventArgs e) + { + if (m_autoReconnect) + { + await RetryConnect(); + } + } + + private void OnWebSocketMessageReceived(object sender, MessageReceivedEventArgs e) + { + // 处理接收到的消息 + var msg = JsonConvert.DeserializeObject(e.Message); + + // TODO: 优化代码 + if (msg.Type == "action") + { + var mainPage = App.ServiceProvider.GetRequiredService(); + var mainPageObj = mainPage as Page; + mainPageObj.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => + { + if (msg.Action == "ShowMessageToast") + { + // 解析参数 + var message = msg.Params["message"]?.ToString(); + var seconds = msg.Params["seconds"]?.ToObject() ?? 2; // 默认值为2秒 + + // 调用Notify.ShowMessageToast方法 + Notify.ShowMessageToast(message, seconds); + } + else if (msg.Action == "ExecuteAction") + { + var name = msg.Params["name"]?.ToString(); + var shortcutKeyService = App.ServiceProvider.GetRequiredService(); + shortcutKeyService.ExecuteAction(name); + } + else if (msg.Action == "SetPosition") + { + var position = msg.Params["position"]?.ToObject() ?? 0; + if (!(mainPage.CurrentPage is PlayPage page)) return; + page.SetPosition(position); + } + }); + } + } + + private void OnWebSocketError(object sender, SuperSocket.ClientEngine.ErrorEventArgs e) + { + // 处理 WebSocket 错误 + Debug.WriteLine($"WebSocket error: {e.Exception.Message}"); + } + + private async Task WakePlugin() + { + var success = await Launcher.LaunchUriAsync(new Uri(WakeProto)); + if (!success) + { + // 处理唤醒失败的情况 + throw new Exception("Failed to wake the plugin."); + } + // 等待一段时间让插件启动 + await Task.Delay(5000); + } + + private async Task CheckIsEnable() + { + try + { + var response = await $"{CheckUrl}".GetAsync(); + // 假设如果插件启动了,这个请求会返回200 OK + return response.StatusCode == 200; + } + catch (Exception) + { + // 如果请求失败,可能意味着插件没有启动 + return false; + } + } + } + + public static class PluginCenter + { + public static event EventHandler BroadcastEvent; + + public static void BroadcastPosition(object sender, double position) + { + BroadcastEvent?.Invoke(sender, new + { + @event = "PositionChanged", + position, + }); + } + } + + public class PluginMessage + { + public string Type { get; set; } + + public string Action { get; set; } + + public JObject Params { get; set; } + } +} diff --git a/src/BiliLite.UWP/Services/ShortcutKeyService.cs b/src/BiliLite.UWP/Services/ShortcutKeyService.cs index 3d047835..7584419b 100644 --- a/src/BiliLite.UWP/Services/ShortcutKeyService.cs +++ b/src/BiliLite.UWP/Services/ShortcutKeyService.cs @@ -193,6 +193,12 @@ public void HandleKeyUp(VirtualKey virtualKey) } } + public void ExecuteAction(string name) + { + var function = DefaultShortcuts.GetDefaultShortcutFunctions().FirstOrDefault(x => x.TypeName==name); + function?.Action(m_mainPage.CurrentPage); + } + public void SetDefault() { m_shortcutKeys = DefaultShortcuts.GetDefaultShortcutFunctions(); diff --git a/src/BiliLite.UWP/Startup.cs b/src/BiliLite.UWP/Startup.cs index b574436a..ce163e64 100644 --- a/src/BiliLite.UWP/Startup.cs +++ b/src/BiliLite.UWP/Startup.cs @@ -11,6 +11,7 @@ public void ConfigureServices(HostBuilderContext context, IServiceCollection ser { services.AddDbContext(); services.AddSingleton(); + services.AddSingleton(); services.AddTransient(); services.AddMapper(); diff --git a/src/BiliLite.UWP/ViewModels/Plugins/WebSocketPluginViewModel.cs b/src/BiliLite.UWP/ViewModels/Plugins/WebSocketPluginViewModel.cs new file mode 100644 index 00000000..32c7d223 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Plugins/WebSocketPluginViewModel.cs @@ -0,0 +1,27 @@ +using BiliLite.ViewModels.Common; + +namespace BiliLite.ViewModels.Plugins +{ + public class WebSocketPluginViewModel : BaseViewModel + { + /// + /// 插件的唤醒协议, 例如 bilibili:// + /// + public string WakeProto { get; set; } + + /// + /// 连接插件的WebSocket地址 + /// + public string WebSocketUrl { get; set; } + + /// + /// 检查插件是否已启动的Http地址 + /// + public string CheckUrl { get; set; } + + /// + /// 插件名称 + /// + public string Name { get; set; } + } +} diff --git a/src/BiliLite.UWP/ViewModels/Settings/DevSettingsControlViewModel.cs b/src/BiliLite.UWP/ViewModels/Settings/DevSettingsControlViewModel.cs new file mode 100644 index 00000000..7d4f9037 --- /dev/null +++ b/src/BiliLite.UWP/ViewModels/Settings/DevSettingsControlViewModel.cs @@ -0,0 +1,39 @@ +using System.Collections.ObjectModel; +using System.Linq; +using BiliLite.ViewModels.Common; +using BiliLite.ViewModels.Plugins; +using PropertyChanged; + +namespace BiliLite.ViewModels.Settings +{ + public class DevSettingsControlViewModel : BaseViewModel + { + public ObservableCollection Plugins { get; set; } = + new ObservableCollection(); + + [DependsOn(nameof(Plugins))] + public bool ShowPluginList => Plugins.Any (); + + public void AddPlugin(WebSocketPluginViewModel plugin) + { + var oldPlugin = Plugins.FirstOrDefault(x => x.Name == plugin.Name); + if (oldPlugin != null) + { + oldPlugin.CheckUrl = plugin.CheckUrl; + oldPlugin.WakeProto = plugin.WakeProto; + oldPlugin.WebSocketUrl = plugin.WebSocketUrl; + } + else + { + Plugins.Add(plugin); + Set(nameof(ShowPluginList)); + } + } + + public void RemovePlugin(WebSocketPluginViewModel plugin) + { + Plugins.Remove(plugin); + Set(nameof(ShowPluginList)); + } + } +}