ytdl-org/youtube-dl · error · ExtractorError

Invalid URL

Error message

Invalid URL

What it means

Raised by the Arkena extractor when the URL matched _VALID_URL but captured neither id nor account_id groups, AND the query string lacks mediaId/accountId parameters. It is the guard for embed player URLs (video.arkena.com/play2/embed/player) that were expected to carry the ids in the query but do not. Marked expected=True.

Source

Thrown at youtube_dl/extractor/arkena.py:76

        # See https://support.arkena.com/display/PLAY/Ways+to+embed+your+video
        mobj = re.search(
            r'<iframe[^>]+src=(["\'])(?P<url>(?:https?:)?//play\.arkena\.com/embed/avp/.+?)\1',
            webpage)
        if mobj:
            return mobj.group('url')

    def _real_extract(self, url):
        mobj = re.match(self._VALID_URL, url)
        video_id = mobj.group('id')
        account_id = mobj.group('account_id')

        # Handle http://video.arkena.com/play2/embed/player URL
        if not video_id:
            qs = compat_urlparse.parse_qs(compat_urlparse.urlparse(url).query)
            video_id = qs.get('mediaId', [None])[0]
            account_id = qs.get('accountId', [None])[0]
            if not video_id or not account_id:
                raise ExtractorError('Invalid URL', expected=True)

        media = self._download_json(
            'https://video.qbrick.com/api/v1/public/accounts/%s/medias/%s' % (account_id, video_id),
            video_id, query={
                # https://video.qbrick.com/docs/api/examples/library-api.html
                'fields': 'asset/resources/*/renditions/*(height,id,language,links/*(href,mimeType),type,size,videos/*(audios/*(codec,sampleRate),bitrate,codec,duration,height,width),width),created,metadata/*(title,description),tags',
            })
        metadata = media.get('metadata') or {}
        title = metadata['title']

        duration = None
        formats = []
        thumbnails = []
        subtitles = {}
        for resource in media['asset']['resources']:
            for rendition in (resource.get('renditions') or []):
                rendition_type = rendition.get('type')
                for i, link in enumerate(rendition.get('links') or []):

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Re-copy the full embed URL including the complete ?mediaId=<id>&accountId=<acct> query string
  2. Quote the URL in the shell so '&' is not interpreted
  3. If the embed gives only a partial id, open the parent page and extract the canonical arkena media URL

Example fix

# before
youtube-dl 'http://video.arkena.com/play2/embed/player'

# after
youtube-dl 'http://video.arkena.com/play2/embed/player?mediaId=abc123&accountId=acct456'
Defensive patterns

Strategy: validation

Validate before calling

# Validate Arkena embed URLs before extraction
from urllib.parse import urlparse, parse_qs
q = parse_qs(urlparse(url).query)
if 'arkena.com/play2/embed/player' in url and not (q.get('mediaId') and q.get('accountId')):
    raise ValueError('Arkena embed URL missing mediaId/accountId query params: %s' % url)

Type guard

def is_valid_arkena_embed(url):
    """Embed player URLs must carry both mediaId and accountId in the query."""
    if 'play2/embed/player' not in url:
        return True  # path-style URLs are matched by regex groups
    q = parse_qs(urlparse(url).query)
    return bool(q.get('mediaId', [None])[0] and q.get('accountId', [None])[0])

Try / catch

try:
    ydl.extract_info(url)
except ExtractorError as e:
    if str(e) == 'Invalid URL':
        url = recover_full_embed_url_from_parent_page(url)  # re-scrape the embed snippet

Prevention

When it happens

Trigger: A /play2/embed/player URL without ?mediaId=...&accountId=...; malformed embed snippets copied without their query string; regex-captured groups empty for a URL that still matched the pattern.

Common situations: Truncated embed code copied from a page; query string stripped by URL normalization or shell quoting; player URLs from older Arkena integrations using different parameter names.

Related errors


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