ytdl-org/youtube-dl · error · ExtractorError

Invalid URL

Error message

Invalid URL

What it means

Raised by the Rice University (mediahub.rice.edu, Ensemble Video platform) extractor when the URL's query string is missing any of PortalID, DestinationID or ContentID parameters. The extractor parses the query string via regex and requires all three ids before it can call the GetContentTitle API. Expected=True.

Source

Thrown at youtube_dl/extractor/rice.py:35

class RICEIE(InfoExtractor):
    _VALID_URL = r'https?://mediahub\.rice\.edu/app/[Pp]ortal/video\.aspx\?(?P<query>.+)'
    _TEST = {
        'url': 'https://mediahub.rice.edu/app/Portal/video.aspx?PortalID=25ffd62c-3d01-4b29-8c70-7c94270efb3e&DestinationID=66bc9434-03bd-4725-b47e-c659d8d809db&ContentID=YEWIvbhb40aqdjMD1ALSqw',
        'md5': '9b83b4a2eead4912dc3b7fac7c449b6a',
        'info_dict': {
            'id': 'YEWIvbhb40aqdjMD1ALSqw',
            'ext': 'mp4',
            'title': 'Active Learning in Archeology',
            'upload_date': '20140616',
            'timestamp': 1402926346,
        }
    }
    _NS = 'http://schemas.datacontract.org/2004/07/ensembleVideo.Data.Service.Contracts.Models.Player.Config'

    def _real_extract(self, url):
        qs = compat_parse_qs(re.match(self._VALID_URL, url).group('query'))
        if not qs.get('PortalID') or not qs.get('DestinationID') or not qs.get('ContentID'):
            raise ExtractorError('Invalid URL', expected=True)

        portal_id = qs['PortalID'][0]
        playlist_id = qs['DestinationID'][0]
        content_id = qs['ContentID'][0]

        content_data = self._download_xml('https://mediahub.rice.edu/api/portal/GetContentTitle', content_id, query={
            'portalId': portal_id,
            'playlistId': playlist_id,
            'contentId': content_id
        })
        metadata = xpath_element(content_data, './/metaData', fatal=True)
        title = xpath_text(metadata, 'primaryTitle', fatal=True)
        encodings = xpath_element(content_data, './/encodings', fatal=True)
        player_data = self._download_xml('https://mediahub.rice.edu/api/player/GetPlayerConfig', content_id, query={
            'temporaryLinkId': xpath_text(encodings, 'temporaryLinkId', fatal=True),
            'contentId': content_id,
        })

View on GitHub (pinned to 956b8c5855)

Solutions

  1. Get the complete embed URL from the page's iframe/embed code and use it verbatim, including all three query parameters.
  2. Manually append the missing parameter(s) if you know the ids from the original page.
  3. If the site genuinely dropped a parameter from its embeds, the extractor's requirement is stale - update youtube-dl or fix the qs check in rice.py.

Example fix

# before (missing params)
https://mediahub.rice.edu/Portals/Embed.aspx?PortalID=7&ContentID=123
# after
https://mediahub.rice.edu/Portals/Embed.aspx?PortalID=7&DestinationID=45&ContentID=123
Defensive patterns

Strategy: validation

Validate before calling

from urllib.parse import urlparse, parse_qs
def valid_rice_url(url):
    qs = parse_qs(urlparse(url).query)
    return all(qs.get(k) for k in ('PortalID', 'DestinationID', 'ContentID'))

Prevention

When it happens

Trigger: A URL matching _VALID_URL whose query string lacks ?PortalID=...&DestinationID=...&ContentID=..., e.g. a truncated/copy-pasted embed URL or one where a parameter was renamed by the site.

Common situations: Copying only part of an embed iframe src; the portal migrating and dropping a parameter; URL-encoding mistakes stripping ampersands.

Related errors


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