Files
UHD_Media_Tool/packages/adapters/src/sites/feed-item.test.ts
T
rootandClaude Opus 5.5 cabd772243 fix(sites): normalize HHClub RSS items, complete detail page parsing (HH-2)
- RSS: split NexusPHP "[category]name[subtitle][size][uploader]" titles in the
  site adapter layer (category id/name/media type, clean title, subtitle,
  size); snapshot fields win on merge; lazily renormalize old RSS rows and
  re-emit release.observed; unknown list fields show an em dash
- Detail: HHClub section layout (douban info block as description,
  screenshots section, IMDb/TMDB from MediaInfo lines, upload time field,
  on-demand viewfilelist.php once); site CDN screenshots get a Referer
- Site request count now includes site-bound RSS fetches
- Origin view shows "自动化" when idle and "Agent" only after recent
  automation actions (lastAutomationAt); agent step titles no longer get
  squeezed to a sliver by long notes

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-29 17:30:25 +08:00

66 lines
3.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { normalizeSiteFeedItem } from "./feed-item.ts";
// 标题取自 2026-09-29 憨憨 RSS 真实条目(公开种子名,无凭据)
describe("站点 RSS 条目规范化(憨憨)", () => {
it("[分类]种子名[副标题][大小] → 分类 / 标题 / 副标题 / 大小", () => {
const r = normalizeSiteFeedItem(
"hhanclub",
"[音乐]Travis - L.A. Times (2024) - WEB-DL - 24bit ALAC-HHWEB[Travis - L.A. Times | ALAC | 苹果音乐 | 现场版专辑][697.64 MB]",
);
expect(r).toEqual({
title: "Travis - L.A. Times (2024) - WEB-DL - 24bit ALAC-HHWEB",
subtitle: "Travis - L.A. Times | ALAC | 苹果音乐 | 现场版专辑",
category: { id: "410", name: "音乐" },
mediaType: "music",
sizeBytes: Math.round(697.64 * 1024 ** 2),
uploader: null,
});
});
it("电视剧:副标题里的 | 与 / 保留,GB 换算", () => {
const r = normalizeSiteFeedItem(
"hhanclub",
"[电视剧]Spring of the Blade S01 2026 2160p YK WEB-DL H.265 DV HFR HQ AAC2.0-HHWEB[一瓯春 | 第20-24集 | 4K 高码 杜比视界 | 类型: 爱情/古装][26.37 GB]",
);
expect(r.title).toBe("Spring of the Blade S01 2026 2160p YK WEB-DL H.265 DV HFR HQ AAC2.0-HHWEB");
expect(r.subtitle).toBe("一瓯春 | 第20-24集 | 4K 高码 杜比视界 | 类型: 爱情/古装");
expect(r.category).toEqual({ id: "402", name: "电视剧" });
expect(r.mediaType).toBe("tv");
expect(r.sizeBytes).toBe(Math.round(26.37 * 1024 ** 3));
});
it("副标题内嵌方括号、[新] 标记、不在任何媒体大类的分类(纪录片)", () => {
const r = normalizeSiteFeedItem(
"hhanclub",
"[纪录片]Thirteen Talks S09 2016 2160p WEB-DL H.265 AAC2.0-HHWEB[新][十三邀 | 第14集 [内嵌中字]][3.6 GB]",
);
expect(r.title).toBe("Thirteen Talks S09 2016 2160p WEB-DL H.265 AAC2.0-HHWEB");
expect(r.subtitle).toBe("十三邀 | 第14集 [内嵌中字]");
expect(r.category).toEqual({ id: "404", name: "纪录片" });
expect(r.mediaType).toBeNull();
});
it("带上传者段:[副标题][大小][上传者]", () => {
const r = normalizeSiteFeedItem("hhanclub", "[电影]Some Movie 2024 1080p WEB-DL-HHWEB[某电影][8.5 GB][uploader01]");
expect(r).toMatchObject({
title: "Some Movie 2024 1080p WEB-DL-HHWEB",
subtitle: "某电影",
uploader: "uploader01",
});
});
it("没有大小段时不拆尾部方括号;未登记的前缀不当分类", () => {
const r = normalizeSiteFeedItem("hhanclub", "[BDMV]Some.Disc.2024[Extras]");
expect(r).toMatchObject({ title: "[BDMV]Some.Disc.2024[Extras]", subtitle: null, sizeBytes: null });
expect(r.category).toEqual({ id: null, name: null });
});
it("未知站点只去 [新]", () => {
const r = normalizeSiteFeedItem(null, "[电影]Foo 2024[新][foo][1 GB]");
expect(r.category.id).toBeNull();
expect(r.title).toBe("[电影]Foo 2024");
expect(r.subtitle).toBe("foo");
});
});