Skip to content

Commit

Permalink
移除RestSharp依赖;处理Simple.AES、System.Drawing.Common版本问题
Browse files Browse the repository at this point in the history
  • Loading branch information
ywmoyue committed Oct 25, 2024
1 parent 281bb61 commit 9fbbb09
Show file tree
Hide file tree
Showing 34 changed files with 276 additions and 267 deletions.
5 changes: 1 addition & 4 deletions src/BiliLite.UWP/BiliLite.UWP.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -1540,10 +1540,7 @@
<PackageReference Include="QRCoder">
<Version>1.4.3</Version>
</PackageReference>
<PackageReference Include="RestSharp">
<Version>107.3.0</Version>
</PackageReference>
<PackageReference Include="Simple.AES">
<PackageReference Include="Simple.AES.Core.Fork">
<Version>2.0.2</Version>
</PackageReference>
<PackageReference Include="SYEngine.uwp">
Expand Down
3 changes: 2 additions & 1 deletion src/BiliLite.UWP/Extensions/ApiModelExtensions.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,7 +19,7 @@ public static class ApiModelExtensions
public static async Task<HttpResults> 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)
{
Expand Down
9 changes: 9 additions & 0 deletions src/BiliLite.UWP/Models/Common/Enumerates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ public enum LogType
Necessary,
}

public enum HttpMethods
{
Get,
Post,
Put,
Patch,
Delete,
}

public enum LoginStatus
{
/// <summary>
Expand Down
78 changes: 39 additions & 39 deletions src/BiliLite.UWP/Models/Requests/Api/AccountApi.cs

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions src/BiliLite.UWP/Models/Requests/Api/CommentApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -145,7 +145,7 @@ public ApiModel AddComment(string oid, CommentType type, string message, List<Dy
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}&type={(int)type}&message={Uri.EscapeDataString(message)}&csrf={csrf}",
need_cookie = true,
Expand Down Expand Up @@ -178,7 +178,7 @@ public ApiModel UploadDraw(UploadFileInfo file)
var csrf = m_cookieService.GetCSRFToken();
var api = new ApiModel()
{
method = RestSharp.Method.Post,
method = HttpMethods.Post,
baseUrl = $"{ApiHelper.API_BASE_URL}/x/dynamic/feed/draw/upload_bfs",
FormData = new Dictionary<string, object>()
{
Expand Down
5 changes: 3 additions & 2 deletions src/BiliLite.UWP/Models/Requests/Api/EmoteApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BiliLite.Services;
using BiliLite.Models.Common;
using BiliLite.Services;

namespace BiliLite.Models.Requests.Api
{
Expand All @@ -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(),
Expand Down
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/Models/Requests/Api/GitApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()}"
};
Expand All @@ -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()}"
};
Expand Down
8 changes: 4 additions & 4 deletions src/BiliLite.UWP/Models/Requests/Api/Home/AnimeAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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
};
Expand All @@ -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}"
};
Expand Down
4 changes: 2 additions & 2 deletions src/BiliLite.UWP/Models/Requests/Api/Home/CinemaAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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}"
};
Expand Down
5 changes: 3 additions & 2 deletions src/BiliLite.UWP/Models/Requests/Api/Home/HotApi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BiliLite.Services;
using BiliLite.Models.Common;
using BiliLite.Services;

namespace BiliLite.Models.Requests.Api.Home
{
Expand All @@ -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}"
};
Expand Down
7 changes: 4 additions & 3 deletions src/BiliLite.UWP/Models/Requests/Api/Home/LiveAPI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BiliLite.Services;
using BiliLite.Models.Common;
using BiliLite.Services;

namespace BiliLite.Models.Requests.Api.Home
{
Expand All @@ -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",
};
Expand All @@ -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"
};
Expand Down
9 changes: 5 additions & 4 deletions src/BiliLite.UWP/Models/Requests/Api/Home/RecommendAPI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BiliLite.Services;
using BiliLite.Models.Common;
using BiliLite.Services;

namespace BiliLite.Models.Requests.Api.Home
{
Expand All @@ -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()
Expand All @@ -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}"
Expand All @@ -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}"
Expand Down
7 changes: 4 additions & 3 deletions src/BiliLite.UWP/Models/Requests/Api/Live/LiveAreaAPI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BiliLite.Services;
using BiliLite.Models.Common;
using BiliLite.Services;

namespace BiliLite.Models.Requests.Api.Live
{
Expand All @@ -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"
};
Expand All @@ -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}"
};
Expand Down
13 changes: 7 additions & 6 deletions src/BiliLite.UWP/Models/Requests/Api/Live/LiveCenterAPI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BiliLite.Services;
using BiliLite.Models.Common;
using BiliLite.Services;

namespace BiliLite.Models.Requests.Api.Live
{
Expand All @@ -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",
};
Expand All @@ -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",
};
Expand All @@ -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",
};
Expand All @@ -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",
};
Expand All @@ -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"
};
Expand Down
5 changes: 3 additions & 2 deletions src/BiliLite.UWP/Models/Requests/Api/Live/LiveRecommendAPI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BiliLite.Services;
using BiliLite.Models.Common;
using BiliLite.Services;

namespace BiliLite.Models.Requests.Api.Live
{
Expand All @@ -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}"
};
Expand Down
Loading

0 comments on commit 9fbbb09

Please sign in to comment.