- sites/spiders: Haidan/HDDolby/RousiPro/SunnyPT/TNode/TorrentLeech/Yema (+mTorrent wrapper), specialized SiteAdapter, indirect download resolved at download time - sites/user-parsers: SiteParserBase + all 20 MP SiteSchema parsers (lxml XPath via xpath+xmldom), refreshSiteUserData with schema fallback - sites/definitions: zod SiteDefinition schemas, 23 MovieClaw v0.27.0 (MIT) definitions via scripts/mp-sync/movieclaw-import.mjs, registry getSiteDefinition/listSiteDefinitions, NOTICE - scripts/mp-sync: ledger.json (upstream sha256), check.mjs, build-ledger.mjs; docs/porting/mp-sync-ledger.md - license-and-provenance: add copied-mit kind, re-anchor MovieClaw rows to v0.27.0 Co-Authored-By: Claude Opus 5.5 <[email protected]>
55 lines
2.4 KiB
TypeScript
55 lines
2.4 KiB
TypeScript
/**
|
|
* 随产品发布的站点注册表(迁移账本 SA1)。
|
|
* 对应 MP `SitesHelper.get_indexers()/get_indexer(domain)`(闭源,sites.pyi)与
|
|
* `IndexerModule` 按 `indexer.parser` 分派专用解析器(`mTorrent` → MTorrentSpider,其余 → SiteSpider)。
|
|
* 加站:MovieClaw 来源重跑 scripts/mp-sync/movieclaw-import.mjs;其他来源新增 JSON 并登记到 definitions/。
|
|
*/
|
|
|
|
import { BUILTIN_SITE_DEFINITIONS, type SiteDefinition } from "./definitions/index.ts";
|
|
import type { SiteAdapterDeps } from "./deps.ts";
|
|
import { createMteamAdapter } from "./mteam/adapter.ts";
|
|
import type { MteamDefinition } from "./mteam/definition.ts";
|
|
import { createSpiderSiteAdapter } from "./spider/adapter.ts";
|
|
import type { IndexerDefinition } from "./spider/schema.ts";
|
|
import { createSpecializedAdapterFor } from "./spiders/index.ts";
|
|
import type { SpecializedSiteDefinition } from "./spiders/types.ts";
|
|
import type { SiteAdapter } from "./types.ts";
|
|
|
|
export type { SiteDefinition };
|
|
|
|
/** 全部内置定义(含 enabled:false 的未实测站点) */
|
|
export const SITE_DEFINITIONS: Readonly<Record<string, SiteDefinition>> = BUILTIN_SITE_DEFINITIONS;
|
|
|
|
/** MP `SitesHelper.get_indexer`:按 id 取定义;未知返回 undefined */
|
|
export function getSiteDefinition(id: string): SiteDefinition | undefined {
|
|
return SITE_DEFINITIONS[id];
|
|
}
|
|
|
|
/** MP `SitesHelper.get_indexers`:列出定义;默认含未启用站点,`enabledOnly` 只列 enabled !== false */
|
|
export function listSiteDefinitions(opts: { enabledOnly?: boolean } = {}): SiteDefinition[] {
|
|
return Object.values(SITE_DEFINITIONS)
|
|
.filter((d) => !opts.enabledOnly || d.enabled !== false)
|
|
.sort((a, b) => a.id.localeCompare(b.id));
|
|
}
|
|
|
|
/**
|
|
* MP `IndexerModule` 按 `indexer.parser` 分派:mTorrent → 馒头适配器;SPIDER_PARSER_CLASSES 其余键(umt.kind=api)
|
|
* → 专用 spider 适配器;其余 → 通用 SiteSpider。
|
|
*/
|
|
export function createSiteAdapter(def: SiteDefinition, deps: SiteAdapterDeps): SiteAdapter {
|
|
switch (def.umt.kind) {
|
|
case "mteam":
|
|
return createMteamAdapter(def as MteamDefinition, deps);
|
|
case "api":
|
|
return createSpecializedAdapterFor(def as SpecializedSiteDefinition, deps);
|
|
default:
|
|
return createSpiderSiteAdapter(def as IndexerDefinition, deps);
|
|
}
|
|
}
|
|
|
|
export function getSiteAdapter(siteId: string, deps: SiteAdapterDeps): SiteAdapter {
|
|
const def = SITE_DEFINITIONS[siteId];
|
|
if (!def) throw new Error(`未知站点:${siteId}`);
|
|
return createSiteAdapter(def, deps);
|
|
}
|