diff --git a/src/platforms/gal/VikaACG.ts b/src/platforms/gal/VikaACG.ts index ebc1575..6343b7d 100644 --- a/src/platforms/gal/VikaACG.ts +++ b/src/platforms/gal/VikaACG.ts @@ -48,14 +48,8 @@ async function searchVikaACG(game: string): Promise { // 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); + const matches = html.replaceAll('\\/', '/').replaceAll('\\\\', '\\').matchAll(REGEX); const items: SearchResultItem[] = []; for (const match of matches) { diff --git a/src/platforms/patch/TWOdfan.ts b/src/platforms/patch/TWOdfan.ts index d4fb0d1..2bcece6 100644 --- a/src/platforms/patch/TWOdfan.ts +++ b/src/platforms/patch/TWOdfan.ts @@ -5,10 +5,6 @@ const API_URL = "https://2dfan.com/subjects/search"; const BASE_URL = "https://2dfan.com"; const REGEX = /

(?.*?)<\/a><\/h4>/gs; -interface TwoDFanResponse { - subjects: string; // This is an HTML string -} - async function searchTWOdfan(game: string): Promise { const searchResult: PlatformSearchResult = { name: "2dfan", @@ -25,14 +21,13 @@ async function searchTWOdfan(game: string): Promise { throw new Error(`资源平台 SearchAPI 响应异常状态码 ${response.status}`); } + const html: string = await response.text(); + console.log(JSON.stringify({ message: "2dfan API HTML Response", - html: response.text(), + html: html, level: "info", })); - - const data = await response.json() as TwoDFanResponse; - const html = data.subjects; const matches = html.matchAll(REGEX);