Youtube Video Integration
SECTION 27 — YOUTUBE VIDEO INTEGRATION
Scope notice: The YouTube Data API OAuth scope is not used anywhere in this application. No role — including Teacher — requires or requests YouTube API credentials. All YouTube video discovery and linking is performed via a custom URL-based interface backed by a server-side public channel feed fetch. This keeps the OAuth consent screen limited to the approved non-sensitive scopes (Drive + profile only).
27.1 Connection
- Each Teacher manually configures their YouTube channel reference in Account Settings → Integrations → YouTube.
- No OAuth handshake with YouTube is performed — the Teacher simply provides their
channel_IDand/orchannel_URLas plain text. - The connection is per-Teacher and is stored in the Teacher’s organisation settings record.
- No YouTube API credentials, tokens, or read scopes are requested at any point in the authentication or onboarding flow.
27.2 Video Picker Flow — All Roles (Custom URL-Based UI)
All roles — Teacher, Editor, and Sub-member — use the same custom URL-based video picker UI. There is no API-authenticated flow for any role.- The user opens the Metadata Sheet (right slide-in panel during document creation or review).
- The user clicks the YouTube video field or “Browse Channel” button.
- The system reads the Teacher’s configured
channel_ID/channel_URLfrom the organisation settings. - The backend (FastAPI) attempts to fetch the channel’s public video listing server-side:
- Primary path: Server-side HTTP fetch of the public channel feed using the Teacher’s
channel_IDorchannel_URL— no YouTube API key required for public channel listings. - Fallback path: If the server-side fetch fails (e.g. rate-limited or blocked), the UI falls back to rendering an embedded iframe of
https://www.youtube.com/channel/\{channel_ID\}/videosso the user can still browse and manually provide the URL.
- Primary path: Server-side HTTP fetch of the public channel feed using the Teacher’s
- A modal renders the channel’s video list with thumbnail, title, upload date, and duration.
- The user selects a video — its URL is populated in the
video-urlfield of the document metadata. - The backend optionally fetches supplemental video metadata (title, thumbnail, duration, channel name) via a lightweight public URL parse and stores it in
metadata.video-metadata; no YouTube API key is required for this.
27.3 Video Picker Flow — Editor & Sub-member
Editors and Sub-members use the identical flow described in Section 27.2. There is no distinction between the Teacher flow and the Editor/Sub-member flow — all roles use the custom URL-based interface backed by the same FastAPI server-side fetch + iframe fallback mechanism.27.4 Video Link — Optional
- The YouTube video link is optional for every Newsletter.
- Any role can skip the video picker and leave
video-url = null. - Teacher can attach or update the YouTube video link at any point before the document is finalised.
- Editor can also attach or update the YouTube video link on the Teacher’s behalf during the Editor’s Stage 1 review.
- Sub-member can also attach or update the YouTube video link via the custom URL-based UI (Section 27.2).
27.5 PDF Injection
- The YouTube video URL is dynamically injected into the PDF during WeasyPrint rendering.
- Injection point: wherever the organisation’s configured template places the
\{yt_url\}dynamic placeholder block. - If no template is configured, or the template does not include a
\{yt_url\}block, the URL is not embedded in the PDF. - The URL in the PDF is rendered as a clickable hyperlink (supported by WeasyPrint’s PDF link generation).