ytdl-org/youtube-dl · error · ExtractorError
Invalid metadata XML file
Error message
Invalid metadata XML file
What it means
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.
Source
Thrown at youtube_dl/extractor/stanfordoc.py:46
mobj = re.match(self._VALID_URL, url)
if mobj.group('course') and mobj.group('video'): # A specific video
course = mobj.group('course')
video = mobj.group('video')
info = {
'id': course + '_' + video,
'uploader': None,
'upload_date': None,
}
baseUrl = 'http://openclassroom.stanford.edu/MainFolder/courses/' + course + '/videos/'
xmlUrl = baseUrl + video + '.xml'
mdoc = self._download_xml(xmlUrl, info['id'])
try:
info['title'] = mdoc.findall('./title')[0].text
info['url'] = baseUrl + mdoc.findall('./videoFile')[0].text
except IndexError:
raise ExtractorError('Invalid metadata XML file')
return info
elif mobj.group('course'): # A course page
course = mobj.group('course')
info = {
'id': course,
'_type': 'playlist',
'uploader': None,
'upload_date': None,
}
coursepage = self._download_webpage(
url, info['id'],
note='Downloading course info page',
errnote='Unable to download course info page')
info['title'] = self._html_search_regex(
r'<h1>([^<]+)</h1>', coursepage, 'title', default=info['id'])
View on GitHub (pinned to 956b8c5855)
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.
Example fix
# before
info['title'] = mdoc.findall('./title')[0].text
info['url'] = baseUrl + mdoc.findall('./videoFile')[0].text
# after
titles = mdoc.findall('./title')
files = mdoc.findall('./videoFile')
if not titles or not files:
raise ExtractorError('Invalid metadata XML file: missing title or videoFile')
info['title'] = titles[0].text
info['url'] = baseUrl + files[0].text Defensive patterns
Strategy: validation
Validate before calling
# Verify metadata XML has required children before extracting
import urllib.request, xml.etree.ElementTree as ET
xml = ET.fromstring(urllib.request.urlopen(xmlUrl).read())
if xml.find('./title') is None or xml.find('./videoFile') is None:
skip('invalid metadata XML for %s' % vid) Try / catch
try:
info = ydl.extract_info(url)
except ExtractorError as e:
if 'Invalid metadata XML file' in str(e):
log.warning('stanfordoc metadata incomplete for %s', url)
return None
raise Prevention
- 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.
When it happens
Trigger: 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).
Common situations: 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.
Related errors
- Missing "id" field in extractor result
- Missing "title" field in extractor result
- No video formats found!
- Failed to get the video URL
- Invalid rendition field.
AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14).
Data as JSON: /api/errors/43b9003a956dcb16.
Report an issue: GitHub.