On this page
Overview
Parses YouTube video/playlist locators and constructs ordinary embed URLs with opt-in privacy enhancement.
- Artifact
YouTubeMedia.js· esm - Classification
public first party - Availability
Cross-host - Normalization
Fully normalized.
Import and lifecycle
import * as module from '/arcane/modules/YouTubeMedia.js';
Pure URL parsing and construction; does not fetch, navigate, embed, or contact YouTube.
Application-facing behavior: parseYouTubeMedia(), youtubeEmbedUrl().
Protocol and host implementation
URL construction only This detail does not widen the application-facing API or grant authority.
Exports, signatures, parameters, and results
| Binding | Form | Declaration or signature | Parameter syntax |
|---|---|---|---|
parseYouTubeMedia | function | function parseYouTubeMedia(value) | value |
youtubeEmbedUrl | function | function youtubeEmbedUrl(locator,{privacyEnhanced=false}={}) | locator,{privacyEnhanced=false}={} |
| Callable | Kind | Exact public signature | Parameter syntax |
|---|---|---|---|
parseYouTubeMedia | exported-function | function parseYouTubeMedia(value) | value |
youtubeEmbedUrl | exported-function | function youtubeEmbedUrl(locator,{privacyEnhanced=false}={}) | locator,{privacyEnhanced=false}={} |
Parameter meanings and results
parseYouTubeMedia(value) returns mutable {type:'video',id,playlist?} or {type:'playlist',id}; current behavior accepts a bare video id or supported YouTube watch/embed/shorts/list URL locator. youtubeEmbedUrl(locator,{privacyEnhanced=false}) returns a regular YouTube embed URL by default; privacyEnhanced:true explicitly selects youtube-nocookie.
Events, side effects, and errors
Source-literal CustomEvent dispatches
No source-literal CustomEvent dispatch is part of this artifact.
Lifecycle and event flow
This artifact has no additional documented lifecycle event flow.
Direct coded failures
This artifact directly assigns no stable coded failure.
Exported Error subclasses
This artifact exports no Error subclass.
Documented failure behavior
- TypeError for blank, invalid, unsupported-host, or id-less input.
Availability and capabilities
Cross-host. Fully normalized.
None; a later iframe or navigation owns external network/media policy.
Contract example
import {parseYouTubeMedia,youtubeEmbedUrl} from '/arcane/modules/YouTubeMedia.js';
const media = parseYouTubeMedia('https://youtu.be/dQw4w9WgXcQ');
console.log(youtubeEmbedUrl(media));
Related reference
No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.