{"record":{"id":"43b9003a956dcb16","repo":"ytdl-org/youtube-dl","slug":"invalid-metadata-xml-file","errorCode":null,"errorMessage":"Invalid metadata XML file","messagePattern":"Invalid metadata XML file","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"youtube_dl/extractor/stanfordoc.py","lineNumber":46,"sourceCode":"        mobj = re.match(self._VALID_URL, url)\n\n        if mobj.group('course') and mobj.group('video'):  # A specific video\n            course = mobj.group('course')\n            video = mobj.group('video')\n            info = {\n                'id': course + '_' + video,\n                'uploader': None,\n                'upload_date': None,\n            }\n\n            baseUrl = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/'\n            xmlUrl = baseUrl + video + '.xml'\n            mdoc = self._download_xml(xmlUrl, info['id'])\n            try:\n                info['title'] = mdoc.findall('./title')[0].text\n                info['url'] = baseUrl + mdoc.findall('./videoFile')[0].text\n            except IndexError:\n                raise ExtractorError('Invalid metadata XML file')\n            return info\n        elif mobj.group('course'):  # A course page\n            course = mobj.group('course')\n            info = {\n                'id': course,\n                '_type': 'playlist',\n                'uploader': None,\n                'upload_date': None,\n            }\n\n            coursepage = self._download_webpage(\n                url, info['id'],\n                note='Downloading course info page',\n                errnote='Unable to download course info page')\n\n            info['title'] = self._html_search_regex(\n                r'<h1>([^<]+)</h1>', coursepage, 'title', default=info['id'])\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/ytdl-org/youtube-dl/blob/956b8c585591b401a543e409accb163eeaaa1193/youtube_dl/extractor/stanfordoc.py#L28-L64","documentation":"Raised by StanfordOpenClassRoomIE after downloading the per-video metadata XML from openclassroom.stanford.edu. The XML parsed successfully, but mdoc.findall('./title')[0] or mdoc.findall('./videoFile')[0] raised IndexError, meaning the XML root lacks a <title> or <videoFile> child. Only the IndexError is caught; a malformed (non-parsing) XML surfaces as a download/XML error instead.","triggerScenarios":"Requesting a course video page whose .xml metadata file exists but has no <title> or <videoFile> element (e.g. an empty or template XML returned by the server).","commonSituations":"Stanford OpenClassroom is largely defunct; many course XML endpoints now return placeholder or error pages with 200 status, so this fires on most legacy playlist crawls.","solutions":["Verify the XML URL manually (http://openclassroom.stanford.edu/MainFolder/courses/<course>/videos/<video>.xml) and confirm it contains <title> and <videoFile>.","Find the lecture on Stanford's current hosting (e.g. edX/Stanford Online or YouTube channel).","If maintaining the extractor, check findall length before indexing and raise a clearer error."],"exampleFix":"# before\ninfo['title'] = mdoc.findall('./title')[0].text\ninfo['url'] = baseUrl + mdoc.findall('./videoFile')[0].text\n# after\ntitles = mdoc.findall('./title')\nfiles = mdoc.findall('./videoFile')\nif not titles or not files:\n    raise ExtractorError('Invalid metadata XML file: missing title or videoFile')\ninfo['title'] = titles[0].text\ninfo['url'] = baseUrl + files[0].text","handlingStrategy":"validation","validationCode":"# Verify metadata XML has required children before extracting\nimport urllib.request, xml.etree.ElementTree as ET\nxml = ET.fromstring(urllib.request.urlopen(xmlUrl).read())\nif xml.find('./title') is None or xml.find('./videoFile') is None:\n    skip('invalid metadata XML for %s' % vid)","typeGuard":null,"tryCatchPattern":"try:\n    info = ydl.extract_info(url)\nexcept ExtractorError as e:\n    if 'Invalid metadata XML file' in str(e):\n        log.warning('stanfordoc metadata incomplete for %s', url)\n        return None\n    raise","preventionTips":["OpenClassroom is largely defunct; do not build new pipelines on it.","Validate remote XML structure before indexing findall results.","Prefer Stanford's current video platforms for new links."],"tags":["malformed-metadata","xml","site-degraded","extractor"],"backgroundTag":null,"analyzedSha":"956b8c585591b401a543e409accb163eeaaa1193","analyzedAt":"2026-08-14T18:59:47.863Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}