diff --git a/src/platforms/gal/TaoHuaYuan.ts b/src/platforms/gal/TaoHuaYuan.ts deleted file mode 100644 index 4750270..0000000 --- a/src/platforms/gal/TaoHuaYuan.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { fetchClient } from "../../utils/httpClient"; -import type { Platform, PlatformSearchResult, SearchResultItem } from "../../types"; - -const DATA_URL = "https://peach.sslswwdx.top/page/search/index.json"; - -interface TaoHuaYuanItem { - title: string; - permalink: string; -} - -async function searchTaoHuaYuan(game: string): Promise { - const searchResult: PlatformSearchResult = { - count: 0, - items: [], - }; - - try { - const response = await fetchClient(DATA_URL); - if (!response.ok) { - throw new Error(`Failed to fetch data from ${DATA_URL}`); - } - - const data = await response.json() as TaoHuaYuanItem[]; - - const items: SearchResultItem[] = data - .filter(item => item.title.includes(game)) - .map(item => ({ - name: item.title.trim(), - url: item.permalink, - })); - - searchResult.items = items; - searchResult.count = items.length; - - } catch (error) { - if (error instanceof Error) { - searchResult.error = error.message; - } else { - searchResult.error = "An unknown error occurred"; - } - searchResult.count = -1; - } - - return searchResult; -} - -const TaoHuaYuan: Platform = { - name: "桃花源", - color: "lime", - tags: ["NoReq", "SuDrive"], - magic: false, - search: searchTaoHuaYuan, -}; - -export default TaoHuaYuan; \ No newline at end of file diff --git a/src/platforms/gal/Hikarinagi.ts b/src/platforms/gal/TianYouErCiYuan.ts similarity index 65% rename from src/platforms/gal/Hikarinagi.ts rename to src/platforms/gal/TianYouErCiYuan.ts index 5cac60c..40865be 100644 --- a/src/platforms/gal/Hikarinagi.ts +++ b/src/platforms/gal/TianYouErCiYuan.ts @@ -1,19 +1,18 @@ import { fetchClient } from "../../utils/httpClient"; import type { Platform, PlatformSearchResult, SearchResultItem } from "../../types"; -const API_URL = "https://www.hikarinagi.net/"; -const REGEX = /" class="lazyload fit-cover radius8">.*?

(?.*?)<\/a><\/h2>/gs; +const API_URL = "https://www.tiangal.com/search/"; +const REGEX = /

