Skip to content

feat: add YouTube playback as an optional provider plugin #136

Description

@rowkav09

Goal

Add YouTube as an optional provider plugin while keeping the media core provider-neutral and being explicit about what YouTube's APIs can and cannot detect.

Integration reality

The YouTube Data API can fetch metadata for a known video ID, but it does not expose a reliable "what this user is watching right now" endpoint. OAuth/watch-history polling is not a dependable real-time playback source.

Chosen architecture (confirmed by project owner):

  • Detect playback locally in an opt-in browser extension/content script on youtube.com and music.youtube.com.
  • Read the active player's video ID, title, channel, thumbnail, duration, current position, play/pause and live-stream state.
  • Send a minimal validated event to the local nowplaying bridge; use the Data API only as an optional metadata enrichment/fallback for a known ID.
  • Keep site selectors and player event handling isolated in the YouTube plugin because YouTube DOM/player changes are expected maintenance.

Documented alternatives (not the implementation target):

  • userscript/local companion (easier prototype; weaker distribution/update story)
  • desktop media-session capture (less site-specific, but inconsistent metadata/browser support)
  • YouTube Data API alone (not suitable for current-playback detection)

Scope

  • Browser extension/content script is the chosen capture route. Start with a short spike to prove the player events, local bridge protocol, privacy boundary and selector resilience before full implementation.
  • YouTube and YouTube Music support if the same mechanism is reliable.
  • Provider adapter mapping into the existing media model.
  • Local-only connection by default, origin allowlist and no browsing-history collection.
  • No account scraping, cookie extraction, watch-history polling or playback control in the first version.

Done when

  • A browser-extension spike proves active-player detection on youtube.com and music.youtube.com, the minimal local event schema, permission set and failure behavior.
  • The implementation notes record why userscript, Media Session and Data API-only approaches were not chosen.
  • Only active playback events are sent; page visits, searches, recommendations and history are never collected.
  • Video ID, title/channel, artwork, position/duration and pause/stop map to cards and Discord Rich Presence.
  • Live streams, Shorts, Music, ads, private/deleted videos, tab switches and multiple YouTube tabs have defined behavior.
  • The local bridge authenticates the plugin and rejects other origins/invalid payloads.
  • Site selectors/event hooks are isolated, fixture-tested and have a documented maintenance owner/fallback when YouTube changes.
  • The app works unchanged when the plugin is absent or disconnected.
  • Setup/privacy docs explain browser permissions and the local-only data path in plain language.
  • Shipping commit is a feat, producing the next minor release under the project versioning rule.

Official references

Activity

  1. moved this to Backlog in nowplayingon Sep 23, 2026
  2. moved this from Backlog to In Progress in nowplayingon Sep 24, 2026
  3. rowkav09 commented on Sep 24, 2026

    @rowkav09
    MemberAuthor

    Scope update from Rowan (24 Sep):

    • Discord: yes for YouTube, but not for Shorts. Shorts and ads are ignored everywhere (no card, no Discord). Spotify stays card-only.
    • Distribution: load unpacked for now. A Chrome Web Store listing comes later (Rowan will set up the account).
    • Repo: the extension lives in its own repo, https://github.com/rowkavdev/nowplaying-youtube. The app side (bridge, pairing token, settings API) stays here.

    Done so far:

    Still to do: the pairing-code section on the settings page (web UI lane), then finishing the extension in nowplaying-youtube (pairing entry on the options page, sending to the app, end-to-end check on a dev build).

  4. rowkav09 commented on Sep 24, 2026

    @rowkav09
    MemberAuthor

    Done. YouTube and YouTube Music now show on the card, the hosted card and Discord (Watching for videos, Listening for YouTube Music). Shorts and ads are ignored. When YouTube, Spotify and a media server overlap, whichever started most recently shows.

    The extension is in its own repo, https://github.com/rowkavdev/nowplaying-youtube. Install it with load unpacked for now; the Chrome Web Store comes later.

    PR map:

    End-to-end check (24 Sep, main f849c93 plus nowplaying-youtube 6a0c4ad), in headless Chrome 151 with the extension loaded unpacked:

    • The pairing code came from the settings API.
    • A wrong code was refused on the options page; the real code gave "Paired." and was stored.
    • A real YouTube video playing showed on /card.svg as "Rick Astley - Never Gonna Give You Up …" within 8 s.
    • Closing the tab took it off the card.
  5. moved this from In Progress to Done in nowplayingon Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions