ytdl-org/youtube-dl · warning · ExtractorError

%s said: %s

Error message

%s said: %s

What it means

Raised by the fallback _lock_file stub selected when the platform has neither the Windows msvcrt path nor the fcntl module (the ImportError branch). On such platforms, acquiring a locked_file raises IOError with the constant UNSUPPORTED_MSG. It is an explicit capability declaration, not a runtime failure of a working feature — youtube-dl refuses to pretend to lock where the OS offers no locking primitive.

Source

Thrown at youtube_dl/extractor/abc.py:73

            'title': 'NAB lifts interest rates, following Westpac and CBA',
            'description': 'md5:f13d8edc81e462fce4a0437c7dc04728',
        },
    }, {
        'url': 'http://www.abc.net.au/news/2015-10-19/6866214',
        'only_matching': True,
    }]

    def _real_extract(self, url):
        video_id = self._match_id(url)
        webpage = self._download_webpage(url, video_id)

        mobj = re.search(
            r'inline(?P<type>Video|Audio|YouTube)Data\.push\((?P<json_data>[^)]+)\);',
            webpage)
        if mobj is None:
            expired = self._html_search_regex(r'(?s)class="expired-(?:video|audio)".+?<span>(.+?)</span>', webpage, 'expired', None)
            if expired:
                raise ExtractorError('%s said: %s' % (self.IE_NAME, expired), expected=True)
            raise ExtractorError('Unable to extract video urls')

        urls_info = self._parse_json(
            mobj.group('json_data'), video_id, transform_source=js_to_json)

        if not isinstance(urls_info, list):
            urls_info = [urls_info]

        if mobj.group('type') == 'YouTube':
            return self.playlist_result([
                self.url_result(url_info['url']) for url_info in urls_info])

        formats = [{
            'url': url_info['url'],
            'vcodec': url_info.get('codec') if mobj.group('type') == 'Video' else 'none',
            'width': int_or_none(url_info.get('width')),
            'height': int_or_none(url_info.get('height')),
            'tbr': int_or_none(url_info.get('bitrate')),

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Run on a standard CPython build (Linux/macOS/Windows) where fcntl or msvcrt exists.
  2. If your runtime genuinely lacks locking, avoid code paths that use locked_file (e.g. provide --no-cache-dir and a single-process setup), or monkeypatch youtube_dl.utils._lock_file/_unlock_file to no-ops accepting the concurrency risk.
  3. For Jython specifically, prefer invoking the youtube-dl CLI under CPython rather than importing the module.
  4. Check for the condition up front: import fcntl fails → expect locking to be unavailable.

Example fix

# before
with locked_file(cache_path, 'w') as f:  # IOError on Jython/no-fcntl
    f.write(data)

# after
try:
    import fcntl
    have_locks = True
except ImportError:
    have_locks = False

if have_locks:
    with locked_file(cache_path, 'w') as f:
        f.write(data)
else:
    with open(cache_path, 'w') as f:  # single-process fallback
        f.write(data)
Defensive patterns

Strategy: validation

Validate before calling

def file_locking_supported():
    if sys.platform == 'win32':
        return True  # msvcrt path
    try:
        import fcntl  # noqa: F401
        return True
    except ImportError:
        return False

if not file_locking_supported():
    # avoid locked_file, or run under CPython on a supported platform

Try / catch

try:
    with locked_file(path, 'w') as f:
        f.write(data)
except IOError as e:
    if 'file locking is not supported' in str(e):
        with open(path, 'w') as f:  # single-process fallback without locking
            f.write(data)
    else:
        raise

Prevention

When it happens

Trigger: Running youtube-dl (or embedding its locked_file/utils) on a Python runtime without fcntl: Jython, some embedded/thin Python builds, IronPython, or restricted sandbox environments where the module is missing. Opening any locked_file (used for output .part coordination and cache writes) triggers it.

Common situations: Embedding youtube_dl.utils in a non-CPython runtime; minimal Docker images with stripped Python; ancient/odd platforms. Rare on standard CPython Linux/macOS/Windows, which all take the fcntl or msvcrt branches.

Related errors


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