mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-21 20:46:36 -05:00
[pbs] Revert prefer portalplayer
This commit is contained in:
parent
154c209e2d
commit
9a61dfba0c
1 changed files with 13 additions and 11 deletions
|
@ -4,6 +4,7 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..compat import compat_HTTPError
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
|
@ -433,21 +434,22 @@ def _real_extract(self, url):
|
||||||
for vid_id in video_id]
|
for vid_id in video_id]
|
||||||
return self.playlist_result(entries, display_id)
|
return self.playlist_result(entries, display_id)
|
||||||
|
|
||||||
|
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(
|
player = self._download_webpage(
|
||||||
'http://player.pbs.org/portalplayer/%s' % video_id, display_id)
|
'http://player.pbs.org/portalplayer/%s' % video_id, display_id)
|
||||||
|
|
||||||
info = self._parse_json(
|
info = self._parse_json(
|
||||||
self._search_regex(
|
self._search_regex(
|
||||||
r'(?s)PBS\.videoData\s*=\s*({.+?});\n',
|
r'(?s)PBS\.videoData\s*=\s*({.+?});\n',
|
||||||
player, 'video data', default='{}'),
|
player, 'video data', default='{}'),
|
||||||
display_id, transform_source=js_to_json, fatal=False)
|
display_id, transform_source=js_to_json, fatal=False)
|
||||||
|
|
||||||
# Fallback to old videoInfo API
|
|
||||||
if not info:
|
|
||||||
info = self._download_json(
|
|
||||||
'http://player.pbs.org/videoInfo/%s?format=json&type=partner' % video_id,
|
|
||||||
display_id, 'Downloading video info JSON')
|
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for encoding_name in ('recommended_encoding', 'alternate_encoding'):
|
for encoding_name in ('recommended_encoding', 'alternate_encoding'):
|
||||||
redirect = info.get(encoding_name)
|
redirect = info.get(encoding_name)
|
||||||
|
|
Loading…
Reference in a new issue