ytdl-org/youtube-dl · error · ExtractorError

Invalid URL

Error message

Invalid URL

What it means

Raised by KalturaIE._real_extract for a URL that matched _VALID_URL but contained neither a path nor a query string beyond the host. The extractor requires partner_id+entry_id directly in the URL, or a path/query carrying wid/p/partner_id parameters; with both empty there is nothing to dispatch on, so it fails fast with an expected error.

Source

Thrown at youtube_dl/extractor/kaltura.py:241

                'ks': '{1:result:ks}',
            },
        ]
        return self._kaltura_api_call(
            video_id, actions, service_url, note='Downloading video info JSON')

    def _real_extract(self, url):
        url, smuggled_data = unsmuggle_url(url, {})

        mobj = re.match(self._VALID_URL, url)
        partner_id, entry_id = mobj.group('partner_id', 'id')
        ks = None
        captions = None
        if partner_id and entry_id:
            _, info, flavor_assets, captions = self._get_video_info(entry_id, partner_id, smuggled_data.get('service_url'))
        else:
            path, query = mobj.group('path', 'query')
            if not path and not query:
                raise ExtractorError('Invalid URL', expected=True)
            params = {}
            if query:
                params = compat_parse_qs(query)
            if path:
                splitted_path = path.split('/')
                params.update(dict((zip(splitted_path[::2], [[v] for v in splitted_path[1::2]]))))
            if 'wid' in params:
                partner_id = params['wid'][0][1:]
            elif 'p' in params:
                partner_id = params['p'][0]
            elif 'partner_id' in params:
                partner_id = params['partner_id'][0]
            else:
                raise ExtractorError('Invalid URL', expected=True)
            if 'entry_id' in params:
                entry_id = params['entry_id'][0]
                _, info, flavor_assets, captions = self._get_video_info(entry_id, partner_id)
            elif 'uiconf_id' in params and 'flashvars[referenceId]' in params:

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Re-copy the complete embed URL including the query string (wid/p/partner_id and entry_id/uiconf_id).
  2. Prefer the full iframe src attribute from the page's HTML.
  3. Construct the canonical form: <kaltura_host>/.../entry_id/<ID> or keep ?entry_id=...&p=...

Example fix

// before
youtube_dl 'http://cdnapi.kaltura.com/'
# => Invalid URL

// after
youtube_dl 'http://cdnapi.kaltura.com/html5/html5lib/v2.86/mwEmbedFrame.php?wid=_123456&entry_id=1_abcdefg'
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse, parse_qs
u = urlparse(candidate_url)
q = parse_qs(u.query)
has_path_params = len(u.path.strip('/').split('/')) >= 2
if not q and not has_path_params:
    reject('Kaltura URL lacks path and query parameters')

Type guard

def is_actionable_kaltura_url(url: str) -> bool:
    p = urlparse(url)
    return bool(p.path.strip('/')) or bool(p.query)

Try / catch

try:
    ydl.extract_info(url)
except ExtractorError as e:
    if str(e) == 'Invalid URL':
        re_fetch_embed_src_from_page(page_url)  # URL was truncated; get original iframe src

Prevention

When it happens

Trigger: URLs like 'http://cdnapi.kaltura.com/' or a bare Kaltura host that regex-matched but whose named groups 'path' and 'query' are both empty - typically hand-typed or truncated embed URLs.

Common situations: Users strip the query string (?wid=...&entry_id=...) when copying Kaltura embed URLs, or a CMS mangles the URL and drops everything after the host.

Related errors


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