Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(web): 核实来源站标与会话范围

longmeidao69396034a5e0
diff --git a/docs/REUSE.md b/docs/REUSE.md
index cc4c9ee09..27013eb2b 100644
--- a/docs/REUSE.md
+++ b/docs/REUSE.md
@@ -172,7 +172,7 @@ Windows 连接清理复用 [CPython 3.14.7 的 Proactor 对象协议](https://gi
诊断页复用同一报告、TanStack Query、BoardUI 设置组合件及覆盖式滚动条。库健康参照 javm `dd0e6b62`(MIT)的计数→清单入口,采用 Peach 的资产、封面键与处理日志。来源证据复用 `performer_profile_followup` 成功落库来源与 `scraping_access.cooldown_state`,不复用 HTTP 200 作为内容健康。无新增依赖;本机只读试验已核对现有日志与成功记录。
-系统诊断作为配置分区,复用配置页签及深链。来源会话各自复用 BoardUI `SettingsCard`,站标由共用 `SiteMark` 读取本站缓存、静态资源并提供失败回退;近期解析、历史成功和无记录分别显示。无新增依赖或 ledger 写入。
+系统诊断作为配置分区,复用配置页签及深链。来源会话各自复用 BoardUI `SettingsCard`,由共用 `SiteMark` 读取已核对的本地 favicon 并提供失败回退;近期解析、历史成功和无记录分别显示。会话列表展示资料平台与连接服务;片商页面及按片商选择站点的路由不单列。默认链之外的可选来源有实际检查或冷却记录时展示。图标来源见 `resources/site-marks/ORIGIN.md`。无新增依赖或 ledger 写入。
## 资源索引器
diff --git a/frontend/e2e/catalog-list.test.ts b/frontend/e2e/catalog-list.test.ts
index d8a0874a0..3e9d80d78 100644
--- a/frontend/e2e/catalog-list.test.ts
+++ b/frontend/e2e/catalog-list.test.ts
@@ -28,6 +28,7 @@ describe('馆藏卡片与列表', () => {
const opened = await visit(browser, '/?browse=folders&loc=local', viewport);
const { page } = opened;
try {
+ await page.locator('#grid [data-media-card]').first().waitFor({ state: 'visible' });
const folder = page.getByRole('button', { name: '文件夹模式', exact: true });
assert.equal(await folder.getAttribute('aria-pressed'), 'true');
assert.equal(await folder.evaluate(node => !!node.closest('[data-entity-sorts]')), true);
diff --git a/resources/site-marks/1pondo.png b/resources/site-marks/1pondo.png
new file mode 100644
index 000000000..938764546
Binary files /dev/null and b/resources/site-marks/1pondo.png differ
diff --git a/resources/site-marks/ORIGIN.md b/resources/site-marks/ORIGIN.md
index 2c6411a26..5dd63b63c 100644
--- a/resources/site-marks/ORIGIN.md
+++ b/resources/site-marks/ORIGIN.md
@@ -1,6 +1,6 @@
# 来源图标
-这五枚图标用于「来源和凭证」页的站点身份,归各站点所有,不用于 Peach 品牌。
+这些图标用于来源设置与诊断页的站点身份,归各站点所有,不用于 Peach 品牌。favicon 保留原色与画布,ICO 仅解码为 PNG。
| 文件 | 来源 | 获取原因 |
| --- | --- | --- |
@@ -9,5 +9,18 @@
| avwikidb.png | `https://avwikidb.com/apple-touch-icon.png` | 首页有验证页,公开图标可读取 |
| minnano-av.png | みんなのAV 的公开图标缓存:`https://www.google.com/s2/favicons?domain=minnano-av.com&sz=64`(缓存只有 32×32) | 官方 apple-touch-icon 与 favicon.ico 对 HTTP 客户端返回 Cloudflare 403 |
| github.png | `https://github.githubassets.com/favicons/favicon.svg` | 官方声明的矢量图标,经现有 `link_marks` 渲染 |
+| avsox.png | `https://avsox.click/res/fonts/favicon.2a4d5d787e44d9be7614.ico` | 页面运行后动态写入的 `shortcut icon`;首页 HTML 没有声明,根 favicon 返回 HTML |
+| manko.png | `https://manko.fun/images/favicon.ico` | 首页声明的 favicon;apple-touch-icon 指向正文宣传图 |
+| sukebei.png | `https://sukebei.nyaa.si/static/favicon.png` | 用户指定并核实的蓝色原图 |
+| dmm.png | `https://www.dmm.co.jp/age_check/images/fanza-favicon.ico` | 官方入口声明的 FANZA favicon |
+| mgstage.png | `https://static.mgstage.com/mgs/favicon.ico` | 首页声明的 favicon |
+| fc2cmadb.png | `https://fc2cmadb.com/favicon.ico` | 官方站点的 favicon |
+| javarchive.png | `https://javarchive.com/favicon.ico` | 首页声明的 favicon |
+| javdb.png | `https://javdb.com/favicon-32x32.png` | 首页声明的 favicon |
+| javbus.png | `https://www.javbus.com/favicon.ico` | 官方站点的 favicon |
+| avbase.png | `https://www.avbase.net/favicon.ico` | 首页需验证,公开 favicon 可读取 |
+| r18dev.png | 已有 `https://r18.dev/` 站标缓存 | 复用 dev 字标;官方 favicon 核对为同一标识 |
+| fc2.png | 已有 FC2 站标缓存;原图来源见 `site_icons.HOST_OVERRIDES['fc2.com']` | 复用用户确认的纯红色独角兽 |
+| 1pondo.png | 已有 `https://www.1pondo.tv/` 站标缓存 | 复用现有一本道标识 |
-取证:javten、fc2ppvdb、avwikidb、github 为 2026-09-30,minnano-av 为 2026-10-01。资源经 `/site-icon/{name}.png` 提供,前端不向图标缓存服务发送访客请求;其余站点沿用 `/site-mark` 的发现与缓存。
+取证:javten、fc2ppvdb、avwikidb、github 为 2026-09-30,minnano-av 为 2026-10-01,其余为 2026-10-19。五个既有静态入口经 `/site-icon/{name}.png` 提供;`/site-mark?source=…` 优先提供本目录中对应的已核对资源。浏览器不向外部图标服务发请求。
diff --git a/resources/site-marks/avbase.png b/resources/site-marks/avbase.png
new file mode 100644
index 000000000..8a2727340
Binary files /dev/null and b/resources/site-marks/avbase.png differ
diff --git a/resources/site-marks/avsox.png b/resources/site-marks/avsox.png
new file mode 100644
index 000000000..3df76b776
Binary files /dev/null and b/resources/site-marks/avsox.png differ
diff --git a/resources/site-marks/dmm.png b/resources/site-marks/dmm.png
new file mode 100644
index 000000000..32ebb865f
Binary files /dev/null and b/resources/site-marks/dmm.png differ
diff --git a/resources/site-marks/fc2.png b/resources/site-marks/fc2.png
new file mode 100644
index 000000000..24fb95d73
Binary files /dev/null and b/resources/site-marks/fc2.png differ
diff --git a/resources/site-marks/fc2cmadb.png b/resources/site-marks/fc2cmadb.png
new file mode 100644
index 000000000..41ffb337c
Binary files /dev/null and b/resources/site-marks/fc2cmadb.png differ
diff --git a/resources/site-marks/javarchive.png b/resources/site-marks/javarchive.png
new file mode 100644
index 000000000..06f5a021c
Binary files /dev/null and b/resources/site-marks/javarchive.png differ
diff --git a/resources/site-marks/javbus.png b/resources/site-marks/javbus.png
new file mode 100644
index 000000000..effbff4e2
Binary files /dev/null and b/resources/site-marks/javbus.png differ
diff --git a/resources/site-marks/javdb.png b/resources/site-marks/javdb.png
new file mode 100644
index 000000000..36de812bf
Binary files /dev/null and b/resources/site-marks/javdb.png differ
diff --git a/resources/site-marks/manko.png b/resources/site-marks/manko.png
new file mode 100644
index 000000000..0c1c4ac64
Binary files /dev/null and b/resources/site-marks/manko.png differ
diff --git a/resources/site-marks/mgstage.png b/resources/site-marks/mgstage.png
new file mode 100644
index 000000000..81ad8e56a
Binary files /dev/null and b/resources/site-marks/mgstage.png differ
diff --git a/resources/site-marks/r18dev.png b/resources/site-marks/r18dev.png
new file mode 100644
index 000000000..a22c895a5
Binary files /dev/null and b/resources/site-marks/r18dev.png differ
diff --git a/resources/site-marks/sukebei.png b/resources/site-marks/sukebei.png
new file mode 100644
index 000000000..afab77d9b
Binary files /dev/null and b/resources/site-marks/sukebei.png differ
diff --git a/src/peach/library_diagnostics.py b/src/peach/library_diagnostics.py
index 87d2b76a6..a886b604e 100644
--- a/src/peach/library_diagnostics.py
+++ b/src/peach/library_diagnostics.py
@@ -11,6 +11,8 @@ from datetime import datetime, timezone
from urllib.parse import urlsplit
from .catalog_rules import normalise_code_key, release_code_from_text
+from .metadata_policy import MAKER_SOURCES
+from .metadata_routes import AMANE_STAGE, ROUTES
from .scraping_access import SOURCES, cooldown_state, source_checks
LIMIT = 500
@@ -141,8 +143,8 @@ def _source_health(cooling, failed, fresh, recent, connection_ok, reason_key, *,
return "unchecked", "尚无检查或解析记录,可在来源和凭证中检查连接"
-def sources(settings, config, *, now=None):
- now = time.time() if now is None else now
+def _profile_success(settings):
+ """从女优资料的来源证据读取最近解析成功时间。"""
success = {"minnano-av": None, "javdb": None}
try:
with closing(sqlite3.connect(settings.db_path.resolve().as_uri() + "?mode=ro", uri=True, timeout=1)) as connection:
@@ -163,13 +165,22 @@ def sources(settings, config, *, now=None):
break
except (sqlite3.Error, OSError, ValueError):
pass
+ return success
+
+
+def sources(settings, config, *, now=None):
+ now = time.time() if now is None else now
+ success = _profile_success(settings)
result = []
+ optional = set(AMANE_STAGE) - {source for chain in ROUTES.values() for source in chain}
for key in dict.fromkeys([*success, *SOURCES]):
- if key == "instagram":
+ if key == "instagram" or key in MAKER_SOURCES:
continue
until, _ = cooldown_state(config.directory("secrets"), key)
cooling = now < until < now + 366 * 86400
checks = source_checks(config.directory("secrets"), key)
+ if key in optional and not cooling and not checks:
+ continue
parsed = checks.get("metadata", {})
connection = checks.get("connection", {})
candidate = timestamp(parsed.get("last_success_at"))
diff --git a/src/peach/routes_media.py b/src/peach/routes_media.py
index 24f86196a..569e89078 100644
--- a/src/peach/routes_media.py
+++ b/src/peach/routes_media.py
@@ -34,7 +34,7 @@ from . import (
jav_poster_crop, link_marks, link_status, scraping_access, site_icons, social_links, subtitles,
taste_history, timeline_sheets, web_follow,
)
-from .config import GENERATED_DIR
+from .config import GENERATED_DIR, PROJECT_ROOT
from .entities import resolve_entity_id
from .follow import FollowSourceError
from .follow_avatar import profile_avatar_tiers, profile_identities, resolve_official_avatar
@@ -1194,7 +1194,7 @@ def link_mark(request: Request, id: int = 0, args: dict[str, str] = Depends(requ
@router.api_route("/site-mark", methods=["GET", "HEAD"])
def site_mark(request: Request, source: str = "", domain: str = "",
args: dict[str, str] = Depends(require_auth)):
- """采集来源与口味排行的站点圆标。
+ """采集来源的已核对 favicon 与口味排行的站点圆标。
两个参数都不是地址,是键:`source` 查 `scraping_access.SOURCES`,`domain` 查
`taste_history.TASTE_DOMAIN_SUFFIXES`,都不在表里就是 404。和 `/link-mark`
@@ -1212,6 +1212,12 @@ def site_mark(request: Request, source: str = "", domain: str = "",
spec = scraping_access.SOURCES.get(source)
if spec is None:
return JSONResponse({"error": "no such source"}, status_code=404)
+ # 来源身份使用已核对的原图,保留站点 favicon 的颜色和画布。
+ icon = PROJECT_ROOT / "resources" / "site-marks" / f"{source}.png"
+ if icon.is_file():
+ result = FileResponse(icon, media_type="image/png")
+ result.headers["Cache-Control"] = "public, no-cache"
+ return result
target = spec["login"]
else:
host = domain.casefold().strip().removeprefix("www.").rstrip(".")
diff --git a/tests/test_fastapi_api.py b/tests/test_fastapi_api.py
index 19f256885..589fe8487 100644
--- a/tests/test_fastapi_api.py
+++ b/tests/test_fastapi_api.py
@@ -945,11 +945,11 @@ class FastApiContractTests(unittest.IsolatedAsyncioTestCase):
headers={"content-type": "image/png"})
self._swap_http_client(upstream)
- denied = await self.client.get("/site-mark?source=mgstage")
+ denied = await self.client.get("/site-mark?source=airav")
self.assertEqual(denied.status_code, 401)
- await self.client.get("/site-mark?t=secret&source=mgstage")
+ await self.client.get("/site-mark?t=secret&source=airav")
self.assertTrue(hosts, "表里的采集来源要真的去问对方站点")
- self.assertTrue(all(host.endswith("mgstage.com") for host in hosts), hosts)
+ self.assertTrue(all(host.endswith("airav.io") for host in hosts), hosts)
reached = len(hosts)
for query in ("source=evil.example", "domain=evil.example",
@@ -961,6 +961,21 @@ class FastApiContractTests(unittest.IsolatedAsyncioTestCase):
await self.client.get("/site-mark?t=secret&domain=kemono.cr")
self.assertTrue(any(host.endswith("kemono.cr") for host in hosts[reached:]), hosts)
+ async def test_source_favicons_keep_verified_pixels_without_upstream_discovery(self):
+ from peach.config import PROJECT_ROOT
+
+ reached = []
+ def upstream(request):
+ reached.append(str(request.url))
+ return httpx.Response(502, request=request)
+ self._swap_http_client(upstream)
+ for name in ('avsox', 'manko', 'sukebei', 'mgstage', 'dmm', 'fc2'):
+ response = await self.client.get(f'/site-mark?source={name}&t=secret')
+ self.assertEqual(response.status_code, 200, name)
+ self.assertEqual(response.content, (PROJECT_ROOT / 'resources/site-marks' / f'{name}.png').read_bytes())
+ self.assertEqual(response.headers['Cache-Control'], 'public, no-cache')
+ self.assertEqual(reached, [])
+
async def test_copy_editor_is_source_only_and_rejects_cross_origin_saves(self):
from unittest.mock import patch
from peach import routes_pages
diff --git a/tests/test_library_diagnostics.py b/tests/test_library_diagnostics.py
index 04e3b3ae6..e3d03223c 100644
--- a/tests/test_library_diagnostics.py
+++ b/tests/test_library_diagnostics.py
@@ -110,8 +110,11 @@ class LibraryDiagnosticsTests(unittest.TestCase):
self.assertEqual(rows['airav']['status'], 'stale')
self.assertIn('解析成功', rows['airav']['reason'])
self.assertIsNotNone(rows['airav']['last_success_at'])
- self.assertEqual(rows['fc2club']['status'], 'unchecked')
- self.assertIn('尚无', rows['fc2club']['reason'])
+ self.assertEqual(rows['avsox']['status'], 'unchecked')
+ self.assertIn('尚无', rows['avsox']['reason'])
+ self.assertNotIn('fc2club', rows)
+ self.assertFalse({'makers', 'prestige', 'faleno', 'dahlia'} & rows.keys())
+ self.assertTrue({'mgstage', 'dmm', 'fc2'} <= rows.keys())
def test_connection_and_parsing_evidence_remain_distinct_for_all_bridge_sources(self):
from peach.scraping_access import record_source_check