ytdl-org/youtube-dl · error · ExtractorError
%s
Error message
%s
What it means
SonyLIVIE._call_api wraps _download_json against apiv2.sonyliv.com; on HTTP 403 it parses the body's 'message' field. If the message is 'Geoblocked Country' it raises geo-restriction, otherwise it re-raises the API's message as a plain (unexpected) ExtractorError. Typical messages cover invalid/expired security tokens and unauthorized content.
Source
Thrown at youtube_dl/extractor/sonyliv.py:68
}]
_GEO_COUNTRIES = ['IN']
_TOKEN = None
def _call_api(self, version, path, video_id):
headers = {}
if self._TOKEN:
headers['security_token'] = self._TOKEN
try:
return self._download_json(
'https://apiv2.sonyliv.com/AGL/%s/A/ENG/WEB/%s' % (version, path),
video_id, headers=headers)['resultObj']
except ExtractorError as e:
if isinstance(e.cause, compat_HTTPError) and e.cause.code == 403:
message = self._parse_json(
e.cause.read().decode(), video_id)['message']
if message == 'Geoblocked Country':
self.raise_geo_restricted(countries=self._GEO_COUNTRIES)
raise ExtractorError(message)
raise
def _real_initialize(self):
self._TOKEN = self._call_api('1.4', 'ALL/GETTOKEN', None)
def _real_extract(self, url):
video_id = self._match_id(url)
content = self._call_api(
'1.5', 'IN/CONTENT/VIDEOURL/VOD/' + video_id, video_id)
if content.get('isEncrypted'):
raise ExtractorError('This video is DRM protected.', expected=True)
dash_url = content['videoURL']
headers = {
'x-playback-session-id': '%s-%d' % (uuid.uuid4().hex, time.time() * 1000)
}
formats = self._extract_mpd_formats(
dash_url, video_id, mpd_id='dash', headers=headers, fatal=False)
formats.extend(self._extract_m3u8_formats(View on GitHub (pinned to 956b8c5855)
Solutions
- If the message says geoblocked, use an Indian VPN/proxy - there is no other workaround.
- Update to the latest yt-dlp; SonyLIV's token/bootstrap flow changes frequently and old extractors get 403 everywhere.
- Retry after clearing the cache so a fresh security token is minted (transient token failures happen).
- If the token call itself 403s, the API contract changed - needs extractor fix, not user action.
Defensive patterns
Strategy: try-catch
Try / catch
try:
extract(url)
except GeoRestrictedError:
retry_via_in_proxy()
except ExtractorError as e:
if 'token' in str(e).lower():
clear_cache(); retry_once()
else:
raise Prevention
- Use Indian egress for all SonyLIV downloads.
- Update yt-dlp before reporting - token bootstrap changes often.
- Clear cache to force a fresh security token on strange 403s.
When it happens
Trigger: Any AGL API call (ALL/GETTOKEN, IN/CONTENT/VIDEOURL/VOD/<id>) answered with HTTP 403 and a JSON body: message 'Geoblocked Country' from non-Indian IPs, or token-invalid/auth messages when the security_token header obtained in _real_initialize has expired or failed.
Common situations: Using SonyLIV outside India without a VPN (India-only service); the token endpoint itself returning 403 so every later call fails with a token message; Sony rotating their API in ways that break token bootstrap on older youtube-dl versions.
Related errors
AI-assisted analysis of ytdl-org/youtube-dl@956b8c5855 (2026-08-14).
Data as JSON: /api/errors/265602a4ff909392.
Report an issue: GitHub.