Merge pull request #7105 from remitamine/pbs

[pbs] detect errors from http error code
pull/7107/head
Sergey M. 9 years ago
commit cbb7287204

@ -108,12 +108,12 @@ class PBSIE(InfoExtractor):
{ {
'url': 'http://www.pbs.org/wgbh/americanexperience/films/death/player/', 'url': 'http://www.pbs.org/wgbh/americanexperience/films/death/player/',
'info_dict': { 'info_dict': {
'id': '2280706814', 'id': '2276541483',
'display_id': 'player', 'display_id': 'player',
'ext': 'mp4', 'ext': 'mp4',
'title': 'American Experience - Death and the Civil War', 'title': 'American Experience - Death and the Civil War, Chapter 1',
'description': 'American Experience, TVs most-watched history series, brings to life the compelling stories from our past that inform our understanding of the world today.', 'description': 'American Experience, TVs most-watched history series, brings to life the compelling stories from our past that inform our understanding of the world today.',
'duration': 6705, 'duration': 682,
'thumbnail': 're:^https?://.*\.jpg$', 'thumbnail': 're:^https?://.*\.jpg$',
}, },
'params': { 'params': {
@ -134,6 +134,7 @@ class PBSIE(InfoExtractor):
'params': { 'params': {
'skip_download': True, # requires ffmpeg 'skip_download': True, # requires ffmpeg
}, },
'skip': 'Expired',
}, },
{ {
# Video embedded in iframe containing angle brackets as attribute's value (e.g. # Video embedded in iframe containing angle brackets as attribute's value (e.g.
@ -154,6 +155,12 @@ class PBSIE(InfoExtractor):
}, },
} }
] ]
_ERRORS = {
101: 'We\'re sorry, but this video is not yet available.',
403: 'We\'re sorry, but this video is not available in your region due to right restrictions.',
404: 'We are experiencing technical difficulties that are preventing us from playing the video at this time. Please check back again soon.',
410: 'This video has expired and is no longer available for online streaming.',
}
def _extract_webpage(self, url): def _extract_webpage(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
@ -231,13 +238,7 @@ class PBSIE(InfoExtractor):
'Downloading %s video url info' % encoding_name) 'Downloading %s video url info' % encoding_name)
if redirect_info['status'] == 'error': if redirect_info['status'] == 'error':
if redirect_info['http_code'] == 403: raise ExtractorError('PBS said: %s' % self._ERRORS.get(redirect_info['http_code'], redirect_info['message']), expected=True)
message = (
'The video is not available in your region due to '
'right restrictions')
else:
message = redirect_info['message']
raise ExtractorError(message, expected=True)
format_url = redirect_info.get('url') format_url = redirect_info.get('url')
if not format_url: if not format_url:

Loading…
Cancel
Save