{"record":{"id":"165a9a4d24ba1c37","repo":"yt-dlp/yt-dlp","slug":"self-ie-name-returned-error-media-selection-er","errorCode":null,"errorMessage":"{self.IE_NAME} returned error: {media_selection_error.id}","messagePattern":"(.+?) returned error: (.+?)","errorType":"exception","errorClass":"ExtractorError","httpStatus":null,"severity":"error","filePath":"yt_dlp/extractor/bbc.py","lineNumber":314,"sourceCode":"        for connection in self._extract_connections(media):\n            cc_url = url_or_none(connection.get('href'))\n            if not cc_url:\n                continue\n            captions = self._download_xml(\n                cc_url, programme_id, 'Downloading captions', fatal=False)\n            if not isinstance(captions, xml.etree.ElementTree.Element):\n                continue\n            subtitles['en'] = [\n                {\n                    'url': connection.get('href'),\n                    'ext': 'ttml',\n                },\n            ]\n            break\n        return subtitles\n\n    def _raise_extractor_error(self, media_selection_error):\n        raise ExtractorError(\n            f'{self.IE_NAME} returned error: {media_selection_error.id}',\n            expected=True)\n\n    def _download_media_selector(self, programme_id):\n        last_exception = None\n        formats, subtitles = [], {}\n        for media_set in self._MEDIA_SETS:\n            try:\n                fmts, subs = self._download_media_selector_url(\n                    self._MEDIA_SELECTOR_URL_TEMPL % (media_set, programme_id), programme_id)\n                formats.extend(fmts)\n                if subs:\n                    self._merge_subtitles(subs, target=subtitles)\n            except BBCCoUkIE.MediaSelectionError as e:\n                if e.id in ('notukerror', 'geolocation', 'selectionunavailable'):\n                    last_exception = e\n                    continue\n                self._raise_extractor_error(e)","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/yt-dlp/yt-dlp/blob/81ecd58b1394793e6da9998cc19fdb45657f1685/yt_dlp/extractor/bbc.py#L296-L332","documentation":"Raised by BBCCoUkIE._raise_extractor_error (yt_dlp/extractor/bbc.py:314) when the media-selector JSON for a programme contains a 'result' field - the BBC's own error signal - which _extract_mediasas turns into MediaSelectionError. The error id is echoed in the message; the classic value is 'geolocation' for UK-only programmes. Marked expected=True.","triggerScenarios":"Requesting a media set for a programme the BBC will not serve to your IP: geolocation restrictions on iPlayer/Sounds content, or unavailable media sets; the loop over _MEDIA_SETS at bbc.py:320 catches MediaSelectionError and re-raises via this method only after every set fails.","commonSituations":"Downloading BBC iPlayer/radio programmes from outside the UK without a proxy; UK-only sport and rights-restricted content; programmes whose media sets have been pulled.","solutions":["If the id is 'geolocation', route through a UK proxy/VPN: yt-dlp --proxy socks5://... and retry","Confirm the programme plays on the BBC site from the same network","Update yt-dlp (yt-dlp -U) in case selector endpoints changed","For non-geo ids, report the programme URL and error id at https://github.com/yt-dlp/yt-dlp/issues"],"exampleFix":"# before\nydl_opts = {}\n\n# after: present a UK IP for geo-locked BBC programmes\nydl_opts = {'proxy': 'socks5://uk-proxy.example.com:1080'}","handlingStrategy":"fallback","validationCode":"import urllib.request\n\ndef appears_uk():\n    return 'GB' in urllib.request.urlopen('https://ipinfo.io/json').read().decode()","typeGuard":null,"tryCatchPattern":"from yt_dlp.utils import ExtractorError\n\ntry:\n    info = ydl.extract_info(url, download=False)\nexcept ExtractorError as e:\n    if 'returned error: geolocation' in str(e):\n        with YoutubeDL({'proxy': UK_PROXY}) as ydl_uk:\n            info = ydl_uk.extract_info(url, download=False)\n    else:\n        raise","preventionTips":["Configure a UK proxy for BBC iPlayer jobs up front","Check the error id in the message - only 'geolocation' is proxy-fixable","Verify programmes play on bbc.co.uk from the same egress IP before extracting"],"tags":["bbc","geolocation","geo-restricted","iplayer","yt-dlp"],"backgroundTag":"geo-restricted-content","analyzedSha":"81ecd58b1394793e6da9998cc19fdb45657f1685","analyzedAt":"2026-08-22T12:21:25.439Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}