mirror of
https://jihulab.com/DGP-Studio/Snap.Hutao.git
synced 2025-11-19 21:02:53 +08:00
correct game record requests
This commit is contained in:
@@ -132,9 +132,11 @@ internal static class ApiEndpoints
|
||||
/// <returns>游戏记录主页字符串</returns>
|
||||
public static string GameRecordIndex(in PlayerUid uid)
|
||||
{
|
||||
return $"{ApiTakumiRecordApi}/index?server={uid.Region}&role_id={uid.Value}";
|
||||
return $"{GameRecordIndexPath}?server={uid.Region}&role_id={uid.Value}";
|
||||
}
|
||||
|
||||
public const string GameRecordIndexPath = $"{ApiTakumiRecordApi}/index";
|
||||
|
||||
/// <summary>
|
||||
/// 深渊信息
|
||||
/// </summary>
|
||||
@@ -143,8 +145,10 @@ internal static class ApiEndpoints
|
||||
/// <returns>深渊信息字符串</returns>
|
||||
public static string GameRecordSpiralAbyss(Hoyolab.Takumi.GameRecord.SpiralAbyssSchedule scheduleType, in PlayerUid uid)
|
||||
{
|
||||
return $"{ApiTakumiRecordApi}/spiralAbyss?schedule_type={(int)scheduleType}&role_id={uid.Value}&server={uid.Region}";
|
||||
return $"{GameRecordSpiralAbyssPath}?schedule_type={(int)scheduleType}&role_id={uid.Value}&server={uid.Region}";
|
||||
}
|
||||
|
||||
public const string GameRecordSpiralAbyssPath = $"{ApiTakumiRecordApi}/spiralAbyss";
|
||||
#endregion
|
||||
|
||||
#region ApiTakumiEventCalculate
|
||||
|
||||
@@ -32,6 +32,8 @@ internal static class HoyolabOptions
|
||||
/// </summary>
|
||||
public const string MobileUserAgentOversea = $"Mozilla/5.0 (Linux; Android 12) Mobile miHoYoBBSOversea/{SaltConstants.OSVersion}";
|
||||
|
||||
public const string ToolVersion = "v4.2.2-ys";
|
||||
|
||||
/// <summary>
|
||||
/// 米游社设备Id
|
||||
/// </summary>
|
||||
|
||||
@@ -101,20 +101,4 @@ internal sealed partial class CardClient
|
||||
[JsonPropertyName("geetest_seccode")]
|
||||
public string GeetestSeccode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class CardVerifiationHeaders
|
||||
{
|
||||
public int ChallengeGame { get; private set; }
|
||||
|
||||
public string ChallengePath { get; private set; }
|
||||
|
||||
public static CardVerifiationHeaders Create(string path)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
ChallengeGame = 2,
|
||||
ChallengePath = path,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// Copyright (c) DGP Studio. All rights reserved.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
namespace Snap.Hutao.Web.Hoyolab.Takumi.GameRecord;
|
||||
|
||||
internal sealed class CardVerifiationHeaders
|
||||
{
|
||||
public int ChallengeGame { get; private set; }
|
||||
|
||||
public string ChallengePath { get; private set; } = string.Empty;
|
||||
|
||||
public string Page { get; private set; } = string.Empty;
|
||||
|
||||
public static CardVerifiationHeaders CreateForDailyNote()
|
||||
{
|
||||
return Create(ApiEndpoints.GameRecordDailyNotePath);
|
||||
}
|
||||
|
||||
public static CardVerifiationHeaders CreateForIndex()
|
||||
{
|
||||
return Create(ApiEndpoints.GameRecordIndexPath);
|
||||
}
|
||||
|
||||
public static CardVerifiationHeaders CreateForSpiralAbyss()
|
||||
{
|
||||
return Create(ApiEndpoints.GameRecordSpiralAbyssPath);
|
||||
}
|
||||
|
||||
public static CardVerifiationHeaders CreateForCharacter()
|
||||
{
|
||||
return Create(ApiEndpoints.GameRecordCharacter, $"{HoyolabOptions.ToolVersion}_#/ys/role/all");
|
||||
}
|
||||
|
||||
private static CardVerifiationHeaders Create(string path, string page = $"{HoyolabOptions.ToolVersion}_#/ys")
|
||||
{
|
||||
return new()
|
||||
{
|
||||
ChallengeGame = 2,
|
||||
ChallengePath = path,
|
||||
Page = page,
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
@@ -28,12 +28,6 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
||||
private readonly ILogger<GameRecordClient> logger;
|
||||
private readonly HttpClient httpClient;
|
||||
|
||||
/// <summary>
|
||||
/// 异步获取实时便笺
|
||||
/// </summary>
|
||||
/// <param name="userAndUid">用户与角色</param>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>实时便笺</returns>
|
||||
[ApiInformation(Cookie = CookieType.Cookie, Salt = SaltType.X4)]
|
||||
public async ValueTask<Response<DailyNote.DailyNote>> GetDailyNoteAsync(UserAndUid userAndUid, CancellationToken token = default)
|
||||
{
|
||||
@@ -54,9 +48,9 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
||||
{
|
||||
// Replace message
|
||||
resp.Message = SH.WebDailyNoteVerificationFailed;
|
||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||
|
||||
CardVerifiationHeaders headers = CardVerifiationHeaders.Create(ApiEndpoints.GameRecordDailyNotePath);
|
||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||
CardVerifiationHeaders headers = CardVerifiationHeaders.CreateForDailyNote();
|
||||
|
||||
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, headers, token).ConfigureAwait(false) is { } challenge)
|
||||
{
|
||||
@@ -78,12 +72,6 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
||||
return Response.Response.DefaultIfNull(resp);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取玩家基础信息
|
||||
/// </summary>
|
||||
/// <param name="userAndUid">用户与角色</param>
|
||||
/// <param name="token">取消令牌</param>
|
||||
/// <returns>玩家的基础信息</returns>
|
||||
[ApiInformation(Cookie = CookieType.LToken, Salt = SaltType.X4)]
|
||||
public async ValueTask<Response<PlayerInfo>> GetPlayerInfoAsync(UserAndUid userAndUid, CancellationToken token = default)
|
||||
{
|
||||
@@ -104,9 +92,9 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
||||
{
|
||||
// Replace message
|
||||
resp.Message = SH.WebIndexOrSpiralAbyssVerificationFailed;
|
||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||
|
||||
CardVerifiationHeaders headers = CardVerifiationHeaders.Create(ApiEndpoints.GameRecordDailyNotePath);
|
||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||
CardVerifiationHeaders headers = CardVerifiationHeaders.CreateForIndex();
|
||||
|
||||
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, headers, token).ConfigureAwait(false) is { } challenge)
|
||||
{
|
||||
@@ -155,9 +143,9 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
||||
{
|
||||
// Replace message
|
||||
resp.Message = SH.WebIndexOrSpiralAbyssVerificationFailed;
|
||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||
|
||||
CardVerifiationHeaders headers = CardVerifiationHeaders.Create(ApiEndpoints.GameRecordDailyNotePath);
|
||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||
CardVerifiationHeaders headers = CardVerifiationHeaders.CreateForSpiralAbyss();
|
||||
|
||||
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, headers, token).ConfigureAwait(false) is { } challenge)
|
||||
{
|
||||
@@ -230,9 +218,9 @@ internal sealed partial class GameRecordClient : IGameRecordClient
|
||||
{
|
||||
// Replace message
|
||||
resp.Message = SH.WebIndexOrSpiralAbyssVerificationFailed;
|
||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||
|
||||
CardVerifiationHeaders headers = CardVerifiationHeaders.Create(ApiEndpoints.GameRecordDailyNotePath);
|
||||
IGeetestCardVerifier verifier = serviceProvider.GetRequiredKeyedService<IGeetestCardVerifier>(GeetestCardVerifierType.Custom);
|
||||
CardVerifiationHeaders headers = CardVerifiationHeaders.CreateForCharacter();
|
||||
|
||||
if (await verifier.TryValidateXrpcChallengeAsync(userAndUid.User, headers, token).ConfigureAwait(false) is { } challenge)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user