Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(metadata): javdb 插进 FC2 标题的混淆串不再落库

longmeidao1128a9026642
diff --git a/src/peach/catalog_rules.py b/src/peach/catalog_rules.py
index c4002dc06..66403dfd1 100644
--- a/src/peach/catalog_rules.py
+++ b/src/peach/catalog_rules.py
@@ -1195,6 +1195,15 @@ def solo_performer_clause(asset: str, entity: str) -> str:
#: FC2 站方替敏感词打的码:一个星号顶一个字(`10代**生` 原文是 `10代現役生`)。
MASKED_TITLE_CHARS = "**"
+#: javdb 往 FC2 标题里插的混淆串:两个星号后接一串小写字母与星号(`**pp*jonsoo`、
+#: `**zs*yj*ospn`),卖家原文里没有这一段。卖家自己打的码后面接的是日文(`都立**超`、
+#: `THE LAST**】`),不会被它带走。2026-09-24 本机 37 条带码标题里六种,都是 9~10 位。
+SCRAPE_MARK = re.compile(r"\*\*[a-z*]{8,}[  ]?")
+
+
+def strip_scrape_mark(title: str) -> str:
+ """去掉 javdb 插进标题的混淆串(`SCRAPE_MARK`)。"""
+ return SCRAPE_MARK.sub("", str(title or "")).strip()
def fill_masked_title(masked: str, originals) -> str | None:
diff --git a/src/peach/metadata_auto_apply.py b/src/peach/metadata_auto_apply.py
index e66adda6f..e53f6fd97 100644
--- a/src/peach/metadata_auto_apply.py
+++ b/src/peach/metadata_auto_apply.py
@@ -25,6 +25,7 @@ from .catalog_rules import (
normalise_code_key,
release_code_from_filename,
same_release_code,
+ strip_scrape_mark,
superseded_taste_tags,
)
from .entities import (
@@ -491,16 +492,20 @@ def _unmasked_titles(field: str, candidates: list[dict], current: str = "") -> l
FC2 官方页与镜像 fc2cmadb 把敏感词换成星号,JavArchive、javdb 给的是原文;链上
fc2 排在前面,不补的话打码那份就压过原文落进账本。账本现值也算一份原文:存量补好
之后下一轮只剩打码那一家时,补出来的还是现值,不会被星号覆盖回去。
+
+ javdb 插进去的混淆串(`strip_scrape_mark`)先剥掉再补:社区之间听 javdb,不剥的话
+ 只有 JavArchive 与 javdb 两家时,带混淆串的那份就压过 JavArchive 的原文。
"""
if field not in {"title", "original_title"}:
return candidates
- originals = [str(c.get("display_value") or "") for c in candidates] + [current]
+ shown = [str(c.get("display_value") or "") for c in candidates]
+ stripped = [strip_scrape_mark(text) for text in shown]
+ originals = stripped + [strip_scrape_mark(current)]
rows = []
- for candidate in candidates:
- filled = fill_masked_title(str(candidate.get("display_value") or ""), originals)
- rows.append(candidate if filled is None else {
- **candidate, "value": filled, "display_value": filled,
- "masked_value": str(candidate.get("display_value") or "")})
+ for candidate, text, clean in zip(candidates, shown, stripped):
+ value = fill_masked_title(clean, originals) or clean
+ rows.append(candidate if value == text else {
+ **candidate, "value": value, "display_value": value, "masked_value": text})
return rows
diff --git a/tests/test_web_review.py b/tests/test_web_review.py
index 4da4b70c0..68cf0c827 100644
--- a/tests/test_web_review.py
+++ b/tests/test_web_review.py
@@ -864,6 +864,26 @@ class ReviewQueueTests(unittest.TestCase):
"两家原文各补出一句时不猜")
self.assertIsNone(fill_masked_title(whole, [whole]))
+ def test_the_string_javdb_slips_into_a_title_does_not_land(self):
+ """社区之间听 javdb,它插的 `**pp*jonsoo` 剥掉之后才去和 JavArchive 比;卖家的码不动。"""
+ self._asset(133, "FC2-PPV-4241237", "FC2-PPV-4241237.mp4")
+ self.write_metadata_rows([
+ {"item_key": "MARK:title", "field": "title", "current": "", "code": "FC2-PPV-4241237",
+ "candidates": [{"source": "javdb", "value": "ゆあちゃんラスト作品!**pp*jonsoo カメラマンあり撮影"},
+ {"source": "javarchive", "value": "ゆあちゃんラスト作品!カメラマンあり撮影"}]},
+ ])
+ self._auto()
+ con = sqlite3.connect(self.db_path)
+ try:
+ title = con.execute("SELECT catalog_title FROM asset WHERE id=133").fetchone()[0]
+ finally:
+ con.close()
+ self.assertEqual(title, "ゆあちゃんラスト作品!カメラマンあり撮影")
+ from peach.catalog_rules import strip_scrape_mark
+ self.assertEqual(strip_scrape_mark("【取り消し確定?】**zs*yj*ospnIカップ"), "【取り消し確定?】Iカップ")
+ self.assertEqual(strip_scrape_mark("【真夏THE LAST**】特別な"), "【真夏THE LAST**】特別な")
+ self.assertEqual(strip_scrape_mark("完全顔出し都立**超スジ"), "完全顔出し都立**超スジ")
+
def test_library_collection_fills_an_empty_field_from_a_lone_community_source(self):
"""官方落空时只有 javdb 一家也补空,note 里分得清是一家还是两家一致(ADR-0034)。"""
self._asset(90, "ABW-358", "ABW-358.mp4")