chore: 标准化 2dfan API HTML 响应日志格式

- 在 `VikaACG` 和 `TWOdfan` 平台中,标准化 2dfan API HTML 响应的日志格式。
- 日志输出采用 JSON 格式,包含 `message`、`html` 和 `level: "info"` 字段。
- 此更改有助于改进 API 响应的调试和监控。
This commit is contained in:
Jurangren
2025-08-23 01:01:06 +08:00
parent 37f47f981a
commit 6d16623f36
2 changed files with 12 additions and 2 deletions

View File

@@ -48,6 +48,12 @@ async function searchVikaACG(game: string): Promise<PlatformSearchResult> {
// The response is a JSON-encoded string containing HTML.
// .json() will parse the JSON and unescape the string content.
const html: string = await response.text();
console.log(JSON.stringify({
message: "2dfan API HTML Response",
html: html,
level: "info",
}));
const matches = html.matchAll(REGEX);

View File

@@ -24,8 +24,12 @@ async function searchTWOdfan(game: string): Promise<PlatformSearchResult> {
if (!response.ok) {
throw new Error(`资源平台 SearchAPI 响应异常状态码 ${response.status}`);
}
console.log("2dfan API HTML Response:", response.text());
console.log(JSON.stringify({
message: "2dfan API HTML Response",
html: response.text(),
level: "info",
}));
const data = await response.json() as TwoDFanResponse;
const html = data.subjects;