feat(search): Library provenance filter (organic / all / search-only)

Replace the binary 'show search-discovered' toggle with a 3-way Source selector in the
Library toolbar, so users can also see ONLY search-discovered videos — not just hide or
mix them. Backend: feed param library_source = organic (default, hides via_search) | all
(both) | search (only via_search), applied in scope=all. Strings in HU/EN/DE.
This commit is contained in:
npeter83 2026-06-29 02:11:53 +02:00
parent 546be57963
commit 8b19faaed1
6 changed files with 57 additions and 33 deletions

View file

@ -124,7 +124,7 @@ def _filtered_query(
include_live: bool, include_live: bool,
show: str, show: str,
scope: str = "my", scope: str = "my",
exclude_search_discovered: bool = True, library_source: str = "organic",
exclude_tag_category: str | None = None, exclude_tag_category: str | None = None,
) -> tuple[Select, object]: ) -> tuple[Select, object]:
"""Build the feed query (joins + all WHERE filters), shared by /feed and /feed/count. """Build the feed query (joins + all WHERE filters), shared by /feed and /feed/count.
@ -172,11 +172,16 @@ def _filtered_query(
# either way they shouldn't show in any feed view meanwhile. # either way they shouldn't show in any feed view meanwhile.
query = query.where(Video.unavailable_since.is_(None)) query = query.where(Video.unavailable_since.is_(None))
# Hide videos that only entered the catalog via a live YouTube search (search-discovered # Provenance filter for the Library: search-discovered videos are "noise" hidden by
# "noise") from the Library by default. Only meaningful in "all" scope: "my" already # default ("organic"), can be mixed in ("all"), or shown exclusively ("search"). Only
# restricts to subscribed channels, where a once-searched video is legitimately the user's. # meaningful in "all" scope: "my" already restricts to subscribed channels, where a
if scope == "all" and exclude_search_discovered: # once-searched video is legitimately the user's.
query = query.where(Video.via_search.is_(False)) if scope == "all":
if library_source == "organic":
query = query.where(Video.via_search.is_(False))
elif library_source == "search":
query = query.where(Video.via_search.is_(True))
# "all" → both organic and search-discovered videos
if channel_id: if channel_id:
query = query.where(Video.channel_id == channel_id) query = query.where(Video.channel_id == channel_id)
@ -278,7 +283,7 @@ def _feed_params(
include_live: bool = False, include_live: bool = False,
show: str = "unwatched", show: str = "unwatched",
scope: str = "my", scope: str = "my",
exclude_search_discovered: bool = True, library_source: str = "organic",
) -> dict: ) -> dict:
return { return {
"tags": tags, "tags": tags,
@ -295,7 +300,7 @@ def _feed_params(
"include_live": include_live, "include_live": include_live,
"show": show, "show": show,
"scope": scope, "scope": scope,
"exclude_search_discovered": exclude_search_discovered, "library_source": library_source,
} }

View file

@ -417,20 +417,24 @@ export default function Feed({
{filters.scope === "all" && ( {filters.scope === "all" && (
<> <>
<span className="mx-1 h-5 w-px bg-border" aria-hidden="true" /> <span className="mx-1 h-5 w-px bg-border" aria-hidden="true" />
<button <label className="inline-flex items-center gap-1.5 text-xs text-muted">
onClick={() => <span>{t("feed.source.label")}</span>
setFilters({ ...filters, showSearchDiscovered: !filters.showSearchDiscovered }) <select
} value={filters.librarySource ?? "organic"}
aria-pressed={!!filters.showSearchDiscovered} onChange={(e) =>
title={t("feed.searchDiscoveredTip")} setFilters({
className={`text-xs px-3 py-1.5 rounded-full border transition ${ ...filters,
filters.showSearchDiscovered librarySource: e.target.value as FeedFilters["librarySource"],
? "bg-accent text-accent-fg border-accent" })
: "border-border text-muted hover:text-fg hover:border-accent" }
}`} title={t("feed.source.tip")}
> className="bg-card border border-border rounded-lg px-2 py-1 text-xs outline-none focus:border-accent"
{t("feed.searchDiscovered")} >
</button> <option value="organic">{t("feed.source.organic")}</option>
<option value="all">{t("feed.source.all")}</option>
<option value="search">{t("feed.source.only")}</option>
</select>
</label>
</> </>
)} )}
</div> </div>

View file

@ -30,8 +30,13 @@
"markedWatchedNamed": "Als angesehen markiert: „{{title}}”", "markedWatchedNamed": "Als angesehen markiert: „{{title}}”",
"markedWatched": "Als angesehen markiert", "markedWatched": "Als angesehen markiert",
"unwatch": "Nicht mehr als angesehen", "unwatch": "Nicht mehr als angesehen",
"searchDiscovered": "Über Suche gefunden", "source": {
"searchDiscoveredTip": "Auch Videos anzeigen, die nur über eine Live-YouTube-Suche in die Bibliothek kamen.", "label": "Quelle",
"tip": "Bibliothek danach filtern, wie Videos hierher kamen: nur organischer Katalog, mit Suchergebnissen, oder nur über Live-YouTube-Suche gefundene Videos.",
"organic": "Ohne Suchergebnisse",
"all": "Mit Suchergebnissen",
"only": "Nur Suchergebnisse"
},
"yt": { "yt": {
"searchFor": "Auf YouTube suchen nach „{{query}}”", "searchFor": "Auf YouTube suchen nach „{{query}}”",
"resultsFor": "YouTube-Ergebnisse für „{{query}}”", "resultsFor": "YouTube-Ergebnisse für „{{query}}”",

View file

@ -30,8 +30,13 @@
"markedWatchedNamed": "Marked watched “{{title}}”", "markedWatchedNamed": "Marked watched “{{title}}”",
"markedWatched": "Marked watched", "markedWatched": "Marked watched",
"unwatch": "Unwatch", "unwatch": "Unwatch",
"searchDiscovered": "Search-discovered", "source": {
"searchDiscoveredTip": "Also show videos that entered the library only through a live YouTube search.", "label": "Source",
"tip": "Filter the Library by how videos got here: organic catalog only, plus search results, or only videos found via live YouTube search.",
"organic": "Hide search results",
"all": "Include search results",
"only": "Search results only"
},
"yt": { "yt": {
"searchFor": "Search YouTube for “{{query}}”", "searchFor": "Search YouTube for “{{query}}”",
"resultsFor": "YouTube results for “{{query}}”", "resultsFor": "YouTube results for “{{query}}”",

View file

@ -30,8 +30,13 @@
"markedWatchedNamed": "Megnézettnek jelölve: „{{title}}”", "markedWatchedNamed": "Megnézettnek jelölve: „{{title}}”",
"markedWatched": "Megnézettnek jelölve", "markedWatched": "Megnézettnek jelölve",
"unwatch": "Megnézés visszavonása", "unwatch": "Megnézés visszavonása",
"searchDiscovered": "Keresésből talált", "source": {
"searchDiscoveredTip": "Mutasd azokat a videókat is, amelyek csak élő YouTube-keresésen át kerültek a könyvtárba.", "label": "Forrás",
"tip": "Szűrd a könyvtárat aszerint, hogyan kerültek be a videók: csak organikus katalógus, kereséssel együtt, vagy csak az élő YouTube-keresésből talált videók.",
"organic": "Keresés nélkül",
"all": "Kereséssel együtt",
"only": "Csak keresésből"
},
"yt": { "yt": {
"searchFor": "Keresés a YouTube-on: „{{query}}”", "searchFor": "Keresés a YouTube-on: „{{query}}”",
"resultsFor": "YouTube találatok erre: „{{query}}”", "resultsFor": "YouTube találatok erre: „{{query}}”",

View file

@ -141,9 +141,9 @@ export interface FeedFilters {
includeShorts: boolean; includeShorts: boolean;
includeLive: boolean; includeLive: boolean;
show: string; show: string;
// Library (scope "all") only: when set, also show videos that entered the catalog via a // Library (scope "all") only — provenance filter: "organic" (default) hides search-
// live YouTube search. Default (falsy) hides that search-discovered "noise". // discovered videos, "all" mixes them in, "search" shows only them. Ignored for "my".
showSearchDiscovered?: boolean; librarySource?: "organic" | "all" | "search";
channelId?: string; channelId?: string;
channelName?: string; channelName?: string;
maxAgeDays?: number; maxAgeDays?: number;
@ -309,8 +309,8 @@ function filterParams(f: FeedFilters): URLSearchParams {
if (f.dateTo) p.set("published_before", f.dateTo); if (f.dateTo) p.set("published_before", f.dateTo);
if (f.minDuration != null) p.set("min_duration", String(f.minDuration)); if (f.minDuration != null) p.set("min_duration", String(f.minDuration));
if (f.maxDuration != null) p.set("max_duration", String(f.maxDuration)); if (f.maxDuration != null) p.set("max_duration", String(f.maxDuration));
// Only relevant in Library scope; the backend ignores it for "my". Default = hide. // Only relevant in Library scope; the backend ignores it for "my". Default = hide search.
p.set("exclude_search_discovered", String(!f.showSearchDiscovered)); p.set("library_source", f.librarySource ?? "organic");
return p; return p;
} }