# YouTube Daily 25 A self-hosted recommender that learns what you like from your **subscriptions, watch history and Watch Later**, and builds a list of **25 videos each morning**. You browse the list on a local web page and rate videos with 👍 / 👎 / ✓ to teach it. Everything runs locally in Docker. You don't need a Google Cloud project or API key, and nothing is sent to an AI service. ## How it works ``` 05:30 daily (APScheduler) │ ├─ yt-dlp + cookies ─► Watch History, Watch Later, Subscriptions feed, channel list ├─ RSS (public) ─► latest uploads + publish dates for every subscribed channel ├─ yt-dlp search ─► newest videos on your topics (discovery outside subscriptions) │ ├─ fastembed (bge-small, CPU) ─► vector per video title/description ├─ taste profile = weighted history + Watch Later + 👍 (minus 👎) ├─ score = content similarity + channel affinity + freshness (+ Watch Later boost) └─ diversity pass: max 3 per channel, no near-duplicates, 3 discovery slots │ ▼ SQLite ─► web page at http://:8080 ``` **Why cookies?** The official YouTube Data API hasn't returned Watch History or Watch Later since 2016. yt-dlp reads those pages the same way your browser does, so it needs your signed-in cookies. What it learns from, from strongest to weakest: | Signal | Weight | |---|---| | 👍 in the app | 3.0 | | ✓ Watched in the app, or on Watch Later | 1.5 | | Watch history (recent counts more) | 0.3 – 1.3 | | Opened from the app | 0.5 | | 👎 in the app | pushes similar videos and that channel down | ## Setup ### 1. Export your YouTube cookies (the only credential) `data/cookies.txt` must be a Netscape-format cookies file for a signed-in YouTube session. **Treat it like a password.** Anyone with it can act as your Google account on YouTube. It's git-ignored and only mounted into the container. **Option A, most durable (recommended by yt-dlp).** This stops the browser rotating the cookies out from under you: 1. Open a **private/incognito window** and sign in to YouTube. 2. In the same tab, go to `https://www.youtube.com/robots.txt`. 3. Export cookies for youtube.com with an extension such as *Get cookies.txt LOCALLY* (Chrome) or *cookies.txt* (Firefox). Save as `data/cookies.txt`. 4. **Close the private window** and don't reuse that session. **Option B, quick (from CachyOS, if yt-dlp is installed):** ```bash yt-dlp --cookies-from-browser firefox --cookies ./data/cookies.txt \ --skip-download "https://www.youtube.com/feed/history" ``` Cookies exported this way can stop working after a few days or weeks, because the browser keeps rotating them. When cookies expire, the page header shows "last run failed". Re-export them and click **Refresh from YouTube**. ### 2. Configure and start ```bash cp .env.example .env # adjust run time, topics, weights mkdir -p data && sudo chown 1000:1000 data # container runs as uid 1000 docker compose up -d --build docker compose exec youtube-recommender python -m app.pipeline --check-cookies ``` Open `http://:8080`. On first start it builds a list right away. The first run downloads the embedding model (~70 MB) and embeds your history, which takes a few minutes. After that it runs every day at `RUN_HOUR:RUN_MINUTE` in `TZ`. ### Useful commands ```bash docker compose logs -f # watch a run docker compose exec youtube-recommender python -m app.pipeline # full run now docker compose exec youtube-recommender python -m app.pipeline --skip-sync # re-rank only ``` In the web UI, **Re-rank** applies your latest ratings instantly. **Refresh from YouTube** pulls fresh data. ## Tuning (`.env`) | Setting | Default | What it does | |---|---|---| | `DAILY_COUNT` | 25 | Videos per day | | `MAX_PER_CHANNEL` | 3 | Stops one channel dominating | | `EXPLORE_SLOTS` | 3 | Slots for channels you don't watch yet | | `NEW_VIDEO_DAYS` | 7 | **Hard limit**: nothing older is ever recommended, including Watch Later items. Videos with no known upload date are skipped. | | `NO_REPEAT_DAYS` | 14 | Don't re-suggest a video you skipped within this window | | `EXCLUDE_SHORTS` / `MIN_DURATION_SEC` | true / 90 | Drops Shorts and very short videos | | `DISCOVERY_TOPICS` | (empty) | Extra comma-separated search topics, e.g. `entra id,proxmox,splunk` | | `AUTO_TOPICS` | 5 | Topics auto-derived from words that recur in what you watch | | `W_CONTENT` / `W_CHANNEL` / `W_FRESH` | .60 / .25 / .10 | Ranking weights | ## Notes and limits - **Unofficial access.** yt-dlp scrapes YouTube pages. It can break when YouTube changes things, so keep it updated by rebuilding the image now and then (`docker compose build --pull`). Request volume is low: a few page loads plus one RSS fetch per channel each day, with a 1-second delay between yt-dlp requests. - **No login on the web page.** Keep it on your LAN or put it behind your reverse proxy with auth. It only exposes video lists and ratings, never the cookies. - **Videos you watch elsewhere** show up in History on the next run and are removed from candidates automatically. ## Project layout ``` app/ config.py settings from env youtube.py yt-dlp + RSS fetchers db.py SQLite schema/helpers embed.py fastembed text vectors recommender.py taste profile, scoring, diversity selection, auto topics pipeline.py daily job (sync -> embed -> rank); CLI entry point web.py FastAPI UI/API + scheduler templates/index.html ```