handle _download_json error correctly

This commit will fallback to webpage extraction if the API url is not found in particular regiom
This commit is contained in:
HobbyistDev 2024-04-11 07:13:34 +08:00
parent 9a6fc7f863
commit f92dedc92a

View file

@ -6,8 +6,8 @@
from .common import InfoExtractor
from ..compat import compat_str
from ..networking.exceptions import HTTPError
from ..utils import (
DownloadError,
ExtractorError,
int_or_none,
merge_dicts,
@ -304,10 +304,12 @@ def _real_extract(self, url):
try:
product_data = self._download_json(
f'http://www.viu.com/ott/{country_code}/index.php', video_id,
'Downloading video info', query=query, fatal=False)['data']
'Downloading video info', query=query)['data']
# The `fatal` in `_download_json` didn't prevent json error
# FIXME: probably the error still too broad
except (DownloadError, ExtractorError):
except ExtractorError as e:
if not isinstance(e.cause, (json.JSONDecodeError, HTTPError)):
raise
# NOTE: some geo-blocked like https://www.viu.com/ott/sg/en/vod/108599/The-Beauty-Inside actually can bypassed
# on other region (like in ID)
product_data = traverse_obj(