Skip to content

armgit / peach

Public Imported from GitHub
0

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

fix(feeds): 封面卡片取 WebP 派生档,订阅只从人物页进

longmeidao71a3fa7ef691
diff --git a/docs/FRONTEND.md b/docs/FRONTEND.md
index ed28836ef..fc6cb8e47 100644
--- a/docs/FRONTEND.md
+++ b/docs/FRONTEND.md
@@ -35,7 +35,7 @@ island。原因是那一套一上来就打 `/api/items`,而未配置的机器
`h2.configgroup` 小标题,没有内容的组连标题一起省略。数据契约是 `/api/configuration`
(`src/peach/routes_configuration.py`),端点字符串只在 `frontend/src/configuration-endpoints.ts`
声明一次,整页和挂载状态那一块读同一个 `queryKey`。「通用」里的「订阅源」是例外:它读自己的
-`/api/feeds`(`feed-settings.tsx`),增删开关之后只重取这一节,这一组因此总有内容、标题不省略。
+`/api/feeds`(`feed-settings.tsx`),开关与移除之后只重取这一节,这一组因此总有内容、标题不省略。
日常入口是右上角的设置弹层:同一个 island 挂进 `#machineSettings`,左栏「这台电脑」
那一块按 `.configgroup` 标题拆成四条(`web/app.js` 的 `configTabItems`)。壳挂完这一页紧接着
就读它画出来的结构,所以第一帧要同步落到 DOM 上:`react/entry.tsx` 的 `mounter` 用 `flushSync`
diff --git a/docs/adr/0047-feed-subscriptions-enter-from-the-performer-page.md b/docs/adr/0047-feed-subscriptions-enter-from-the-performer-page.md
new file mode 100644
index 000000000..5f09589c1
--- /dev/null
+++ b/docs/adr/0047-feed-subscriptions-enter-from-the-performer-page.md
@@ -0,0 +1,46 @@
+# ADR-0047:订阅只从人物页进,订阅源只有 JavDB 演员页一类
+
+- 状态:Accepted
+- 日期:2026-09-23
+- 关系:收窄 [ADR-0042](0042-feeds-discover-codes-not-files.md)「后果」里「能用的只有
+ sukebei 的原生 RSS 与 JavDB 演员页伪 Feed 两类」,其余各条不变
+
+## 背景
+
+ADR-0042 落地时有两个入口:设置页「订阅源」下面一张表单(来源类型、拉取间隔、订阅地址、名称),
+和人物页资料卡上的「订阅新作」开关。开关按这位的 JavDB 身份现拼演员页地址,页面只送开和关。
+
+用了一天之后的情况是:库里的订阅全部来自人物页的开关,表单一条都没建过。表单唯一多出来的用途
+是手填 sukebei 的 RSS 地址,而那种源不绑定任何人。它发现的新作只能出现在首页,
+人物页那一块看不到。用户看到表单时问的是「这里填写后会发生什么,在哪里更新」,
+说明它在界面上没有自己的位置。
+
+## 决策
+
+**一、订阅只从人物页的「订阅新作」开关进。** 设置页「订阅源」只列已有的源,
+能开关、移除、立即拉取,不再收地址。`/api/feeds/source` 只认 `follow`、`enabled`、`remove`
+三个动作,页面送来的地址一律不收。
+
+**二、订阅源只有 JavDB 演员页一类。** RSS/Atom 的解析、`rss` 类型、拉取间隔的上下限与
+设置页的类型下拉一并清退。`feed_source.kind` 列保留:它是解析器的分派键,拉取时认不出的类型
+按解析失败写进那一行的 `last_error`,不拿演员页的解析器硬读。
+
+**三、拉取间隔固定为默认的 6 小时。** 间隔原本只有表单能改,而 JavDB 按出口 IP 计配额,
+一张一天更新几条的演员页没有拉得更密的理由。
+
+## 被否决的方案
+
+**只留地址一栏,类型按地址判断。** 入口少了两个字段,问题还在:手填的源不绑定人物,
+发现的新作在人物页上看不见。要让它有位置,就得再做「这条源属于谁」的选择,
+那又是一个人物页开关已经回答了的问题。
+
+**保留表单不动。** 四个字段里有三个在唯一的实际用法里用不上,而「任意 HTTPS 地址」
+是这个应用里又一处由页面决定去哪发请求的入口。
+
+## 后果
+
+- 设置页「订阅源」只剩列表、开关、移除和「立即拉取」。
+- 想盯 sukebei 这类不按人组织的源,需要重新设计「这条源的新作挂在哪」,再新增 ADR。
+ 源的取证记录留在 `docs/SOURCING.md`「番号发现源(Feed)」。
+- 账本里若有 `rss` 类型的旧行,它会在下一轮拉取时报解析失败,在设置页那一行下面看得到,
+ 可以直接移除。
diff --git a/frontend/src/islands.ts b/frontend/src/islands.ts
index a77e70262..6dd2a7a22 100644
--- a/frontend/src/islands.ts
+++ b/frontend/src/islands.ts
@@ -22,7 +22,7 @@ import type * as ReactBundle from '@peach/react';
export { watchJob, followJobProgress, jobActivityHtml } from './jobs';
export { selectRange, selectionSummary, selectGroup, syncSelectionToolbar } from './selection';
export { paginationHtml, pageCount, clampPage } from './pagination';
-export { nativeImageFit, matchesFaceSource, faceSourceScale } from './native-image';
+export { nativeImageFit, faceSourceScale } from './native-image';
export { entitySkeletonHtml } from './entity-skeleton';
export { boardPageSkeleton, detailSkeletonHtml } from './board-skeleton';
export { catalogSuggestions, catalogEmptyHtml, emptyCatalogLayout } from './catalog-onboarding';
diff --git a/frontend/src/native-image.ts b/frontend/src/native-image.ts
index 99c8754a8..127fb5df1 100644
--- a/frontend/src/native-image.ts
+++ b/frontend/src/native-image.ts
@@ -1,8 +1,3 @@
-/** 焦点只适用于生成它的源图尺寸,缓存中的另一张图不得借用。 */
-export function matchesFaceSource(width: number, height: number, sourceWidth: number, sourceHeight: number) {
- return width > 0 && height > 0 && width === sourceWidth && height === sourceHeight;
-}
-
/** 手上这张相对边车那张源图缩了多少;换成了别的图就是 0。
*
* 索引页取的是实体图缩到长边 640 的派生件,人脸边车记的仍是原件的像素。取景的几何
diff --git a/frontend/src/react/settings/feed-settings.tsx b/frontend/src/react/settings/feed-settings.tsx
index b1bca04b7..b0858e6a5 100644
--- a/frontend/src/react/settings/feed-settings.tsx
+++ b/frontend/src/react/settings/feed-settings.tsx
@@ -1,24 +1,21 @@
-/* 「订阅源」小节:增删、开关、上次拉取时间与错误(ADR-0042)。
+/* 「订阅源」小节:列表、开关、移除、上次拉取时间与错误(ADR-0042)。
*
- * 数据不在 `/api/configuration` 那份快照里:订阅源有自己的写接口,增删开关之后要重取的
+ * 数据不在 `/api/configuration` 那份快照里:订阅源有自己的写接口,开关与移除之后要重取的
* 只是这一节。自己收自己的状态,不进共用的 `QueryClient`——这一节是「通用」组里唯一
* 不看配置快照的内容,而它的几个兄弟分区在用例里是脱离 Provider 单独挂的。
*
- * 这一节只管「订阅什么、多久拉一次」。拉回来的新作在首页与人物页的「新作 · 未入库」里,
- * 不在设置里列——设置页列一遍就成了第二个入口,两处的已读状态会各说各话。 */
-import { useCallback, useEffect, useState, type FormEvent } from 'react';
+ * 订阅只从人物页的「订阅新作」进,这里不收地址(ADR-0047)。拉回来的新作在首页与人物页的
+ * 「新作 · 未入库」里,不在设置里列——设置页列一遍就成了第二个入口,两处的已读状态会各说各话。 */
+import { useCallback, useEffect, useState } from 'react';
import { RiCloseLine } from '@remixicon/react';
import { SettingsRow } from '@/components/application/settings/settings-rows';
import { Button } from '@/components/base/buttons/button';
-import { IconButton } from '@/components/base/buttons/icon-button';
-import { Input } from '@/components/base/input/input';
-import { Select, SelectItem } from '@/components/base/select/select';
import { Switch } from '@/components/base/switch/switch';
import { apiGet, apiSend, errorMessage } from '../../api';
import { Note } from '../components/note';
-import { ErrorText, FieldLabel, Footer, Help, Rows, Section, Stack } from './section';
+import { ErrorText, Footer, Help, Rows, Section, Stack } from './section';
import { busyProps, useAction } from './use-action';
interface FeedSource {
@@ -39,9 +36,6 @@ interface FeedSource {
interface FeedsData {
sources: FeedSource[];
unread: number;
- kinds: { value: string; label: string }[];
- min_interval_minutes: number;
- max_interval_minutes: number;
}
/** 一行订阅源在名称下面那句话:上次什么时候拉的、拉到几条。没拉过就直说还没拉过。 */
@@ -58,8 +52,7 @@ function describe(source: FeedSource): string {
export function FeedSettings() {
const [data, setData] = useState<FeedsData | null>(null);
const [failure, setFailure] = useState('');
- /* 服务端是唯一真相:增删开关之后重取整份,不在前端按响应拼一份新的本地状态。
- 拉取间隔会被后端按上下限收窄,拼出来的那份和库里的从第一次保存起就不一样。 */
+ /* 服务端是唯一真相:开关与移除之后重取整份,不在前端按响应拼一份新的本地状态。 */
const reload = useCallback(async (signal?: AbortSignal) => {
try {
const payload = await apiGet<FeedsData>('/api/feeds', signal);
@@ -75,26 +68,8 @@ export function FeedSettings() {
void reload(controller.signal);
return () => controller.abort();
}, [reload]);
- const kinds = data?.kinds ?? [];
- const [kind, setKind] = useState('');
- const [url, setUrl] = useState('');
- const [name, setName] = useState('');
- const [hours, setHours] = useState('6');
const action = useAction();
- const add = (event: FormEvent<HTMLFormElement>) => {
- event.preventDefault();
- const minutes = Math.round(Number(hours) * 60);
- void action.run('add', (signal) => apiSend('/api/feeds/source', {
- action: 'add', kind: kind || kinds[0]?.value, url: url.trim(), name: name.trim(),
- interval_minutes: Number.isFinite(minutes) ? minutes : undefined,
- }, 'POST', signal), () => {
- setUrl('');
- setName('');
- void reload();
- });
- };
-
const toggle = (source: FeedSource, enabled: boolean) => {
void action.run(`enabled-${source.id}`, (signal) => apiSend('/api/feeds/source',
{ action: 'enabled', id: source.id, enabled }, 'POST', signal), () => void reload());
@@ -124,15 +99,17 @@ export function FeedSettings() {
}
return (
- <Section title="订阅源" onSubmit={add}>
+ <Section title="订阅源">
{data.sources.length ? (
<Rows>
{data.sources.map((source) => (
<SettingsRow key={source.id} label={source.name || source.url} description={describe(source)}>
- <div className="flex items-center gap-1">
+ {/* 移除键取 xs 那一档:和开关一样 24px 高,两样并排才读成同一行的两个控件。 */}
+ <div className="flex items-center gap-2">
<Switch aria-label={`启用 ${source.name || source.url}`} isSelected={source.enabled}
onChange={(enabled) => toggle(source, enabled)} />
- <IconButton icon={RiCloseLine} aria-label={`移除 ${source.name || source.url}`}
+ <Button variant="danger" size="xs" iconOnly leadingIcon={RiCloseLine}
+ aria-label={`移除 ${source.name || source.url}`}
onClick={() => remove(source)} {...busyProps(action.busy === `remove-${source.id}`)} />
</div>
</SettingsRow>
@@ -146,28 +123,11 @@ export function FeedSettings() {
{source.last_error}
</Note>
))}
- <div className="inline-grid grid-cols-1 gap-3 @lg:grid-cols-2">
- <div className="flex flex-col gap-1.5">
- <FieldLabel>来源类型</FieldLabel>
- <Select aria-label="来源类型" selectedKey={kind || kinds[0]?.value}
- onSelectionChange={(key) => { if (key !== null) setKind(String(key)); }}>
- {kinds.map((item) => (
- <SelectItem key={item.value} id={item.value} textValue={item.label}>{item.label}</SelectItem>
- ))}
- </Select>
- </div>
- <Input label="拉取间隔(小时)" inputMode="decimal" value={hours} onChange={setHours}
- hint={`最短 ${data.min_interval_minutes} 分钟。`} />
- </div>
- <Input label="订阅地址" placeholder="https://" value={url} onChange={setUrl}
- hint="RSS/Atom 的地址,或 JavDB 的演员页地址。只收 HTTPS。" />
- <Input label="名称" maxLength={80} placeholder="不填就用地址" value={name} onChange={setName} />
{action.error ? <ErrorText>{action.error}</ErrorText> : null}
- <Help>订阅只发现番号、建一条「未入库」的新作,不下载任何文件。新作在首页和人物页里看。</Help>
+ <Help>在人物页点「订阅新作」就会加到这里。订阅只发现番号、建一条「未入库」的新作,不下载任何文件;新作在首页和人物页里看。</Help>
</Stack>
<Footer status={data.unread ? `有 ${data.unread} 条新作还没看` : '新作都看过了'}>
<Button onClick={check} {...busyProps(action.busy === 'check')}>立即拉取</Button>
- <Button type="submit" {...busyProps(action.busy === 'add')}>添加订阅</Button>
</Footer>
</Section>
);
diff --git a/frontend/test/native-image.test.ts b/frontend/test/native-image.test.ts
index 33458956c..48072e3e4 100644
--- a/frontend/test/native-image.test.ts
+++ b/frontend/test/native-image.test.ts
@@ -1,10 +1,10 @@
import { describe, expect, it } from 'vitest';
-import { nativeImageFit, matchesFaceSource, faceSourceScale } from '../src/native-image';
+import { nativeImageFit, faceSourceScale } from '../src/native-image';
it('544×724 的旧人像不能使用 2184×1468 封面的焦点', () => {
- expect(matchesFaceSource(544, 724, 2184, 1468)).toBe(false);
- expect(matchesFaceSource(544, 724, 544, 724)).toBe(true);
- expect(matchesFaceSource(0, 0, 0, 0)).toBe(false);
+ expect(faceSourceScale(544, 724, 2184, 1468)).toBe(0);
+ expect(faceSourceScale(544, 724, 544, 724)).toBe(1);
+ expect(faceSourceScale(0, 0, 0, 0)).toBe(0);
});
describe('派生件相对边车源图的比例', () => {
diff --git a/scripts/build_entity_thumbs.py b/scripts/build_entity_thumbs.py
index 47ad08d8f..19df0f79b 100644
--- a/scripts/build_entity_thumbs.py
+++ b/scripts/build_entity_thumbs.py
@@ -10,7 +10,7 @@ r"""给已落盘的实体图缩出索引页那一档派生件。
服务端本来就会在第一次请求时现缩,这个脚本只是把那一次挪到没人等的时候:现缩一张
实测 68 ms,一屏一百来张全没缩过的话,第一个打开索引页的人要替后来所有人等这一遍。
-缩法与判据都在 `peach.previews.EntityThumbnailService`,这里只是批量入口;可反复
+缩法与判据都在 `peach.previews.DerivedImageService`,这里只是批量入口;可反复
运行,已经缩好且不比原件旧的默认跳过。派生件缺了不影响显示,页面退回原件。
"""
from __future__ import annotations
@@ -25,7 +25,7 @@ if str(SRC_DIR) not in sys.path:
sys.path.insert(0, str(SRC_DIR))
from peach.config import GENERATED_DIR
-from peach.previews import EntityThumbnailService, entity_thumb_root
+from peach.previews import DerivedImageService, entity_thumb_root
def build_parser() -> argparse.ArgumentParser:
@@ -38,7 +38,7 @@ def build_parser() -> argparse.ArgumentParser:
def run(args: argparse.Namespace) -> int:
# 派生件目录跟着实体图目录走,和服务端同一条推导,不在这里另写一个默认值。
- service = EntityThumbnailService(entity_thumb_root(args.avatars))
+ service = DerivedImageService(entity_thumb_root(args.avatars))
images = sorted(args.avatars.glob("*.img"))
if args.limit:
images = images[:args.limit]
diff --git a/src/peach/api.py b/src/peach/api.py
index 68a84c10f..f98d36c4a 100644
--- a/src/peach/api.py
+++ b/src/peach/api.py
@@ -51,9 +51,12 @@ from .mdns import create_mdns_publisher
from .mp4repair import HeaderRepairStore
from .platform import location_mounts
from .previews import (
- EntityThumbnailService,
+ COVER_THUMB_EDGE,
+ COVER_THUMB_QUALITY,
+ DerivedImageService,
PhotoThumbnailService,
PreviewService,
+ cover_thumb_root,
entity_thumb_root,
)
from .push_discovery import PushDiscoveryService
@@ -185,7 +188,9 @@ def create_app(
settings.avatar_root, settings.logo_root,
)
photo_service = PhotoThumbnailService(settings.photo_root)
- entity_thumb_service = EntityThumbnailService(entity_thumb_root(settings.avatar_root))
+ entity_thumb_service = DerivedImageService(entity_thumb_root(settings.avatar_root))
+ cover_thumb_service = DerivedImageService(cover_thumb_root(settings.cover_root),
+ edge=COVER_THUMB_EDGE, quality=COVER_THUMB_QUALITY)
transcode_service = TranscodeService(resolver, settings.transcode_root)
header_repairs = HeaderRepairStore(settings.transcode_root, resolver)
hls_plan_executor = ThreadPoolExecutor(
@@ -223,8 +228,8 @@ def create_app(
)
contract.follow_scheduler = follow_scheduler
# 订阅源拉取(ADR-0042)用同一个调度实现,只换 job id、状态文件与默认间隔。
- # 默认 6 小时:两类可用来源一天更新几十条,比这更密只是把 JavDB 的配额花在
- # 一张没变的页面上。
+ # 默认 6 小时:一位女优的 JavDB 演员页一天更新几条,比这更密只是把 JavDB 的配额
+ # 花在一张没变的页面上。
feed_scheduler = FollowUpdateScheduler(
settings.follow_state_root,
lambda: web_feeds.w_feed_check(contract, {"automatic": True}),
@@ -315,6 +320,7 @@ def create_app(
app.state.preview_service = preview_service
app.state.photo_service = photo_service
app.state.entity_thumb_service = entity_thumb_service
+ app.state.cover_thumb_service = cover_thumb_service
app.state.transcode_service = transcode_service
app.state.header_repairs = header_repairs
app.state.hls_plan_executor = hls_plan_executor
diff --git a/src/peach/feeds.py b/src/peach/feeds.py
index 137a425b7..78aa0dc7f 100644
--- a/src/peach/feeds.py
+++ b/src/peach/feeds.py
@@ -4,8 +4,8 @@ Feed 只回答一个问题——最近出了哪些番号。一次拉取的全部
的记录和一条「这个番号还没入库」的记录;不下载种子、不下载 enclosure、不建目录、
不碰任何媒体文件。
-解析用标准库 `xml.etree`,不为这件事引 feedparser:这里只需要 RSS 2.0 与 Atom 里的四个
-字段,而多一个依赖要一直跟着升级和审计。代价是日期格式与命名空间得自己认,都在本模块里。
+订阅只有一类:JavDB 演员页当伪 Feed 抓,由人物页的「订阅新作」开关按这位的 JavDB 身份
+现拼地址(ADR-0047)。页面不送地址,所以这里没有「任意地址」这条入口。
**解析只吃已下载的字节**,地址由调用方自己取(`peach.http` 的 transport 加主机限流)。
把地址交给一个会自己发 HTTP 的解析器,等于绕过项目的代理、限流、超时与预算闸门。
@@ -16,25 +16,17 @@ import re
import sqlite3
from dataclasses import dataclass
from datetime import datetime, timedelta, timezone
-from email.utils import parsedate_to_datetime
from urllib.parse import urljoin
-from xml.etree import ElementTree
from .catalog_rules import normalise_code_key, release_code_from_text
from .entities import normalize_entity_name
-#: 原生 RSS/Atom。
-KIND_RSS = "rss"
#: JavDB 演员页当伪 Feed 抓。它按发行日排在前面,所以「还没发行的作品」会先出现。
KIND_JAVDB_ACTOR = "javdb-actor"
-KINDS = (KIND_RSS, KIND_JAVDB_ACTOR)
-KIND_LABELS = {KIND_RSS: "RSS / Atom", KIND_JAVDB_ACTOR: "JavDB 演员页"}
+KIND_LABELS = {KIND_JAVDB_ACTOR: "JavDB 演员页"}
-#: 拉取间隔的上下界。下界 30 分钟不是性能考虑:JavDB 按出口 IP 计配额,比这更密只会
-#: 把配额花在一个一天才更新几条的页面上。
-MIN_INTERVAL_MINUTES = 30
-MAX_INTERVAL_MINUTES = 7 * 24 * 60
+#: 拉取间隔。JavDB 按出口 IP 计配额,一张一天才更新几条的页面拉得再密也只是花配额。
DEFAULT_INTERVAL_MINUTES = 360
#: 一次拉取最多解析多少条。源正常一页几十条,异常的那种(被替换成别的页面、
@@ -45,10 +37,8 @@ MAX_ENTRIES = 200
#: 这里先截一刀是为了让第一次订阅不至于把整页历史都排成任务。
MAX_NEW_PER_POLL = 20
-_ATOM = "{http://www.w3.org/2005/Atom}"
-
-#: 切词元用的分隔符。标题里的番号被中文剧情简介夹着,整段丢给
-#: `release_code_from_text` 认不出来(2026-09-22 实测 sukebei 75 条里只认出 3 条)。
+#: 切词元用的分隔符。标题里的番号被剧情简介夹着时,整段丢给
+#: `release_code_from_text` 认不出来(2026-09-22 实测一份种子站标题 75 条里只认出 3 条)。
_TOKEN = re.compile(r"[^\s\[\]()()【】{}、,,/|_+]+")
#: JavDB 演员页的一部作品:`/v/<id>` 是条目身份,`<strong>` 里是干净的番号,
@@ -106,86 +96,20 @@ class ParsedFeed:
entries: tuple[FeedEntry, ...]
-def _text(node, *paths: str) -> str | None:
- for path in paths:
- value = node.findtext(path)
- if isinstance(value, str) and value.strip():
- return value.strip()
- return None
-
-
-def _as_utc(moment: datetime) -> str:
- """没带时区的时间按 UTC 读,不按本机时区。
-
- 两种来源都会给出这种值:RSS 的 `-0000` 按 RFC 5322 表示「时区未知」,
- `parsedate_to_datetime` 于是返回 naive;JavDB 的 `.meta` 只有一个日期。
- naive 值交给 `astimezone` 会被当成本机时间,于是同一份 feed 在 UTC+8 的机器上
- 整体前移八小时——发行日 2026-10-20 变成 10-19,而排序和「这一天发了什么」都按它算。
- """
- return stamp(moment if moment.tzinfo is not None
- else moment.replace(tzinfo=timezone.utc))
-
-
-def _published(value: str | None) -> str | None:
- """RSS 的 RFC 822 与 Atom 的 ISO-8601 都认,认不出就当没有。
+def _published(value: str) -> str | None:
+ """`.meta` 里的发行日按 UTC 零点读,认不出就当没有。
+ 它只有日期、没有时区。按本机时区读的话,同一页在 UTC+8 的机器上整体前移八小时,
+ 发行日 2026-10-20 变成 10-19,而排序和「这一天发了什么」都按它算。
发布时间是排序真值:拿不到它才回退到首次见到的时间。把认不出的日期当成「现在」
会让一整页历史条目全部挤在同一秒,那之后就再也分不出先后了。
"""
- if not value:
- return None
- raw = value.strip()
try:
- return _as_utc(parsedate_to_datetime(raw))
- except (TypeError, ValueError):
- pass
- try:
- return _as_utc(datetime.fromisoformat(raw.replace("Z", "+00:00")))
+ return stamp(datetime.fromisoformat(value).replace(tzinfo=timezone.utc))
except ValueError:
return None
-def parse_feed(body: bytes) -> ParsedFeed | None:
- """RSS 2.0 或 Atom 的字节 → 条目。不是 feed 时返回 None。
-
- 条目为空但文档本身合法不算失败:源这一刻确实没有新东西。
- """
- if not body or not body.strip():
- return None
- try:
- root = ElementTree.fromstring(body)
- except ElementTree.ParseError:
- return None
- tag = root.tag.split("}")[-1]
- rows: list[FeedEntry] = []
- if tag == "rss":
- channel = root.find("channel")
- if channel is None:
- return None
- for item in channel.findall("item")[:MAX_ENTRIES]:
- title = _text(item, "title") or ""
- link = _text(item, "link")
- key = _text(item, "guid") or link or title
- if not key:
- continue
- rows.append(FeedEntry(key, title, link,
- _published(_text(item, "pubDate"))))
- return ParsedFeed(_text(channel, "title"), tuple(rows))
- if tag == "feed":
- for item in root.findall(f"{_ATOM}entry")[:MAX_ENTRIES]:
- title = _text(item, f"{_ATOM}title") or ""
- anchor = item.find(f"{_ATOM}link")
- link = anchor.get("href") if anchor is not None else None
- key = _text(item, f"{_ATOM}id") or link or title
- if not key:
- continue
- rows.append(FeedEntry(key, title, link,
- _published(_text(item, f"{_ATOM}published",
- f"{_ATOM}updated"))))
- return ParsedFeed(_text(root, f"{_ATOM}title"), tuple(rows))
- return None
-
-
def parse_javdb_actor(html: str, base_url: str) -> ParsedFeed | None:
"""JavDB 演员页 → 条目。一条作品都解不出时返回 None。
@@ -209,9 +133,10 @@ def parse_javdb_actor(html: str, base_url: str) -> ParsedFeed | None:
def parse(kind: str, body: bytes, url: str) -> ParsedFeed | None:
+ """认不出的类型当解析失败,原因落到那一行的 `last_error` 上。"""
if kind == KIND_JAVDB_ACTOR:
return parse_javdb_actor(body.decode("utf-8", "replace"), url)
- return parse_feed(body)
+ return None
# -- 订阅 ------------------------------------------------------------------
@@ -220,9 +145,8 @@ def parse(kind: str, body: bytes, url: str) -> ParsedFeed | None:
def normalize_url(value: object) -> str:
"""订阅地址只收 HTTPS。
- 明文地址在这里没有可用的场景:两类可用来源都是 HTTPS,而 Feed 拉回来的东西会直接
- 变成用户看见的新作——中途被改写的内容没有任何一步会被察觉。地址解析到内网的那一层
- 由 `http.public_https_url` 在真正发请求时挡住。
+ JavDB 是 HTTPS,而 Feed 拉回来的东西会直接变成用户看见的新作——中途被改写的内容
+ 没有任何一步会被察觉。地址解析到内网的那一层由 `http.public_https_url` 在真正发请求时挡住。
"""
url = str(value or "").strip()
if not url.startswith("https://"):
@@ -230,40 +154,24 @@ def normalize_url(value: object) -> str:
return url
-def normalize_interval(value: object) -> int:
- try:
- minutes = int(value)
- except (TypeError, ValueError) as error:
- raise ValueError("拉取间隔必须是整数分钟") from error
- if not MIN_INTERVAL_MINUTES <= minutes <= MAX_INTERVAL_MINUTES:
- raise ValueError(
- f"拉取间隔必须在 {MIN_INTERVAL_MINUTES} 到 {MAX_INTERVAL_MINUTES} 分钟之间")
- return minutes
-
-
-def add_source(connection: sqlite3.Connection, *, kind: str, url: str, name: str = "",
- entity_id: int | None = None,
- interval_minutes: int = DEFAULT_INTERVAL_MINUTES,
- enabled: bool = True) -> int:
- """登记一条订阅。地址重复直接拒绝——同一个源订两遍只会让同一条新作出现两次。"""
- if kind not in KINDS:
- raise ValueError(f"认不出这种订阅源:{kind}")
+def add_source(connection: sqlite3.Connection, *, url: str, name: str = "",
+ entity_id: int | None = None) -> int:
+ """登记一条 JavDB 演员页订阅。地址重复直接拒绝——同一个源订两遍只会让同一条新作出现两次。"""
address = normalize_url(url)
- minutes = normalize_interval(interval_minutes)
if connection.execute("SELECT 1 FROM feed_source WHERE url=?", (address,)).fetchone():
raise ValueError("这个订阅地址已经在列表里了")
cursor = connection.execute(
"INSERT INTO feed_source(kind,name,url,entity_id,enabled,interval_minutes,"
- "created_at) VALUES(?,?,?,?,?,?,?)",
- (kind, str(name or "").strip(), address, entity_id, 1 if enabled else 0,
- minutes, stamp()))
+ "created_at) VALUES(?,?,?,?,1,?,?)",
+ (KIND_JAVDB_ACTOR, str(name or "").strip(), address, entity_id,
+ DEFAULT_INTERVAL_MINUTES, stamp()))
return int(cursor.lastrowid)
def follow_entity(connection: sqlite3.Connection, entity_id: int, urls) -> list[int]:
"""人物页那枚开关打开:这位的每个 JavDB 演员页各一条源,全部启用。
- 地址已经登记过的(设置页手动加过、或者之前关掉过)原地启用并补上人物,不另建一条:
+ 地址已经登记过的(之前关掉过,或者登记时还没挂上人物)原地启用并补上人物,不另建一条:
`feed_item` 的去重记忆挂在那条源上,重建一条等于让整页历史再被当成新作一遍。
"""
ids: list[int] = []
@@ -272,7 +180,7 @@ def follow_entity(connection: sqlite3.Connection, entity_id: int, urls) -> list[
row = connection.execute(
"SELECT id FROM feed_source WHERE url=?", (address,)).fetchone()
if row is None:
- ids.append(add_source(connection, kind=KIND_JAVDB_ACTOR, url=address,
+ ids.append(add_source(connection, url=address,
entity_id=int(entity_id)))
continue
connection.execute(
diff --git a/src/peach/previews.py b/src/peach/previews.py
index d84f0f874..1abb87790 100644
--- a/src/peach/previews.py
+++ b/src/peach/previews.py
@@ -397,24 +397,46 @@ def entity_thumb_root(avatar_root: Path) -> Path:
return avatar_root.parent / "avatar-thumbs"
-class EntityThumbnailService:
- """实体图的索引页派生件。
+#: 卡片网格那一档封面的长边上限。封面按正封取景,图宽约是卡宽的两倍:桌面一列
+#: 200–250 CSS px,二倍屏要 800–1000 设备像素,1600 盖得住,也仍比馆里普通封面的
+#: 1024 宽。高清封面原件 3762×2535、单张 8–10 MB,解码一张就是 38 MB:一页几十张
+#: 挤爆解码缓存,来回滚动时滚走的被清掉、滚回来现解,那一段就是空白。这一档实测
+#: 一张 429 KB、解码约 7 MB,首次现缩约 0.35 秒。这一档只在它的像素铺满屏幕还有富余时
+#: 才被留用(页面按实际显示尺寸决定要不要换回原件),画质取 90 而不是实体图的 80。
+#: 原件不另转 WebP:原尺寸那一份能小到六分之一,解码却慢 2.5 倍,滚回来等的正是解码。
+COVER_THUMB_EDGE = 1600
+COVER_THUMB_QUALITY = 90
+
+
+def cover_thumb_root(cover_root: Path) -> Path:
+ """封面派生件的目录:封面目录旁边那一个,理由同 `entity_thumb_root`。
+
+ 不放进封面目录本身:`web_state.cover_index` 逐次扫它来判「这个番号有没有封面」。
+ """
+ return cover_root.parent / "cover-thumbs"
+
+
+class DerivedImageService:
+ """原件的缩小派生件:实体图给索引页,封面给卡片网格。
实体图是给资料页大位存的高清照片,本库 727 张合计 157 MB、均 221 KB;索引页把它
铺进 150 px 的格子,一屏 120 格就是二十多 MB,而屏幕上只要其中百分之几的像素。
- 所以索引页取的是这里缩好的一份,资料页照旧取原件。
+ 所以索引页取的是这里缩好的一份,资料页照旧取原件。封面同理,详情与裁切取原件。
- 落在自己的目录而不是 `avatar_root`:那个目录被 `web_state._scan_avatar_root` 逐次
- 扫描用来判「这个实体有没有图」,往里塞一倍数量的派生件等于给每次扫描加一倍成本。
- 目录由 `entity_thumb_root` 从实体图目录推出来,接线处不各写一份默认值。
+ 落在自己的目录而不是原件目录:`web_state._scan_avatar_root` 与 `cover_index` 逐次
+ 扫描原件目录来判「有没有图」,往里塞一倍数量的派生件等于给每次扫描加一倍成本。
+ 目录由 `entity_thumb_root` 与 `cover_thumb_root` 从原件目录推出来,接线处不各写
+ 一份默认值。
- 换头像会原子替换原件,所以派生件按原件的修改时间复验:比原件旧就重做一张。
+ 换头像、换封面都会原子替换原件,所以派生件按原件的修改时间复验:比原件旧就重做一张。
只比时间不比内容——复核批准落地时原件必然变新,而人手摆进去的文件也带自己的时间。
"""
- def __init__(self, root: Path, edge: int = ENTITY_THUMB_EDGE):
+ def __init__(self, root: Path, edge: int = ENTITY_THUMB_EDGE,
+ quality: int = ENTITY_THUMB_QUALITY):
self.root = root.resolve()
self.edge = edge
+ self.quality = quality
def path_for(self, key: str) -> Path:
return self.root / f"{key}.{self.edge}.webp"
@@ -444,7 +466,7 @@ class EntityThumbnailService:
# `thumbnail` 只缩不放:本来就比这一档小的图原样重编码,不上采样。
image.thumbnail((self.edge, self.edge), Image.LANCZOS)
image.save(temporary, ENTITY_THUMB_FORMAT,
- quality=ENTITY_THUMB_QUALITY, method=4)
+ quality=self.quality, method=4)
except (OSError, ValueError, Image.DecompressionBombError,
Image.UnidentifiedImageError):
return None
diff --git a/src/peach/routes_media.py b/src/peach/routes_media.py
index 4abe7d8b5..205fa0e1c 100644
--- a/src/peach/routes_media.py
+++ b/src/peach/routes_media.py
@@ -484,11 +484,20 @@ def timeline(request: Request, id: int, s: int = 0, args: dict[str, str] = Depen
@router.api_route("/cover", methods=["GET", "HEAD"])
-def cover(request: Request, code: str = "", args: dict[str, str] = Depends(require_auth)):
- """官方封套原图。存原图不裁:4:3 与 16:9 两种版式在界面上按比例取景。"""
+def cover(request: Request, code: str = "", thumb: int = 0,
+ args: dict[str, str] = Depends(require_auth)):
+ """官方封套原图。存原图不裁:4:3 与 16:9 两种版式在界面上按比例取景。
+
+ `thumb=1` 要的是卡片网格那一档派生件(`COVER_THUMB_EDGE`),详情与裁切取原件。
+ 开关是布尔而不是像素数,理由同 `/entity-image`。
+ """
path = request.app.state.web_contract.cover_path(code)
if path is None:
return JSONResponse({"error": "no cover"}, status_code=404)
+ if thumb:
+ derived = request.app.state.cover_thumb_service.thumbnail(path.stem, path)
+ if derived is not None:
+ return _image_response(request, derived, media_type=ENTITY_THUMB_TYPE)
return _image_response(request, path, media_type="image/jpeg")
diff --git a/src/peach/web_feeds.py b/src/peach/web_feeds.py
index cafe90015..f0d4fa4a7 100644
--- a/src/peach/web_feeds.py
+++ b/src/peach/web_feeds.py
@@ -15,8 +15,8 @@ from . import entities, entry_links, feed_followup, feeds
from .jobs import TaskRunConflict
from .http import HttpRequest, public_https_url
-#: 一次拉取的超时与体积上限。一份 RSS 正常几十到几百 KB;JavDB 演员页 78 KB。
-#: 2 MiB 之外的东西不是 feed,是被替换成了别的页面。
+#: 一次拉取的超时与体积上限。JavDB 演员页 78 KB;2 MiB 之外的东西不是演员页,
+#: 是被替换成了别的页面。
FETCH_TIMEOUT = 30.0
FETCH_MAX_BYTES = 2 * 1024 * 1024
@@ -40,8 +40,7 @@ def fetch(transport, url: str, *, etag: str | None = None,
"""取一次订阅地址。304 不是失败,原样交给调用方判。"""
if not public_https_url(url):
raise ValueError("订阅地址必须是解析到公网的 HTTPS 地址")
- headers = {"Accept": "application/rss+xml, application/atom+xml, application/xml,"
- " text/xml;q=0.9, text/html;q=0.8"}
+ headers = {"Accept": "text/html"}
if etag:
headers["If-None-Match"] = etag
if last_modified:
@@ -182,16 +181,15 @@ def q_feeds(contract, args) -> dict:
pending = connection.execute(
"SELECT count(*) FROM feed_discovery WHERE ignored_at IS NULL"
" AND read_at IS NULL").fetchone()[0]
- return {"ok": True, "sources": rows, "unread": int(pending or 0),
- "kinds": [{"value": kind, "label": feeds.KIND_LABELS[kind]}
- for kind in feeds.KINDS],
- "min_interval_minutes": feeds.MIN_INTERVAL_MINUTES,
- "max_interval_minutes": feeds.MAX_INTERVAL_MINUTES}
+ return {"ok": True, "sources": rows, "unread": int(pending or 0)}
def w_feed_source(contract, body) -> dict:
- """增删订阅与开关。新增不当场拉取:第一轮由到期扫描带上,错误显示在那一行。"""
- action = str(body.get("action") or "add")
+ """订阅的移除与开关,以及人物页的「订阅新作」。
+
+ 这里不收页面送来的地址:订阅只从人物页进,地址由服务端按这位的 JavDB 身份现拼(ADR-0047)。
+ """
+ action = str(body.get("action") or "")
if action == "remove":
source_id = body.get("id")
if not isinstance(source_id, int):
@@ -208,16 +206,7 @@ def w_feed_source(contract, body) -> dict:
return {"ok": True, "source": source_id, "enabled": enabled}
if action == "follow":
return _follow_entity(contract, body)
- if action != "add":
- raise ValueError(f"unknown feed source action: {action}")
- entity_id = body.get("entity_id")
- with contract.database.write_transaction() as connection:
- source_id = feeds.add_source(
- connection, kind=str(body.get("kind") or feeds.KIND_RSS),
- url=body.get("url"), name=str(body.get("name") or ""),
- entity_id=int(entity_id) if isinstance(entity_id, int) else None,
- interval_minutes=body.get("interval_minutes", feeds.DEFAULT_INTERVAL_MINUTES))
- return {"ok": True, "source": source_id}
+ raise ValueError(f"unknown feed source action: {action}")
def _follow_entity(contract, body) -> dict:
diff --git a/tests/test_fastapi_api.py b/tests/test_fastapi_api.py
index 69961c16b..f3dce215c 100644
--- a/tests/test_fastapi_api.py
+++ b/tests/test_fastapi_api.py
@@ -1,5 +1,6 @@
import csv
import importlib.util
+import io
import json
import sqlite3
import tempfile
@@ -2220,6 +2221,33 @@ class FastApiContractTests(unittest.IsolatedAsyncioTestCase):
full = await self.client.get("/photo?id=9", headers=headers)
self.assertEqual(full.content, source.read_bytes())
+ async def test_the_card_grade_cover_is_a_smaller_webp_beside_the_cover_directory(self):
+ """卡片网格取 `/cover?thumb=1`,详情与裁切取原件。
+
+ 派生件不进封面目录:`cover_index` 逐次扫它判「有没有封面」,混进派生件就多判一倍。
+ """
+ from PIL import Image
+
+ self.cover_root.mkdir(parents=True, exist_ok=True)
+ source = self.cover_root / "ABC-123.jpg"
+ image = Image.new("RGB", (2400, 1620), (200, 120, 90))
+ # 纯色图压出来只有几百字节,比不出「缩了没有」。噪声让体积跟着像素量走。
+ for y in range(0, 1620, 4):
+ for x in range(0, 2400, 4):
+ image.putpixel((x, y), ((x * 7) % 256, (y * 13) % 256, (x + y) % 256))
+ image.save(source, "JPEG", quality=95)
+ headers = {"X-Token": "secret"}
+ card = await self.client.get("/cover?code=ABC-123&thumb=1", headers=headers)
+ self.assertEqual(card.status_code, 200)
+ self.assertEqual(card.headers["content-type"], "image/webp")
+ self.assertLess(len(card.content), source.stat().st_size)
+ with Image.open(io.BytesIO(card.content)) as derived:
+ self.assertEqual(derived.size, (1600, 1080))
+ self.assertEqual(sorted(path.name for path in self.cover_root.iterdir()), ["ABC-123.jpg"])
+ self.assertTrue(any((self.cover_root.parent / "cover-thumbs").iterdir()))
+ full = await self.client.get("/cover?code=ABC-123", headers=headers)
+ self.assertEqual(full.content, source.read_bytes())
+
async def test_a_warm_photo_thumbnail_answers_without_resolving_the_original(self):
"""缩略图已经躺在本地时,这条路径不再去解析原图。
diff --git a/tests/test_feeds.py b/tests/test_feeds.py
index c5e597575..8bf6833f3 100644
--- a/tests/test_feeds.py
+++ b/tests/test_feeds.py
@@ -15,40 +15,6 @@ from peach.repository import LedgerDatabase # noqa: E402
MIGRATIONS = Path(__file__).resolve().parents[1] / "migrations"
-RSS = b"""<?xml version="1.0" encoding="UTF-8"?>
-<rss version="2.0"><channel>
- <title>Sukebei - Home - Torrent File RSS</title>
- <item>
- <title>HMN-071 \xe6\x96\xb0\xe4\xba\xba \xe6\x88\xb6\xe5\xb7\x9d\xe6\xad\xa5[\xe6\x9c\x89\xe7\xa2\xbc]</title>
- <link>https://sukebei.nyaa.si/download/4719097.torrent</link>
- <guid>https://sukebei.nyaa.si/view/4719097</guid>
- <pubDate>Tue, 22 Sep 2026 10:36:13 -0000</pubDate>
- </item>
- <item>
- <title>[H265 1080p] DSOD-114 \xe8\x8a\xb1\xe5\xae\xae\xe4\xba\xac\xe5\xad\x90</title>
- <link>https://sukebei.nyaa.si/download/4719080.torrent</link>
- <guid>https://sukebei.nyaa.si/view/4719080</guid>
- <pubDate>Tue, 22 Sep 2026 09:12:00 -0000</pubDate>
- </item>
- <item>
- <title>\xe5\x90\x88\xe9\x9b\x86 30 \xe9\x83\xa8\xe6\x89\x93\xe5\x8c\x85</title>
- <link>https://sukebei.nyaa.si/download/4719001.torrent</link>
- <guid>https://sukebei.nyaa.si/view/4719001</guid>
- <pubDate>Tue, 22 Sep 2026 08:00:00 -0000</pubDate>
- </item>
-</channel></rss>"""
-
-ATOM = b"""<?xml version="1.0" encoding="UTF-8"?>
-<feed xmlns="http://www.w3.org/2005/Atom">
- <title>example</title>
- <entry>
- <id>tag:example,2026:1</id>
- <title>SSIS-950 sample</title>
- <link href="https://example.test/a"/>
- <published>2026-09-20T03:00:00Z</published>
- </entry>
-</feed>"""
-
JAVDB_ACTOR = """
<div class="movie-list h cols-4 vcols-8">
<div class="item">
@@ -70,6 +36,15 @@ JAVDB_ACTOR = """
</div>
</a>
</div>
+ <div class="item">
+ <a href="/v/Zx9Qa1" class="box" title="ignored">
+ <div class="cover"><img src="z.jpg" /></div>
+ <div class="video-title"><strong></strong> 合集 30 部打包</div>
+ <div class="meta">
+ 2026-10-01
+ </div>
+ </a>
+ </div>
</div>
"""
@@ -81,27 +56,6 @@ def _database(root: Path) -> LedgerDatabase:
class FeedParsingTest(unittest.TestCase):
- def test_rss_entries_take_guid_as_item_key(self):
- parsed = feeds.parse_feed(RSS)
- self.assertIsNotNone(parsed)
- self.assertEqual(parsed.title, "Sukebei - Home - Torrent File RSS")
- self.assertEqual([entry.item_key for entry in parsed.entries],
- ["https://sukebei.nyaa.si/view/4719097",
- "https://sukebei.nyaa.si/view/4719080",
- "https://sukebei.nyaa.si/view/4719001"])
- self.assertEqual(parsed.entries[0].published_at, "2026-09-22T10:36:13.000Z")
-
- def test_atom_entries_take_id_and_link(self):
- parsed = feeds.parse_feed(ATOM)
- self.assertEqual(len(parsed.entries), 1)
- self.assertEqual(parsed.entries[0].item_key, "tag:example,2026:1")
- self.assertEqual(parsed.entries[0].link, "https://example.test/a")
- self.assertEqual(parsed.entries[0].code, "SSIS-950")
-
- def test_not_a_feed_is_none(self):
- self.assertIsNone(feeds.parse_feed(b"<html><body>hi</body></html>"))
- self.assertIsNone(feeds.parse_feed(b""))
-
def test_code_is_found_inside_a_title_full_of_prose(self):
# 整段丢给 `release_code_from_text` 认不出来,词元扫描才认得出。
title = "HMN-071 新人 帶來超稀有妹子 戶川步[有碼高清中文字幕]"
@@ -112,10 +66,16 @@ class FeedParsingTest(unittest.TestCase):
def test_javdb_actor_page_reads_code_and_release_date(self):
parsed = feeds.parse_javdb_actor(JAVDB_ACTOR, "https://javdb.com/actors/pRMq")
self.assertEqual([entry.item_key for entry in parsed.entries],
- ["/v/5nr8mp", "/v/RkPb5z"])
+ ["/v/5nr8mp", "/v/RkPb5z", "/v/Zx9Qa1"])
self.assertEqual(parsed.entries[0].code, "PBD-528")
self.assertEqual(parsed.entries[0].link, "https://javdb.com/v/5nr8mp")
self.assertEqual(parsed.entries[0].published_at, "2026-10-20T00:00:00.000Z")
+ self.assertIsNone(parsed.entries[2].code)
+
+ def test_an_unknown_kind_is_a_parse_failure(self):
+ # 账本里若留着别的类型,拉取把原因写在那一行上,不拿演员页的解析器硬读。
+ self.assertIsNone(feeds.parse("rss", JAVDB_ACTOR.encode("utf-8"),
+ "https://example.test/rss"))
def test_a_page_without_any_work_is_a_failure_not_an_empty_poll(self):
# 带查询串的演员页会回一份不含作品的页面。当成「这次没有新作」会让一个坏掉的
@@ -133,12 +93,12 @@ class FeedStoreTest(unittest.TestCase):
def _source(self, **kwargs) -> int:
with self.database.write_transaction() as connection:
- return feeds.add_source(connection, kind=feeds.KIND_RSS,
- url=kwargs.pop("url", "https://example.test/rss"),
+ return feeds.add_source(connection,
+ url=kwargs.pop("url", "https://javdb.com/actors/pRMq"),
**kwargs)
- def _poll(self, source_id: int, body: bytes = RSS) -> dict:
- parsed = feeds.parse_feed(body)
+ def _poll(self, source_id: int) -> dict:
+ parsed = feeds.parse_javdb_actor(JAVDB_ACTOR, "https://javdb.com/actors/pRMq")
with self.database.write_transaction() as connection:
source = connection.execute("SELECT * FROM feed_source WHERE id=?",
(source_id,)).fetchone()
@@ -161,7 +121,7 @@ class FeedStoreTest(unittest.TestCase):
# 解不出番号的条目照样记一行,只是不建壳。
self.assertEqual(outcome["without_code"], 1)
self.assertEqual(sorted(code for _id, code in outcome["created"]),
- ["DSOD-114", "HMN-071"])
+ ["BBSS-106", "PBD-528"])
with self.database.read_connection() as connection:
self.assertEqual(connection.execute(
"SELECT count(*) FROM feed_item").fetchone()[0], 3)
@@ -174,8 +134,8 @@ class FeedStoreTest(unittest.TestCase):
self.assertEqual(outcome["created"], [])
def test_two_sources_reporting_one_code_share_a_single_shell(self):
- first = self._source(url="https://example.test/a.xml")
- second = self._source(url="https://example.test/b.xml")
+ first = self._source(url="https://javdb.com/actors/pRMq")
+ second = self._source(url="https://javdb.com/actors/d45k9")
self._poll(first)
outcome = self._poll(second)
# 源内那一层是各自的,所以第二个源仍然把三条都记成新条目……
@@ -192,11 +152,11 @@ class FeedStoreTest(unittest.TestCase):
with self.database.write_transaction() as connection:
connection.execute(
"INSERT INTO asset(location,path,name,medium,code) "
- "VALUES('R','R:\\\\media\\\\hmn071.mp4','hmn071.mp4','video','hmn00071')")
+ "VALUES('R','R:\\\\media\\\\pbd528.mp4','pbd528.mp4','video','pbd00528')")
source_id = self._source()
outcome = self._poll(source_id)
- # 归一化之后 `hmn00071` 与 `HMN-071` 是同一部片。
- self.assertEqual([code for _id, code in outcome["created"]], ["DSOD-114"])
+ # 归一化之后 `pbd00528` 与 `PBD-528` 是同一部片。
+ self.assertEqual([code for _id, code in outcome["created"]], ["BBSS-106"])
def test_read_and_ignore_are_independent_and_do_not_touch_dedupe(self):
source_id = self._source()
@@ -222,7 +182,7 @@ class FeedStoreTest(unittest.TestCase):
self.assertIsNotNone(row["ignored_at"])
def test_settle_writes_the_next_time_on_every_path(self):
- source_id = self._source(interval_minutes=60)
+ source_id = self._source()
with self.database.write_transaction() as connection:
feeds.settle(connection, source_id, error="来源回了 HTTP 503",
interval_minutes=60)
@@ -259,13 +219,16 @@ class ShellBoundaryTest(unittest.TestCase):
self.database = _database(Path(self._tmp.name))
self.addCleanup(self._tmp.cleanup)
+ def _poll_once(self, connection) -> int:
+ source_id = feeds.add_source(connection, url="https://javdb.com/actors/pRMq")
+ feeds.poll(connection, connection.execute(
+ "SELECT * FROM feed_source WHERE id=?", (source_id,)).fetchone(),
+ feeds.parse_javdb_actor(JAVDB_ACTOR, "https://javdb.com/actors/pRMq"))
+ return source_id
+
def test_a_shell_adds_no_asset_row(self):
with self.database.write_transaction() as connection:
- source_id = feeds.add_source(connection, kind=feeds.KIND_RSS,
- url="https://example.test/rss")
- feeds.poll(connection, connection.execute(
- "SELECT * FROM feed_source WHERE id=?", (source_id,)).fetchone(),
- feeds.parse_feed(RSS))
+ self._poll_once(connection)
with self.database.read_connection() as connection:
self.assertEqual(connection.execute(
"SELECT count(*) FROM asset").fetchone()[0], 0)
@@ -282,12 +245,7 @@ class ShellBoundaryTest(unittest.TestCase):
# 壳是「这个番号还没入库」,它不该随着某个订阅被删而消失。
with self.database.write_transaction() as connection:
connection.execute("PRAGMA foreign_keys=ON")
- source_id = feeds.add_source(connection, kind=feeds.KIND_RSS,
- url="https://example.test/rss")
- feeds.poll(connection, connection.execute(
- "SELECT * FROM feed_source WHERE id=?", (source_id,)).fetchone(),
- feeds.parse_feed(RSS))
- feeds.remove_source(connection, source_id)
+ feeds.remove_source(connection, self._poll_once(connection))
with self.database.read_connection() as connection:
self.assertEqual(connection.execute(
"SELECT count(*) FROM feed_item").fetchone()[0], 0)
diff --git a/tests/test_feeds_web.py b/tests/test_feeds_web.py
index e3a48c3e4..672d955bb 100644
--- a/tests/test_feeds_web.py
+++ b/tests/test_feeds_web.py
@@ -20,28 +20,16 @@ from support.ledger import fresh_ledger # noqa: E402
#: 端到端那一趟读的是临时数据根里的这份文件:拉取只吃已下载的字节,
#: 字节从网络来还是从盘上来与解析、去重、建壳那几步无关。
-SAMPLE = """<?xml version="1.0" encoding="UTF-8"?>
-<rss version="2.0"><channel>
- <title>示例新作</title>
- <item>
- <title>SSIS-950 作品标题</title>
- <link>https://feeds.example.test/view/2</link>
- <guid>https://feeds.example.test/view/2</guid>
- <pubDate>Mon, 21 Sep 2026 03:00:00 +0000</pubDate>
- </item>
- <item>
- <title>HMN-071 另一部作品[有碼高清中文字幕]</title>
- <link>https://feeds.example.test/view/1</link>
- <guid>https://feeds.example.test/view/1</guid>
- <pubDate>Sun, 20 Sep 2026 03:00:00 +0000</pubDate>
- </item>
- <item>
- <title>合集 30 部打包</title>
- <link>https://feeds.example.test/view/0</link>
- <guid>https://feeds.example.test/view/0</guid>
- <pubDate>Sat, 19 Sep 2026 03:00:00 +0000</pubDate>
- </item>
-</channel></rss>
+SAMPLE = """
+<a href="/v/Ab2" class="box" title="x"><div class="video-title"><strong>SSIS-950</strong>
+ 作品标题</div><div class="meta">
+ 2026-09-21</div></a>
+<a href="/v/Ab1" class="box" title="x"><div class="video-title"><strong>HMN-071</strong>
+ 另一部作品</div><div class="meta">
+ 2026-09-20</div></a>
+<a href="/v/Ab0" class="box" title="x"><div class="video-title"><strong></strong>
+ 合集 30 部打包</div><div class="meta">
+ 2026-09-19</div></a>
"""
@@ -70,11 +58,11 @@ class FeedWebFixture(unittest.TestCase):
# assert 之后才写完,也可能在临时目录删掉之后才醒。这里关掉自动领取,
# 要跑后继的用例自己 `drain()`。
self.contract.followups.stop()
- self.url = "https://feeds.example.test/new.xml"
- sample = Path(self.temporary.name) / "feed-sample.xml"
+ self.url = "https://javdb.com/actors/Smp1"
+ sample = Path(self.temporary.name) / "feed-sample.html"
sample.write_text(SAMPLE, encoding="utf-8")
self.transport = FakeTransport({self.url: HttpResponse(
- 200, {"ETag": 'W/"abc"', "Content-Type": "application/xml"},
+ 200, {"ETag": 'W/"abc"', "Content-Type": "text/html"},
sample.read_bytes(), self.url)})
self._patched = web_feeds.fetch
web_feeds.fetch = self._fetch
@@ -115,10 +103,10 @@ class FeedWebFixture(unittest.TestCase):
from peach.http import HttpRequest
return transport(HttpRequest("GET", url, headers), 30.0, 1 << 21)
- def _add(self, **body):
- return dispatch_api_post(self.contract, "/api/feeds/source",
- {"action": "add", "url": self.url, "name": "示例源",
- **body})
+ def _add(self, entity_id=None):
+ with self.contract.database.write_transaction() as connection:
+ return feeds.add_source(connection, url=self.url, name="示例源",
+ entity_id=entity_id)
def _check(self, **body):
original = web_feeds._transport
@@ -130,14 +118,20 @@ class FeedWebFixture(unittest.TestCase):
class FeedWebTest(FeedWebFixture):
- def test_settings_snapshot_lists_the_source_and_its_kinds(self):
+ def test_settings_snapshot_lists_the_source(self):
self._add()
snapshot = dispatch_api_get(self.contract, "/api/feeds", {})
self.assertEqual(len(snapshot["sources"]), 1)
self.assertEqual(snapshot["sources"][0]["name"], "示例源")
+ self.assertEqual(snapshot["sources"][0]["kind_label"], "JavDB 演员页")
self.assertTrue(snapshot["sources"][0]["enabled"])
- self.assertEqual([kind["value"] for kind in snapshot["kinds"]],
- list(feeds.KINDS))
+
+ def test_the_source_endpoint_takes_no_address_from_the_page(self):
+ # 订阅只从人物页进,地址由服务端现拼(ADR-0047);页面送来的地址一律不收。
+ with self.assertRaises(ValueError):
+ dispatch_api_post(self.contract, "/api/feeds/source",
+ {"action": "add", "url": "https://example.test/rss"})
+ self.assertEqual(dispatch_api_get(self.contract, "/api/feeds", {})["sources"], [])
def test_one_round_turns_a_local_feed_into_unfiled_new_releases(self):
self._add()
@@ -419,9 +413,9 @@ class PerformerFeedSwitchTest(FeedWebFixture):
self.assertEqual(again["id"], paused["id"])
self.assertTrue(again["enabled"])
- def test_a_page_added_by_hand_is_adopted_instead_of_duplicated(self):
- dispatch_api_post(self.contract, "/api/feeds/source", {
- "action": "add", "kind": feeds.KIND_JAVDB_ACTOR, "url": self.page})
+ def test_a_listed_page_without_a_person_is_adopted_instead_of_duplicated(self):
+ with self.contract.database.write_transaction() as connection:
+ feeds.add_source(connection, url=self.page)
self._switch(True)
self._settled()
[source] = self._sources()
diff --git a/tests/test_previews.py b/tests/test_previews.py
index 431bdd7e2..d66cd2972 100644
--- a/tests/test_previews.py
+++ b/tests/test_previews.py
@@ -367,7 +367,7 @@ class EntityThumbnailTests(unittest.TestCase):
self.tmp = tempfile.TemporaryDirectory()
root = Path(self.tmp.name).resolve()
self.source = root / "performer-11.img"
- self.service = previews.EntityThumbnailService(root / "thumbs")
+ self.service = previews.DerivedImageService(root / "thumbs")
self.write_source(1600, 2000)
def tearDown(self):
diff --git a/tests/test_web_ui.py b/tests/test_web_ui.py
index 01d775c1d..a17bde2e8 100644
--- a/tests/test_web_ui.py
+++ b/tests/test_web_ui.py
@@ -2871,9 +2871,9 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains("if(img.dataset.frame!=='sleeve')return;")
# 没有框就一个字都不写,CSS 里那份贴右缘的回退照旧生效。
self.assertPageContains("if(!frame)return;")
- # 框按那一版源图算;封面被更大的那张换掉之后,它描述的是另一张图。
+ # 框按那一版源图算:等比缩小的派生档照用,封面被另一张换掉之后它描述的是另一张图。
self.assertPageContains(
- "if(!matchesFaceSource(img.naturalWidth,img.naturalHeight,imgW,imgH))return;")
+ "if(!faceSourceScale(img.naturalWidth,img.naturalHeight,imgW,imgH))return;")
def test_narrow_front_cover_fills_the_gap_with_a_blurred_backdrop(self):
"""正封窄于卡片时两侧的留白垫同一张封面的模糊放大版,不留黑边也不露封底。
@@ -2883,8 +2883,8 @@ class WebUiSourceTests(unittest.TestCase):
另一个元素上的自定义属性,所以 `syncJavImages` 里单写了一句。
"""
self.assertPageContains(
- "img.closest('.pic')?.style.setProperty('--cover-blur',"
- "`url(\"${img.currentSrc||img.src}\")`);")
+ "img.closest('.pic')?.style.setProperty('--cover-blur',\n"
+ " `url(\"${img.dataset.thumbSrc||img.currentSrc||img.src}\")`);")
self.assertPageContains(
".pic::before{content:\"\";position:absolute;inset:-8%;pointer-events:none;")
self.assertPageContains("background:var(--cover-blur,none) center/cover no-repeat;"
@@ -2932,7 +2932,7 @@ class WebUiSourceTests(unittest.TestCase):
self.assertPageContains('<script type="module" src="/app.js"></script>')
self.assertPageContains("document.addEventListener('load',event=>{")
self.assertPageContains(
- "if(img.classList.contains('cover'))coverAnchor(img);")
+ "if(img.classList.contains('cover')){coverAnchor(img);upgradeCover(img)}")
self.assertPageContains("else if(img.dataset.facebox)avatarFrame(img);")
self.assertPageContains(" fitNativeImage(img);")
self.assertPageLacks('onload="', "模块作用域的函数在内联属性里取不到")
diff --git a/web/app.js b/web/app.js
index 8b6b78231..7af8ec35c 100644
--- a/web/app.js
+++ b/web/app.js
@@ -15,7 +15,7 @@ import { playUiSound, setUiSoundsEnabled, wireUiSounds } from './js/ui-sounds.js
import { ACCENTS, DEFAULT_ACCENT, DEFAULT_HOME_GLOW, GLASS_NATIVE_PRESET, GLOW_SPOT_LABELS, GLOW_SWATCHES, GLOW_SWATCH_FAMILIES, HOME_GLOW_CHOICES, HOME_GLOW_PRESETS, HOME_GLOW_SPOTS, glowAccent, glowChipFill, glowColor, glowPalette, glowPresetName, isNativeGlass, normalizeAccent, normalizeHomeGlow, paintGlassFaces, paintHomeGlow } from './js/home-glow.js';
import { mountIsland, unmountIsland, islandMounted, paginationHtml, pageCount, clampPage, preferredDirection } from './dist/peach-ui.js';
import { catalogSuggestions, catalogEmptyHtml, emptyCatalogLayout, syncSidebarSurface, sidebarTagCounts, sidebarHasCatalogContent, cleanupSkeletonHtml, cloudLocations, cloudPreferenceLocations } from './dist/peach-ui.js';
-import { javImageKind, normalizeJavImage, normalizeJavLayout, normalizeJavPreferences, panelFrame, syncJavImages, nativeImageFit, matchesFaceSource, faceSourceScale, entitySkeletonHtml } from './dist/peach-ui.js';
+import { javImageKind, normalizeJavImage, normalizeJavLayout, normalizeJavPreferences, panelFrame, syncJavImages, nativeImageFit, faceSourceScale, entitySkeletonHtml } from './dist/peach-ui.js';
import {
attachOverlayScrollbar, breadcrumbHtml, checkboxHtml, collectionSummaryHtml, closeAnchoredMenu, confirmModal, dialSliderHtml, dismissMenu, emptyStateHtml, fieldsetTitle, selectOptionIconHtml,
fillSkeletonTier, fitSkeleton, formModal, iconSwapHtml, iconSwitchHtml, indexSkeletonHtml, loadingDotsHtml,
@@ -3186,7 +3186,8 @@ function posterPanel(img,ratio){
/* 框是按那一版源图的像素算的,而封面会被更大的那张原子替换。尺寸对不上就说明
框描述的是另一张图,落在这张上是一块错位的区域——而错位在页面上和「本来就该
这么取景」看不出区别,所以宁可退回回退值。 */
- if(!matchesFaceSource(img.naturalWidth,img.naturalHeight,imgW,imgH))return;
+ // 卡片先取的是等比缩小的派生档,框的百分比在等比缩放下不变,所以认缩小,不认别的图。
+ if(!faceSourceScale(img.naturalWidth,img.naturalHeight,imgW,imgH))return;
const frame=panelFrame({x0,y0,x1,y1,px:[imgW,imgH]},ratio);
if(!frame)return;
img.classList.add('panel');
@@ -3196,8 +3197,23 @@ function posterPanel(img,ratio){
img.style.setProperty('--panel-top',`${frame.top}%`);
img.style.setProperty('--panel-height',`${frame.height}%`);
/* 正封比卡片窄时左右各留一条,垫的是同一张封面的模糊放大版。挂在卡片上而不是
- 图片上:图片那时已经被 `clip-path` 切成正封那一块,铺不到留白处。 */
- img.closest('.pic')?.style.setProperty('--cover-blur',`url("${img.currentSrc||img.src}")`);
+ 图片上:图片那时已经被 `clip-path` 切成正封那一块,铺不到留白处。糊成一片的底
+ 用不着原件的像素,换回原件之后这一层仍取派生档。 */
+ img.closest('.pic')?.style.setProperty('--cover-blur',
+ `url("${img.dataset.thumbSrc||img.currentSrc||img.src}")`);
+}
+/* 卡片先取封面的派生档(`/cover?thumb=1`):高清原件一张解码 38 MB,一页几十张挤爆
+ 解码缓存,来回滚动时滚走的被清掉、滚回来现解,那一段是空白。取景落定之后量这张图在
+ 屏幕上铺开多大:一个源像素要占不止一个设备像素,就是派生档不够清楚,换回原件。
+ 单列、大图这些真用得上像素的地方照旧是原件,多列时屏幕本来就放不下那么多像素。 */
+function upgradeCover(img){
+ if(!/[?&]thumb=1(&|$)/.test(img.src)||!img.naturalWidth)return;
+ const {width,height}=img.getBoundingClientRect();
+ const pick=getComputedStyle(img).objectFit==='contain'?Math.min:Math.max;
+ const scale=pick(width/img.naturalWidth,height/img.naturalHeight)*(window.devicePixelRatio||1);
+ if(!(scale>1.01))return;
+ img.dataset.thumbSrc=img.src;
+ img.src=img.src.replace(/[?&]thumb=1(?=&|$)/,'');
}
/* 容器比例只有 `.pic` 的 `--card-ratio` 知道:竖屏开关、JAV 大图和普通卡片各写一个
值,在这里按 layout 重算迟早会和它分叉。自定义属性会继承,直接从图片上读;
@@ -3219,7 +3235,7 @@ document.addEventListener('load',event=>{
if(!(img instanceof HTMLImageElement))return;
settleImage(img);
fitNativeImage(img);
- if(img.classList.contains('cover'))coverAnchor(img);
+ if(img.classList.contains('cover')){coverAnchor(img);upgradeCover(img)}
// 头像走同一条路,理由也同一个:倍数要等图和框都落地才算得出来。
else if(img.dataset.facebox)avatarFrame(img);
},true);
@@ -3289,7 +3305,15 @@ function refitNativeImages(root){
if(img.dataset.facebox)avatarFrame(img);
});
}
-window.addEventListener('resize',()=>refitNativeImages($('#index')),{passive:true});
+let coverRecheck=0;
+window.addEventListener('resize',()=>{
+ refitNativeImages($('#index'));
+ // 窗口放大后卡片跟着变大,先前够用的派生档可能就不够了;只增不减,换回来的原件留着。
+ // 等拖动停下再量:逐张量尺寸要读样式和盒子,跟着每一帧 resize 跑就是一次次强制排版。
+ clearTimeout(coverRecheck);
+ coverRecheck=setTimeout(()=>$('#index').querySelectorAll('img.cover').forEach(img=>{
+ if(img.complete)upgradeCover(img)}),200);
+},{passive:true});
/* 大图卡片的容器比例。本机 1014 张封面实测,683 张判定有正封,正封自己的宽高比
从 0.667 到 0.749 都有,中位数 0.704、99% 分位 0.725——一行卡片必须等高,容器
只能取一个数,所以它对不上其中大多数。0.75 比最宽的那张还宽:683 张一张都不用
@@ -3302,7 +3326,7 @@ const COVER_FRONT_RATIO=0.75;
(`.poster` 本来就是 contain + 黑底)。 */
const PORTRAIT_RATIO=9/16;
function coverImage(it,layout,eager){
- const src=`/cover?code=${encodeURIComponent(it.code||'')}`;
+ const src=`/cover?code=${encodeURIComponent(it.code||'')}&thumb=1`;
// 人脸位置原样交给页面,锚点由 `coverAnchor` 在加载后算:哪个轴被裁、要推多远,
// 只有同时拿到图片和容器的比例才知道。人物在画面里的位置差别很大,写死的锚点会把
// 一部分作品裁掉下巴或整个切出画外;取不到人脸就退回固定取景。
@@ -3321,7 +3345,7 @@ function coverImage(it,layout,eager){
function javArtwork(it,layout,eager=false){
const kind=javImageKind(it,appSettings.javImage);
if(!kind)return '<span class="nopic">无预览</span>';
- const cover=it.has_cover&&it.code?`/cover?code=${encodeURIComponent(it.code)}`:'';
+ const cover=it.has_cover&&it.code?`/cover?code=${encodeURIComponent(it.code)}&thumb=1`:'';
const thumb=(it.has_thumb||it.has_local_poster)?`/poster?id=${it.id}&c=4`:'';
const coverHtml=coverImage(it,layout==='big'?'big':'small',eager);
// 取景数据要跟着元素走:换回官方封面时 `syncJavImages` 换的是同一个 <img>,
@@ -8086,8 +8110,8 @@ async function openEntity(kind,name,push=true){
`<a class="entrymark" href="${esc(x.url)}" target="_blank" rel="noreferrer" title="${esc(x.label)}">${
x.mark?icon(x.mark):'<span class="missavmark"><span>MISS</span><span>AV</span></span>'
}${x.ordinal?`<span class="entryordinal">${esc(x.ordinal)}</span>`:''}<span class="sr-only">${esc(x.label)}</span></a>`
- ).join('')+(d.feed?`<label class="entryfeed">${icon('rss')}<span>订阅新作</span><input type="checkbox"
- class="ptoggle" role="switch" data-entity-feed ${d.feed.following?'checked':''}></label>`:'');
+ ).join('')+(d.feed?`<label class="entryfeed" title="订阅新作">${icon('rss')}<input type="checkbox"
+ class="sr-only" role="switch" aria-label="订阅新作" data-entity-feed ${d.feed.following?'checked':''}></label>`:'');
const tags=(d.tags||[]).map(x=>filterChipHtml(tagLabel(x.k),{attr:'data-entity-tag',value:x.k,selected:tagPressed(filters.tag,x.k),count:x.n.toLocaleString()})).join('');
/* 事务所名下的这批人不摆在这排小圆头像里:那是「同台艺人」,一条附注;名册是这一页
的正文,占的是下面那整块。所以同一份 `related_performers` 在事务所页走另一条路。 */
diff --git a/web/css/07-entity.css b/web/css/07-entity.css
index 319fe836d..21c8cc68d 100644
--- a/web/css/07-entity.css
+++ b/web/css/07-entity.css
@@ -91,11 +91,16 @@
text-decoration:none;color:var(--ink);border-radius:var(--control-radius);padding:4px 8px;margin:-4px -8px}
.entityhero .entrymarks a.entrymark:any-link:hover{
background:color-mix(in srgb,var(--ink) 8%,var(--ground));text-decoration:none}
-/* 「订阅新作」开关排在两枚标识后面:它订的就是左边那个 JavDB 演员页。字和图标跟两枚
- 标识同一个量级——同一行里三样东西,这一样要是小一号,读起来就成了挂在后面的注脚。 */
-.entryfeed{display:inline-flex;align-items:center;gap:8px;color:var(--ink);font-size:var(--fs-lg);
- font-weight:500;line-height:24px;cursor:pointer}
-.entryfeed svg{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:2}
+/* 「订阅新作」开关排在两枚标识后面:它订的就是左边那个 JavDB 演员页。只摆一枚 RSS 图标,
+ 高度跟两枚标识一样是 22px;关着跟页面墨色,订上了换成 RSS 自己的橙。开关本身藏给读屏
+ 与键盘,悬停垫底与两枚标识同一档。 */
+.entryfeed{position:relative;display:inline-flex;align-items:center;color:var(--ink);cursor:pointer;
+ border-radius:var(--control-radius);padding:4px;margin:-4px}
+.entryfeed:hover{background:color-mix(in srgb,var(--ink) 8%,var(--ground))}
+.entryfeed:has(:checked){color:#F78422}
+.entryfeed:has(:focus-visible){outline:2px solid var(--tungsten);outline-offset:2px}
+.entryfeed:has([aria-busy="true"]){cursor:progress;opacity:.6}
+.entryfeed svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:2}
/* 两枚标识按字母的高度对齐,不按外框:JavDB 那枚里 `Jav` 三个字母占 viewBox 高的
71/111,高 22px 时是 14.1px;MISSAV 是排出来的字,衬线体的大写字母高约 0.71em,
`--fs-xl` 时是 14.2px。外框对齐的话 MISSAV 的字母比 `Jav` 高出两成,一眼看过去它大一号。
diff --git a/web/css/12-cards.css b/web/css/12-cards.css
index da41c9d2a..fbd5398a7 100644
--- a/web/css/12-cards.css
+++ b/web/css/12-cards.css
@@ -470,7 +470,9 @@ body[data-density="dense"] .shorts-inline .scard{width:calc(214px * 168 / 336)}
* 两种卡长得不一样的地方只应该是它们真的不一样的地方。 */
.feednew{margin:0 0 18px}
.feednewtitle{margin:0 0 10px;font-size:var(--fs-sm);letter-spacing:.08em;color:var(--muted)}
-.feednewrow{padding-bottom:7px}
+/* 卡片悬停时底色向四周多铺 8px(`box-shadow` 的 spread),而横滚容器把纵向溢出一并
+ 裁掉:四边各留 8px 内边距,再用同样的负外边距收回来,卡片落点不动。 */
+.feednewrow{padding:8px;margin:-8px -8px 0}
/* 往右翻时卡片从侧栏底下穿过去,和首页那几排(`board.css` 的 `#tiers .tier`)同一个
理由、同一种写法:让出轨道宽度加 `main` 的 16px 内边距,再原样加回内边距,第一张
仍站在这一屏的左对齐线上。首页与人物页的这一行都直接住在 `main` 里,所以让出的是
diff --git a/web/dist/peach-react.js b/web/dist/peach-react.js
index e0392301b..6a936b3a1 100644
--- a/web/dist/peach-react.js
+++ b/web/dist/peach-react.js
@@ -32201,48 +32201,38 @@ function zD() {
let e = new AbortController();
return i(e.signal), () => e.abort();
}, [i]);
- let a = e?.kinds ?? [], [o, s] = (0, C.useState)(""), [c, l] = (0, C.useState)(""), [u, d] = (0, C.useState)(""), [f, p] = (0, C.useState)("6"), m = mh(), h = (e) => {
- e.preventDefault();
- let t = Math.round(Number(f) * 60);
- m.run("add", (e) => J("/api/feeds/source", {
- action: "add",
- kind: o || a[0]?.value,
- url: c.trim(),
- name: u.trim(),
- interval_minutes: Number.isFinite(t) ? t : void 0
- }, "POST", e), () => {
- l(""), d(""), i();
- });
- }, g = (e, t) => {
- m.run(`enabled-${e.id}`, (n) => J("/api/feeds/source", {
+ let a = mh(), o = (e, t) => {
+ a.run(`enabled-${e.id}`, (n) => J("/api/feeds/source", {
action: "enabled",
id: e.id,
enabled: t
}, "POST", n), () => void i());
- }, _ = (e) => {
- m.run(`remove-${e.id}`, (t) => J("/api/feeds/source", {
+ }, s = (e) => {
+ a.run(`remove-${e.id}`, (t) => J("/api/feeds/source", {
action: "remove",
id: e.id
}, "POST", t), () => void i());
};
return e ? /* @__PURE__ */ (0, w.jsxs)(KS, {
title: "订阅源",
- onSubmit: h,
children: [
e.sources.length ? /* @__PURE__ */ (0, w.jsx)(qS, { children: e.sources.map((e) => /* @__PURE__ */ (0, w.jsx)(US, {
label: e.name || e.url,
description: RD(e),
children: /* @__PURE__ */ (0, w.jsxs)("div", {
- className: "flex items-center gap-1",
+ className: "flex items-center gap-2",
children: [/* @__PURE__ */ (0, w.jsx)(qb, {
"aria-label": `启用 ${e.name || e.url}`,
isSelected: e.enabled,
- onChange: (t) => g(e, t)
- }), /* @__PURE__ */ (0, w.jsx)(Xy, {
- icon: Bf,
+ onChange: (t) => o(e, t)
+ }), /* @__PURE__ */ (0, w.jsx)(K, {
+ variant: "danger",
+ size: "xs",
+ iconOnly: !0,
+ leadingIcon: Bf,
"aria-label": `移除 ${e.name || e.url}`,
- onClick: () => _(e),
- ...X(m.busy === `remove-${e.id}`)
+ onClick: () => s(e),
+ ...X(a.busy === `remove-${e.id}`)
})]
})
}, e.id)) }) : null,
@@ -32254,61 +32244,19 @@ function zD() {
title: `${e.name || e.url} 拉取失败`,
children: e.last_error
}, e.id)),
- /* @__PURE__ */ (0, w.jsxs)("div", {
- className: "inline-grid grid-cols-1 gap-3 @lg:grid-cols-2",
- children: [/* @__PURE__ */ (0, w.jsxs)("div", {
- className: "flex flex-col gap-1.5",
- children: [/* @__PURE__ */ (0, w.jsx)(QS, { children: "来源类型" }), /* @__PURE__ */ (0, w.jsx)(fT, {
- "aria-label": "来源类型",
- selectedKey: o || a[0]?.value,
- onSelectionChange: (e) => {
- e !== null && s(String(e));
- },
- children: a.map((e) => /* @__PURE__ */ (0, w.jsx)(pT, {
- id: e.value,
- textValue: e.label,
- children: e.label
- }, e.value))
- })]
- }), /* @__PURE__ */ (0, w.jsx)(rb, {
- label: "拉取间隔(小时)",
- inputMode: "decimal",
- value: f,
- onChange: p,
- hint: `最短 ${e.min_interval_minutes} 分钟。`
- })]
- }),
- /* @__PURE__ */ (0, w.jsx)(rb, {
- label: "订阅地址",
- placeholder: "https://",
- value: c,
- onChange: l,
- hint: "RSS/Atom 的地址,或 JavDB 的演员页地址。只收 HTTPS。"
- }),
- /* @__PURE__ */ (0, w.jsx)(rb, {
- label: "名称",
- maxLength: 80,
- placeholder: "不填就用地址",
- value: u,
- onChange: d
- }),
- m.error ? /* @__PURE__ */ (0, w.jsx)(ZS, { children: m.error }) : null,
- /* @__PURE__ */ (0, w.jsx)(XS, { children: "订阅只发现番号、建一条「未入库」的新作,不下载任何文件。新作在首页和人物页里看。" })
+ a.error ? /* @__PURE__ */ (0, w.jsx)(ZS, { children: a.error }) : null,
+ /* @__PURE__ */ (0, w.jsx)(XS, { children: "在人物页点「订阅新作」就会加到这里。订阅只发现番号、建一条「未入库」的新作,不下载任何文件;新作在首页和人物页里看。" })
]
}),
- /* @__PURE__ */ (0, w.jsxs)(YS, {
+ /* @__PURE__ */ (0, w.jsx)(YS, {
status: e.unread ? `有 ${e.unread} 条新作还没看` : "新作都看过了",
- children: [/* @__PURE__ */ (0, w.jsx)(K, {
+ children: /* @__PURE__ */ (0, w.jsx)(K, {
onClick: () => {
- m.run("check", (e) => J("/api/feeds/check", { all: !0 }, "POST", e), () => void i());
+ a.run("check", (e) => J("/api/feeds/check", { all: !0 }, "POST", e), () => void i());
},
- ...X(m.busy === "check"),
+ ...X(a.busy === "check"),
children: "立即拉取"
- }), /* @__PURE__ */ (0, w.jsx)(K, {
- type: "submit",
- ...X(m.busy === "add"),
- children: "添加订阅"
- })]
+ })
})
]
}) : /* @__PURE__ */ (0, w.jsx)(KS, {
diff --git a/web/dist/peach-ui.js b/web/dist/peach-ui.js
index 1a704bd3d..0340d3801 100644
--- a/web/dist/peach-ui.js
+++ b/web/dist/peach-ui.js
@@ -292,7 +292,7 @@ async function E(e) {
await t(2e3);
}
}
-function D(e) {
+function ne(e) {
let t = e.note || ((e) => i(e, {
label: "任务状态",
variant: "error"
@@ -325,11 +325,11 @@ function D(e) {
}
//#endregion
//#region src/selection.ts
-function O(e, t, n, r, i, a = i || !e.has(r)) {
+function re(e, t, n, r, i, a = i || !e.has(r)) {
let o = n === null ? -1 : t.indexOf(n), s = t.indexOf(r);
return i && o >= 0 && s >= 0 ? t.slice(Math.min(o, s), Math.max(o, s) + 1).forEach((t) => e.add(t)) : a ? e.add(r) : e.delete(r), r;
}
-function k(e, t) {
+function ie(e, t) {
let n = t.filter((t) => e.has(t)).length;
return {
count: n,
@@ -337,14 +337,14 @@ function k(e, t) {
mixed: n > 0 && n < t.length
};
}
-function ne(e, t, n) {
+function ae(e, t, n) {
t.forEach((t) => n ? e.add(t) : e.delete(t));
}
-function re({ count: e, label: t, all: n, summary: r, actions: i, locked: a = !1 }) {
+function oe({ count: e, label: t, all: n, summary: r, actions: i, locked: a = !1 }) {
e && (e.textContent = t), n && (n.checked = r.all, n.indeterminate = r.mixed);
for (let e of i) e.disabled = !r.count || a;
}
-function ie(e, t, n = 1) {
+function se(e, t, n = 1) {
let r = (e, t) => Array.from({ length: t - e + 1 }, (t, n) => e + n);
if (n * 2 + 5 >= t) return r(1, t);
let i = Math.max(e - n, 1), a = Math.min(e + n, t), o = i > 2, s = a < t - 2;
@@ -364,15 +364,15 @@ function ie(e, t, n = 1) {
t
];
}
-function ae(e, t) {
+function D(e, t) {
return Math.max(1, Math.ceil(e / t));
}
-function oe(e, t) {
+function O(e, t) {
return Math.min(Math.max(1, Math.floor(e) || 1), t);
}
-function se(e, t, n) {
+function k(e, t, n) {
if (t <= 1) return "";
- let r = ie(e, t).map((t) => t === "…" ? "<li class=\"board-page-dots\" aria-hidden=\"true\">…</li>" : `<li><button type="button" class="board-page" data-page="${t}" aria-label="第 ${t} 页"${t === e ? " aria-current=\"page\"" : ""}>${t}</button></li>`).join("");
+ let r = se(e, t).map((t) => t === "…" ? "<li class=\"board-page-dots\" aria-hidden=\"true\">…</li>" : `<li><button type="button" class="board-page" data-page="${t}" aria-label="第 ${t} 页"${t === e ? " aria-current=\"page\"" : ""}>${t}</button></li>`).join("");
return `<nav class="board-pagination" aria-label="${n}">
<button type="button" class="geist-button" data-page="${e - 1}"${e <= 1 ? " disabled" : ""}><svg viewBox="0 0 24 24" aria-hidden="true"><use href="#i-chevron-left"></use></svg>上一页</button>
<ul>${r}</ul>
@@ -382,14 +382,11 @@ function se(e, t, n) {
//#endregion
//#region src/native-image.ts
function A(e, t, n, r) {
- return e > 0 && t > 0 && e === n && t === r;
-}
-function j(e, t, n, r) {
if (!(e > 0 && t > 0 && n > 0 && r > 0)) return 0;
let i = e / n, a = t / r;
return i > 1.001 || a > 1.001 || Math.abs(i - a) > Math.max(i, a) * .01 ? 0 : i;
}
-function M(e, t, n, r, i = 1) {
+function j(e, t, n, r, i = 1) {
let a = Number.isFinite(i) && i > 0 ? i : 1;
e /= a, t /= a;
let o = [
@@ -420,16 +417,16 @@ function ce(e, t, n) {
}
//#endregion
//#region src/board-skeleton.ts
-var N = (e = "60%") => `<span class="skeleton" style="width:${e}"></span>`, P = () => `${N("80%")}${N("48%")}`, F = (e, t) => e.repeat(t), I = (e, t = "metricstrip") => `<div class="${t}">${e.map((e) => `<div class="tastesummary"><span class="board-stat-label">${e}</span><b class="board-stat-value">${N("45%")}</b><small class="board-stat-footer">${N("60%")}</small></div>`).join("")}</div>`, L = (e, t = "skeleton-tabs") => `<div class="${t}">${e.map((e) => `<span>${e}</span>`).join("")}</div>`, R = (e, t) => `<div class="${t} skeleton-segments" data-board-segments="true">${e.map((e, t) => `<span${t === 0 ? " class=\"skeleton-segment-selected\"" : ""}>${e}</span>`).join("")}</div>`, z = (e) => `<section class="insightpanel"><header>${e}</header><div class="insightpanelbody skeleton-lines">${F(P(), 3)}</div></section>`, B = (e, t, n = "") => `<button class="fbtn follow-skeleton-button ${n}" type="button" disabled>${l(t)}${e ? `<span>${e}</span>` : ""}</button>`, V = (e) => `<div class="fsechead follow-skeleton-toolbar" data-collapse-toolbar><h3>关注列表</h3><span class="fmeta follow-skeleton-count">${N("132px")}</span><div class="followtoolbaractions">${B("检查全部", "refresh-cw", "primary followcheckall")}<span class="board-button-group follow-skeleton-button-group">${B("", "layout-grid", "selected")}${B("", "table")}</span><span class="fmanagesort" data-collapse-field>${l("sort")}${a([["checked", "检查时间"]], "checked", {
+var M = (e = "60%") => `<span class="skeleton" style="width:${e}"></span>`, N = () => `${M("80%")}${M("48%")}`, P = (e, t) => e.repeat(t), F = (e, t = "metricstrip") => `<div class="${t}">${e.map((e) => `<div class="tastesummary"><span class="board-stat-label">${e}</span><b class="board-stat-value">${M("45%")}</b><small class="board-stat-footer">${M("60%")}</small></div>`).join("")}</div>`, I = (e, t = "skeleton-tabs") => `<div class="${t}">${e.map((e) => `<span>${e}</span>`).join("")}</div>`, L = (e, t) => `<div class="${t} skeleton-segments" data-board-segments="true">${e.map((e, t) => `<span${t === 0 ? " class=\"skeleton-segment-selected\"" : ""}>${e}</span>`).join("")}</div>`, R = (e) => `<section class="insightpanel"><header>${e}</header><div class="insightpanelbody skeleton-lines">${P(N(), 3)}</div></section>`, z = (e, t, n = "") => `<button class="fbtn follow-skeleton-button ${n}" type="button" disabled>${l(t)}${e ? `<span>${e}</span>` : ""}</button>`, B = (e) => `<div class="fsechead follow-skeleton-toolbar" data-collapse-toolbar><h3>关注列表</h3><span class="fmeta follow-skeleton-count">${M("132px")}</span><div class="followtoolbaractions">${z("检查全部", "refresh-cw", "primary followcheckall")}<span class="board-button-group follow-skeleton-button-group">${z("", "layout-grid", "selected")}${z("", "table")}</span><span class="fmanagesort" data-collapse-field>${l("sort")}${a([["checked", "检查时间"]], "checked", {
label: "关注列表排序",
attr: "disabled"
-})}</span>${B("", "arrow-down", "square fmanagedir")}${e ? "" : B("全部收起", "chevron-up")}</div></div>`, H = () => "<span class=\"fchannelcheck follow-skeleton-check\" aria-hidden=\"true\"></span>", U = () => `<div class="fsource frow follow-skeleton-source">${H()}<b class="follow-skeleton-source-name">${N("72%")}</b><span class="fprovider follow-skeleton-provider skeleton"></span><span class="follow-skeleton-status skeleton"></span><span class="fmeta fchecked follow-skeleton-date">${N("100%")}</span><span class="fsourceactions follow-skeleton-row-actions"><i></i><i></i></span></div>`, W = (e = 3) => `<details class="fauthor follow-skeleton-author" open><summary class="fauthorhead"><span class="favatar follow-skeleton-avatar skeleton"></span><b>${N("92px")}</b><span class="fmeta follow-skeleton-author-meta skeleton"></span><span class="board-author-actions follow-skeleton-author-actions"><i></i><button type="button" class="fbtn small" data-follow-author-select disabled>${l("check-check")}<span data-author-select-label>全选</span></button><i></i></span></summary><div class="fauthorsources follow-skeleton-sources">${F(U(), e)}</div></details>`, G = () => {
+})}</span>${z("", "arrow-down", "square fmanagedir")}${e ? "" : z("全部收起", "chevron-up")}</div></div>`, V = () => "<span class=\"fchannelcheck follow-skeleton-check\" aria-hidden=\"true\"></span>", H = () => `<div class="fsource frow follow-skeleton-source">${V()}<b class="follow-skeleton-source-name">${M("72%")}</b><span class="fprovider follow-skeleton-provider skeleton"></span><span class="follow-skeleton-status skeleton"></span><span class="fmeta fchecked follow-skeleton-date">${M("100%")}</span><span class="fsourceactions follow-skeleton-row-actions"><i></i><i></i></span></div>`, U = (e = 3) => `<details class="fauthor follow-skeleton-author" open><summary class="fauthorhead"><span class="favatar follow-skeleton-avatar skeleton"></span><b>${M("92px")}</b><span class="fmeta follow-skeleton-author-meta skeleton"></span><span class="board-author-actions follow-skeleton-author-actions"><i></i><button type="button" class="fbtn small" data-follow-author-select disabled>${l("check-check")}<span data-author-select-label>全选</span></button><i></i></span></summary><div class="fauthorsources follow-skeleton-sources">${P(H(), e)}</div></details>`, W = () => {
try {
return Number(JSON.parse(localStorage.getItem("peach.settings.v1") || "{}").followPageSize) || 20;
} catch {
return 20;
}
-}, le = (e) => `<div class="ftableframe follow-skeleton-table"><div class="ftablewrap"><div class="ftable follow-skeleton-table-row head">${[
+}, G = (e) => `<div class="ftableframe follow-skeleton-table"><div class="ftablewrap"><div class="ftable follow-skeleton-table-row head">${[
"",
"创作者",
"来源",
@@ -437,62 +434,62 @@ var N = (e = "60%") => `<span class="skeleton" style="width:${e}"></span>`, P =
"状态",
"上次检查",
""
-].map((e) => `<span>${e}</span>`).join("")}</div>${F(`<div class="follow-skeleton-table-row">${H()}${[
+].map((e) => `<span>${e}</span>`).join("")}</div>${P(`<div class="follow-skeleton-table-row">${V()}${[
"74%",
"88%",
"62%",
"54%",
"78%"
-].map((e) => `<span>${N(e)}</span>`).join("")}<span class="fsourceactions follow-skeleton-row-actions"><i></i><i></i></span></div>`, e)}</div></div>`;
-function ue() {
- return `<div data-skeleton="detail" role="status" aria-label="正在读取作品详情"><div class="sgrid" aria-hidden="true"><div class="vwrap skeleton-detail-media skeleton"></div><aside class="side"><div class="sidecontent skeleton-lines">${N("85%")}${N("65%")}${F(P(), 4)}</div></aside></div></div>`;
+].map((e) => `<span>${M(e)}</span>`).join("")}<span class="fsourceactions follow-skeleton-row-actions"><i></i><i></i></span></div>`, e)}</div></div>`;
+function le() {
+ return `<div data-skeleton="detail" role="status" aria-label="正在读取作品详情"><div class="sgrid" aria-hidden="true"><div class="vwrap skeleton-detail-media skeleton"></div><aside class="side"><div class="sidecontent skeleton-lines">${M("85%")}${M("65%")}${P(N(), 4)}</div></aside></div></div>`;
}
-function de(e, t = {}) {
+function K(e, t = {}) {
let n = "";
- if (e === "/stats") n = `<div class="insightpage statsdashboard"><header class="insighttoolbar">${N("38%")}</header>${I([
+ if (e === "/stats") n = `<div class="insightpage statsdashboard"><header class="insighttoolbar">${M("38%")}</header>${F([
"馆藏视频",
"看过",
"内容标签",
"使用空间"
- ])}${z("馆藏视频")}${z("内容标签")}</div>`;
- else if (e === "/taste") n = `<div class="tastepage"><header class="tastehead">${R(["浏览器记录", "Peach 内部"], "insightswitch")}${N("24%")}</header><div class="tastestate"></div>${I([
+ ])}${R("馆藏视频")}${R("内容标签")}</div>`;
+ else if (e === "/taste") n = `<div class="tastepage"><header class="tastehead">${L(["浏览器记录", "Peach 内部"], "insightswitch")}${M("24%")}</header><div class="tastestate"></div>${F([
"浏览记录",
"口味维度",
"浏览候选",
"私有导出"
- ], "tastesummaries")}<section class="tastehero"><div class="insightcopy"><span>浏览器画像</span><div class="skeleton skeleton-radar"></div></div><div class="tastebars skeleton-lines">${F(P(), 4)}</div></section>${z("口味分析")}<div class="board-activity-charts">${z("浏览活动")}${z("时间分布")}</div>${z("标签")}</div>`;
+ ], "tastesummaries")}<section class="tastehero"><div class="insightcopy"><span>浏览器画像</span><div class="skeleton skeleton-radar"></div></div><div class="tastebars skeleton-lines">${P(N(), 4)}</div></section>${R("口味分析")}<div class="board-activity-charts">${R("浏览活动")}${R("时间分布")}</div>${R("标签")}</div>`;
else if (e === "/follow-manage") {
- let e = t.followLayout === "table", r = e ? le(t.followPageSize || G()) : `<div class="follow-skeleton-authors">${W(3)}${W(4)}${W(3)}</div>`;
+ let e = t.followLayout === "table", r = e ? G(t.followPageSize || W()) : `<div class="follow-skeleton-authors">${U(3)}${U(4)}${U(3)}</div>`;
n = `<div class="follow followmanage follow-list-skeleton"><div class="fmanageoverview">${[
"关注创作者",
"启用来源",
"检查失败",
"未看更新"
- ].map((e) => `<div><span>${e}</span><b>${N()}</b></div>`).join("")}</div>${R([
+ ].map((e) => `<div><span>${e}</span><b>${M()}</b></div>`).join("")}</div>${L([
"关注列表",
"添加关注",
"来源和凭证"
- ], "follow-workspace-switch")}<div class="fmain"><section class="fsec follow-skeleton-surface" data-follow-workspace-panel="list">${V(e)}${e ? "" : `<div class="board-follow-selection follow-skeleton-select-all">${H()}<span>全选本页</span></div>`}<div class="frows fsources" data-layout="${e ? "table" : "default"}">${r}<footer class="followpagefooter follow-skeleton-footer"><span class="followpageinfo">${N("116px")}</span><span>${N("96px")}</span><span class="follow-skeleton-pages"><i></i><i></i><i></i></span></footer></div></section></div></div>`;
- } else if (e === "/configuration") n = `<div class="configpage">${L([
+ ], "follow-workspace-switch")}<div class="fmain"><section class="fsec follow-skeleton-surface" data-follow-workspace-panel="list">${B(e)}${e ? "" : `<div class="board-follow-selection follow-skeleton-select-all">${V()}<span>全选本页</span></div>`}<div class="frows fsources" data-layout="${e ? "table" : "default"}">${r}<footer class="followpagefooter follow-skeleton-footer"><span class="followpageinfo">${M("116px")}</span><span>${M("96px")}</span><span class="follow-skeleton-pages"><i></i><i></i><i></i></span></footer></div></section></div></div>`;
+ } else if (e === "/configuration") n = `<div class="configpage">${I([
"通用",
"媒体",
"网络与访问",
"更新与维护"
- ])}<section class="configfieldset"><div class="geist-fieldset-content"><h3 class="geist-fieldset-title">开机自启</h3><div class="skeleton-lines">${F(`<div class="skeleton-setting">${N("35%")}<span class="skeleton skeleton-toggle"></span></div>`, 3)}</div></div><footer class="geist-fieldset-footer">${N("100px")}</footer></section></div>`;
+ ])}<section class="configfieldset"><div class="geist-fieldset-content"><h3 class="geist-fieldset-title">开机自启</h3><div class="skeleton-lines">${P(`<div class="skeleton-setting">${M("35%")}<span class="skeleton skeleton-toggle"></span></div>`, 3)}</div></div><footer class="geist-fieldset-footer">${M("100px")}</footer></section></div>`;
else if (e === "/activity") n = `<div class="activitypage">${[
"正在进行",
"被挡下的",
"最近完成"
- ].map((e) => `<section class="activitysection"><h3 class="geist-fieldset-title">${e}</h3><div class="activity-runs"><article class="cleanupfieldset activity-run"><div class="geist-fieldset-content skeleton-lines">${N("35%")}${P()}</div></article></div></section>`).join("")}</div>`;
- else if (e === "/duplicates") n = `<div class="review"><div class="collection-summary">${N("38%")}</div><div class="fsechead dupactions"><h3>批量保留</h3>${N("40%")}</div>${F(`<section class="dupgroup"><div class="duphead">${N("45%")}</div><div class="duplist">${F(`<div class="duprow"><span class="dupcover skeleton"></span><span class="dupmarks">${N()}</span><span class="dupname">${N("90%")}</span>${N()}${N()}${N()}<span class="duppath">${N("70%")}</span></div>`, 2)}</div></section>`, 2)}</div>`;
- else if (e === "/quality-goals") n = `<div class="quality-workspace"><div class="collection-summary"><strong>待升级</strong>${N("20%")}</div><div class="qualitylist">${F(`<article class="qualityitem"><span class="qualitycover skeleton"></span><div class="qualitybody skeleton-lines">${P()}</div><footer class="qualityactions">${N("80%")}</footer></article>`, 6)}</div></div>`;
- else if (e === "/playlists") n = `<section class="playlistpage"><header><div><h2>播放列表</h2><p>保存 Mix,按自己的顺序继续播放。</p></div><div class="playlistcreate skeleton-lines"><span>新播放列表</span>${N("200px")}</div></header><div class="playlistcards">${F(`<article class="card playlistcard"><div class="mixstack"><div class="pic skeleton"></div></div><div class="mixmeta"><span class="mav skeleton"></span><div class="mixcopy skeleton-lines">${P()}</div></div></article>`, 6)}</div></section>`;
+ ].map((e) => `<section class="activitysection"><h3 class="geist-fieldset-title">${e}</h3><div class="activity-runs"><article class="cleanupfieldset activity-run"><div class="geist-fieldset-content skeleton-lines">${M("35%")}${N()}</div></article></div></section>`).join("")}</div>`;
+ else if (e === "/duplicates") n = `<div class="review"><div class="collection-summary">${M("38%")}</div><div class="fsechead dupactions"><h3>批量保留</h3>${M("40%")}</div>${P(`<section class="dupgroup"><div class="duphead">${M("45%")}</div><div class="duplist">${P(`<div class="duprow"><span class="dupcover skeleton"></span><span class="dupmarks">${M()}</span><span class="dupname">${M("90%")}</span>${M()}${M()}${M()}<span class="duppath">${M("70%")}</span></div>`, 2)}</div></section>`, 2)}</div>`;
+ else if (e === "/quality-goals") n = `<div class="quality-workspace"><div class="collection-summary"><strong>待升级</strong>${M("20%")}</div><div class="qualitylist">${P(`<article class="qualityitem"><span class="qualitycover skeleton"></span><div class="qualitybody skeleton-lines">${N()}</div><footer class="qualityactions">${M("80%")}</footer></article>`, 6)}</div></div>`;
+ else if (e === "/playlists") n = `<section class="playlistpage"><header><div><h2>播放列表</h2><p>保存 Mix,按自己的顺序继续播放。</p></div><div class="playlistcreate skeleton-lines"><span>新播放列表</span>${M("200px")}</div></header><div class="playlistcards">${P(`<article class="card playlistcard"><div class="mixstack"><div class="pic skeleton"></div></div><div class="mixmeta"><span class="mav skeleton"></span><div class="mixcopy skeleton-lines">${N()}</div></div></article>`, 6)}</div></section>`;
else return "";
return `<div class="board-page-skeleton" data-skeleton="board${e}" role="status" aria-label="正在读取页面"><div aria-hidden="true" inert>${n}</div></div>`;
}
//#endregion
//#region src/catalog-onboarding.ts
-var fe = [
+var ue = [
"loc",
"creator",
"performer",
@@ -510,16 +507,16 @@ var fe = [
"jav",
"thumb"
];
-function pe() {
+function de() {
let e = (e) => Array(64).fill(e).join("");
return {
tiers: "<div class=\"tier catalog-placeholder\" aria-hidden=\"true\">" + e("<span class=\"av\"><span class=\"ring\"></span><span class=\"nm\">&nbsp;</span></span>") + "</div><div class=\"tier catalog-placeholder\" aria-hidden=\"true\">" + e("<span class=\"brandpill\"><span class=\"mk\"></span><span class=\"placeholder-name\">&nbsp;</span></span>") + "</div>",
tags: "<span class=\"catalog-placeholder placeholder-tags\" aria-hidden=\"true\">" + e("<span class=\"pill\">&nbsp;</span>") + "</span>"
};
}
-async function K(e, t) {
+async function fe(e, t) {
let n = new URLSearchParams();
- for (let t of fe) e[t] && n.set(t, e[t]);
+ for (let t of ue) e[t] && n.set(t, e[t]);
let [r, i] = await Promise.all([t("/api/facets?" + n), t("/api/items?" + n + "&limit=5")]), a = [...new Set([
...r.creators || [],
...r.tagperformers || [],
@@ -530,7 +527,7 @@ async function K(e, t) {
return r.set("q", e), r.set("limit", "1"), (await t("/api/items?" + r)).total > 0 ? e : "";
}))).filter(Boolean);
}
-function me({ kind: e = "catalog", filtered: n = !1, jav: r = !1, configurable: i = !1, online: a = !1 } = {}) {
+function pe({ kind: e = "catalog", filtered: n = !1, jav: r = !1, configurable: i = !1, online: a = !1 } = {}) {
let o = i ? "<button class=\"geist-button primary\" data-empty-settings>添加内容</button>" : "", s = "<a class=\"geist-button" + (!i || a ? " primary" : "") + "\" href=\"/follow-manage?tab=add\">添加关注</a>";
if (n || r) return t("search", r ? "还没有符合条件的 JAV 作品" : "没有符合条件的内容", r ? "已扫描但尚未补充发行资料的视频可在全部内容中查看。" : "清除筛选或搜索条件后查看全部内容。", { actions: "<a class=\"geist-button primary\" href=\"/?loc=&thumb=0\">查看全部内容</a>" });
if (e !== "catalog") {
@@ -551,7 +548,7 @@ function me({ kind: e = "catalog", filtered: n = !1, jav: r = !1, configurable:
}
//#endregion
//#region src/sidebar.ts
-function he(e) {
+function me(e) {
return [
"/",
"/unseen",
@@ -561,23 +558,23 @@ function he(e) {
"/junk-files"
].includes(e) || /^\/(item|mix|parts|editions)\//.test(e) || /^\/playlists\/\d+\/\d+$/.test(e) || /^\/(performers|studios|creators|series|agencies)\/.+/.test(e);
}
-function ge(e, t) {
+function he(e, t) {
return e.dataset.surface?.split("?")[0] === t.split("?")[0] && e.querySelector(".dnav") ? (e.dataset.surface = t, !1) : (e.dataset.surface = t, e.replaceChildren(), !0);
}
-function _e(e) {
+function ge(e) {
let t = /* @__PURE__ */ new Map();
for (let n of e) for (let e of new Set(n.tags || [])) t.set(e, (t.get(e) || 0) + 1);
return [...t].sort((e, t) => t[1] - e[1]).slice(0, 30);
}
//#endregion
//#region src/management.ts
-function ve(e) {
+function _e(e) {
return e.filter((e) => ["115", "pikpak"].includes(e.location) && (e.roots === void 0 || e.roots.length > 0)).map((e) => e.location);
}
-function ye(e, t) {
+function ve(e, t) {
return t.filter((t) => e.some((e) => e.location === t));
}
-function be() {
+function ye() {
let e = [
["人工复核", "square-check-big"],
["高清版", "sparkles"],
@@ -624,20 +621,20 @@ function be() {
}
//#endregion
//#region src/resource-sync.ts
-var q = (e = 0) => Number(e).toLocaleString(), xe = {
+var q = (e = 0) => Number(e).toLocaleString(), be = {
local: "本地磁盘",
115: "115",
pikpak: "PikPak"
-}, Se = (t) => o(e[t] ?? "database"), J = (e, t, n) => `<article class="board-plain-stat resourcestat">
+}, xe = (t) => o(e[t] ?? "database"), J = (e, t, n) => `<article class="board-plain-stat resourcestat">
<span class="board-plain-stat-head">${e}</span>
<strong>${t}</strong>
<span class="cleanupmeta">${n}</span></article>`;
-function Ce(e, t) {
+function Se(e, t) {
let n = e.cache || {
files: 0,
bytes: 0
}, r = !!(e.missing || n.files);
- return `<div class="cleanupstats resourcestats">${(e.sources || []).map((e) => J(`<span class="board-stat-tile resourcestat-tile">${Se(e.location)}</span>${xe[e.location] || "媒体来源"}<span class="resourcestat-state ${e.online ? "online" : "offline"}">${e.online ? "可访问" : "离线,已跳过"}</span>`, e.online ? `${q(e.missing)} 项` : "—", [e.online ? `找不到文件 · 已检查 ${q(e.checked)} 项` : `馆藏中有 ${q(e.total)} 项`, e.unreadable ? `${q(e.unreadable)} 项读取失败,已跳过` : ""].filter(Boolean).join(" · "))).join("")}
+ return `<div class="cleanupstats resourcestats">${(e.sources || []).map((e) => J(`<span class="board-stat-tile resourcestat-tile">${xe(e.location)}</span>${be[e.location] || "媒体来源"}<span class="resourcestat-state ${e.online ? "online" : "offline"}">${e.online ? "可访问" : "离线,已跳过"}</span>`, e.online ? `${q(e.missing)} 项` : "—", [e.online ? `找不到文件 · 已检查 ${q(e.checked)} 项` : `馆藏中有 ${q(e.total)} 项`, e.unreadable ? `${q(e.unreadable)} 项读取失败,已跳过` : ""].filter(Boolean).join(" · "))).join("")}
${J("待移入回收站", `${q(e.missing)} 项`, "")}
${J("可清理的缓存", `${q(n.files)} 个`, n.files ? t(n.bytes) : "")}</div>
${r ? i(`将把找不到文件的 ${q(e.missing)} 项馆藏记录移入回收站,并清理 ${q(n.files)} 个闲置缓存。`, { label: "清理内容" }) : ""}
@@ -652,7 +649,7 @@ function Y(e) {
"preview"
].includes(String(e)) ? "small" : "big";
}
-function we(e) {
+function Ce(e) {
return {
javLayout: Y(e.javLayout),
javImage: X(e.javLayout === "preview" ? "thumbnail" : e.javImage)
@@ -661,10 +658,10 @@ function we(e) {
function X(e) {
return e === "thumbnail" ? "thumbnail" : "cover";
}
-function Te(e, t) {
+function we(e, t) {
return e.is_jav && e.code && e.has_cover && (X(t) === "cover" || !e.has_thumb) ? "cover" : e.has_thumb ? "thumbnail" : "";
}
-function Ee(e, t) {
+function Te(e, t) {
let n = Number(e?.px?.[0]), r = Number(e?.px?.[1]), i = Number(e?.x0);
if (!(n > 0 && r > 0 && t > 0) || !Number.isFinite(i)) return null;
let a = (e, t, n) => Math.min(n, Math.max(0, Number.isFinite(Number(e)) ? Number(e) : t)), o = a(i, 0, n), s = Math.max(o, a(e?.x1, n, n)), c = a(e?.y0, 0, r), l = Math.max(c, a(e?.y1, r, r)), u = s - o, d = l - c;
@@ -684,7 +681,7 @@ function Ee(e, t) {
height: m(r / d)
};
}
-function De(e, t) {
+function Ee(e, t) {
e.querySelectorAll("img[data-jav-image]").forEach((e) => {
let n = e.dataset.javCover || "", r = e.dataset.javThumb || "", i = !!(n && (X(t) === "cover" || !r)), a = i ? n : r;
e.classList.toggle("cover", i), e.classList.toggle("whole", i && e.dataset.javImageLayout !== "big"), e.classList.toggle("front", i && e.dataset.javImageLayout === "big"), e.classList.remove("panel"), e.removeAttribute("style"), e.closest(".pic")?.style.removeProperty("--cover-blur"), a && e.getAttribute("src") !== a && (e.src = a);
@@ -704,8 +701,8 @@ var Z = {
activity: { react: "activity" },
stats: { react: "stats" },
taste: { react: "taste" }
-}, Oe = () => Object.keys(Z), Q = /* @__PURE__ */ new Map();
-async function ke(e, t, n, r = {}) {
+}, De = () => Object.keys(Z), Q = /* @__PURE__ */ new Map();
+async function Oe(e, t, n, r = {}) {
let i = Z[e];
if (!i) throw Error(`未注册的 island:${String(e)}`);
$(t);
@@ -717,7 +714,7 @@ async function ke(e, t, n, r = {}) {
} catch {
if (a.controller.signal.aborted) return;
}
- if (!Ae(t, a, r)) return;
+ if (!ke(t, a, r)) return;
let s = t.ownerDocument.createElement("div");
s.className = "peach-react", t.append(s);
let c = o.mount(s, n);
@@ -725,16 +722,16 @@ async function ke(e, t, n, r = {}) {
c.unmount(), s.remove();
};
}
-function Ae(e, t, n) {
+function ke(e, t, n) {
return Q.get(e) === t ? n.isCurrent && !n.isCurrent() ? (Q.delete(e), !1) : (e.textContent = "", !0) : !1;
}
-var je = (e) => !!e && Q.has(e);
+var Ae = (e) => !!e && Q.has(e);
function $(e) {
- for (let t of [...Q.keys()]) (t === e || e.contains(t)) && Me(t);
+ for (let t of [...Q.keys()]) (t === e || e.contains(t)) && je(t);
}
-function Me(e) {
+function je(e) {
let t = Q.get(e);
t && (t.controller.abort(), Q.delete(e), t.dispose?.());
}
//#endregion
-export { de as boardPageSkeleton, f as boundedPreference, me as catalogEmptyHtml, K as catalogSuggestions, oe as clampPage, be as cleanupSkeletonHtml, ve as cloudLocations, ye as cloudPreferenceLocations, ue as detailSkeletonHtml, pe as emptyCatalogLayout, ce as entitySkeletonHtml, j as faceSourceScale, D as followJobProgress, g as initBoardControls, je as islandMounted, Oe as islandNames, Te as javImageKind, T as jobActivityHtml, A as matchesFaceSource, ke as mountIsland, m as mountNumberSetting, M as nativeImageFit, X as normalizeJavImage, Y as normalizeJavLayout, we as normalizeJavPreferences, ae as pageCount, se as paginationHtml, Ee as panelFrame, u as preferredDirection, Ce as resourceScanHtml, ne as selectGroup, O as selectRange, k as selectionSummary, he as sidebarHasCatalogContent, S as sidebarSectionHtml, _e as sidebarTagCounts, h as syncBoardRange, De as syncJavImages, p as syncNumberSetting, re as syncSelectionToolbar, ge as syncSidebarSurface, te as transitionTheme, $ as unmountIsland, E as watchJob, ee as wireSidebarGroups };
+export { K as boardPageSkeleton, f as boundedPreference, pe as catalogEmptyHtml, fe as catalogSuggestions, O as clampPage, ye as cleanupSkeletonHtml, _e as cloudLocations, ve as cloudPreferenceLocations, le as detailSkeletonHtml, de as emptyCatalogLayout, ce as entitySkeletonHtml, A as faceSourceScale, ne as followJobProgress, g as initBoardControls, Ae as islandMounted, De as islandNames, we as javImageKind, T as jobActivityHtml, Oe as mountIsland, m as mountNumberSetting, j as nativeImageFit, X as normalizeJavImage, Y as normalizeJavLayout, Ce as normalizeJavPreferences, D as pageCount, k as paginationHtml, Te as panelFrame, u as preferredDirection, Se as resourceScanHtml, ae as selectGroup, re as selectRange, ie as selectionSummary, me as sidebarHasCatalogContent, S as sidebarSectionHtml, ge as sidebarTagCounts, h as syncBoardRange, Ee as syncJavImages, p as syncNumberSetting, oe as syncSelectionToolbar, he as syncSidebarSurface, te as transitionTheme, $ as unmountIsland, E as watchJob, ee as wireSidebarGroups };