# Notes for AI agents working on YouTube for Fennec OS Read first (Fennec SDK, https://gitea.bluefox.support/fennec/sdk): - `docs/store-app-guide.md`: what a Fennec OS store app must be (manifest, sandbox, remote, packaging, release). - `docs/sf-ui.md`: the UI kit. Liquid Glass model, components, focus, dev tools, pitfalls. ## Layout ``` app.toml store manifest (id support.bluefox.youtube; permissions network, gpu, audio) src/main.rs window, glass layer (lists every exported [GlassRect]), images, controller src/app.rs Controller: screen stack, keys, QR sign-in overlay, toast, backdrop src/page.rs the line-based page engine (from Netflex TV): lines and chips -> layout, focus, scroll, lazy images src/screens/mod.rs sections, cards (v:/c:/p:/m: ids), Load, Paged (feeds with continuations), opening a card src/screens/*.rs home, subs, library, search, settings, channel, playlist src/player.rs video id -> yt::stream -> MPD -> sf_ui::video::Player; captions, quality, SponsorBlock, up next src/yt/mod.rs InnerTube client: client profiles, browse/search/next/player, account src/yt/parse.rs the tree walker: any answer -> shelves of videos/channels/playlists (skips ads) src/yt/auth.rs OAuth device flow (youtube.com/activate), refresh, revoke src/yt/stream.rs player answer -> formats -> one-quality DASH manifest; TV client signatures src/yt/jsc.rs yt-dlp's ejs solver in QuickJS (n / sig challenges), player script cache src/yt/extras.rs SponsorBlock, channel RSS, captions (json3), mark watched src/config.rs settings.toml, account.toml, library.json (history, local subscriptions) ejs/ yt-dlp ejs 0.8.0 solver scripts (Unlicense), embedded with include_str! ui/app.slint root: screens, one FocusScope -> Rust `key`, glass exports ui/{page,player,link,overlays,types}.slint ``` ## Rules of this codebase - **Rust owns state and focus.** Slint only draws. Every key goes to `Controller::key`, except while the search keyboard has the focus. - **Short borrows:** never hold `state.borrow_mut()` while calling `images.load*` or anything that may call back. - **Glass:** new glass elements need their `glass` listed in a root `out property <[GlassRect]>`, and that array added in `main.rs`. - **A new page** is a `Screen`: `spec` returns lines, `activate` gets (line id, card/chip id). Feeds use `Paged` (continuations). - **YouTube changes often.** Don't hard-code one layout: add renderers to `parse::walk`, keep tests with small JSON samples. Client versions follow yt-dlp's `_base.py`; the stream client order follows its `_DEFAULT_CLIENTS`. - **One quality per manifest:** GStreamer's adaptive DASH starts at 144p; `Playable::uri` writes only the chosen height. - **No ads:** never request ad endpoints, keep ad renderers in `parse::SKIP`. - **Texts are Hungarian** (the client asks YouTube with hl=hu, gl=HU, so YouTube's own texts are Hungarian too). ## Check your change ```sh cargo test cargo test live -- --ignored --nocapture # real YouTube: search, stream formats, channel, solver HOME=/tmp/ythome SF_UI_SIZE=1920x1080 SF_UI_KEYS="wait wait wait wait down enter" SF_UI_SNAPSHOT=/tmp/shot.png cargo run ``` - **Playback** needs Linux (GStreamer). WSL with WSLg works (software decoding, Material look). - A written manifest can be tried alone: `gst-launch-1.0 playbin uri=file:///tmp/youtube-.mpd`. - Too many requests in a row get HTTP 429 from YouTube for a while.