forked from retoor/devplacepy
Inline YouTube Music embeds with one shared embed spec
YouTube Music has no player of its own and music.youtube.com sends X-Frame-Options SAMEORIGIN, so music links render YouTube's own player with an Open in YouTube Music caption. Tracks, playlists and OLAK5uy albums embed; browse, channel, search and library stay plain links. - embeds.py is the single URL spec (exact host allowlists, query-order independent, validated ids only); embed-spec.js is generated from it by the embeds-sync CLI command and drift is tested - rendering.py and ContentRenderer.js both follow it; the old duplicate YouTube regexes are removed - max 3 music embeds per content item, overflow stays a plain link - fixes evilyoutube.com matching and watch?feature=share&v=ID links - fixes the invalid unicode CSS escape that printed u2197 after every external link in rendered content - docs, privacy third-party row, parser table tests, server/client parity Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1188,6 +1188,19 @@ Two background services bridge persisted state onto the bus so the interface upd
|
||||
- Session-scoped browser context with per-test cookie clearing
|
||||
- `page.locator(...).wait_for(state="visible")` preferred over bare selectors
|
||||
|
||||
## Media embeds (YouTube and YouTube Music)
|
||||
|
||||
A bare YouTube or YouTube Music link in a post, comment, message or description renders as an inline player. YouTube Music has no player of its own: its track and playlist ids are YouTube's, so the embed is YouTube's own player, shown with an "Open in YouTube Music" caption that links back to the original.
|
||||
|
||||
| Link | Result |
|
||||
|------|--------|
|
||||
| `youtube.com/watch?v=ID`, `youtu.be/ID`, `/embed/ID`, `/v/ID`, `/shorts/ID`, `m.` and `-nocookie` hosts | Video player; `t=` / `start=` seconds are kept |
|
||||
| `music.youtube.com/watch?v=ID[&list=ID]` | Track player with the caption, queue kept when `list=` is a valid playlist id |
|
||||
| `music.youtube.com/playlist?list=ID`, `youtube.com/playlist?list=ID` | Playlist or album player (`OLAK5uy...` album ids work) |
|
||||
| `music.youtube.com/browse/...`, `/channel/...`, `/search`, `/library` | Plain link: these URLs carry no playlist id |
|
||||
|
||||
Parsing is by exact host allowlist and query parameter, in any order, so look-alike hosts such as `evilyoutube.com` never embed. A single post renders at most 3 music embeds; further music links stay plain links. The URL rules live in one place, `devplacepy/embeds.py`; the browser gets them through the generated `static/js/embed-spec.js` (`devplace embeds-sync` after changing the table, never hand-edit) and `static/js/EmbedParser.js`. A unit test fails when the generated file drifts and an e2e test runs one shared case table through both parsers.
|
||||
|
||||
## Avatars
|
||||
|
||||
Uses [Multiavatar](https://github.com/multiavatar/multiavatar-python) - generates deterministic SVG avatars locally from a seed string (the username). No external API calls, no network dependency. Generation takes <5ms. Results are cached in-memory (cleared on server restart).
|
||||
|
||||
Reference in New Issue
Block a user