Peach: Local-first video metadata scraper and media manager.
fix(catalog): restore online filtering and home navigation
longmeidaoa369fabe1bff
diff --git a/src/peach/web_contract.py b/src/peach/web_contract.pyindex 9b07066ef..1ab85c6af 100644--- a/src/peach/web_contract.py+++ b/src/peach/web_contract.py@@ -388,7 +388,10 @@ def q_items(contract: WebContract, args):if state:where.append(state)if args.get("thumb") == "1":- where.append("a.snapshot_path IS NOT NULL")+ # 已保存的关注条目只登记在线资产,不下载媒体或生成本地缩略图。+ # 它仍然是可筛选的真实资产;若沿用首页的缩略图门槛,来源 facet 会显示+ # 「在线 1」,点进去却永远是 0 条。+ where.append("(a.snapshot_path IS NOT NULL OR a.location = 'online')")order = {"new": "a.first_seen DESC, a.id DESC","big": "a.size DESC",diff --git a/tests/test_fastapi_api.py b/tests/test_fastapi_api.pyindex 1db3785bf..fa1c0936b 100644--- a/tests/test_fastapi_api.py+++ b/tests/test_fastapi_api.py@@ -520,6 +520,22 @@ class FastApiContractTests(unittest.IsolatedAsyncioTestCase):{"k": "横屏", "n": 1},])+ async def test_saved_online_asset_survives_the_default_thumbnail_filter(self):+ connection = sqlite3.connect(self.db)+ connection.execute(+ "INSERT INTO asset(id,location,path,name,medium,first_seen) "+ "VALUES(2,'online','https://example.test/post/2','Saved online post','video','2026-08-30')"+ )+ connection.commit(); connection.close()++ listed = await self.client.get(+ "/api/items?t=secret&loc=online&thumb=1&limit=10"+ )+ self.assertEqual(listed.status_code, 200)+ self.assertEqual(listed.json()["total"], 1)+ self.assertEqual(listed.json()["items"][0]["location"], "online")+ self.assertFalse(listed.json()["items"][0]["has_thumb"])+async def test_multipart_api_keeps_assets_separate_but_returns_an_ordered_queue(self):connection = sqlite3.connect(self.db)connection.executemany(diff --git a/tests/test_web_ui.py b/tests/test_web_ui.pyindex 95c315ddf..76ebd5f99 100644--- a/tests/test_web_ui.py+++ b/tests/test_web_ui.py@@ -716,6 +716,12 @@ class WebUiSourceTests(unittest.TestCase):# 分支只能存在一处;再出现第二份就是下一次漂移。self.assertEqual(self.page.count("if(k==='immerse'){openTok();return}"), 1)+ def test_online_assets_use_rss_and_open_the_saved_follow_surface(self):+ self.assertPageContains("online:icon('rss')")+ self.assertPageLacks("online:icon('globe')")+ self.assertPageContains('id="onlineGate"')+ self.assertPageContains("$('#openSavedFollow').onclick=()=>{followFilter='saved';openFollow()}")+def test_scrim_never_covers_the_drawer_it_dims(self):"""遮罩铺满全屏。它排在抽屉之上时,抽屉里每一下点击都落在遮罩上,而遮罩的 onclick 是「收起抽屉」——表现就是能弹出、什么都点不到、一点就关。@@ -895,6 +901,7 @@ class WebUiSourceTests(unittest.TestCase):# 两份副本正是当初把追更入口漏在抽屉里的原因。self.assertEqual(self.page.count("function navTo(k){"), 1,"导航分支只能留一份 navTo")+ self.assertPageContains("if(k==='')state.jav='';")self.assertPageContains("state.state=k}\n route(homePath());")def test_ads_icon_matches_the_lucide_stroke_style(self):diff --git a/web/app.js b/web/app.jsindex 83e051465..58a3318fd 100644--- a/web/app.js+++ b/web/app.js@@ -162,7 +162,7 @@ const SRCICON={'115':'<img class="source-icon" src="/logo?studio=115" alt="" onerror="this.remove()">',// PikPak 官方触屏图标(取证 follow-source-icons-measured.md);/logo 的生成 logo 不对版。pikpak:'<img class="source-icon" src="https://mypikpak.com/apple-touch-icon.png" alt="" loading="lazy" referrerpolicy="no-referrer" onerror="this.remove()">',- online:icon('globe'),+ online:icon('rss'),};const srcBadge=(loc,cost,cls)=>{const label=`${LOC[loc]||loc}${cost==='metered'?' · 计费':''}`;return `<span class="${cls||'src'} ${cost==='metered'?'metered':'free'}" title="${esc(label)}" aria-label="${esc(label)}">`@@ -3749,6 +3749,7 @@ function navTo(k){if(k==='manage'){openManage();return}if(k==='jav'){toggleJavMode();return}if(k==='performers'||k==='tags'){setSelectMode(false,true);openIndex(k);return}+ if(k==='')state.jav='';if(k==='shorts'){state.orient='竖屏';state.state=''}else{state.orient='';state.state=k}route(homePath());showHomeSurfaces();@@ -4069,6 +4070,7 @@ async function openItem(id,push=true,queueContext=null){? {...returnBars.filters}:emptyEntityFilters()};const gated=it.cost==='metered';const offline=sourceOffline(it.location);+ const online=it.location==='online';const who=it.creator||it.code||it.studio||'未归属';const refs=it.entity_refs||{},studioRef=(refs.studio||[])[0];// 共演作品的女优逐行列出,每行带自己的头像;标签只写在第一行,其余留空保持对齐。@@ -4135,6 +4137,13 @@ async function openItem(id,push=true,queueContext=null){<button class="chip" id="offlineRetry" type="button">重新检测</button></div><video id="vid" class="video-js vjs-big-play-centered" controls playsinline preload="none"hidden style="display:none"></video>`+ :online?`<div class="gate" id="onlineGate" role="status">+ ${srcBadge(it.location,it.cost,'srcbig')}+ <b style="font-size:14px">在线资产</b>+ <span style="font-size:12px;color:var(--muted)">这条内容从关注候选保存;媒体与原始页面在关注详情中查看。</span>+ <button class="chip" id="openSavedFollow" type="button">打开已保存关注</button></div>+ <video id="vid" class="video-js vjs-big-play-centered" controls playsinline preload="none"+ hidden style="display:none"></video>`:gated?`<div class="gate" id="gate">${srcBadge(it.location,it.cost,'srcbig')}<span style="font-size:12px;color:var(--muted)">点此开始拉流 · ${fmtSize(it.size||0)}</span></div>@@ -4195,6 +4204,7 @@ async function openItem(id,push=true,queueContext=null){$('#stage').querySelectorAll('[data-queue-remove]').forEach(b=>b.onclick=()=>removePlaylistItem(queueContext,+b.dataset.queueRemove,it.id));wireDrag($('#stage').querySelector('.mixlist'));const g=$('#gate');+ const onlineGate=$('#onlineGate');$('#addPlaylist').onclick=()=>openAddToPlaylist(it);$('#stage').querySelectorAll('[data-kind]').forEach(b=>b.onclick=async()=>{try{@@ -4325,6 +4335,9 @@ async function openItem(id,push=true,queueContext=null){openItem(it.id,false); // 盘回来了就按正常路径重开,不在这里半路挂播放器};}+ else if(onlineGate){+ $('#openSavedFollow').onclick=()=>{followFilter='saved';openFollow()};+ }else if(g)g.onclick=()=>{vv.hidden=false;g.remove();mountDetailPlayer(it,vv,true);stopAmbient=startAmbient()};else{mountDetailPlayer(it,vv,true);stopAmbient=startAmbient()}vv.addEventListener('emptied',()=>stopAmbient(),{once:true});