Skip to content

armgit / peach

Public Imported from GitHub
0

Peach: Local-first video metadata scraper and media manager.

fix(web): 事务所页上指回自家站的链接写「官方网站」,不再把页头的公司名重复一遍

longmeidaof76472468cd6
diff --git a/tests/test_web_js.py b/tests/test_web_js.py
index 4127f358f..2c7fb5c24 100644
--- a/tests/test_web_js.py
+++ b/tests/test_web_js.py
@@ -360,8 +360,8 @@ class WebJsBehaviourTests(unittest.TestCase):
("core.js", "siteName", ["不是网址"], ""),
])
- def test_a_studio_page_calls_its_own_site_the_official_site(self):
- """厂牌页上指回自家站的链接写「官方网站」,指向别家的保留那家的名字;事务所页与人物页照旧写名字。"""
+ def test_a_company_page_calls_its_own_site_the_official_site(self):
+ """厂牌页与事务所页上指回自家站的链接写「官方网站」,指向别家的保留那家的名字;人物页照旧写名字。"""
light = {"url": "https://lightpro.jp/", "label": "LIGHT"}
nax = {"url": "https://official.nax-pro.com/", "label": "New Actor eXperience"}
self.assertJsResults([
@@ -388,8 +388,13 @@ class WebJsBehaviourTests(unittest.TestCase):
("core.js", "officialLinkText",
[{"url": "https://www.prestige-av.com/goods/", "label": "Prestige"}, "studio",
["Jackson"]], "Prestige"),
- ("core.js", "officialLinkText", [light, "agency", ["LIGHT", "RIGHT"]], "LIGHT"),
- ("core.js", "officialLinkText", [nax, "agency", ["New Actor eXperience"]], "NAX"),
+ ("core.js", "officialLinkText", [light, "agency", ["LIGHT", "RIGHT"]], "官方网站"),
+ ("core.js", "officialLinkText", [nax, "agency", ["New Actor eXperience"]], "官方网站"),
+ ("core.js", "officialLinkText",
+ [{"url": "https://old-crew.blog.jp/", "label": "官方博客"}, "agency",
+ ["Office Old Crew"]], "官方博客"),
+ # 事务所页上链到别家(拆分出来的 EST 链着 LIGHT 的旧站)保留那家的名字。
+ ("core.js", "officialLinkText", [light, "agency", ["EST", "エスト"]], "LIGHT"),
("core.js", "officialLinkText", [light, "performer", ["松本一香"]], "LIGHT"),
# 存档快照照写 label,厂牌页上也不改写成「官方网站」。
("core.js", "officialLinkText",
diff --git a/web/js/core.js b/web/js/core.js
index 313a9347c..9b8d0ce75 100644
--- a/web/js/core.js
+++ b/web/js/core.js
@@ -129,8 +129,8 @@ const brandIcon=url=>{
const foldName=s=>String(s??'').normalize('NFKC').trim().toLocaleLowerCase();
/* 官网链接上那行字。写站点短名(`siteName`),表里没有就用账本 label。
- 只有厂牌页上指回自家站的写「官方网站」:页头已经是厂牌名,链接再写一遍 S1、
- KMP 只是重复。事务所页和人物页照旧写名字,那里的名字就是要看的信息。名字是
+ 厂牌页和事务所页上指回自家站的写「官方网站」:页头已经是公司名,链接再写一遍 S1、
+ LIGHT 只是重复。人物页照旧写名字,那里的名字说的是她归哪一家,正是要看的信息。名字是
别家的(Jackson 页上链到 Prestige 的名录页)也保留,那说的是另一家。自家的判据是
短名或 label 与规范名、别名互相包含:`C-more` 之于 `C-more Entertainment`,短名是缩写
时看 label(`NAX` 那条的 label 是 `New Actor eXperience`)。label 只是这条链接自己的
@@ -142,7 +142,7 @@ const ARCHIVE_HOSTS=['web.archive.org'];
const isArchiveLink=url=>ARCHIVE_HOSTS.includes(linkHost(url));
const officialLinkText=(link,kind,names=[])=>{
const text=siteName(link.url)||link.label||'';
- if(kind!=='studio'||isArchiveLink(link.url))return text;
+ if((kind!=='studio'&&kind!=='agency')||isArchiveLink(link.url))return text;
const said=[text,link.label].map(foldName).filter(Boolean);
const own=!said.length||said.includes('官方网站')||said.some(shown=>
bareHost(shown)===linkHost(link.url)||names.some(name=>{