Peach: Local-first video metadata scraper and media manager.
feat(sources): FC2PPV-DB 女优栏交出站内女优页编号
longmeidao24c20d0aec3e
diff --git a/docs/adr/0061-fc2cmadb-cast-lists-name-the-woman-behind-a-nickname.md b/docs/adr/0061-fc2cmadb-cast-lists-name-the-woman-behind-a-nickname.mdindex 510cea206..e823d647e 100644--- a/docs/adr/0061-fc2cmadb-cast-lists-name-the-woman-behind-a-nickname.md+++ b/docs/adr/0061-fc2cmadb-cast-lists-name-the-woman-behind-a-nickname.md@@ -47,5 +47,8 @@ fc2cmadb 作品页的女优栏(Inertia 延迟 prop `actresses`)每位都带曾用名串对上的 10 位里,宣传照与封面比脸达到两张过线(`face_match.MATCH_REQUIRED`)的只有 9333 一位;9215 只有一张封面,一张过线不够;其余 8 位没有过线,或者封面上的脸打了码。它能当单人的佐证链接与头像来源,不当别名证据。-- ADR-0060 的 fc2ppv-db 女优栏链到站内女优页;解析器按第一条的形状交出 `external_id`,就能按同一口径- 接进这条后继。javten 不给演员,不涉及。+- ADR-0060 的 fc2ppv-db 按第一条的形状交出 `external_id`:女优栏每位链到 `/ja/actresses/<uuid>`,+ uuid 登记成 `fc2ppvdb` 的外部编号。javten 不给演员,不涉及。+- fc2ppv-db 的女优页不接进补别名后继(2026-09-24 实测):页面数据里有 `aliases` 一栏,但女优列表抽样+ 120 位只有 4 位填了;`川北すずね` 那一页是空的,而 fc2cmadb 上她的曾用名有十几个;主名本身也常是卖家+ 称呼(`色白スレンダー美女×JD`)。它给不出 fc2cmadb 之外的写法,每问一位还要多花一次过 Cloudflare 的请求。diff --git a/src/peach/sources/fc2ppvdb.py b/src/peach/sources/fc2ppvdb.pyindex 5c22a7cb6..7ea349955 100644--- a/src/peach/sources/fc2ppvdb.py+++ b/src/peach/sources/fc2ppvdb.py@@ -34,6 +34,8 @@ _META_TAIL = re.compile(r"販売者:\s*(?P<seller>.*?)\s*/\s*公開日:\s*(?P<da_JAPANESE_DATE = re.compile(r"(\d{4})年(\d{1,2})月(\d{1,2})日")#: 站上没有女优时那一栏写的话。_NO_INFORMATION = "情報がありません"+#: 女优页地址末尾那段 uuid。+_ACTRESS_ID = re.compile(r"/actresses/([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})/?(?:[?#]|$)")def _number(wanted: str) -> re.Pattern:@@ -68,16 +70,27 @@ def _block_after(soup: BeautifulSoup, label: str):return None-def _performers(soup: BeautifulSoup) -> list[str]:+def _performers(soup: BeautifulSoup) -> list[dict]:+ """出演女優那一块 → 每位一份 `{japanese_name, external_id?}`,同名只留一个。++ `external_id` 是站内女优页 `/ja/actresses/<uuid>` 的 uuid:同一个人在站上只有一页,落库时登记成外部+ 编号,她以后的作品按编号挂回同一条实体(ADR-0061)。女优页自己的别名栏几乎是空的,不去读它。+ """block = _block_after(soup, "出演女優")if block is None:return []- names = []+ found: dict[str, dict] = {}for link in block.select('a[href*="/actresses/"]'):picture = link.select_one("img[alt]")- name = str(picture.get("alt") or "").strip() if picture is not None else ""- names.append(name or text_of(link))- return list(dict.fromkeys(name for name in names if name and name != _NO_INFORMATION))+ name = (str(picture.get("alt") or "").strip() if picture is not None else "") or text_of(link)+ if not name or name == _NO_INFORMATION or name in found:+ continue+ person = {"japanese_name": name}+ uuid = _ACTRESS_ID.search(str(link.get("href") or ""))+ if uuid:+ person["external_id"] = uuid.group(1).lower()+ found[name] = person+ return list(found.values())def _seller(soup: BeautifulSoup) -> tuple[str, str]:@@ -149,7 +162,7 @@ class Fc2ppvdbSource(SiteSource):title=strip_code(title, wanted),release_date=japanese_date(_labelled(soup, "販売日") or (tail.group("date") if tail else "")),runtime=runtime_minutes(tail.group("runtime")) if tail else None,- performers=({"japanese_name": name} for name in _performers(soup)),+ performers=_performers(soup),label=seller or (tail.group("seller").strip() if tail else ""),seller_url=seller_page(slug) if slug else "",tags=_tags(soup))diff --git a/tests/test_metadata_fc2.py b/tests/test_metadata_fc2.pyindex aadcaaff2..3254b69a9 100644--- a/tests/test_metadata_fc2.py+++ b/tests/test_metadata_fc2.py@@ -499,6 +499,11 @@ class JavArchiveTests(unittest.TestCase):DB_COVER = "https://d39jz7pbpqkw9s.cloudfront.net/thumbnails/48/4898837.webp"+def db_actress(at: int) -> str:+ """站内女优页的编号:标准写法的 uuid,实测 `5fb206c2-f8a0-4447-8e6e-c33869f54ea3`。"""+ return f"5fb206c2-f8a0-4447-8e6e-{at:012d}"++def db_page(video="4898837", title="ふたりの巨乳美少女と3P。", seller="ぷにぷに製作所", slug="punipuni",sold="2026年5月10日", runtime="55:00", performers=("川北すずね",), leaked="流出なし",tags=("巨乳", "3P")):@@ -506,7 +511,7 @@ def db_page(video="4898837", title="ふたりの巨乳美少女と3P。", sellerPR 位与関連動画也链到女优页,放进来看解析只认出演女優那一块。"""- cast = ("".join(f'<a href="/ja/actresses/{at}-uuid"><span><img alt="{name}" src="/a.webp"></span>'+ cast = ("".join(f'<a href="/ja/actresses/{db_actress(at)}"><span><img alt="{name}" src="/a.webp"></span>'f"<span>{name}</span></a>" for at, name in enumerate(performers))if performers else "<p>情報がありません</p>")marks = "".join(f'<a href="/ja/videos?tags={tag}">{tag}</a>' for tag in tags)@@ -544,7 +549,7 @@ class Fc2ppvdbTests(unittest.TestCase):def test_the_database_page_gives_the_women_the_seller_the_date_and_the_leak_mark(self):found = database(db_page(), "FC2-PPV-4898837")self.assertEqual(found["title"], "ふたりの巨乳美少女と3P。")- self.assertEqual(found["actresses"], [{"japanese_name": "川北すずね"}])+ self.assertEqual(found["actresses"], [{"japanese_name": "川北すずね", "external_id": db_actress(0)}])self.assertEqual((found["label"], found["seller_url"]),("ぷにぷに製作所", "https://adult.contents.fc2.com/users/punipuni/"))self.assertEqual((found["release_date"], found["runtime"]), ("2026-05-10", 55.0))@@ -562,9 +567,17 @@ class Fc2ppvdbTests(unittest.TestCase):def test_only_the_cast_block_names_the_women_of_this_film(self):# PR 位与関連動画也链到女优页,那些不是这部片的人;站上没有女优时那一栏写「情報がありません」。self.assertEqual(database(db_page(performers=("A", "B")), "FC2-PPV-4898837")["actresses"],- [{"japanese_name": "A"}, {"japanese_name": "B"}])+ [{"japanese_name": "A", "external_id": db_actress(0)},+ {"japanese_name": "B", "external_id": db_actress(1)}])self.assertEqual(database(db_page(performers=()), "FC2-PPV-4898837")["actresses"], [])+ def test_each_woman_carries_her_actress_page_id_once(self):+ # 同一位在栏里列两次只留一个;链接不是站内女优页的 uuid 时只交名字,不拿半截地址当编号。+ doubled = database(db_page(performers=("A", "A")), "FC2-PPV-4898837")["actresses"]+ self.assertEqual(doubled, [{"japanese_name": "A", "external_id": db_actress(0)}])+ odd = db_page(performers=("A",)).replace(f"/ja/actresses/{db_actress(0)}", "/ja/actresses/a-page")+ self.assertEqual(database(odd, "FC2-PPV-4898837")["actresses"], [{"japanese_name": "A"}])+def test_the_sale_date_falls_back_to_the_meta_line_and_japanese_dates_read_as_iso(self):self.assertEqual(japanese_date("2026年9月21日"), "2026-09-21")self.assertEqual(japanese_date("いつか"), "")