Peach: Local-first video metadata scraper and media manager.
fix(feed): 补齐在线封面本地处理与整幅画面取景
longmeidao38e98a06b8b1
diff --git a/docs/REUSE.md b/docs/REUSE.mdindex 4d498b242..e16dc1502 100644--- a/docs/REUSE.md+++ b/docs/REUSE.md@@ -186,7 +186,9 @@ JAV 默认封面(官方封面/预览图)与视频默认大小(大图/详情人物头像复用 `card-art.entityFaceImg` 与 `avatarFrame`,图片直接挂在有尺寸的 `[data-id-face]` 圆框内。取景读取图片的父框几何,`display:contents` 包装层没有可用尺寸。首字与图片由同一段 HTML 承载,图片加载失败时共用回退链,浏览器回归覆盖带人脸框的桌面与手机详情。-新作列表与 JAV 推荐的来源封面复用详情的 `q_jav_image`、持久字节缓存、番号校验与失败冷却,经 `/jav-cover` 提供同源图片;有封面地址时使用已有地址,没有时按已知作品身份取图。Blu-ray 版次标记与图片比例共同决定宽封套取景,复用 `jav_poster_crop` 的 0.85 正封比例,正封完整放入卡片;FC2 与普通横版剧照保持整幅画面取景。无新增依赖或真实 ledger 写入。+新作封面优先复用 `best_cover` 的官方候选,未取得时复用 `javdb_public` 的作品身份校验与 `RemoteMediaCache` 的持久字节缓存、失败冷却;来源图片沿用 ADR-0030、0032 的 240px 小图下限,按实际尺寸保存,证据区分小图,再经 `cover_artwork.install_cover` 安装本地封面、正封框、人脸坐标与来源证据。原图缓存与详情预览分键,JPEG 解包后保留原字节、原尺寸;其他格式按原尺寸转为 JPEG。缺图时 `/jav-cover` 提供同源显示回退。++取景由 `poster-crop-v11` 管理。Blu-ray 来源标题与图片比例共同决定 0.85 正封比例,标题随正封框保留,重算人脸与正封框均读取同一版次;有效宽正封框在没有版次标题的卡片上也完整显示。VR 标记与 IENEE、IENFE、SDHS 数字发行拼图保留整幅画面,由 `cover_frame.layout=still` 传给卡片,人脸检测包含左侧主图;FC2 与普通横版画面保持人脸取景。手工框保持用户取景。重试队列按最早尝试时间轮转,收起的合集沿用设置跳过;逐番号结果保存在 `feed-cover-attempts/`。复用现有 HTTP、Pillow、OpenCV 与文件锁,无新增依赖。## 复用决策门槛diff --git a/frontend/e2e/wide-cover.test.ts b/frontend/e2e/wide-cover.test.tsindex 206e1cefd..1da5062b6 100644--- a/frontend/e2e/wide-cover.test.ts+++ b/frontend/e2e/wide-cover.test.ts@@ -17,13 +17,19 @@ describe('宽封套与来源封面', () => {const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="800" height="438"><rect width="428" height="438" fill="#777"/><rect x="428" width="372" height="438" fill="#ccc"/></svg>';await page.route(remote, route => route.fulfill({ contentType: 'image/svg+xml', body: svg }));await page.route('**/jav-cover?code=MIDA-085', route => route.fulfill({ contentType: 'image/svg+xml', body: svg }));+ await page.route('**/cover?code=EXM-006*', route => route.fulfill({ contentType: 'image/svg+xml', body: svg }));+ await page.route('**/cover?code=MDVR-276*', route => route.fulfill({ contentType: 'image/svg+xml',+ body: '<svg xmlns="http://www.w3.org/2000/svg" width="800" height="600"><rect width="800" height="600" fill="#ccc"/></svg>' }));await page.route('**/api/feeds/discoveries?*', route => route.fulfill({ json: { ok: true, items: [...['MIDA-122', 'MIDA-239', 'MIDA-198'].map((code, id) => ({ id: id + 1, code, title: '作品(ブルーレイディスク)', cover_url: remote })),{ id: 4, code: 'EXM-004', title: '横版剧照', cover_url: remote },{ id: 5, code: 'MIDA-085', title: '作品(ブルーレイディスク)', cover_url: '/jav-cover?code=MIDA-085' },+ { id: 6, code: 'EXM-006', title: '作品', has_cover: true,+ poster_box: { x0: 428, y0: 0, x1: 800, y1: 438, px: [800, 438] } },+ { id: 7, code: 'MDVR-276', title: '【VR】作品', has_cover: true, cover_frame: { cx: .22, cy: .2, layout: 'still' } },] } }));await page.goto(requiredEnv('PEACH_E2E_ORIGIN') + '/');- for (const id of [1, 2, 3, 5]) {+ for (const id of [1, 2, 3, 5, 6]) {const image = page.locator(`#feedNew [data-feed-id="${id}"] img.cover`);await image.scrollIntoViewIfNeeded();await image.evaluate((img: HTMLImageElement) => img.decode());@@ -35,7 +41,7 @@ describe('宽封套与来源封面', () => {y0: rect.y + rect.height * top / 100, y1: rect.bottom - rect.height * bottom / 100,pic: { x: pic.x, right: pic.right, y: pic.y, bottom: pic.bottom }, fit: css.objectFit };});- assert.equal(frame.kind, 'sleeve');+ assert.equal(frame.kind, id === 6 ? 'still' : 'sleeve');assert.equal(frame.panel, true);assert.ok(frame.x0 >= frame.pic.x - 1 && frame.x1 <= frame.pic.right + 1, JSON.stringify(frame));assert.ok(frame.y0 >= frame.pic.y - 1 && frame.y1 <= frame.pic.bottom + 1, JSON.stringify(frame));@@ -45,6 +51,12 @@ describe('宽封套与来源封面', () => {await still.evaluate((img: HTMLImageElement) => img.decode());assert.equal(await still.getAttribute('data-frame'), 'still');assert.equal(await still.evaluate(img => img.classList.contains('panel')), false);+ const vr = page.locator('#feedNew [data-feed-id="7"] img.cover');+ await vr.scrollIntoViewIfNeeded();+ await vr.evaluate((img: HTMLImageElement) => img.decode());+ assert.equal(await vr.getAttribute('data-frame'), 'still');+ assert.equal(await vr.evaluate(img => img.classList.contains('panel')), false);+ assert.equal(await vr.evaluate(img => img.style.getPropertyValue('--cover-x')), '0%');} finally { await context.close() }});}diff --git a/frontend/src/card-art/framing.ts b/frontend/src/card-art/framing.tsindex f52468551..28196e2c2 100644--- a/frontend/src/card-art/framing.ts+++ b/frontend/src/card-art/framing.ts@@ -77,7 +77,7 @@ export function coverAnchor(img: HTMLImageElement): void {if (!r) return;const code = img.dataset.coverCode || new URL(img.currentSrc || img.src, location.href).searchParams.get('code') || '';// FC2 封面是整幅画面,横向取景跟随人脸;宽高比不代表有 DVD 正封。- img.dataset.frame = /^FC2(?:-PPV)?-/i.test(code) ? 'still' : wideSleeve(img) ? 'sleeve' : r >= 1.65 ? 'still' : r > 1.2 ? 'sleeve' : 'front';+ img.dataset.frame = img.dataset.coverLayout === 'still' || /^FC2(?:-PPV)?-/i.test(code) ? 'still' : wideSleeve(img) ? 'sleeve' : r >= 1.65 ? 'still' : r > 1.2 ? 'sleeve' : 'front';/* `object-position` 的百分比说的是「图片上这个点对齐可见窗口的同一个百分比位置」,不是「这个点落到窗口正中」。所以人脸中心原样当锚点只能保证脸还在画面里:0.81那种偏右的脸会贴着窗口右缘,图片右边还剩一截永远露不出来。可见窗口占图片 w 时,@@ -104,7 +104,7 @@ export function coverAnchor(img: HTMLImageElement): void {的 16:9 拼图才有正封可切;没有框(本机 1516 张封面里 771 张判定为不裁,永远拿不到)就一个字都不写,CSS 里那份贴右缘或按人脸的回退照旧生效。 */export function posterPanel(img: HTMLImageElement, ratio: number): void {- if (img.dataset.frame === 'front') return;+ if (img.dataset.frame === 'front' || img.dataset.coverLayout === 'still') return;let [x0 = NaN, imgW = NaN, imgH = NaN, y0 = NaN, x1 = NaN, y1 = NaN] = String(img.dataset.posterbox || '').split(' ').map(Number);/* 没有框的双页封套按先验从右缘量回去,与服务端折痕找不到时的比例框一致。 */if (!img.dataset.posterbox && img.dataset.frame === 'sleeve') {@@ -116,7 +116,11 @@ export function posterPanel(img: HTMLImageElement, ratio: number): void {这么取景」看不出区别,所以宁可退回回退值。 */// 卡片先取的是等比缩小的派生档,框的百分比在等比缩放下不变,所以认缩小,不认别的图。if (!faceSourceScale(img.naturalWidth, img.naturalHeight, imgW, imgH)) return;- const frame = panelFrame({ x0, y0, x1, y1, px: [imgW, imgH] }, ratio, wideSleeve(img));+ const panelAspect = (x1 - x0) / (y1 - y0);+ const sourceAspect = imgW / imgH;+ const widePanel = sourceAspect >= WIDE_SLEEVE_RATIO_MIN && sourceAspect < WIDE_SLEEVE_RATIO_MAX+ && Math.abs(panelAspect - WIDE_PANEL_ASPECT) <= .02;+ const frame = panelFrame({ x0, y0, x1, y1, px: [imgW, imgH] }, ratio, wideSleeve(img) || widePanel);if (!frame) return;img.style.setProperty('--panel-aspect', `${img.naturalWidth} / ${img.naturalHeight}`);img.classList.add('panel');diff --git a/frontend/src/card-art/markup.ts b/frontend/src/card-art/markup.tsindex 79b8fd65b..fb94dfb20 100644--- a/frontend/src/card-art/markup.ts+++ b/frontend/src/card-art/markup.ts@@ -204,8 +204,8 @@ export interface CoverItem {cover_version?: string;has_thumb?: boolean;has_local_poster?: boolean;- cover_frame?: { cx?: number | null; cy?: number | null } | null;- poster_box?: { x0?: number; y0?: number; x1?: number; y1?: number; px?: number[] } | null;+ cover_frame?: { cx?: number | null; cy?: number | null; layout?: string } | null;+ poster_box?: { x0?: number; y0?: number; x1?: number; y1?: number; px?: number[]; method?: string } | null;[field: string]: unknown;}@@ -216,16 +216,19 @@ export function coverImage(item: CoverItem, layout: 'big' | 'small', eager = falconst src = coverUrl(item, true);const wide = /ブルーレイ|blu[\s-]?ray/i.test(String(item.title || item.display_title || item.name || ''));const f = item.cover_frame || {};- // 纵向夹在 5%–60%:脸不会长在图片下半截,落在那儿是检出跑偏而不是构图。+ const still = item.poster_box?.method !== 'manual' && (f.layout === 'still'+ || /^(IENEE|IENFE|SDHS)-/i.test(String(item.code || ''))+ || /(?:【|\[|\(|()\s*(?:[48]K\s*)?VR\s*(?:】|\]|\)|))/i.test(String(item.title || item.display_title || item.name || '')));+ const faceY = f.cy == null ? null : still ? Math.min(1, Math.max(0, f.cy)) : Math.min(0.6, Math.max(0.05, f.cy));const face = [f.cx != null ? ` data-cx="${f.cx}"` : '',- f.cy != null ? ` data-cy="${Math.min(0.6, Math.max(0.05, f.cy))}"` : ''].join('');+ faceY != null ? ` data-cy="${faceY}"` : ''].join('');/* 正封那一块的取景框,源图像素坐标加源图尺寸,由 `posterPanel` 在加载后换算成百分比。`map(Number)` 既是校验也是转义:进到属性里的一定是数字。 */const pb = item.poster_box;const box = pb ? ` data-posterbox="${[pb.x0, (pb.px || [])[0], (pb.px || [])[1], pb.y0, pb.x1, pb.y1].map(Number).join(' ')}"` : '';// 小图看整张(含剧照拼贴),大图只取右侧正封。return `<img class="poster cover ${layout === 'small' ? 'whole' : 'front'}" src="${src}"- width="640" height="360" alt="" loading="${eager ? 'eager' : 'lazy'}" data-cover-code="${esc(item.code || '')}"${wide ? ' data-wide-sleeve="1"' : ''}${face}${box} data-drop="self">`;+ width="640" height="360" alt="" loading="${eager ? 'eager' : 'lazy'}" data-cover-code="${esc(item.code || '')}"${wide ? ' data-wide-sleeve="1"' : ''}${still ? ' data-cover-layout="still"' : ''}${face}${box} data-drop="self">`;}/** 封面格的两种图:官方封套(取景链接管)或预览图。空串是这一条没有可用的图。 */diff --git a/frontend/test/card-art/framing.test.ts b/frontend/test/card-art/framing.test.tsindex 89d8d8f66..156ac9d93 100644--- a/frontend/test/card-art/framing.test.ts+++ b/frontend/test/card-art/framing.test.ts@@ -158,6 +158,25 @@ describe('coverAnchor:封面按自己的宽高比分流', () => {});});+describe('宽正封框', () => {+ it('VR 画面在 4:3 源图上按左侧人脸取景', () => {+ const host = mount('<div class="pic"><img class="poster cover front" src="/cover?code=MDVR-276" style="--card-ratio:.75" data-cover-layout="still" data-cx=".22" data-posterbox="380 800 600 0 800 600"></div>');+ const img = sized(host.querySelector('img')!, 800, 600);+ coverAnchor(img);+ expect(img.dataset.frame).toBe('still');+ expect(img.classList.contains('panel')).toBe(false);+ expect(img.style.getPropertyValue('--cover-x')).toBe('0%');+ });+ it('来源框独立于标题保留完整宽正封', () => {+ const host = mount('<div class="pic"><img class="poster cover front" src="/cover?code=MIDA-239" style="--card-ratio:.75" data-posterbox="428 800 438 0 800 438"></div>');+ const img = sized(host.querySelector('img')!, 800, 438);+ coverAnchor(img);+ expect(img.classList.contains('panel')).toBe(true);+ expect(parseFloat(img.style.getPropertyValue('--panel-height'))).toBeLessThan(100);+ expect(parseFloat(img.style.getPropertyValue('--panel-top'))).toBeGreaterThan(0);+ });+});+describe('upgradeCover:派生档不够清楚就换回原件', () => {it('一个源像素要占不止一个设备像素才换,模糊底仍取派生档', () => {const host = mount('<div class="pic"><img class="poster cover" src="/cover?code=A&thumb=1"></div>');diff --git a/frontend/test/card-art/markup.test.ts b/frontend/test/card-art/markup.test.tsindex 442c92804..d618412d1 100644--- a/frontend/test/card-art/markup.test.ts+++ b/frontend/test/card-art/markup.test.ts@@ -209,6 +209,16 @@ describe('人脸取景的换算', () => {});describe('coverImage:官方封面', () => {+ it('VR 画面标记来自标题或取景记录,手工框保持其取景', () => {+ expect(parse(coverImage({ code: 'MDVR-276', title: '【VR】作品' }, 'big'))!.dataset.coverLayout).toBe('still');+ expect(parse(coverImage({ code: 'MDVR-276', cover_frame: { layout: 'still' } }, 'big'))!.dataset.coverLayout).toBe('still');+ const manual = parse(coverImage({ code: 'MDVR-276', title: '【VR】作品',+ poster_box: { x0: 0, y0: 0, x1: 300, y1: 600, px: [800, 600], method: 'manual' } }, 'big'))!;+ expect(manual.dataset.coverLayout).toBeUndefined();+ expect(manual.dataset.posterbox).toBeDefined();+ expect(parse(coverImage({ code: 'IENFE-5301' }, 'big'))!.dataset.coverLayout).toBe('still');+ expect(parse(coverImage({ code: 'IENFE-5301', cover_frame: { cy: .8 } }, 'big'))!.dataset.cy).toBe('0.8');+ });it('来源封面携带作品身份和明确的 Blu-ray 版次', () => {const img = parse(coverImage({ code: 'MIDA-122', title: '作品(ブルーレイディスク)' }, 'big'))!;expect(img.dataset.coverCode).toBe('MIDA-122');diff --git a/scripts/detect_cover_faces.py b/scripts/detect_cover_faces.pyindex 75f5d6b23..bb136706e 100644--- a/scripts/detect_cover_faces.py+++ b/scripts/detect_cover_faces.py@@ -33,12 +33,13 @@ if str(SRC_DIR) not in sys.path:from peach.config import COVER_DIRfrom peach.cover_artwork import face_recordfrom peach.face_detect import FaceDetector, FaceModelUnavailable+from peach.jav_poster_crop import read_sidecardef detect(path: Path, detector: FaceDetector) -> dict | None:import cv2image = cv2.imread(str(path))- return face_record(image, detector, code=path.stem)+ return face_record(image, detector, code=path.stem, title=(read_sidecar(path) or {}).get('title', ''))def build_parser() -> argparse.ArgumentParser:diff --git a/scripts/poster_crop_boxes.py b/scripts/poster_crop_boxes.pyindex d70afc242..c13b0bde3 100644--- a/scripts/poster_crop_boxes.py+++ b/scripts/poster_crop_boxes.py@@ -94,7 +94,8 @@ def run(args: argparse.Namespace) -> int:print(f"[{index}/{len(todo)}] 读图失败 {path.name}", flush=True)continuerecord = jav_poster_crop.crop_record(- path.stem, width, height, jav_poster_crop.file_gradient(path))+ path.stem, width, height, jav_poster_crop.file_gradient(path),+ title=(jav_poster_crop.read_sidecar(path) or {}).get('title', ''))method = record["box"]["method"]counts[method] += 1bucket = samples.setdefault(method, [])diff --git a/src/peach/cover_artwork.py b/src/peach/cover_artwork.pyindex f53f8d239..8b7e101e6 100644--- a/src/peach/cover_artwork.py+++ b/src/peach/cover_artwork.py@@ -23,7 +23,7 @@ def _default_detector() -> FaceDetector:return FaceDetector(allow_download=False)-def face_record(image, detector, *, code: str) -> dict | None:+def face_record(image, detector, *, code: str, title: str = '') -> dict | None:"""已解码的封面 → 页面取景记录;无法解码时不生成记录。脸框宽高与源图尺寸 `px` 也记下,形状与头像边车(`avatar_face.face_record_of`)@@ -35,17 +35,22 @@ def face_record(image, detector, *, code: str) -> dict | None:height, width = image.shape[:2]ratio = width / height if height else 0faces = detector.detect(image)- if (jav_poster_crop.crops_to_portrait(code)- and jav_poster_crop.SLEEVE_RATIO_MIN <= ratio < jav_poster_crop.SLEEVE_RATIO_MAX):+ if (jav_poster_crop.crops_to_portrait(code, title)+ and (jav_poster_crop.SLEEVE_RATIO_MIN <= ratio < jav_poster_crop.SLEEVE_RATIO_MAX+ or (jav_poster_crop.is_wide_sleeve_label(code, title)+ and jav_poster_crop.WIDE_SLEEVE_RATIO_MIN <= ratio < jav_poster_crop.WIDE_SLEEVE_RATIO_MAX))):faces = [face for face in faces if face.cx >= FRONT_START]- faces = [face for face in faces if MIN_FACE_Y <= face.cy <= MAX_FACE_Y]+ low, high = (0.0, 1.0) if jav_poster_crop.is_scene_cover(code, title) else (MIN_FACE_Y, MAX_FACE_Y)+ faces = [face for face in faces if low <= face.cy <= high]best = main_face(faces)- return {"ratio": round(ratio, 3), "px": [int(width), int(height)], "face": (+ return {"ratio": round(ratio, 3), "px": [int(width), int(height)],+ **({'layout': 'still'} if jav_poster_crop.is_scene_cover(code, title) else {}), "face": ({"cx": best.cx, "cy": best.cy, "w": best.width, "h": best.height,"score": best.score} if best else None)}-def _sidecars(code: str, payload: bytes, size: tuple[int, int], detector=None) -> dict[str, bytes]:+def _sidecars(code: str, payload: bytes, size: tuple[int, int], detector=None, evidence=None) -> dict[str, bytes]:+ title = str((evidence or {}).get('title') or '')image = Nonetry:image = decode(payload)@@ -54,11 +59,12 @@ def _sidecars(code: str, payload: bytes, size: tuple[int, int], detector=None) -poster = jav_poster_crop.crop_record(code, size[0], size[1],(lambda: jav_poster_crop.column_gradient(image)) if image is not None else None,+ title=title,)records = {jav_poster_crop.SIDECAR_SUFFIX: poster}try:active = detector if detector is not None else _default_detector()- face = face_record(image, active, code=code)+ face = face_record(image, active, code=code, title=title)except (FaceModelUnavailable, ImportError):face = Noneif face is not None:@@ -72,7 +78,7 @@ def install_cover(target: Path, code: str, payload: bytes, size: tuple[int, int]"""准备完成后安装整组文件;失败时还原旧组,避免图片与取景跨版本。"""target = Path(target)target.parent.mkdir(parents=True, exist_ok=True)- prepared = _sidecars(code, payload, size, detector)+ prepared = _sidecars(code, payload, size, detector, evidence)if evidence is not None:prepared[".scraping.json"] = json.dumps(evidence, ensure_ascii=False).encode("utf-8")token = uuid.uuid4().hexdiff --git a/src/peach/feed_followup.py b/src/peach/feed_followup.pyindex 22d74959b..94684858e 100644--- a/src/peach/feed_followup.py+++ b/src/peach/feed_followup.py@@ -12,7 +12,7 @@(`metadata_routes`)和发请求那一层(`library_processing.LibraryMetadataProvider`),不借结算。-**封面走馆藏那一条。** 取图是 `jav_cover_fetch.best_cover`(和重探封面同一个),落盘是+**封面走馆藏那一条。** 官方候选复用 `jav_cover_fetch.best_cover`,来源图复用详情的身份校验与缓存,落盘是`cover_artwork.install_cover`:书脊折痕的正封框与人脸位置随图一起写进边车,新作卡和资产卡按同一份边车取景。文件到手、建成 `asset` 之后,这张封面原样就是它的封面。@@ -22,6 +22,10 @@from __future__ import annotationsimport hashlib+import base64+import io+import json+import reimport timefrom datetime import datetime, timedelta, timezonefrom pathlib import Path@@ -100,7 +104,7 @@ def backlog(connection, cover_root: Path, *, exclude=(), now: datetime | None =" AND NOT EXISTS (SELECT 1 FROM asset a WHERE a.code IS NOT NULL"" AND COALESCE(a.disposal,'')<>'vanished'"" AND normalise_code_key(a.code)=normalise_code_key(d.code))"- " ORDER BY COALESCE(d.release_date,d.discovered_at) DESC, d.id DESC",+ " ORDER BY COALESCE(d.scraped_at,''), COALESCE(d.release_date,d.discovered_at) DESC, d.id DESC",(cutoff,)).fetchall()found: list[str] = []for row in rows:@@ -158,25 +162,29 @@ def collect(provider, code: str) -> tuple[dict, str | None]:def fetch_cover(contract, code: str,cover_url: str | None = None) -> tuple[bytes, tuple[int, int], dict]:- """官方渠道里这个番号最大的那张封面,连同写进 `.scraping.json` 的来路。+ """优先官方封面,未取得时使用已绑定作品的来源封面;返回图片与来路。`cover_url` 是取资料那一步来源给的地址,它是官方图路径时一起参与择优。`DAZD-308`这类番号 r18 与本机快照里都没有,官方渠道一条候选也列不出来,来源给的却正是 DMM 那张封套;不收它,这部就只能在页面上拿远程图按固定比例切,书脊切不干净。取不到就抛;原因交给调用方记账,一部取不到不影响同批其余几部。"""- from .jav_cover_fetch import HostLimitedTransport, best_cover, official_image_candidates- from .scraping_access import SourceTransport+ from .jav_cover_fetch import HostLimitedTransport, Unavailable, best_cover, official_image_candidates+ from .scraping_access import SourcePaused, SourceTransport+ import httpxraw = SourceTransport(contract.follow_secrets_root, max_requests=40,max_bytes=32 * 1024 * 1024, max_seconds=COVER_SECONDS)transport = HostLimitedTransport(raw, 1.0)try:- candidate, size, data = best_cover(- transport, code, 0,- metadata_root=contract.follow_sources_root / "metadata" / "javinizer-go",- prior_candidates=tuple(official_image_candidates(cover_url or "")),- deadline=time.monotonic() + COVER_SECONDS)+ try:+ candidate, size, data = best_cover(+ transport, code, 0,+ metadata_root=contract.follow_sources_root / "metadata" / "javinizer-go",+ prior_candidates=tuple(official_image_candidates(cover_url or "")),+ deadline=time.monotonic() + COVER_SECONDS)+ except (Unavailable, SourcePaused, httpx.TransportError, OSError):+ return source_cover(contract, code)finally:transport.close()digest = hashlib.sha256(data).hexdigest()@@ -187,6 +195,54 @@ def fetch_cover(contract, code: str,return data, size, evidence+def source_cover(contract, code: str) -> tuple[bytes, tuple[int, int], dict]:+ """已绑定作品的来源封面,复用详情的身份校验与持久图片缓存。"""+ from PIL import Image+ from .jav_cover_fetch import MIN_WIDTH, SMALL_MIN_WIDTH, Unavailable+ from .javdb_public import PUBLIC_API, public_cache_scope+ from .remote_media_cache import cache_for++ with contract.database.read_connection() as connection:+ row = connection.execute('SELECT link,title FROM feed_discovery WHERE code=?', (code,)).fetchone()+ if row is None:+ raise Unavailable('未取得已绑定的来源作品')+ link = re.fullmatch(r'https://javdb\.com/v/([A-Za-z0-9]+)/?', str(row['link'] or ''))+ if link is None:+ raise Unavailable('未取得已绑定的来源作品')+ with public_cache_scope(contract.cover_root.parent / 'jav-public'):+ PUBLIC_API.remember_movie_identity(code, {'number': code, 'id': link[1]})+ data = cache_for(contract).bytes(f'jav:{code}:cover:original', lambda:+ base64.b64decode(PUBLIC_API.image(code, 'cover', original=True).partition(',')[2], validate=True))+ with Image.open(io.BytesIO(data)) as image:+ size = image.size+ image.verify()+ if size[0] < SMALL_MIN_WIDTH:+ raise Unavailable('来源封面宽度不足 240px')+ digest = hashlib.sha256(data).hexdigest()+ return data, size, {'code': code, 'width': size[0], 'height': size[1],+ 'source': 'javdb-public', 'source_url': row['link'], 'title': row['title'],+ 'verified_by': [], 'raw_sha256': digest, 'installed_sha256': digest,+ 'quality': 'source-small' if size[0] < MIN_WIDTH else 'source',+ 'checked_at': time.time(), 'resolver': 'peach-jav-source-cover-v1'}+++def record_cover_attempt(contract, code: str, *, ok: bool, error=None):+ """逐番号保存封面处理结果;不记录请求凭据或来源返回正文。"""+ from .fsutil import atomic_write_text+ path = contract.cover_root.parent / 'feed-cover-attempts' / (normalise_code_key(code) + '.json')+ path.parent.mkdir(parents=True, exist_ok=True)+ record = {'code': code, 'checked_at': time.time(), 'ok': ok}+ if error is not None:+ from .jav_cover_fetch import Unavailable+ from .javdb_public import PublicSourceUnavailable+ from .remote_media_cache import RemoteMediaUnavailable+ import httpx+ reason = (re.sub(r'https?://\S+', '来源地址', str(error)) if isinstance(error, (Unavailable, PublicSourceUnavailable, RemoteMediaUnavailable))+ else '来源连接失败' if isinstance(error, httpx.TransportError) else '封面处理未完成')+ record.update(error_type=type(error).__name__, reason=reason[:300])+ atomic_write_text(path, json.dumps(record, ensure_ascii=False))++def ensure_cover(contract, code: str, cover_url: str | None = None) -> bool:"""本机还没有这个番号的封面就去取来装上。返回这一部现在有没有封面。"""from .catalog_rules import is_korean_mib_code@@ -197,8 +253,17 @@ def ensure_cover(contract, code: str, cover_url: str | None = None) -> bool:return Falseif has_local_cover(contract.cover_root, key):return True- data, size, evidence = fetch_cover(contract, key, cover_url)- install_cover(Path(contract.cover_root) / f"{key}.jpg", key, data, size, evidence=evidence)+ try:+ data, size, evidence = fetch_cover(contract, key, cover_url)+ with contract.database.read_connection() as connection:+ row = connection.execute('SELECT title FROM feed_discovery WHERE code=?', (key,)).fetchone()+ if row:+ evidence = {**evidence, 'title': row['title']}+ install_cover(Path(contract.cover_root) / f"{key}.jpg", key, data, size, evidence=evidence)+ except Exception as error:+ record_cover_attempt(contract, key, ok=False, error=error)+ raise+ record_cover_attempt(contract, key, ok=True)return Truediff --git a/src/peach/jav_poster_crop.py b/src/peach/jav_poster_crop.pyindex dabf65ab7..c7e2c8b15 100644--- a/src/peach/jav_poster_crop.py+++ b/src/peach/jav_poster_crop.py@@ -46,6 +46,7 @@ OpenCV 不在(`vision` 是可选依赖组)或图读不出来时直接走 `rafrom __future__ import annotationsimport json+import reimport statisticsfrom collections.abc import Callable, Sequencefrom pathlib import Path@@ -168,7 +169,7 @@ MANUAL = "manual"MANUAL_SOURCE = "user:crop"#: 算法版本号。sidecar 记着它,落后的重算。改动判据、常数或框的形状都要进位。-ALGORITHM_VERSION = "poster-crop-v10"+ALGORITHM_VERSION = "poster-crop-v11"#: sidecar 与封面同名换后缀:`ABW-232.jpg` → `ABW-232.poster.json`。人脸取景是#: `.face.json`,两者同目录、同命名风格,各描述一件事:一个是脸在哪,一个是正封在哪。SIDECAR_SUFFIX = ".poster.json"@@ -178,7 +179,21 @@ SIDECAR_SUFFIX = ".poster.json"GradientSource = Sequence[float] | Callable[[], Sequence[float] | None] | None-def crops_to_portrait(code: str | None) -> bool:+SCENE_COVER_LABELS = frozenset({'IENEE', 'IENFE', 'SDHS'})+++def is_vr_title(title: str | None) -> bool:+ """来源标题明确标记为 VR 作品。"""+ return bool(re.search(r'(?:【|\[|\(|()\s*(?:[48]K\s*)?VR\s*(?:】|\]|\)|))', str(title or ''), re.I))+++def is_scene_cover(code: str | None, title: str = '') -> bool:+ """VR 与数字发行厂牌的整幅宣传画面。"""+ key = normalise_code_key(code)+ return is_vr_title(title) or bool(key and key.split('-', 1)[0] in SCENE_COVER_LABELS)+++def crops_to_portrait(code: str | None, title: str = '') -> bool:"""这个番号的封面是横版封套吗。判据全部走 `catalog_rules` 现有函数,不在这里另立一套番号形态:@@ -191,19 +206,21 @@ def crops_to_portrait(code: str | None) -> bool:key = normalise_code_key(code)if not key or not is_jav_code(key):return False- if key.startswith("FC2"):+ if key.startswith("FC2") or is_scene_cover(code, title):return Falsereturn not (is_uncensored_code(key) or is_korean_mib_code(key))-def is_wide_sleeve_label(code: str | None) -> bool:- """这个番号的厂牌用的是宽封套模板吗。+def is_wide_sleeve_label(code: str | None, title: str = '') -> bool:+ """厂牌或来源标题是否标明宽封套版次。- 只看厂牌字母段,比例那一关在 `front_panel_box`:厂牌只负责开门,同一厂牌哪一期+ 比例那一关在 `front_panel_box`:版次只负责开门,同一厂牌哪一期换了封面比例,仍按图本身的比例走对应的那一档。"""key = normalise_code_key(code)- return bool(key) and key.split("-", 1)[0] in WIDE_SLEEVE_LABELS+ return bool(key) and not key.startswith('FC2') and (+ key.split("-", 1)[0] in WIDE_SLEEVE_LABELS+ or bool(re.search(r'ブルーレイ|blu[\s-]?ray', str(title or ''), re.I)))class ColumnProfile(list):@@ -257,7 +274,7 @@ def file_gradient(path: Path | str) -> Callable[[], ColumnProfile | None]:def front_panel_box(width: int, height: int,gradient_source: GradientSource = None,- code: str | None = None) -> dict:+ code: str | None = None, title: str = '') -> dict:"""源图尺寸加列梯度 → 正封那一块的取景框。纯函数,不碰文件也不碰 OpenCV。返回 `{"x0", "y0", "x1", "y1", "method"}`,坐标是源图像素,右下开区间。@@ -270,8 +287,10 @@ def front_panel_box(width: int, height: int,width, height = int(width or 0), int(height or 0)if width <= 0 or height <= 0:return {"x0": 0, "y0": 0, "x1": 0, "y1": 0, "method": NONE}+ if is_scene_cover(code, title):+ return _whole(width, height)ratio = width / height- if (is_wide_sleeve_label(code)+ if (is_wide_sleeve_label(code, title)and WIDE_SLEEVE_RATIO_MIN <= ratio < WIDE_SLEEVE_RATIO_MAX):return _sleeve(width, height, gradient_source, WIDE_PANEL)if ratio >= SLEEVE_RATIO_MAX:@@ -534,15 +553,16 @@ def _panel(width: int, height: int, start: int, method: str) -> dict:def crop_record(code: str | None, width: int, height: int,- gradient_source: GradientSource = None) -> dict:+ gradient_source: GradientSource = None, *, title: str = '') -> dict:"""可直接落盘的 sidecar 内容:算法版本、源图尺寸、框。番号形态先判:不该裁的图连梯度都不算,`gradient_source` 是惰性的就一次都不解码。"""width, height = int(width or 0), int(height or 0)- box = (front_panel_box(width, height, gradient_source, code)- if crops_to_portrait(code) else _whole(width, height))- return {"version": ALGORITHM_VERSION, "px": [width, height], "box": box}+ box = (front_panel_box(width, height, gradient_source, code, title)+ if crops_to_portrait(code, title) else _whole(width, height))+ return {"version": ALGORITHM_VERSION, "px": [width, height], "box": box,+ **({'title': title} if title else {})}def manual_record(width: int, height: int, box: object) -> dict | None:diff --git a/src/peach/javdb_public.py b/src/peach/javdb_public.pyindex 0553ffc3c..962927fe8 100644--- a/src/peach/javdb_public.py+++ b/src/peach/javdb_public.py@@ -418,7 +418,7 @@ class PublicAPI:return {'url': url, **({'release_date': released} if url else {})}return self._cached('preview:prestige:' + normalise_code_key(code), read, refresh=refresh)- def image(self, code: str, index: str) -> str:+ def image(self, code: str, index: str, *, original=False) -> str:movie = self.media_movie(code)if index == "cover":url = movie.get("cover_url") or movie.get("thumb_url")@@ -437,9 +437,9 @@ class PublicAPI:raise ValueError("预览图不存在") from Noneif isinstance(url, dict):url = url.get("large_url") or url.get("url")- return self.image_from_url(url)+ return self.image_from_url(url, original=True) if original else self.image_from_url(url)- def image_from_url(self, url) -> str:+ def image_from_url(self, url, *, original=False) -> str:"""静态头像与作品图片共用校验、并发下载、解码和请求缓存。"""if not public_image_url(url):raise PublicSourceUnavailable("图片未取得")@@ -448,13 +448,14 @@ class PublicAPI:import base64with self.image_slots:body = self._get(str(url), limit=4 * 1024 * 1024, image=True).body- decoded = decode_image(body)+ decoded = decode_image(body, original=True) if original else decode_image(body)return "data:image/jpeg;base64," + base64.b64encode(decoded).decode("ascii")- return self._cached('image:' + hashlib.sha256(str(url).encode()).hexdigest(), fetch)+ key = ('image:original:' if original else 'image:') + hashlib.sha256(str(url).encode()).hexdigest()+ return self._cached(key, fetch)-def decode_image(body: bytes) -> bytes:+def decode_image(body: bytes, *, original=False) -> bytes:"""标准图片与公开前端 XOR 包装,只接受 Pillow 完整解码的图像。"""candidates = [body]if body:@@ -466,9 +467,12 @@ def decode_image(body: bytes) -> bytes:if image.width * image.height > 20_000_000:continueimage.load()- image.thumbnail((1200, 1200))+ if original and image.format == 'JPEG':+ return raw+ if not original:+ image.thumbnail((1200, 1200))output = io.BytesIO()- image.convert("RGB").save(output, "JPEG", quality=85)+ image.convert("RGB").save(output, "JPEG", quality=95 if original else 85)return output.getvalue()except (OSError, ValueError, Image.DecompressionBombError):continuediff --git a/src/peach/web_state.py b/src/peach/web_state.pyindex f184f77e6..ba7fb64f3 100644--- a/src/peach/web_state.py+++ b/src/peach/web_state.py@@ -420,19 +420,22 @@ class WebContract:@staticmethoddef _cover_focus(sidecar: str) -> dict | None:- """sidecar 里的人脸中心。没算过、读不出或没检出都是 None,页面退回固定取景。+ """sidecar 里的人脸中心与整幅画面标记。缺少坐标时页面退回固定取景。两个轴都给出去:哪个轴生效由容器和图片的宽高比决定,不由这里判断。缺哪个键就不带哪个键,前端各自回落,不要拿另一个轴的值顶替。"""try:with open(sidecar, encoding="utf-8") as handle:- face = (json.load(handle) or {}).get("face")+ record = json.load(handle) or {}+ if not isinstance(record, dict):+ return None+ face = record.get("face")except (OSError, ValueError):return None- if not isinstance(face, dict):- return None- focus = {axis: face[axis] for axis in ("cx", "cy") if axis in face}+ focus = {'layout': 'still'} if record.get('layout') == 'still' else {}+ if isinstance(face, dict):+ focus.update({axis: face[axis] for axis in ("cx", "cy") if axis in face})return focus or None@staticmethod@@ -615,11 +618,11 @@ class WebContract:return key in self.avatar_root_index().generated or self.has_snapshot(snapshot_path)def cover_frame(self, code: str | None) -> dict | None:- """封面的取景提示:人脸中心的两个轴。没算过或没检出就返回 None。+ """封面的取景提示:人脸中心与整幅画面标记。未检出时不含人脸坐标。双页封套的横向锚点仍由版式决定(正封贴着右边缘,几何规则已经稳定),人脸- 横向只用在 16:9 官方剧照上——那种图在大图容器里只会横向裁,写死的居中会把- 偏在一侧的人整个切掉。取不到时前端退回固定取景,不影响显示。+ 锚点用于整幅画面被裁掉的那一轴,VR 与数字发行拼图携带 `layout=still` 标记。+ 取不到人脸时前端退回固定取景,不影响显示。"""return (self._cover_entry(code) or {}).get("frame")diff --git a/tests/test_feeds_web.py b/tests/test_feeds_web.pyindex e5f67044c..395af010d 100644--- a/tests/test_feeds_web.py+++ b/tests/test_feeds_web.py@@ -569,6 +569,80 @@ class FeedWebTest(FeedWebFixture):self.assertEqual(items["SSIS-950"]["poster_box"]["px"], [800, 538])self.assertFalse(items["HMN-071"]["has_cover"])self.assertIsNone(items["HMN-071"]["poster_box"])+ attempt = json.loads((covers.parent / 'feed-cover-attempts/HMN-071.json').read_text(encoding='utf-8'))+ self.assertFalse(attempt['ok'])+ self.assertIn('error_type', attempt)++ def test_official_miss_uses_the_bound_source_image(self):+ import base64+ from peach.jav_cover_fetch import Unavailable+ self._add()+ self._check()+ with self.contract.database.write_transaction() as connection:+ connection.execute("UPDATE feed_discovery SET link='https://javdb.com/v/Source01' WHERE code='SSIS-950'")+ body, size, _ = self._fake_cover(self.contract, 'SSIS-950')+ with patch('peach.jav_cover_fetch.best_cover', side_effect=Unavailable('官方封面未取得')), \+ patch('peach.javdb_public.PUBLIC_API.image', return_value=+ 'data:image/jpeg;base64,' + base64.b64encode(body).decode()) as source_image, \+ patch('peach.javdb_public.PUBLIC_API.remember_movie_identity') as identity:+ found, actual, evidence = self._fetch_cover(self.contract, 'SSIS-950')+ self.assertEqual((found, actual), (body, size))+ self.assertEqual(evidence['source'], 'javdb-public')+ identity.assert_called_once_with('SSIS-950', {'number': 'SSIS-950', 'id': 'Source01'})+ source_image.assert_called_once_with('SSIS-950', 'cover', original=True)++ def test_source_image_requires_a_bound_movie_and_full_size(self):+ import base64+ from peach.jav_cover_fetch import Unavailable+ self._add()+ self._check()+ with self.contract.database.write_transaction() as connection:+ connection.execute("UPDATE feed_discovery SET link='https://example.test/v/Source01' WHERE code='SSIS-950'")+ with patch('peach.javdb_public.PUBLIC_API.image') as image:+ with self.assertRaises(Unavailable):+ feed_followup.source_cover(self.contract, 'SSIS-950')+ image.assert_not_called()+ with self.contract.database.write_transaction() as connection:+ connection.execute("UPDATE feed_discovery SET link='https://javdb.com/v/Source01' WHERE code='SSIS-950'")+ from PIL import Image+ buffer = io.BytesIO()+ Image.new('RGB', (200, 200)).save(buffer, 'JPEG')+ with patch('peach.javdb_public.PUBLIC_API.image', return_value=+ 'data:image/jpeg;base64,' + base64.b64encode(buffer.getvalue()).decode()), \+ patch('peach.javdb_public.PUBLIC_API.remember_movie_identity'):+ with self.assertRaisesRegex(Unavailable, '240px'):+ feed_followup.source_cover(self.contract, 'SSIS-950')++ def test_bound_portrait_source_cover_keeps_its_native_size(self):+ import base64+ from PIL import Image+ self._add()+ self._check()+ buffer = io.BytesIO()+ Image.new('RGB', (560, 800)).save(buffer, 'JPEG')+ body = buffer.getvalue()+ with patch('peach.javdb_public.PUBLIC_API.image', return_value=+ 'data:image/jpeg;base64,' + base64.b64encode(body).decode()), \+ patch('peach.javdb_public.PUBLIC_API.remember_movie_identity'):+ actual, size, evidence = feed_followup.source_cover(self.contract, 'SSIS-950')+ self.assertEqual((actual, size), (body, (560, 800)))+ self.assertEqual(evidence['quality'], 'source-small')++ def test_vr_layout_survives_without_a_detected_face(self):+ target = self.contract.cover_root / 'MDVR-276.face.json'+ target.parent.mkdir(parents=True, exist_ok=True)+ target.write_text(json.dumps({'layout': 'still', 'face': None}), encoding='utf-8')+ self.assertEqual(self.contract._cover_focus(str(target)), {'layout': 'still'})++ def test_cover_backlog_prioritises_the_least_recent_attempt(self):+ self._add()+ self._check()+ with self.contract.database.write_transaction() as connection:+ connection.execute("UPDATE feed_discovery SET scraped_at='2026-01-01T00:00:00Z',release_date='2026-10-01' WHERE code='SSIS-950'")+ connection.execute("UPDATE feed_discovery SET scraped_at='2025-01-01T00:00:00Z',release_date='2025-01-01' WHERE code='HMN-071'")+ with self.contract.database.read_connection() as connection:+ result = feed_followup.backlog(connection, self.contract.cover_root, hidden=frozenset(), limit=1)+ self.assertEqual(result, ['HMN-071'])def test_covers_cut_off_at_the_connection_are_counted_for_the_new_release_row(self):"""连不上图片主机的几部单独记数,列表把最近一轮的数带给页面去提示换线路;diff --git a/tests/test_jav_cover_artwork.py b/tests/test_jav_cover_artwork.pyindex cb2aabd4b..ac809d2a6 100644--- a/tests/test_jav_cover_artwork.py+++ b/tests/test_jav_cover_artwork.py@@ -55,6 +55,52 @@ class CoverArtworkTests(unittest.TestCase):self.assertEqual((face["px"], face["face"]["w"]), ([840, 472], .1))self.assertTrue(jav_poster_crop.is_current(poster, 840, 472))+ def test_bluray_title_frames_the_front_panel_and_its_face(self):+ detector = Detector()+ title = '作品 ブルーレイディスク'+ with patch.object(detector, 'detect', return_value=[+ Face(.2, .25, .2, .2, .95), Face(.72, .22, .1, .1, .94)]):+ cover_artwork.install_cover(self.target, 'MIDA-239', jpeg((90, 80, 70), (800, 438)),+ (800, 438), detector=detector, evidence={'title': title})+ poster = jav_poster_crop.read_sidecar(self.target)+ self.assertEqual(poster['box']['x0'], round(800 - .85 * 438))+ self.assertEqual(poster['title'], title)+ face = json.loads(self.target.with_suffix('.face.json').read_text(encoding='utf-8'))+ self.assertEqual(face['face']['cx'], .72)++ def test_fc2_title_keeps_the_whole_image_and_left_face(self):+ detector = Detector()+ with patch.object(detector, 'detect', return_value=[Face(.2, .25, .2, .2, .95)]):+ cover_artwork.install_cover(self.target, 'FC2-PPV-12345', jpeg((90, 80, 70), (800, 438)),+ (800, 438), detector=detector, evidence={'title': 'Blu-ray'})+ self.assertIsNone(jav_poster_crop.projection(jav_poster_crop.read_sidecar(self.target)))+ face = json.loads(self.target.with_suffix('.face.json').read_text(encoding='utf-8'))+ self.assertEqual(face['face']['cx'], .2)++ def test_vr_mark_keeps_the_left_main_face_and_whole_artwork(self):+ detector = Detector()+ with patch.object(detector, 'detect', return_value=[+ Face(.22, .25, .2, .2, .95), Face(.75, .2, .1, .1, .94)]):+ cover_artwork.install_cover(self.target, 'MDVR-276', jpeg((90, 80, 70), (800, 600)),+ (800, 600), detector=detector, evidence={'title': '【VR】作品'})+ self.assertIsNone(jav_poster_crop.projection(jav_poster_crop.read_sidecar(self.target)))+ face = json.loads(self.target.with_suffix('.face.json').read_text(encoding='utf-8'))+ self.assertEqual(face['face']['cx'], .22)+ self.assertEqual(face['layout'], 'still')++ def test_digital_collages_keep_the_whole_artwork_and_left_face(self):+ detector = Detector()+ with patch.object(detector, 'detect', return_value=[Face(.22, .8, .2, .2, .95)]):+ for code in ('IENEE-93103', 'IENFE-5301', 'SDHS-039'):+ with self.subTest(code=code):+ cover_artwork.install_cover(self.target, code, jpeg((90, 80, 70), (800, 540)),+ (800, 540), detector=detector)+ self.assertIsNone(jav_poster_crop.projection(jav_poster_crop.read_sidecar(self.target)))+ face = json.loads(self.target.with_suffix('.face.json').read_text(encoding='utf-8'))+ self.assertEqual(face['face']['cx'], .22)+ self.assertEqual(face['face']['cy'], .8)+ self.assertEqual(face['layout'], 'still')+def test_missing_face_model_removes_stale_focus_but_keeps_new_cover(self):self.target.write_bytes(jpeg((10, 10, 10), (800, 539)))self.target.with_suffix(".face.json").write_text('{"ratio":1,"face":{}}')diff --git a/tests/test_javdb_public.py b/tests/test_javdb_public.pyindex 2959af237..b8d657832 100644--- a/tests/test_javdb_public.py+++ b/tests/test_javdb_public.py@@ -224,6 +224,27 @@ class PublicProtocolTests(unittest.TestCase):with self.assertRaises(PublicSourceUnavailable):decode_image(b'<html>unavailable</html>')+ def test_original_cover_keeps_jpeg_bytes_and_dimensions(self):+ output = io.BytesIO()+ Image.new('RGB', (2000, 1100), (40, 100, 160)).save(output, 'JPEG', quality=94)+ raw = output.getvalue()+ for body in (raw, bytes([31]) + bytes(value ^ 31 for value in raw)):+ self.assertEqual(decode_image(body, original=True), raw)+ with Image.open(io.BytesIO(decode_image(raw))) as preview:+ self.assertEqual(preview.size, (1200, 660))++ def test_original_image_cache_is_separate_from_preview(self):+ api = self.api()+ output = io.BytesIO()+ Image.new('RGB', (2000, 1100), (40, 100, 160)).save(output, 'JPEG')+ raw = output.getvalue()+ with patch.object(api, '_get', return_value=HttpResponse(200, {}, raw)) as request:+ preview = api.image_from_url('https://tp.spfcas.com/image.jpg')+ original = api.image_from_url('https://tp.spfcas.com/image.jpg', original=True)+ self.assertNotEqual(preview, original)+ self.assertEqual(api.image_from_url('https://tp.spfcas.com/image.jpg', original=True), original)+ self.assertEqual(request.call_count, 2)+def test_preview_entry_accepts_only_the_public_hls_origin_and_path(self):url = 'https://jdforrepam.com/api/v1/movies/ttm3u8/preview/123/0/720p.m3u8?token=sample'self.assertEqual(preview_video_url({'preview_video_url': url}), url)diff --git a/web/dist/peach-app.js b/web/dist/peach-app.jsindex 34a3c19d6..a55af445b 100644--- a/web/dist/peach-app.js+++ b/web/dist/peach-app.js@@ -12030,16 +12030,16 @@ function ua(e) {].map(Number).join(" ")}"` : "";}function da(e, t, n = !1) {- let r = ta(e, !0), i = /ブルーレイ|blu[\s-]?ray/i.test(String(e.title || e.display_title || e.name || "")), a = e.cover_frame || {}, o = [a.cx == null ? "" : ` data-cx="${a.cx}"`, a.cy == null ? "" : ` data-cy="${Math.min(.6, Math.max(.05, a.cy))}"`].join(""), s = e.poster_box, c = s ? ` data-posterbox="${[- s.x0,- (s.px || [])[0],- (s.px || [])[1],- s.y0,- s.x1,- s.y1+ let r = ta(e, !0), i = /ブルーレイ|blu[\s-]?ray/i.test(String(e.title || e.display_title || e.name || "")), a = e.cover_frame || {}, o = e.poster_box?.method !== "manual" && (a.layout === "still" || /^(IENEE|IENFE|SDHS)-/i.test(String(e.code || "")) || /(?:【|\[|\(|()\s*(?:[48]K\s*)?VR\s*(?:】|\]|\)|))/i.test(String(e.title || e.display_title || e.name || ""))), s = a.cy == null ? null : o ? Math.min(1, Math.max(0, a.cy)) : Math.min(.6, Math.max(.05, a.cy)), c = [a.cx == null ? "" : ` data-cx="${a.cx}"`, s == null ? "" : ` data-cy="${s}"`].join(""), l = e.poster_box, u = l ? ` data-posterbox="${[+ l.x0,+ (l.px || [])[0],+ (l.px || [])[1],+ l.y0,+ l.x1,+ l.y1].map(Number).join(" ")}"` : "";return `<img class="poster cover ${t === "small" ? "whole" : "front"}" src="${r}"- width="640" height="360" alt="" loading="${n ? "eager" : "lazy"}" data-cover-code="${z(e.code || "")}"${i ? " data-wide-sleeve=\"1\"" : ""}${o}${c} data-drop="self">`;+ width="640" height="360" alt="" loading="${n ? "eager" : "lazy"}" data-cover-code="${z(e.code || "")}"${i ? " data-wide-sleeve=\"1\"" : ""}${o ? " data-cover-layout=\"still\"" : ""}${c}${u} data-drop="self">`;}var fa = {kind: "",@@ -13316,7 +13316,7 @@ function Gs(e) {let t = e.naturalWidth / e.naturalHeight;if (!t) return;let n = e.dataset.coverCode || new URL(e.currentSrc || e.src, location.href).searchParams.get("code") || "";- e.dataset.frame = /^FC2(?:-PPV)?-/i.test(n) ? "still" : qs(e) ? "sleeve" : t >= 1.65 ? "still" : t > 1.2 ? "sleeve" : "front";+ e.dataset.frame = e.dataset.coverLayout === "still" || /^FC2(?:-PPV)?-/i.test(n) ? "still" : qs(e) ? "sleeve" : t >= 1.65 ? "still" : t > 1.2 ? "sleeve" : "front";let r = Xs(e), i = (t, n, r) => {if (n == null || !(r > 0 && r < 1)) return;let i = Math.min(1, Math.max(0, (n - r / 2) / (1 - r)));@@ -13325,17 +13325,17 @@ function Gs(e) {i("--cover-x", Zs(e, "cx"), r / t), i("--cover-y", Zs(e, "cy"), t / r), Ks(e, r), (e.classList.contains("whole") || e.dataset.frame === "front") && Math.abs(t / r - 1) > .02 && Js(e);}function Ks(e, t) {- if (e.dataset.frame === "front") return;+ if (e.dataset.frame === "front" || e.dataset.coverLayout === "still") return;let [n = NaN, r = NaN, i = NaN, a = NaN, o = NaN, s = NaN] = String(e.dataset.posterbox || "").split(" ").map(Number);if (!e.dataset.posterbox && e.dataset.frame === "sleeve" && (r = e.naturalWidth, i = e.naturalHeight, n = Math.round(r - (qs(e) ? Yi : Ji) * i), a = 0, o = r, s = i), !Li(e.naturalWidth, e.naturalHeight, r, i)) return;- let c = Xi({+ let c = (o - n) / (s - a), l = r / i, u = l >= 1.75 && l < 1.85 && Math.abs(c - .85) <= .02, d = Xi({x0: n,y0: a,x1: o,y1: s,px: [r, i]- }, t, qs(e));- c && (e.style.setProperty("--panel-aspect", `${e.naturalWidth} / ${e.naturalHeight}`), e.classList.add("panel"), e.style.setProperty("--panel-clip", `${c.clip.top}% ${c.clip.right}% ${c.clip.bottom}% ${c.clip.left}%`), e.style.setProperty("--panel-left", `${c.left}%`), e.style.setProperty("--panel-top", `${c.top}%`), e.style.setProperty("--panel-height", `${c.height}%`), Js(e));+ }, t, qs(e) || u);+ d && (e.style.setProperty("--panel-aspect", `${e.naturalWidth} / ${e.naturalHeight}`), e.classList.add("panel"), e.style.setProperty("--panel-clip", `${d.clip.top}% ${d.clip.right}% ${d.clip.bottom}% ${d.clip.left}%`), e.style.setProperty("--panel-left", `${d.left}%`), e.style.setProperty("--panel-top", `${d.top}%`), e.style.setProperty("--panel-height", `${d.height}%`), Js(e));}function qs(e) {let t = e.dataset.coverCode || new URL(e.currentSrc || e.src, location.href).searchParams.get("code") || "", n = e.naturalWidth / e.naturalHeight;