Skip to content

armgit / peach

Public Imported from GitHub
0

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

feat(feed): ハイライト厂牌算切片,新作那一行默认收起,设置里单独一个开关

longmeidao707e661b2159
diff --git a/src/peach/feed_followup.py b/src/peach/feed_followup.py
index da80d2b20..48400fe80 100644
--- a/src/peach/feed_followup.py
+++ b/src/peach/feed_followup.py
@@ -95,7 +95,7 @@ def backlog(connection, cover_root: Path, *, exclude=(), now: datetime | None =
cutoff = feeds.stamp(moment - retry_after)
skip = set(exclude)
rows = connection.execute(
- "SELECT d.code,d.title,d.performers,d.scraped_at,d.scrape_error FROM feed_discovery d"
+ "SELECT d.code,d.title,d.performers,d.studio,d.scraped_at,d.scrape_error FROM feed_discovery d"
" WHERE d.ignored_at IS NULL AND (d.scraped_at IS NULL OR d.scraped_at<?)"
" AND NOT EXISTS (SELECT 1 FROM asset a WHERE a.code IS NOT NULL"
" AND normalise_code_key(a.code)=normalise_code_key(d.code))"
@@ -104,7 +104,8 @@ def backlog(connection, cover_root: Path, *, exclude=(), now: datetime | None =
found: list[str] = []
for row in rows:
code = row["code"]
- if code in skip or feeds.compilation_kind(row["title"], row["performers"]) in hidden:
+ if code in skip or feeds.compilation_kind(
+ row["title"], row["performers"], row["studio"]) in hidden:
continue
needs_fields = row["scraped_at"] is None or row["scrape_error"] is not None
if needs_fields or not has_local_cover(cover_root, code):
diff --git a/src/peach/feeds.py b/src/peach/feeds.py
index ffceacd82..c161cef7f 100644
--- a/src/peach/feeds.py
+++ b/src/peach/feeds.py
@@ -65,18 +65,26 @@ COMPILATION_PERFORMERS = 8
#: 可能正想要;大合集是一串人的片段拼起来卖。两类各有一个开关,默认只收起大合集。
SOLO_COMPILATION = "solo"
GROUP_COMPILATION = "group"
-DEFAULT_HIDDEN_COMPILATIONS = frozenset({GROUP_COMPILATION})
+#: 切片:把已经出过的正片剪成十几分钟单卖。ハイライト 的 HIGM-218 就是 MRSS-124 里的
+#: 一段,122 分钟剪成 13 分钟、封面印着「¥99」(2026-09-23 对过 DMM 的片长与封面)。
+#: 片名照抄原片的剧情名,标题记号认不出来,只能按厂牌认。
+EXCERPT = "excerpt"
+EXCERPT_STUDIOS = frozenset({"ハイライト"})
+DEFAULT_HIDDEN_COMPILATIONS = frozenset({GROUP_COMPILATION, EXCERPT})
-def compilation_kind(title: str | None, performers: str | None) -> str | None:
- """这部新作是哪一类合集:`solo`、`group`,不是合集为 None。
+def compilation_kind(title: str | None, performers: str | None,
+ studio: str | None = None) -> str | None:
+ """这部新作是哪一类合集:`solo`、`group`、`excerpt`,不是合集为 None。
新作那一行是给「她出了什么新片」看的,合集里的片段多半早就出过。判据只看壳上已有
的标题与出演名单,读的时候现算,壳上不存(ADR-0042):规则或开关改了,已经取回的壳
跟着变,不用重刮。名单只列一个人、标题带精选记号或片长到四小时的是单人合集;名单
- 没取到时按记号与片长算大合集,名单到八人起不看标题也是大合集。
+ 没取到时按记号与片长算大合集,名单到八人起不看标题也是大合集。切片厂牌先于这些判。
"""
- names = [name for name in (performers or "").split("、") if name.strip()]
+ if str(studio or "").strip() in EXCERPT_STUDIOS:
+ return EXCERPT
+ names =[name for name in (performers or "").split("、") if name.strip()]
text = title or ""
marked = (bool(_COMPILATION_TITLE.search(text))
or any(int(hours) * 60 >= COMPILATION_MINUTES for hours in _HOURS.findall(text))
@@ -92,7 +100,8 @@ def register_functions(connection: sqlite3.Connection,
hidden: frozenset[str] = DEFAULT_HIDDEN_COMPILATIONS) -> None:
"""把「这条收起不列」挂到这条连接上,SQL 里按同一份实现筛,分页的条数才对得上。"""
connection.create_function(
- "is_feed_hidden", 2, lambda title, performers: compilation_kind(title, performers) in hidden,
+ "is_feed_hidden", 3,
+ lambda title, performers, studio: compilation_kind(title, performers, studio) in hidden,
deterministic=True)
diff --git a/src/peach/web_feeds.py b/src/peach/web_feeds.py
index 942424a99..a20fa7ff2 100644
--- a/src/peach/web_feeds.py
+++ b/src/peach/web_feeds.py
@@ -301,7 +301,7 @@ DISCOVERY_LIMIT = 24
LISTED = (
"NOT EXISTS (SELECT 1 FROM asset a WHERE a.code IS NOT NULL"
" AND normalise_code_key(a.code)=normalise_code_key(d.code))",
- "NOT is_feed_hidden(d.title,d.performers)",
+ "NOT is_feed_hidden(d.title,d.performers,d.studio)",
)
diff --git a/src/peach/web_settings.py b/src/peach/web_settings.py
index d40571e09..21509dadf 100644
--- a/src/peach/web_settings.py
+++ b/src/peach/web_settings.py
@@ -18,7 +18,7 @@ import json
import time
from typing import Protocol
-from .feeds import DEFAULT_HIDDEN_COMPILATIONS, GROUP_COMPILATION, SOLO_COMPILATION
+from .feeds import DEFAULT_HIDDEN_COMPILATIONS, EXCERPT, GROUP_COMPILATION, SOLO_COMPILATION
DEFAULT_PROFILE_ID = "local-default"
@@ -53,11 +53,13 @@ DEFAULT_FOLLOW_INITIAL_DAYS = 30
SYNCED_SETTING_KEYS = frozenset({
"sidebarOrder", "metadataRefreshDays", "followInitialDays", "postSetupTutorialDone",
"organizeTemplates", "feedHideGroupCompilations", "feedHideSoloCompilations",
+ "feedHideExcerpts",
})
-#: 两个合集开关的键与各自对应的那一类,缺省值取 `feeds.DEFAULT_HIDDEN_COMPILATIONS`。
+#: 三个收起开关的键与各自对应的那一类,缺省值取 `feeds.DEFAULT_HIDDEN_COMPILATIONS`。
FEED_COMPILATION_SWITCHES = (
("feedHideGroupCompilations", GROUP_COMPILATION),
("feedHideSoloCompilations", SOLO_COMPILATION),
+ ("feedHideExcerpts", EXCERPT),
)
diff --git a/tests/test_feeds.py b/tests/test_feeds.py
index f17c88631..90f41cb98 100644
--- a/tests/test_feeds.py
+++ b/tests/test_feeds.py
@@ -114,6 +114,13 @@ class CompilationTest(unittest.TestCase):
with self.subTest(title=title):
self.assertIsNone(feeds.compilation_kind(title, performers))
+ def test_the_highlight_studio_is_an_excerpt_whatever_the_title_says(self):
+ self.assertEqual(feeds.compilation_kind("愛する妻が…", "篠田ゆう", "ハイライト"),
+ feeds.EXCERPT)
+ self.assertEqual(feeds.compilation_kind("涼森れむ 480分 総集編", "涼森れむ", "ハイライト"),
+ feeds.EXCERPT)
+ self.assertIsNone(feeds.compilation_kind("愛する妻が…", "篠田ゆう", "マドンナ"))
+
class FeedStoreTest(unittest.TestCase):
def setUp(self):
diff --git a/tests/test_feeds_web.py b/tests/test_feeds_web.py
index 6bc3ba25e..21ab2c295 100644
--- a/tests/test_feeds_web.py
+++ b/tests/test_feeds_web.py
@@ -253,6 +253,17 @@ class FeedWebTest(FeedWebFixture):
self.assertCountEqual(self._listed(), ["SSIS-950", "HMN-071"])
self.assertEqual(self._backlog(), ["SSIS-950"])
+ def test_a_highlight_excerpt_is_hidden_by_studio_until_its_switch_is_off(self):
+ self._compilation("篠田ゆう")
+ with self.contract.database.write_transaction() as connection:
+ connection.execute("UPDATE feed_discovery SET title='愛する妻が…',studio='ハイライト'"
+ " WHERE code='SSIS-950'")
+ self.assertEqual(self._listed(), ["HMN-071"])
+ self.assertEqual(self._backlog(), [])
+ dispatch_api_post(self.contract, "/api/settings", {"feedHideExcerpts": False})
+ self.assertCountEqual(self._listed(), ["SSIS-950", "HMN-071"])
+ self.assertEqual(self._backlog(), ["SSIS-950"])
+
def test_the_entity_filter_only_returns_that_person(self):
with self.contract.database.write_transaction() as connection:
cursor = connection.execute(
diff --git a/tests/test_web_settings.py b/tests/test_web_settings.py
index ca9783a2b..c0e85ef5d 100644
--- a/tests/test_web_settings.py
+++ b/tests/test_web_settings.py
@@ -96,14 +96,15 @@ class SettingsRoundTripTests(unittest.TestCase):
"metadataRefreshDays": web_settings.DEFAULT_METADATA_REFRESH_DAYS,
"followInitialDays": 30, "postSetupTutorialDone": False,
"organizeTemplates": {}, "feedHideGroupCompilations": True,
- "feedHideSoloCompilations": False})
+ "feedHideSoloCompilations": False, "feedHideExcerpts": True})
def test_the_compilation_switches_take_only_booleans(self):
with self.assertRaises(ValueError):
w_settings(self.contract, {"feedHideSoloCompilations": "yes"})
- self.assertEqual(web_settings.hidden_compilations(self.contract), frozenset({"group"}))
+ self.assertEqual(web_settings.hidden_compilations(self.contract),
+ frozenset({"group", "excerpt"}))
w_settings(self.contract, {"feedHideSoloCompilations": True,
- "feedHideGroupCompilations": False})
+ "feedHideGroupCompilations": False, "feedHideExcerpts": False})
self.assertEqual(web_settings.hidden_compilations(self.contract), frozenset({"solo"}))
def test_the_metadata_refresh_period_round_trips_and_rejects_odd_values(self):
@@ -130,7 +131,7 @@ class SettingsRoundTripTests(unittest.TestCase):
"metadataRefreshDays": web_settings.DEFAULT_METADATA_REFRESH_DAYS,
"followInitialDays": 30, "postSetupTutorialDone": False,
"organizeTemplates": {}, "feedHideGroupCompilations": True,
- "feedHideSoloCompilations": False})
+ "feedHideSoloCompilations": False, "feedHideExcerpts": True})
self.assertEqual(q_settings(self.contract)["sidebarOrder"], order)
self.assertEqual(self._stored_json()["sidebarOrder"], order)
diff --git a/web/app.js b/web/app.js
index 93c6a5892..945965fc9 100644
--- a/web/app.js
+++ b/web/app.js
@@ -548,11 +548,13 @@ appSettings.miniplayer=appSettings.miniplayer!==false;
appSettings.uiSounds=appSettings.uiSounds!==false;
appSettings.feedAutoScroll=appSettings.feedAutoScroll!==false;
/* 新作那一行收不收合集由服务端按账本里的设置筛(列表、未读数、补封面同一份),这里只是
- 镜像:开关的真相在 `/api/settings`。默认收起大合集、单人合集照列。 */
+ 镜像:开关的真相在 `/api/settings`。默认收起大合集与切片、单人合集照列。 */
const FEED_COMPILATION_SWITCHES=[['feedHideGroupSetting','feedHideGroupCompilations','大合集'],
- ['feedHideSoloSetting','feedHideSoloCompilations','单人合集']];
+ ['feedHideSoloSetting','feedHideSoloCompilations','单人合集'],
+ ['feedHideExcerptSetting','feedHideExcerpts','切片']];
appSettings.feedHideGroupCompilations=appSettings.feedHideGroupCompilations!==false;
appSettings.feedHideSoloCompilations=appSettings.feedHideSoloCompilations===true;
+appSettings.feedHideExcerpts=appSettings.feedHideExcerpts!==false;
appSettings.searchHistoryLimit=boundedPreference(+appSettings.searchHistoryLimit,0,50,10);
appSettings.relatedLimit=boundedPreference(+appSettings.relatedLimit,0,60,20);
const METADATA_REFRESH_DAYS=[0,7,30,90];
diff --git a/web/index.html b/web/index.html
index b324aa4cd..8e24f076a 100644
--- a/web/index.html
+++ b/web/index.html
@@ -323,6 +323,7 @@
<label class="settingrow"><span><b>新作自动滚动</b><small id="feedAutoScrollDescription">首页和人物页那一行未入库的新作缓缓向前滚,到头停一下再往回;指针移上去或手动滚过时停下。</small></span><input class="ptoggle" type="checkbox" id="feedAutoScrollSetting" role="switch" aria-describedby="feedAutoScrollDescription"></label>
<label class="settingrow"><span><b>新作收起大合集</b><small id="feedHideGroupDescription">多人片段拼成的精选、总集和连发不进新作那一行,也不替它们补封面。</small></span><input class="ptoggle" type="checkbox" id="feedHideGroupSetting" role="switch" aria-describedby="feedHideGroupDescription"></label>
<label class="settingrow"><span><b>新作收起单人合集</b><small id="feedHideSoloDescription">只有一位女优的精选与长时间合集,比如「8時間 BEST」。</small></span><input class="ptoggle" type="checkbox" id="feedHideSoloSetting" role="switch" aria-describedby="feedHideSoloDescription"></label>
+ <label class="settingrow"><span><b>新作收起切片</b><small id="feedHideExcerptDescription">把出过的正片剪成十几分钟单卖的,比如ハイライト厂牌。</small></span><input class="ptoggle" type="checkbox" id="feedHideExcerptSetting" role="switch" aria-describedby="feedHideExcerptDescription"></label>
</section>
<section class="settinggroup"><h3>播放</h3>
<div class="settingrow"><span><b>悬停放大</b><small>转圈完成后进入放大预览。</small></span><div id="hoverDelaySetting"></div></div>