diff options
author | Remita Amine <remitamine@gmail.com> | 2016-10-05 18:27:02 +0100 |
---|---|---|
committer | Remita Amine <remitamine@gmail.com> | 2016-10-05 18:27:02 +0100 |
commit | 017eb829343dfff9b70ab7f2278053f35cee953c (patch) | |
tree | eb202d61b71570b0d07e53c86b6a4ff7bb8b410d | |
parent | b1d798887e5bc26c938fe8c07ae5ccf382568f58 (diff) |
[npo] detect geo restriction
-rw-r--r-- | youtube_dl/extractor/npo.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/youtube_dl/extractor/npo.py b/youtube_dl/extractor/npo.py index c3915ec6e..c91f58461 100644 --- a/youtube_dl/extractor/npo.py +++ b/youtube_dl/extractor/npo.py @@ -3,6 +3,7 @@ from __future__ import unicode_literals import re from .common import InfoExtractor +from ..compat import compat_HTTPError from ..utils import ( fix_xml_ampersands, orderedSet, @@ -10,6 +11,7 @@ from ..utils import ( qualities, strip_jsonp, unified_strdate, + ExtractorError, ) @@ -181,9 +183,16 @@ class NPOIE(NPOBaseIE): continue streams = format_info.get('streams') if streams: - video_info = self._download_json( - streams[0] + '&type=json', - video_id, 'Downloading %s stream JSON' % format_id) + try: + video_info = self._download_json( + 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: video_info = format_info video_url = video_info.get('url') |