aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/pbs.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2016-02-11 21:22:57 +0600
committerSergey M․ <dstftw@gmail.com>2016-02-11 21:22:57 +0600
commit9a61dfba0cfb9b978278fe2e1c823c205fcd72dd (patch)
tree73d81f307cbddf8783f861b170895ad77758d090 /youtube_dl/extractor/pbs.py
parent154c209e2db2bd6f51998503b15d9a050bc1e738 (diff)
[pbs] Revert prefer portalplayer
Diffstat (limited to 'youtube_dl/extractor/pbs.py')
-rw-r--r--youtube_dl/extractor/pbs.py24
1 files changed, 13 insertions, 11 deletions
diff --git a/youtube_dl/extractor/pbs.py b/youtube_dl/extractor/pbs.py
index cbd1efea0..0d4d709de 100644
--- a/youtube_dl/extractor/pbs.py
+++ b/youtube_dl/extractor/pbs.py
@@ -4,6 +4,7 @@ from __future__ import unicode_literals
import re
from .common import InfoExtractor
+from ..compat import compat_HTTPError
from ..utils import (
ExtractorError,
determine_ext,
@@ -433,20 +434,21 @@ class PBSIE(InfoExtractor):
for vid_id in video_id]
return self.playlist_result(entries, display_id)
- player = self._download_webpage(
- 'http://player.pbs.org/portalplayer/%s' % video_id, display_id)
-
- info = self._parse_json(
- self._search_regex(
- r'(?s)PBS\.videoData\s*=\s*({.+?});\n',
- player, 'video data', default='{}'),
- display_id, transform_source=js_to_json, fatal=False)
-
- # Fallback to old videoInfo API
- if not info:
+ try:
info = self._download_json(
'http://player.pbs.org/videoInfo/%s?format=json&type=partner' % video_id,
display_id, 'Downloading video info JSON')
+ except ExtractorError as e:
+ if not isinstance(e.cause, compat_HTTPError) or e.cause.code != 404:
+ raise
+ # videoInfo API may not work for some videos, fallback to portalplayer API
+ player = self._download_webpage(
+ 'http://player.pbs.org/portalplayer/%s' % video_id, display_id)
+ info = self._parse_json(
+ self._search_regex(
+ r'(?s)PBS\.videoData\s*=\s*({.+?});\n',
+ player, 'video data', default='{}'),
+ display_id, transform_source=js_to_json, fatal=False)
formats = []
for encoding_name in ('recommended_encoding', 'alternate_encoding'):