feat(search): 按作品搜资源时中文作品名在前、原名第二
国内站点按中文名收录、副标题也多写中文名,查询词改为作品名(中文)优先、原名第二; 作品名不含中日韩文字时仍原名在前。仍最多 2 个、按归一化去重,拉丁名在电影上带年份。 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
This commit is contained in:
1 parent
6e71df2769
commit
1845d47d3f
2 files changed
+34
-16
No files matched your search
@@ -32,21 +32,32 @@ const up = await pgAvailable();
|
||||
type Loose = any;
|
||||
|
||||
describe("searchTerms", () => {
|
||||
it("电影:原名带年份 + 译名;同名只留一个;剧集不带年份", () => {
|
||||
it("中文作品名在前、原名第二;拉丁名在电影上带年份;同名只留一个;剧集不带年份", () => {
|
||||
expect(searchTerms({ title: "星际穿越", originalTitle: "Interstellar", year: 2014, movie: true })).toEqual([
|
||||
"Interstellar 2014",
|
||||
"星际穿越",
|
||||
"Interstellar 2014",
|
||||
]);
|
||||
expect(searchTerms({ title: "流浪地球2", originalTitle: "流浪地球2", year: 2023, movie: true })).toEqual([
|
||||
"流浪地球2",
|
||||
]);
|
||||
expect(searchTerms({ title: "熊家餐馆", originalTitle: "The Bear", year: 2022, movie: false })).toEqual([
|
||||
"The Bear",
|
||||
"熊家餐馆",
|
||||
"The Bear",
|
||||
]);
|
||||
expect(searchTerms({ title: "Oppenheimer", originalTitle: null, year: 2023, movie: true })).toEqual([
|
||||
"Oppenheimer 2023",
|
||||
]);
|
||||
// 日文原名:中文名在前,原名第二
|
||||
expect(
|
||||
searchTerms({ title: "药屋少女的呢喃", originalTitle: "薬屋のひとりごと", year: 2023, movie: false }),
|
||||
).toEqual(["药屋少女的呢喃", "薬屋のひとりごと"]);
|
||||
// 繁简只差字形的算同一个
|
||||
expect(searchTerms({ title: "无间道", originalTitle: "無間道", year: 2002, movie: true })).toEqual(["无间道"]);
|
||||
// 作品名没有中文译名(仍是英文)时原名在前
|
||||
expect(
|
||||
searchTerms({ title: "The Apothecary Diaries", originalTitle: "薬屋のひとりごと", year: 2023, movie: false }),
|
||||
).toEqual(["薬屋のひとりごと", "The Apothecary Diaries"]);
|
||||
expect(searchTerms({ title: " ", originalTitle: null, year: null, movie: false })).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -287,18 +298,18 @@ describe.skipIf(!up)("两阶段搜索(SEARCH-2)", () => {
|
||||
await db.deleteFrom("settings").where("key", "=", "search").execute();
|
||||
});
|
||||
|
||||
it("按作品搜资源:服务端用原名 + 年份 / 译名生成查询词,每站每词一次", async () => {
|
||||
it("按作品搜资源:服务端用中文名 / 原名 + 年份生成查询词,每站每词一次", async () => {
|
||||
const before = counts();
|
||||
const r = await req(`/search/releases?tmdb=movie:693134&sites=${sites.a}`);
|
||||
expect(r.status).toBe(200);
|
||||
expect(r.body.data.queries).toEqual(["Dune: Part Two 2024", "沙丘2"]);
|
||||
expect(r.body.data.q).toBe("Dune: Part Two 2024");
|
||||
expect(r.body.data.queries).toEqual(["沙丘2", "Dune: Part Two 2024"]);
|
||||
expect(r.body.data.q).toBe("沙丘2");
|
||||
const sent = searches(a).slice(before[0]);
|
||||
expect(sent).toHaveLength(2);
|
||||
expect(r.body.data.sites[0]).toMatchObject({ siteId: sites.a, status: "ok" });
|
||||
|
||||
const byEntity = await req(`/search/releases?entityId=${dune}&sites=${sites.a}`);
|
||||
expect(byEntity.body.data.queries).toEqual(["Dune: Part Two 2024", "沙丘2"]);
|
||||
expect(byEntity.body.data.queries).toEqual(["沙丘2", "Dune: Part Two 2024"]);
|
||||
expect(byEntity.body.data.cached).toBe(true);
|
||||
|
||||
expect((await req(`/search/releases?sites=${sites.a}`)).status).toBe(422);
|
||||
@@ -320,7 +331,7 @@ describe.skipIf(!up)("两阶段搜索(SEARCH-2)", () => {
|
||||
inventory: { state: "not_collected" },
|
||||
mediaServers: null,
|
||||
seasons: [],
|
||||
queries: ["Oppenheimer 2023", "奥本海默"],
|
||||
queries: ["奥本海默", "Oppenheimer 2023"],
|
||||
externalIds: { imdb: "tt15398776" },
|
||||
});
|
||||
|
||||
@@ -338,7 +349,7 @@ describe.skipIf(!up)("两阶段搜索(SEARCH-2)", () => {
|
||||
[2, 10, null],
|
||||
[3, 10, null],
|
||||
]);
|
||||
expect(tv.body.data.queries).toEqual(["The Bear", "熊家餐馆"]);
|
||||
expect(tv.body.data.queries).toEqual(["熊家餐馆", "The Bear"]);
|
||||
|
||||
expect((await req(`/media/tmdb/movie/999999999`)).status).toBe(404);
|
||||
expect((await req(`/media/tmdb/person/1`)).status).toBe(422);
|
||||
|
||||
Reference in new issue
Block a user