{"record":{"id":"7a67a1e3e7ed3854","repo":"ytdl-org/youtube-dl","slug":"unable-to-find-embedded-youtube-video","errorCode":null,"errorMessage":"Unable to find embedded YouTube video.","messagePattern":"Unable to find embedded YouTube video\\.","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"youtube_dl/extractor/mit.py","lineNumber":122,"sourceCode":"        webpage = self._download_webpage(url, topic)\n        title = self._html_search_meta('WT.cg_s', webpage)\n        description = self._html_search_meta('Description', webpage)\n\n        # search for call to ocw_embed_chapter_media(container_id, media_url, provider, page_url, image_url, start, stop, captions_file)\n        embed_chapter_media = re.search(r'ocw_embed_chapter_media\\((.+?)\\)', webpage)\n        if embed_chapter_media:\n            metadata = re.sub(r'[\\'\"]', '', embed_chapter_media.group(1))\n            metadata = re.split(r', ?', metadata)\n            yt = metadata[1]\n        else:\n            # search for call to ocw_embed_chapter_media(container_id, media_url, provider, page_url, image_url, captions_file)\n            embed_media = re.search(r'ocw_embed_media\\((.+?)\\)', webpage)\n            if embed_media:\n                metadata = re.sub(r'[\\'\"]', '', embed_media.group(1))\n                metadata = re.split(r', ?', metadata)\n                yt = metadata[1]\n            else:\n                raise ExtractorError('Unable to find embedded YouTube video.')\n        video_id = YoutubeIE.extract_id(yt)\n\n        return {\n            '_type': 'url_transparent',\n            'id': video_id,\n            'title': title,\n            'description': description,\n            'url': yt,\n            'ie_key': 'Youtube',\n        }\n","sourceCodeStart":104,"sourceCodeEnd":133,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/mit.py#L104-L133","documentation":"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.","triggerScenarios":"re.search for ocw_embed_chapter_media and ocw_embed_media both return None on the downloaded course-page HTML.","commonSituations":"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.","solutions":["Open the page and locate the actual YouTube URL, then download it directly with youtube-dl.","Run with -v and inspect the fetched HTML to see which embed pattern (if any) is present.","Update youtube-dl / yt-dlp, whose MIT extractors track the OCW template.","Report the course URL upstream with the page snippet containing the new embed markup."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"# Pre-flight: page must contain one of the known OCW embed helpers\nimport urllib.request\nhtml = urllib.request.urlopen(url).read().decode('utf-8', 'replace')\nassert ('ocw_embed_chapter_media' in html or 'ocw_embed_media' in html), 'No OCW embed helper found'","typeGuard":null,"tryCatchPattern":"try:\n    info = ydl.extract_info(url, download=False)\nexcept ExtractorError as e:\n    if 'Unable to find embedded YouTube video' in str(e):\n        info = extract_youtube_link_manually(url)  # fall back to pulling the yt URL from the page\n    else:\n        raise","preventionTips":["For OCW courses, prefer the RSS/JSON course feeds that list direct media links.","If a lecture page uses a plain YouTube link, download that link directly instead of the course URL."],"tags":["embed-detection","regex","ocw"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}