\s* { +async function searchTianYouErCiYuan(game: string): Promise { const searchResult: PlatformSearchResult = { count: 0, items: [], }; try { - const url = new URL(API_URL); - url.searchParams.set("s", game); - + const url = new URL(API_URL + encodeURIComponent(game)); // URL path parameter + const response = await fetchClient(url); if (!response.ok) { throw new Error(`资源平台 SearchAPI 响应异常状态码 ${response.status}`); @@ -27,7 +26,7 @@ async function searchHikarinagi(game: string): Promise { if (match.groups?.NAME && match.groups?.URL) { items.push({ name: match.groups.NAME.trim(), - url: match.groups.URL, + url: new URL(match.groups.URL, API_URL).toString(), }); } } @@ -47,12 +46,12 @@ async function searchHikarinagi(game: string): Promise { return searchResult; } -const Hikarinagi: Platform = { - name: "Hikarinagi", +const TianYouErCiYuan: Platform = { + name: "天游二次元", color: "white", - tags: ["LoginPay", "SuDrive"], - magic: false, - search: searchHikarinagi, + tags: ["LoginPay", "MixDrive"], + magic: true, + search: searchTianYouErCiYuan, }; -export default Hikarinagi; \ No newline at end of file +export default TianYouErCiYuan; \ No newline at end of file diff --git a/src/platforms/gal/YingZhiGuang.ts b/src/platforms/gal/YingZhiGuang.ts new file mode 100644 index 0000000..7a44b11 --- /dev/null +++ b/src/platforms/gal/YingZhiGuang.ts @@ -0,0 +1,59 @@ +import { fetchClient } from "../../utils/httpClient"; +import type { Platform, PlatformSearchResult, SearchResultItem } from "../../types"; + +const DATA_URL = "https://yinghu.netlify.app/search.xml"; +const BASE_URL = "https://yinghu.netlify.app"; +const REGEX = /.*?(.*?)<\/title>.*?<url>(.*?)<\/url>.*?<\/entry>/gs; + +async function searchYingZhiGuang(game: string): Promise<PlatformSearchResult> { + const searchResult: PlatformSearchResult = { + count: 0, + items: [], + }; + + try { + const response = await fetchClient(DATA_URL); + if (!response.ok) { + throw new Error(`Failed to fetch data from ${DATA_URL}`); + } + + const xmlText = await response.text(); + const matches = xmlText.matchAll(REGEX); + + const items: SearchResultItem[] = []; + for (const match of matches) { + const title = match[1]; + const urlPath = match[2]; + + if (title && urlPath && title.includes(game)) { + items.push({ + name: title.trim(), + url: BASE_URL + urlPath, + }); + } + } + + searchResult.items = items; + searchResult.count = items.length; + + } catch (error) { + if (error instanceof Error) { + searchResult.error = error.message; + } else { + searchResult.error = "An unknown error occurred"; + } + searchResult.count = -1; + } + + return searchResult; +} + +const YingZhiGuang: Platform = { + name: "萤ノ光", + color: "lime", + tags: ["NoReq", "SuDrive"], + magic: false, + search: searchYingZhiGuang, +}; + +export default YingZhiGuang; \ No newline at end of file diff --git a/src/platforms/gal/YouYuDeloli.ts b/src/platforms/gal/YouYuDeloli.ts index 9a380a0..44bd581 100644 --- a/src/platforms/gal/YouYuDeloli.ts +++ b/src/platforms/gal/YouYuDeloli.ts @@ -13,6 +13,7 @@ async function searchYouYuDeloli(game: string): Promise<PlatformSearchResult> { try { const url = new URL(API_URL); url.searchParams.set("s", game); + url.searchParams.set("submit", ''); const response = await fetchClient(url); if (!response.ok) { diff --git a/src/platforms/gal/index.ts b/src/platforms/gal/index.ts index 10ce314..936d7ee 100644 --- a/src/platforms/gal/index.ts +++ b/src/platforms/gal/index.ts @@ -7,7 +7,6 @@ import GalgameX from "./GalgameX"; import GalTuShuGuan from "./GalTuShuGuan"; import GGBases from "./GGBases"; import GGS from "./GGS"; -import Hikarinagi from "./Hikarinagi"; import JiMengACG from "./JiMengACG"; import Koyso from "./Koyso"; import KunGalgame from "./KunGalgame"; @@ -18,11 +17,12 @@ import MiaoYuanLingYu from "./MiaoYuanLingYu"; import Nysoure from "./Nysoure"; import QingJiACG from "./QingJiACG"; import ShenShiTianTang from "./ShenShiTianTang"; -import TaoHuaYuan from "./TaoHuaYuan"; +import TianYouErCiYuan from "./TianYouErCiYuan"; import TouchGal from "./TouchGal"; import VikaACG from "./VikaACG"; import WeiZhiYunPan from "./WeiZhiYunPan"; import xxacg from "./xxacg"; +import YingZhiGuang from "./YingZhiGuang"; import YouYuDeloli from "./YouYuDeloli"; import YueYao from "./YueYao"; import ZeroFive from "./ZeroFive"; @@ -39,7 +39,6 @@ const platforms: Platform[] = [ GalTuShuGuan, GGBases, GGS, - Hikarinagi, JiMengACG, Koyso, KunGalgame, @@ -50,11 +49,12 @@ const platforms: Platform[] = [ Nysoure, QingJiACG, ShenShiTianTang, - TaoHuaYuan, + TianYouErCiYuan, TouchGal, VikaACG, WeiZhiYunPan, xxacg, + YingZhiGuang, YouYuDeloli, YueYao, ZeroFive,