From 1d6dfaf486bf555fdc1916fddf6cc5ce5860a738 Mon Sep 17 00:00:00 2001 From: npeter83 Date: Mon, 29 Jun 2026 22:30:03 +0200 Subject: [PATCH] feat(search): drop quota wording when the live search source is scrape The search response now reports its source; in scrape mode (zero quota) the results banner and Load-more button drop the 'uses quota' wording. Adds the search_source toggle's labels/hints and updates the per-user-limit hint to note the cost only applies to the api source. EN/HU/DE. --- frontend/src/components/Feed.tsx | 20 +++++++++++++++----- frontend/src/i18n/locales/de/config.json | 3 ++- frontend/src/i18n/locales/de/feed.json | 4 +++- frontend/src/i18n/locales/en/config.json | 3 ++- frontend/src/i18n/locales/en/feed.json | 4 +++- frontend/src/i18n/locales/hu/config.json | 3 ++- frontend/src/i18n/locales/hu/feed.json | 4 +++- frontend/src/lib/api.ts | 6 +++++- 8 files changed, 35 insertions(+), 12 deletions(-) diff --git a/frontend/src/components/Feed.tsx b/frontend/src/components/Feed.tsx index 1fbadee..6f94efd 100644 --- a/frontend/src/components/Feed.tsx +++ b/frontend/src/components/Feed.tsx @@ -116,9 +116,10 @@ export default function Feed({ placeholderData: keepPreviousData, }); - // Live YouTube search results. Each page spends 100 quota units, so we never auto-paginate - // on scroll — the user pulls more with an explicit button. retry:false so a 429 (quota/limit) - // surfaces at once for inline display. staleTime keeps a revisited search from re-spending. + // Live YouTube search results. We never auto-paginate on scroll — the user pulls more with an + // explicit button (each api-source page spends 100 quota units; scrape-source pages are free). + // retry:false so a 429 (quota/limit) surfaces at once for inline display. staleTime keeps a + // revisited search from re-spending. const ytQuery = useInfiniteQuery({ queryKey: ["yt-search", ytSearch], queryFn: ({ pageParam }) => api.searchYoutube(ytSearch as string, pageParam as string | null), @@ -279,6 +280,9 @@ export default function Feed({ : ytQuery.isError ? t("feed.yt.error") : null; + // The backend reports which source served the search; scrape spends no search quota, so we + // drop the quota warning + "uses quota" wording in that mode. + const zeroQuota = ytQuery.data?.pages?.[0]?.source === "scrape"; return (
@@ -303,7 +307,9 @@ export default function Feed({ {t("feed.yt.resultsFor", { query: ytSearch })} - {t("feed.yt.quotaNote")} + + {zeroQuota ? t("feed.yt.freeNote") : t("feed.yt.quotaNote")} +
{ytQuery.isLoading ? ( @@ -333,7 +339,11 @@ export default function Feed({ disabled={ytQuery.isFetchingNextPage} className="inline-flex items-center gap-2 px-4 py-2 rounded-xl border border-border bg-card text-sm font-medium hover:border-accent hover:text-accent disabled:opacity-50 transition" > - {ytQuery.isFetchingNextPage ? t("feed.loadingMore") : t("feed.yt.loadMore")} + {ytQuery.isFetchingNextPage + ? t("feed.loadingMore") + : zeroQuota + ? t("feed.yt.loadMoreFree") + : t("feed.yt.loadMore")} )} diff --git a/frontend/src/i18n/locales/de/config.json b/frontend/src/i18n/locales/de/config.json index 3a81a26..76e68f5 100644 --- a/frontend/src/i18n/locales/de/config.json +++ b/frontend/src/i18n/locales/de/config.json @@ -19,7 +19,8 @@ "smtp_password": { "label": "SMTP-Passwort", "hint": "App-Passwort. Verschlüsselt gespeichert; nur schreibbar — wird nie wieder angezeigt." }, "quota_daily_budget": { "label": "Tägliches Kontingentbudget", "hint": "YouTube-Data-API-Einheiten pro Tag (kostenloses Limit 10.000). Standard 9000 lässt Puffer." }, "backfill_quota_reserve": { "label": "Nachlade-Kontingentreserve", "hint": "Reservierte Einheiten, damit geplantes Nachladen interaktive Syncs / Anreicherung nie aushungert." }, - "search_daily_limit_per_user": { "label": "Live-Suche — Tageslimit pro Nutzer", "hint": "Maximale Live-YouTube-Suchen pro Nutzer und Tag. Jede Suche kostet 100 Einheiten, das gemeinsame Budget reicht also für insgesamt nur ~80-90/Tag. 0 = Live-Suche deaktiviert." }, + "search_daily_limit_per_user": { "label": "Live-Suche — Tageslimit pro Nutzer", "hint": "Maximale Live-YouTube-Suchen pro Nutzer und Tag. Bei der API-Quelle kostet jede Suche 100 Einheiten (das gemeinsame Budget reicht also für insgesamt nur ~80-90/Tag); bei der Scrape-Quelle ist es ein reines Missbrauchslimit. 0 = Live-Suche deaktiviert." }, + "search_source": { "label": "Quelle der Live-Suche", "hint": "Woher die Ergebnisse der Live-YouTube-Suche stammen. \"scrape\" nutzt YouTubes internen Endpunkt und verbraucht kein API-Kontingent (empfohlen). \"api\" nutzt das offizielle search.list (100 Einheiten/Seite). Auf \"api\" umstellen, falls das Scraping ausfällt oder blockiert wird." }, "backfill_recent_max_videos": { "label": "Aktuelles Nachladen — max. Videos", "hint": "Neueste Videos pro Kanal beim ersten Durchlauf." }, "backfill_recent_max_days": { "label": "Aktuelles Nachladen — max. Alter (Tage)", "hint": "Wie weit der erste Durchlauf pro Kanal zurückreicht." }, "shorts_probe_max_seconds": { "label": "Shorts-Prüfung — max. Dauer (s)", "hint": "Nur Videos bis zu dieser Länge werden als mögliche Shorts geprüft." }, diff --git a/frontend/src/i18n/locales/de/feed.json b/frontend/src/i18n/locales/de/feed.json index c86f13c..b648197 100644 --- a/frontend/src/i18n/locales/de/feed.json +++ b/frontend/src/i18n/locales/de/feed.json @@ -41,10 +41,12 @@ "searchFor": "Auf YouTube suchen nach „{{query}}”", "resultsFor": "YouTube-Ergebnisse für „{{query}}”", "quotaNote": "Live-Ergebnisse — verbraucht gemeinsames API-Kontingent", + "freeNote": "Live-Ergebnisse — kein Suchkontingent verbraucht", "back": "Zurück zum Feed", "searching": "Suche auf YouTube…", "noResults": "Keine YouTube-Videos gefunden.", "error": "YouTube-Suche fehlgeschlagen.", - "loadMore": "Mehr laden (verbraucht Kontingent)" + "loadMore": "Mehr laden (verbraucht Kontingent)", + "loadMoreFree": "Mehr laden" } } diff --git a/frontend/src/i18n/locales/en/config.json b/frontend/src/i18n/locales/en/config.json index fccf74d..ed003a9 100644 --- a/frontend/src/i18n/locales/en/config.json +++ b/frontend/src/i18n/locales/en/config.json @@ -19,7 +19,8 @@ "smtp_password": { "label": "SMTP password", "hint": "App password. Stored encrypted; write-only — it's never shown back." }, "quota_daily_budget": { "label": "Daily quota budget", "hint": "Total YouTube Data API units to spend per day (free tier is 10,000). Default 9000 leaves headroom." }, "backfill_quota_reserve": { "label": "Backfill quota reserve", "hint": "Units kept in reserve so scheduled backfill never starves interactive syncs / enrichment." }, - "search_daily_limit_per_user": { "label": "Live search — daily limit per user", "hint": "Max live YouTube searches per user per day. Each search costs 100 units, so the shared budget only affords ~80-90/day total. Set 0 to disable live search." }, + "search_daily_limit_per_user": { "label": "Live search — daily limit per user", "hint": "Max live YouTube searches per user per day. With the API source each search costs 100 units (so the shared budget affords only ~80-90/day total); with the scrape source it's a pure anti-abuse limit. Set 0 to disable live search." }, + "search_source": { "label": "Live search source", "hint": "Where live YouTube search results come from. \"scrape\" uses YouTube's internal endpoint and spends no API quota (recommended). \"api\" uses the official search.list (100 units/page). Switch to \"api\" if scraping ever breaks or is blocked." }, "backfill_recent_max_videos": { "label": "Recent backfill — max videos", "hint": "Newest videos fetched per channel on the first pass." }, "backfill_recent_max_days": { "label": "Recent backfill — max age (days)", "hint": "How far back the first pass reaches per channel." }, "shorts_probe_max_seconds": { "label": "Shorts probe — max duration (s)", "hint": "Only videos at or below this length are probed as possible Shorts." }, diff --git a/frontend/src/i18n/locales/en/feed.json b/frontend/src/i18n/locales/en/feed.json index 34f6a50..30be33d 100644 --- a/frontend/src/i18n/locales/en/feed.json +++ b/frontend/src/i18n/locales/en/feed.json @@ -41,10 +41,12 @@ "searchFor": "Search YouTube for “{{query}}”", "resultsFor": "YouTube results for “{{query}}”", "quotaNote": "Live results — uses shared API quota", + "freeNote": "Live results — no search quota used", "back": "Back to feed", "searching": "Searching YouTube…", "noResults": "No YouTube videos found.", "error": "YouTube search failed.", - "loadMore": "Load more (uses quota)" + "loadMore": "Load more (uses quota)", + "loadMoreFree": "Load more" } } diff --git a/frontend/src/i18n/locales/hu/config.json b/frontend/src/i18n/locales/hu/config.json index c33300d..4122383 100644 --- a/frontend/src/i18n/locales/hu/config.json +++ b/frontend/src/i18n/locales/hu/config.json @@ -19,7 +19,8 @@ "smtp_password": { "label": "SMTP-jelszó", "hint": "Alkalmazásjelszó. Titkosítva tárolva; csak írható — soha nem jelenik meg újra." }, "quota_daily_budget": { "label": "Napi kvótakeret", "hint": "Naponta elkölthető YouTube Data API-egységek (az ingyenes keret 10 000). Az alap 9000 tartalékot hagy." }, "backfill_quota_reserve": { "label": "Letöltési kvótatartalék", "hint": "Tartalékban tartott egységek, hogy az ütemezett letöltés ne éheztesse ki az interaktív szinkront / gazdagítást." }, - "search_daily_limit_per_user": { "label": "Élő keresés — napi limit / felhasználó", "hint": "Maximális élő YouTube-keresés felhasználónként naponta. Egy keresés 100 egységbe kerül, így a közös büdzséből összesen csak ~80-90 fér bele naponta. 0 = élő keresés kikapcsolva." }, + "search_daily_limit_per_user": { "label": "Élő keresés — napi limit / felhasználó", "hint": "Maximális élő YouTube-keresés felhasználónként naponta. Az API-forrásnál egy keresés 100 egységbe kerül (így a közös büdzséből összesen csak ~80-90 fér bele naponta); a scrape-forrásnál ez tiszta visszaélés-elleni limit. 0 = élő keresés kikapcsolva." }, + "search_source": { "label": "Élő keresés forrása", "hint": "Honnan jönnek az élő YouTube-keresés találatai. A „scrape” a YouTube belső végpontját használja és nem fogyaszt API-kvótát (ajánlott). Az „api” a hivatalos search.list-et (100 egység/oldal). Válts „api”-ra, ha a scrape valaha elromlik vagy letiltják." }, "backfill_recent_max_videos": { "label": "Friss letöltés — max videó", "hint": "Csatornánként az első körben letöltött legújabb videók száma." }, "backfill_recent_max_days": { "label": "Friss letöltés — max kor (nap)", "hint": "Az első kör csatornánként meddig nyúl vissza." }, "shorts_probe_max_seconds": { "label": "Shorts-vizsgálat — max hossz (mp)", "hint": "Csak az ennél nem hosszabb videókat vizsgáljuk lehetséges Shortsként." }, diff --git a/frontend/src/i18n/locales/hu/feed.json b/frontend/src/i18n/locales/hu/feed.json index 0f5a805..04b2b05 100644 --- a/frontend/src/i18n/locales/hu/feed.json +++ b/frontend/src/i18n/locales/hu/feed.json @@ -41,10 +41,12 @@ "searchFor": "Keresés a YouTube-on: „{{query}}”", "resultsFor": "YouTube találatok erre: „{{query}}”", "quotaNote": "Élő találatok — a közös API-kvótát fogyasztja", + "freeNote": "Élő találatok — nem fogyaszt keresési kvótát", "back": "Vissza a hírfolyamhoz", "searching": "Keresés a YouTube-on…", "noResults": "Nincs YouTube-találat.", "error": "A YouTube-keresés nem sikerült.", - "loadMore": "Továbbiak betöltése (kvótát fogyaszt)" + "loadMore": "Továbbiak betöltése (kvótát fogyaszt)", + "loadMoreFree": "Továbbiak betöltése" } } diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index 098d47e..1ae261d 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -82,6 +82,9 @@ export interface FeedResponse { // Opaque keyset cursor for the next page, or null when this is the last page. next_cursor: string | null; limit: number; + // Only set by the live YouTube search: "scrape" (InnerTube, no API quota) or "api" + // (search.list, 100 units/page) — lets the UI drop the quota warning in scrape mode. + source?: "scrape" | "api"; } export interface Playlist { @@ -565,7 +568,8 @@ export const api = { req(`/api/feed/count?${filterParams(f).toString()}`), // Live YouTube search: results are materialised into the catalog and returned as feed cards. // `quiet` so the YT-search panel can render quota/limit errors (incl. 429) inline instead of - // popping the global modal. `cursor` is the YouTube nextPageToken (each page spends 100 units). + // popping the global modal. `cursor` is the next-page token (an InnerTube continuation token + // in scrape mode, or a Data API pageToken in api mode); the response's `source` says which. searchYoutube: (q: string, cursor: string | null): Promise => { const p = new URLSearchParams({ q }); if (cursor) p.set("cursor", cursor);