Peach: Local-first video metadata scraper and media manager.
refactor(catalog): 单独计算推荐的正向行为证据
longmeidao532c74501b1b
diff --git a/docs/STATUS.md b/docs/STATUS.mdindex 9fa02c493..41a7cb3f7 100644--- a/docs/STATUS.md+++ b/docs/STATUS.md@@ -17,8 +17,7 @@- Windows 托盘自动恢复,重启用 `restart_windows_tray.py --source`;代码与数据在内置盘,媒体在外置盘。- 托盘须普通权限启动:提权令牌看不到 CloudDrive 的 `A:`/`B:`,误报脱盘。- Windows:80→HTTPS、LAN:443;`peach-win`、`0.38.0`。CA、健康通过。-- Peach 配置:目录左侧、教程单行;活动明细折叠。-- JAV 发现含库外作品与少看的馆藏,不设发行日期阈值;已有口味维度为女优、标签、厂牌和系列,历史目录扩展见 [发现方案](JAV_DISCOVERY.md)。库外作品共用站内详情,公开评论、预览与资源按需读取。+- 配置分组、活动折叠;[JAV 发现](JAV_DISCOVERY.md)。- `/healthz` 报 `configurable=true`;配置与选目录共用连接判据,托盘管理 HTTPS 地址、端口及重载。- 首启、配置页列缺失依赖(CloudDrive、挂载驱动、FFmpeg/ffprobe、OpenSSL);Windows 识别 CloudDrive、WinFsp。- 访问密码未开,局域网匿名可读;首启可跳过密码,配置页可改可关,登录可记住设备。diff --git a/src/peach/taste_history.py b/src/peach/taste_history.pyindex 458081716..109d8d523 100644--- a/src/peach/taste_history.py+++ b/src/peach/taste_history.py@@ -766,6 +766,21 @@ def _solo_representatives(linked: list[tuple[int, int, str, str]]) -> dict[str,return chosen+def _positive_behavior_score(row: dict, *, exclude_disliked: bool) -> float:+ """按观看与明确反馈计算正向证据,不从不合口味推导负向标签。"""+ if exclude_disliked and row.get("feedback") == "dislike":+ return 0.0+ seconds = max(float(row.get("play_seconds") or 0), 0)+ plays = max(int(row.get("play_count") or 0), 0)+ o_count = max(int(row.get("o_count") or 0), 0)+ rating = max(int(row.get("rating") or 0), 0)+ score = (1.0 if plays or seconds else 0.0) + math.log2(1 + seconds / 60)+ score += min(plays, 12) * .75 + min(o_count, 8) * 1.5 + rating / 20+ score += 3.0 if row.get("liked") else 0.0+ score += .5 if row.get("feedback") == "seen" else 0.0+ return max(score, 0.0)++def _peach_dashboard_evidence(connection: sqlite3.Connection, since: str | None, *, exclude_disliked: bool = False) -> dict[str, object]:since_epoch = datetime.fromisoformat(since).timestamp() if since else Nonerows = connection.execute(@@ -785,16 +800,9 @@ def _peach_dashboard_evidence(connection: sqlite3.Connection, since: str | None,if since_epoch is not None and (played_at is None or played_at < since_epoch):continueseconds = max(float(row.get("play_seconds") or 0), 0)- plays = max(int(row.get("play_count") or 0), 0)- o_count = max(int(row.get("o_count") or 0), 0)- rating = max(int(row.get("rating") or 0), 0)is_liked = bool(row.get("liked"))is_disliked = row.get("feedback") == "dislike"- positive = (1.0 if plays or seconds else 0.0) + math.log2(1 + seconds / 60)- positive += min(plays, 12) * .75 + min(o_count, 8) * 1.5 + rating / 20- positive += 3.0 if is_liked else 0.0- positive += .5 if row.get("feedback") == "seen" else 0.0- row["positive"] = 0.0 if exclude_disliked and is_disliked else max(positive, 0.0)+ row["positive"] = _positive_behavior_score(row, exclude_disliked=exclude_disliked)assets[int(row["id"])] = rowtotal_seconds += secondsliked += int(is_liked)