ytdl-org/youtube-dl · error · ExtractorError

Unable to find embedded YouTube video.

Error message

Unable to find embedded YouTube video.

What it means

Raised by the MIT OpenCourseWare extractor when the page contains neither an ocw_embed_chapter_media(...) call nor an ocw_embed_media(...) call — the two known embed patterns that carry the YouTube media URL. Without one of them the extractor cannot find the YouTube link to delegate to YoutubeIE. Not expected=True.

Source

Thrown at youtube_dl/extractor/mit.py:122

        webpage = self._download_webpage(url, topic)
        title = self._html_search_meta('WT.cg_s', webpage)
        description = self._html_search_meta('Description', webpage)

        # search for call to ocw_embed_chapter_media(container_id, media_url, provider, page_url, image_url, start, stop, captions_file)
        embed_chapter_media = re.search(r'ocw_embed_chapter_media\((.+?)\)', webpage)
        if embed_chapter_media:
            metadata = re.sub(r'[\'"]', '', embed_chapter_media.group(1))
            metadata = re.split(r', ?', metadata)
            yt = metadata[1]
        else:
            # search for call to ocw_embed_chapter_media(container_id, media_url, provider, page_url, image_url, captions_file)
            embed_media = re.search(r'ocw_embed_media\((.+?)\)', webpage)
            if embed_media:
                metadata = re.sub(r'[\'"]', '', embed_media.group(1))
                metadata = re.split(r', ?', metadata)
                yt = metadata[1]
            else:
                raise ExtractorError('Unable to find embedded YouTube video.')
        video_id = YoutubeIE.extract_id(yt)

        return {
            '_type': 'url_transparent',
            'id': video_id,
            'title': title,
            'description': description,
            'url': yt,
            'ie_key': 'Youtube',
        }

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Open the page and locate the actual YouTube URL, then download it directly with youtube-dl.
  2. Run with -v and inspect the fetched HTML to see which embed pattern (if any) is present.
  3. Update youtube-dl / yt-dlp, whose MIT extractors track the OCW template.
  4. Report the course URL upstream with the page snippet containing the new embed markup.
Defensive patterns

Strategy: fallback

Validate before calling

# Pre-flight: page must contain one of the known OCW embed helpers
import urllib.request
html = urllib.request.urlopen(url).read().decode('utf-8', 'replace')
assert ('ocw_embed_chapter_media' in html or 'ocw_embed_media' in html), 'No OCW embed helper found'

Try / catch

try:
    info = ydl.extract_info(url, download=False)
except ExtractorError as e:
    if 'Unable to find embedded YouTube video' in str(e):
        info = extract_youtube_link_manually(url)  # fall back to pulling the yt URL from the page
    else:
        raise

Prevention

When it happens

Trigger: re.search for ocw_embed_chapter_media and ocw_embed_media both return None on the downloaded course-page HTML.

Common situations: OCW page templates changed (new embed helper name, or video moved into a JSON blob); lecture page using a direct YouTube link instead of the embed helper; resource pages (PDFs, subtitles) mistakenly fed to the extractor; chapter pages where metadata sits in a data attribute instead of a JS call.

Related errors


AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14). Data as JSON: /api/errors/7a67a1e3e7ed3854. Report an issue: GitHub.