Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix: keep creator identity out of performer fallback

Peach local maintenance2608bc9585dc
diff --git a/src/peach/web_contract.py b/src/peach/web_contract.py
index 6fb45a944..0fb3f963b 100644
--- a/src/peach/web_contract.py
+++ b/src/peach/web_contract.py
@@ -478,8 +478,14 @@ def q_item(contract: WebContract, aid):
))
canonical_tags = [name for _, kind, name in canonical if kind == "tag"]
canonical_performers = [name for _, kind, name in canonical if kind == "performer"]
+ canonical_creators = {
+ normalize_entity_name(name)
+ for _, kind, name in canonical if kind == "creator"
+ }
performers = canonical_performers or [
- tag[3:] for tag in legacy if tag.startswith("演员:")
+ tag[3:] for tag in legacy
+ if tag.startswith("演员:")
+ and normalize_entity_name(tag[3:]) not in canonical_creators
]
performer_names = {normalize_entity_name(name) for name in performers}
tags = [tag for tag in (canonical_tags or [
diff --git a/tests/test_rm_web.py b/tests/test_rm_web.py
index c3eca8641..52a932fea 100644
--- a/tests/test_rm_web.py
+++ b/tests/test_rm_web.py
@@ -161,6 +161,24 @@ class WebDataTests(unittest.TestCase):
self.assertNotIn("path", result["items"][0])
self.assertNotIn("snapshot_path", result["items"][0])
+ def test_canonical_creator_beats_same_named_legacy_performer_tag(self):
+ """1065 类数据不能被旧 `演员:` 投影改成艺人。"""
+ con = sqlite3.connect(self.db_path)
+ con.execute(
+ "INSERT INTO asset_tag(asset_id,tag,source) "
+ "VALUES(2,'演员:Canonical Creator','performer')"
+ )
+ con.commit(); con.close()
+
+ item = rm_web.q_item(self.contract, 2)
+ self.assertEqual(item["creator"], "Canonical Creator")
+ self.assertEqual(item["entities"]["creator"], ["Canonical Creator"])
+ self.assertEqual(item["entity_refs"]["creator"], [
+ {"id": 12, "name": "Canonical Creator"},
+ ])
+ self.assertEqual(item["performers"], [])
+ self.assertEqual(item["entity_refs"]["performer"], [])
+
def test_reviewed_creator_tags_are_included_in_tag_coverage(self):
con = sqlite3.connect(self.db_path)
con.execute(
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index dcc26407f..3fbca1114 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -69,6 +69,14 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageLacks("const performerName=performerRef?.name")
self.assertPageLacks(".identityrow", "旧的逐行布局必须整段删掉")
+ def test_detail_only_links_canonical_entities(self):
+ """旧标签可以作为显示回退,但不得伪造一个不存在的资料页。"""
+ self.assertPageContains("if(!item.id)return `<span class=\"idcell")
+ self.assertPageContains("const creatorList=(refs.creator||[])")
+ self.assertPageContains("const seriesList=(refs.series||[])")
+ self.assertPageContains(".idcell:not(.entitylink){cursor:default}")
+ self.assertPageContains(".idcell.entitylink:hover .idface")
+
def test_performer_label_says_actress_only_for_jav(self):
"""「女优」是番号发行物的行业称谓。
diff --git a/web/app.css b/web/app.css
index a0489a6c8..97a3af18c 100644
--- a/web/app.css
+++ b/web/app.css
@@ -284,8 +284,9 @@ button,input,textarea{font:inherit;color:inherit}
.idface svg{width:18px;height:18px;stroke:currentColor;fill:none;stroke-width:2}
.idname{font-size:12px;line-height:1.25;text-align:center;width:100%;
overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--ink-2)}
-.idcell:hover .idface{box-shadow:0 0 0 2px var(--tungsten)}
-.idcell:hover .idname{color:var(--ink)}
+.idcell:not(.entitylink){cursor:default}
+.idcell.entitylink:hover .idface{box-shadow:0 0 0 2px var(--tungsten)}
+.idcell.entitylink:hover .idname{color:var(--ink)}
.castmore{align-self:center;height:46px;padding:0 12px;border:1px dashed var(--overlay-10);
border-radius:12px;background:transparent;color:var(--tungsten);font-size:12px;cursor:pointer}
.castmore:hover{background:var(--hover)}
diff --git a/web/app.js b/web/app.js
index 3dcc5e39b..5ec7d8922 100644
--- a/web/app.js
+++ b/web/app.js
@@ -1543,16 +1543,16 @@ async function openItem(id,push=true,mixContext=null){
const performerRefs=(refs.performer||[]).length
? refs.performer
: (it.performers||[]).map(name=>({id:null,name}));
- const studioName=studioRef?.name||it.studio||'';
// 身份按类别分组:标签作为组标题写在上方,同类横向排开。
// 逐行一个名字在共演作品上会把整个侧栏撑满,标签列也重复得毫无信息量。
const identitySeen=new Set();
const fresh=name=>{const key=foldName(name);
if(!name||identitySeen.has(key))return false;identitySeen.add(key);return true};
const castList=performerRefs.filter(ref=>fresh(ref.name));
- const studioList=(studioName&&fresh(studioName))?[{name:studioName}]:[];
- const creatorList=((it.entities&&it.entities.creator)||[]).filter(fresh).map(name=>({name}));
- const seriesList=((it.entities&&it.entities.series)||[]).filter(fresh).map(name=>({name}));
+ const studioFallback=studioRef?[]:(it.studio?[{id:null,name:it.studio}]:[]);
+ const studioList=[...(refs.studio||[]),...studioFallback].filter(ref=>fresh(ref.name));
+ const creatorList=(refs.creator||[]).filter(ref=>fresh(ref.name));
+ const seriesList=(refs.series||[]).filter(ref=>fresh(ref.name));
// BEST 合集实测有 41 位出镜者,全铺开会把标签和反馈按钮挤出可视区。
// 前 8 位直接展示,其余默认收起但仍在 DOM 里,一次点击即可看全。
@@ -1565,9 +1565,10 @@ async function openItem(id,push=true,mixContext=null){
: kind==='series'?icon('tags'):`<span>${esc(item.name.slice(0,1))}</span>`;
const idCell=(kind,item,index)=>{
const hide=kind==='performer'&&index>=CAST_SHOWN;
+ const content=`<span class="idface">${idFace(kind,item)}</span><span class="idname">${esc(item.name)}</span>`;
+ if(!item.id)return `<span class="idcell${kind==='studio'?' logo':''}" title="${esc(item.name)}"${hide?' hidden data-castoverflow':''}>${content}</span>`;
return `<button class="idcell entitylink${kind==='studio'?' logo':''}" data-entity-kind="${kind}"
- data-entity-name="${esc(item.name)}" title="${esc(item.name)}"${hide?' hidden data-castoverflow':''}>
- <span class="idface">${idFace(kind,item)}</span><span class="idname">${esc(item.name)}</span></button>`;
+ data-entity-name="${esc(item.name)}" title="${esc(item.name)}"${hide?' hidden data-castoverflow':''}>${content}</button>`;
};
const idGroup=(label,kind,list,extra='')=>list.length
? `<section class="idgroup"><h5 class="idlabel">${label}</h5>