From 9fbbb0929ded01b6ec0673dacb0b9a807c841da9 Mon Sep 17 00:00:00 2001 From: ywmoyue Date: Fri, 25 Oct 2024 12:09:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4RestSharp=E4=BE=9D=E8=B5=96?= =?UTF-8?q?=EF=BC=9B=E5=A4=84=E7=90=86Simple.AES=E3=80=81System.Drawing.Co?= =?UTF-8?q?mmon=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 @@ - +