Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 按作品语境选择资料页等待态

longmeidao0e730fd1f8be
diff --git a/frontend/e2e/loading-fidelity.test.ts b/frontend/e2e/loading-fidelity.test.ts
index 9b10d79a6..d83980769 100644
--- a/frontend/e2e/loading-fidelity.test.ts
+++ b/frontend/e2e/loading-fidelity.test.ts
@@ -51,7 +51,7 @@ describe('页面等待态的结构', () => {
} finally { release(); await context.close() }
});
- it(`${viewport.name} 数字艺人地址带相关艺人占位与静态筛选`, { timeout: 60_000 }, async () => {
+ for (const jav of [false, true]) it(`${viewport.name} ${jav ? 'JAV' : '普通'}艺人等待态遵循作品语境`, { timeout: 60_000 }, async () => {
const context = await browser.newContext({ viewport });
let release = () => {};
const held = new Promise<void>(resolve => { release = resolve });
@@ -62,7 +62,7 @@ describe('页面等待态的结构', () => {
await route.fulfill({ response });
});
await page.route('**/api/entity/shapes', route => route.fulfill({ json: { ok: true, entities: [
- { id: 90001, kind: 'performer', names: ['演示艺人'], parts: ['costars', 'facts'] },
+ { id: 90001, kind: 'performer', names: ['演示艺人'], parts: ['costars', 'facts', ...(jav ? ['jav'] : [])] },
] } }));
await page.route(/\/api\/entity\?/, async route => { await held; await route.fulfill({ json: { error: '未取得' } }) });
await page.goto(requiredEnv('PEACH_E2E_ORIGIN') + '/performers/90001', { waitUntil: 'load' });
@@ -72,6 +72,10 @@ describe('页面等待态的结构', () => {
assert.ok(await root.locator('[data-entity-facts]').count(), '数字地址漏了资料表');
assert.ok(await root.locator('[data-entity-state]').count(), '观看状态被画成了占位');
assert.ok(await root.locator('[data-entity-sort]').count(), '排序控件被画成了占位');
+ assert.equal(await root.locator('[data-entity-layout]').count() > 0, jav, '卡片版式开关误用了艺人类型');
+ const ratio = await root.locator('[style*="--skeleton-card-ratio"]').first().evaluate(node =>
+ Number((node as HTMLElement).style.getPropertyValue('--skeleton-card-ratio')));
+ assert.equal(ratio, jav ? .75 : 16 / 9, '等待态封面比例与作品语境不一致');
} finally { release(); await context.close() }
});
}
diff --git a/frontend/src/application/entity.js b/frontend/src/application/entity.js
index 05f2cb0f3..3f8eb8e80 100644
--- a/frontend/src/application/entity.js
+++ b/frontend/src/application/entity.js
@@ -152,7 +152,7 @@ export async function entityAliasForm(mine,write){
}
export function showEntityLoading(kind,name){
- const jav=['performer','studio','series'].includes(kind);
+ const jav=['performer','studio'].includes(kind)&&feedState.hasEntityPart(kind,name,'jav');
const head=`<div data-filter-row="bottom" class="flex min-w-0 items-center gap-3 px-3 py-2 min-h-12"><h3 data-entity-readout><span data-skeleton="count" class="relative inline-block h-3.5 w-24 rounded-md align-middle skeleton-sheen"></span></h3>${islandShortcutsEntry()}${kind==='agency'?'':filterControlsSkeletonHtml(sortKeys(state.sort,state.dir,jav),jav?{name:'jav-layout',label:'JAV 卡片版式',value:javLayout(),options:JAV_LAYOUTS}:null)}</div>`;
const top=kind==='agency'?'':`<div data-entity-media><button type="button" data-media-view="videos" aria-label="视频" aria-pressed="true" disabled data-skeleton-action>${icon('play')}</button><button type="button" data-media-view="photos" aria-label="照片" disabled data-skeleton-action>${icon('pics')}</button></div><span data-entity-sep></span><div data-entity-scroll><div data-entity-states>${catalogState.catalogViews().map(view=>`<button type="button" data-entity-state="${esc(view.k)}" aria-pressed="${state.state===view.k}" disabled data-skeleton-action>${esc(view.label)}</button>`).join('')}</div>`;
const body=kind==='agency'
diff --git a/src/peach/web_entity.py b/src/peach/web_entity.py
index e922f5206..81d202c06 100644
--- a/src/peach/web_entity.py
+++ b/src/peach/web_entity.py
@@ -21,6 +21,7 @@ from .entities import normalize_entity_name, resolve_entity, resolve_entity_id,
from .social_links import ARCHIVE_HOSTS, is_archive
from .web_catalog import (
COST,
+ JAV_ASSET_PREDICATE,
VISIBLE_CATALOG_ASSET,
attach_avatar_availability,
seeded_order,
@@ -391,7 +392,7 @@ def agency_mark_link(links: list[dict]) -> int | None:
def q_entity_shapes(contract, args) -> dict:
"""资料页上可有可无的那几块,哪些实体有:新作那一行(`feed`)、卡底的同台艺人(`costars`)、
- 页头右侧那张资料表(`facts`,ADR-0069)。
+ 页头右侧那张资料表(`facts`,ADR-0069),以及作品的 JAV 版式(`jav`)。
骨架在资料到达之前就要照最终形状画:不留位,那一块画出来时从中间顶进来;每页都
留,没有的那一页又得在画出来时收掉。两块各有一半上下的页面有,猜哪一边都有一半在
@@ -410,6 +411,11 @@ def q_entity_shapes(contract, args) -> dict:
parts.setdefault(int(row[0]), []).append("costars")
for entity_id in performer_header.profiled(connection):
parts.setdefault(entity_id, []).append("facts")
+ for row in connection.execute(
+ "SELECT DISTINCT scope.entity_id FROM asset_entity scope"
+ " JOIN entity e ON e.id=scope.entity_id AND e.kind IN ('performer','studio')"
+ " JOIN asset a ON a.id=scope.asset_id WHERE " + COUNTED_VIDEO + " AND " + JAV_ASSET_PREDICATE):
+ parts.setdefault(int(row[0]), []).append("jav")
entities = {int(row["id"]): {"id": int(row["id"]), "kind": row["kind"],
"names": [row["canonical_name"]], "parts": parts[int(row["id"])]}
for row in connection.execute("SELECT id, kind, canonical_name FROM entity ORDER BY id")
diff --git a/tests/test_feeds_web.py b/tests/test_feeds_web.py
index f0d4a805d..e67f2da68 100644
--- a/tests/test_feeds_web.py
+++ b/tests/test_feeds_web.py
@@ -187,6 +187,30 @@ class FeedWebTest(FeedWebFixture):
dispatch_api_post(self.contract, "/api/settings", {"feedHideGroupCompilations": False})
self.assertTrue(shape())
+ def test_entity_shapes_use_the_real_jav_work_predicate(self):
+ people = []
+ with self.contract.database.write_transaction() as connection:
+ for index, region in enumerate(("jp", "kr")):
+ name = f"演示艺人{index}"
+ entity_id = connection.execute(
+ "INSERT INTO entity(kind,canonical_name,normalized_name,created_at,updated_at)"
+ " VALUES('performer',?,peach_normalize(?),?,?)",
+ (name, name, feeds.stamp(), feeds.stamp())).lastrowid
+ asset_id = connection.execute(
+ "INSERT INTO asset(location,path,name,medium,code,region,studio)"
+ " VALUES('local',?,?,'video','SSIS-950',?,'S1')",
+ (f"R:\\media\\shape{index}.mp4", f"shape{index}.mp4", region)).lastrowid
+ connection.execute(
+ "INSERT INTO asset_entity(asset_id,entity_id,role,source)"
+ " VALUES(?,?,'performer','test')", (asset_id, entity_id))
+ people.append((entity_id, name, region == "jp"))
+ shapes = {item["id"]: item["parts"] for item in dispatch_api_get(
+ self.contract, "/api/entity/shapes", {})["entities"]}
+ for entity_id, name, jav in people:
+ items = dispatch_api_get(self.contract, "/api/items", {"performer": name})["items"]
+ self.assertEqual(items[0]["is_jav"], jav)
+ self.assertEqual("jav" in shapes.get(entity_id, []), jav)
+
def test_settings_snapshot_lists_the_source(self):
self._add()
snapshot = dispatch_api_get(self.contract, "/api/feeds", {})
diff --git a/tests/test_rm_web.py b/tests/test_rm_web.py
index 7baa133af..05519333a 100644
--- a/tests/test_rm_web.py
+++ b/tests/test_rm_web.py
@@ -1770,8 +1770,8 @@ class WebDataTests(unittest.TestCase):
# 骨架照这份名单给卡底留出同台艺人那一条,名单与资料页用同一条判据。
shapes = {entry["id"]: entry for entry in web_entity.q_entity_shapes(self.contract, {})["entities"]}
self.assertEqual(shapes[11], {"id": 11, "kind": "performer",
- "names": ["Canonical Alice", "Alice"], "parts": ["costars"]})
- self.assertEqual(shapes[15]["parts"], ["costars"])
+ "names": ["Canonical Alice", "Alice"], "parts": ["costars", "jav"]})
+ self.assertEqual(shapes[15]["parts"], ["costars", "jav"])
self.assertTrue(page["links"][0]["clickable"])
self.assertFalse(page["links"][1]["clickable"])
self.assertIsNone(page["links"][1]["url"])
diff --git a/web/dist/peach-app.js b/web/dist/peach-app.js
index 6920c7296..537d67bf6 100644
--- a/web/dist/peach-app.js
+++ b/web/dist/peach-app.js
@@ -101169,11 +101169,7 @@ async function $st(e, t) {
} }) : Y5.actionReceipt(`${a?.alias} 已经是这条实体的名字`));
}
function ect(e, t) {
- let n = [
- "performer",
- "studio",
- "series"
- ].includes(e), r = `<div data-filter-row="bottom" class="flex min-w-0 items-center gap-3 px-3 py-2 min-h-12"><h3 data-entity-readout><span data-skeleton="count" class="relative inline-block h-3.5 w-24 rounded-md align-middle skeleton-sheen"></span></h3>${ro()}${e === "agency" ? "" : Wst(l7(W.sort, W.dir, n), n ? {
+ let n = ["performer", "studio"].includes(e) && t7.hasEntityPart(e, t, "jav"), r = `<div data-filter-row="bottom" class="flex min-w-0 items-center gap-3 px-3 py-2 min-h-12"><h3 data-entity-readout><span data-skeleton="count" class="relative inline-block h-3.5 w-24 rounded-md align-middle skeleton-sheen"></span></h3>${ro()}${e === "agency" ? "" : Wst(l7(W.sort, W.dir, n), n ? {
name: "jav-layout",
label: "JAV 卡片版式",
value: aE(),