Files
UHD_Media_Tool/packages/adapters/src/sites/mteam/definition.ts
T
rootandClaude Opus 5.5 d9f2af2f3c feat(adapters): port MoviePilot open site framework (7 spiders, 20 user parsers) + MovieClaw v0.27.0 site definitions + mp-sync tools (W1-3c)
- 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]>
2026-09-27 18:39:27 +08:00

53 lines
1.9 KiB
TypeScript

import mteamJson from "../definitions/mteam.json" with { type: "json" };
import { parseMteamDefinition } from "../definitions/schema.ts";
import type { DefinitionProvenance } from "../spider/schema.ts";
import type { SiteCapabilities } from "../types.ts";
/**
* 馒头站点定义:键名沿用 MP indexer dict(id/name/domain/parser/timeout),
* `umt` 为本项目扩展。API Key 不在定义里,经 SecretResolver 注入(MP 放在 indexer['apikey'])。
*/
export interface MteamDefinition {
id: string;
name: string;
enabled?: boolean;
/** MP 用户信息解析器 schema(MTorrent) */
schema?: string;
provenance?: DefinitionProvenance;
/** 网页域(MP `_url`,详情页 = `${domain}detail/${id}`) */
domain: string;
parser: "mTorrent";
timeout: number;
umt: {
version: string;
kind: "mteam";
displayName: string;
/** API 基址;缺省为 `https://api.<根域>`(MP `_searchurl % _domain`) */
apiBaseUrl?: string;
timezone: string;
rateLimit: { minIntervalMs: number; burst: number };
capabilities: SiteCapabilities;
/** 原始分类 ID → 名称(自行编制,待核验) */
categoryNames: Record<string, string>;
authSupported?: string[];
customClass?: string;
};
}
/**
* 馒头定义:definitions/mteam.json(由 scripts/mp-sync/movieclaw-import.mjs 从 MovieClaw v0.27.0 mteam.yaml 转换,
* W1-3b 原值经 movieclaw-overrides/mteam.json 覆盖),加载时 zod 校验。
*/
export const mteamDefinition: MteamDefinition = parseMteamDefinition(mteamJson);
/** MP `site_rules.extract_domain` 的简化:取主机名最后两级。 */
export function rootDomain(url: string): string {
const host = new URL(url).hostname;
const parts = host.split(".");
return parts.length >= 2 ? parts.slice(-2).join(".") : host;
}
export function mteamApiBase(def: MteamDefinition): string {
return (def.umt.apiBaseUrl ?? `https://api.${rootDomain(def.domain)}`).replace(/\/$/, "");
}