Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 复核页同番号资产数按账本现算,不信候选件的 videos 列

longmeidao38a3040b0e2e
diff --git a/src/peach/metadata_auto_apply.py b/src/peach/metadata_auto_apply.py
index cbdf36fa6..c764bb0a5 100644
--- a/src/peach/metadata_auto_apply.py
+++ b/src/peach/metadata_auto_apply.py
@@ -121,6 +121,9 @@ def refresh_current_values(connection, rows: list[dict]) -> None:
演员 22、标题 13、厂牌 8、系列 8、发行日期 5)。队列拿它判「补空还是冲突」,自动
落库拿它判「这里是不是空的」——过期一份,两处一起错,而且错的方向是往库里写。
+ 资产数 `videos` 同理按账本现算:候选件那一列是生成器顺手填的,fc2-cast 那一份
+ 根本没填,复核页就把账本里有资产的番号写成「0 个同番号资产」。
+
账本里找不到这个番号的资产时保留候选件那一份:那种行本来就轮不到按现值判。
"""
codes = [code for code in dict.fromkeys(
@@ -157,6 +160,7 @@ def refresh_current_values(connection, rows: list[dict]) -> None:
targets = by_code.get(key, [])
if not targets:
continue
+ row["videos"] = str(len(targets))
column = METADATA_FIELD_COLUMNS.get(field)
if column:
# 同番号多卷时任取有值的那一卷:落库本来就是整组一起写。
diff --git a/tests/test_web_review.py b/tests/test_web_review.py
index cd641d491..e1defa65b 100644
--- a/tests/test_web_review.py
+++ b/tests/test_web_review.py
@@ -699,6 +699,22 @@ class ReviewQueueTests(unittest.TestCase):
con.close()
self.assertEqual(landed, ["はな"])
+ def test_the_asset_count_in_the_reason_comes_from_the_ledger(self):
+ """候选件的 `videos` 列可能是空的:fc2-cast 生成器就没填。卡片上的资产数按账本现算。"""
+ self._asset(86080, "FC2-PPV-1449453", "FC2-PPV-1449453-CD1.mp4")
+ self._asset(86081, "FC2-PPV-1449453", "FC2-PPV-1449453-CD2.mp4")
+ key = "FC2-PPV-1449453:performers:fc2cmadb"
+ self.write_metadata_candidates([{
+ "item_key": key, "code": "FC2-PPV-1449453", "query": "FC2-PPV-1449453",
+ "field": "performers", "field_label": "演员", "current_value": "",
+ "candidates_json": json.dumps([{
+ "candidate_key": f"{key}:0", "source": "fc2cmadb", "display_value": "Chisa",
+ "value": [{"name": "Chisa"}], "confidence": 0.9,
+ "provider_id": "FC2-PPV-1449453"}], ensure_ascii=False),
+ "source_count": "1", "source_profile": "fc2-cast", "status": "candidate",
+ "size_gb": "", "videos": "", "fetched_at": ""}])
+ self.assertIn("2 个同番号资产", self.queue_row("metadata_fields", key)["reason"])
+
def test_javbus_gives_way_to_any_other_source_on_the_same_field(self):
"""javbus 的取值只在没有别家时才算证据(ADR-0035)。