mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 02:25:11 +00:00
[npo] detect geo restriction
This commit is contained in:
parent
b1d798887e
commit
017eb82934
1 changed files with 12 additions and 3 deletions
|
@ -3,6 +3,7 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_HTTPError
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
fix_xml_ampersands,
|
fix_xml_ampersands,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
|
@ -10,6 +11,7 @@
|
||||||
qualities,
|
qualities,
|
||||||
strip_jsonp,
|
strip_jsonp,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
|
ExtractorError,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,9 +183,16 @@ def _get_info(self, video_id):
|
||||||
continue
|
continue
|
||||||
streams = format_info.get('streams')
|
streams = format_info.get('streams')
|
||||||
if streams:
|
if streams:
|
||||||
video_info = self._download_json(
|
try:
|
||||||
streams[0] + '&type=json',
|
video_info = self._download_json(
|
||||||
video_id, 'Downloading %s stream JSON' % format_id)
|
streams[0] + '&type=json',
|
||||||
|
video_id, 'Downloading %s stream JSON' % format_id)
|
||||||
|
except ExtractorError as ee:
|
||||||
|
if isinstance(ee.cause, compat_HTTPError) and ee.cause.code == 404:
|
||||||
|
error = (self._parse_json(ee.cause.read().decode(), video_id, fatal=False) or {}).get('errorstring')
|
||||||
|
if error:
|
||||||
|
raise ExtractorError(error, expected=True)
|
||||||
|
raise
|
||||||
else:
|
else:
|
||||||
video_info = format_info
|
video_info = format_info
|
||||||
video_url = video_info.get('url')
|
video_url = video_info.get('url')
|
||||||
|
|
Loading…
Reference in a new issue