diff options
author | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2014-12-31 17:24:14 +0100 |
---|---|---|
committer | Jaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com> | 2014-12-31 17:43:49 +0100 |
commit | f86d543ebb6eafa1ca939a17601307bf29b88f6f (patch) | |
tree | 8350cc61cb32910ab6b6b67dac88181efd4c3009 /youtube_dl/extractor | |
parent | 60e47a2699bea32f12a92e59d02d1ba0e9cbdec9 (diff) |
[pbs] Catch geoblocking errors (closes #4516)
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r-- | youtube_dl/extractor/pbs.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/youtube_dl/extractor/pbs.py b/youtube_dl/extractor/pbs.py index 6118ed5c2..afce732e1 100644 --- a/youtube_dl/extractor/pbs.py +++ b/youtube_dl/extractor/pbs.py @@ -4,6 +4,7 @@ import re from .common import InfoExtractor from ..utils import ( + ExtractorError, unified_strdate, US_RATINGS, ) @@ -151,6 +152,19 @@ class PBSIE(InfoExtractor): info_url = 'http://video.pbs.org/videoInfo/%s?format=json' % video_id info = self._download_json(info_url, display_id) + redirect_url = info['alternate_encoding']['url'] + redirect_info = self._download_json( + redirect_url + '?format=json', display_id, + 'Downloading video url info') + if redirect_info['status'] == 'error': + if redirect_info['http_code'] == 403: + message = ( + 'The video is not available in your region due to ' + 'right restrictions') + else: + message = redirect_info['message'] + raise ExtractorError(message, expected=True) + rating_str = info.get('rating') if rating_str is not None: rating_str = rating_str.rpartition('-')[2] @@ -160,7 +174,7 @@ class PBSIE(InfoExtractor): 'id': video_id, 'display_id': display_id, 'title': info['title'], - 'url': info['alternate_encoding']['url'], + 'url': redirect_info['url'], 'ext': 'mp4', 'description': info['program'].get('description'), 'thumbnail': info.get('image_url'), |