Merge pull request #352 from solacens/globalization/gotcha-histories

[Globalization] Read gotcha history from input of url or from cache/data_2
This commit is contained in:
DismissedLight
2023-01-10 15:22:06 +08:00
committed by GitHub
2 changed files with 39 additions and 2 deletions

View File

@@ -63,7 +63,17 @@ internal class GachaLogUrlWebCacheProvider : IGachaLogUrlProvider
using (MemoryStream memoryStream = new())
{
await fileStream.CopyToAsync(memoryStream).ConfigureAwait(false);
string? result = Match(memoryStream);
string? result = null;
if (tempFile.Path.Contains("YuanShen_Data"))
{
result = Match(memoryStream);
}
else
{
result = MatchIntl(memoryStream);
}
return new(!string.IsNullOrEmpty(result), result!);
}
}
@@ -90,4 +100,20 @@ internal class GachaLogUrlWebCacheProvider : IGachaLogUrlProvider
return null;
}
private static string? MatchIntl(MemoryStream stream)
{
ReadOnlySpan<byte> span = stream.ToArray();
ReadOnlySpan<byte> match = "https://webstatic-sea.hoyoverse.com/genshin/event/e20190909gacha-v2/index.html"u8;
ReadOnlySpan<byte> zero = "\0"u8;
int index = span.LastIndexOf(match);
if (index >= 0)
{
int length = span[index..].IndexOf(zero);
return Encoding.UTF8.GetString(span.Slice(index, length));
}
return null;
}
}

View File

@@ -274,7 +274,14 @@ internal static class ApiEndpoints
/// <returns>祈愿记录信息Url</returns>
public static string GachaInfoGetGachaLog(string query)
{
return $"{Hk4eApiGachaInfoApi}/getGachaLog?{query}";
if (query.Contains("mihoyo.com"))
{
return $"{Hk4eApiGachaInfoApi}/getGachaLog?{query}";
}
else
{
return $"{Hk4eIntlApiGachaInfoApi}/getGachaLog?{query}";
}
}
#endregion
@@ -356,6 +363,10 @@ internal static class ApiEndpoints
private const string Hk4eApiAnnouncementApi = $"{Hk4eApi}/common/hk4e_cn/announcement/api";
private const string Hk4eApiGachaInfoApi = $"{Hk4eApi}/event/gacha_info/api";
private const string Hk4eIntlApi = "https://hk4e-api-os.hoyoverse.com";
private const string Hk4eIntlApiAnnouncementApi = $"{Hk4eIntlApi}/common/hk4e_cn/announcement/api";
private const string Hk4eIntlApiGachaInfoApi = $"{Hk4eIntlApi}/event/gacha_info/api";
private const string PassportApi = "https://passport-api.mihoyo.com";
private const string PassportApiAuthApi = $"{PassportApi}/account/auth/api";
private const string PassportApiV4 = "https://passport-api-v4.mihoyo.com";