mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 02:25:11 +00:00
parent
083c1bb960
commit
5890eef6b0
1 changed files with 40 additions and 16 deletions
|
@ -5,6 +5,8 @@
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
ExtractorError,
|
ExtractorError,
|
||||||
|
determine_ext,
|
||||||
|
int_or_none,
|
||||||
unified_strdate,
|
unified_strdate,
|
||||||
US_RATINGS,
|
US_RATINGS,
|
||||||
)
|
)
|
||||||
|
@ -149,21 +151,44 @@ 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)
|
||||||
|
|
||||||
info_url = 'http://video.pbs.org/videoInfo/%s?format=json' % video_id
|
info = self._download_json(
|
||||||
info = self._download_json(info_url, display_id)
|
'http://video.pbs.org/videoInfo/%s?format=json&type=partner' % video_id,
|
||||||
|
display_id)
|
||||||
|
|
||||||
redirect_url = info['alternate_encoding']['url']
|
formats = []
|
||||||
redirect_info = self._download_json(
|
for encoding_name in ('recommended_encoding', 'alternate_encoding'):
|
||||||
redirect_url + '?format=json', display_id,
|
redirect = info.get(encoding_name)
|
||||||
'Downloading video url info')
|
if not redirect:
|
||||||
if redirect_info['status'] == 'error':
|
continue
|
||||||
if redirect_info['http_code'] == 403:
|
redirect_url = redirect.get('url')
|
||||||
message = (
|
if not redirect_url:
|
||||||
'The video is not available in your region due to '
|
continue
|
||||||
'right restrictions')
|
|
||||||
|
redirect_info = self._download_json(
|
||||||
|
redirect_url + '?format=json', display_id,
|
||||||
|
'Downloading %s video url info' % encoding_name)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
format_url = redirect_info.get('url')
|
||||||
|
if not format_url:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if determine_ext(format_url) == 'm3u8':
|
||||||
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
format_url, display_id, 'mp4', preference=1, m3u8_id='hls'))
|
||||||
else:
|
else:
|
||||||
message = redirect_info['message']
|
formats.append({
|
||||||
raise ExtractorError(message, expected=True)
|
'url': format_url,
|
||||||
|
})
|
||||||
|
self._sort_formats(formats)
|
||||||
|
|
||||||
rating_str = info.get('rating')
|
rating_str = info.get('rating')
|
||||||
if rating_str is not None:
|
if rating_str is not None:
|
||||||
|
@ -174,11 +199,10 @@ def _real_extract(self, url):
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'display_id': display_id,
|
'display_id': display_id,
|
||||||
'title': info['title'],
|
'title': info['title'],
|
||||||
'url': redirect_info['url'],
|
|
||||||
'ext': 'mp4',
|
|
||||||
'description': info['program'].get('description'),
|
'description': info['program'].get('description'),
|
||||||
'thumbnail': info.get('image_url'),
|
'thumbnail': info.get('image_url'),
|
||||||
'duration': info.get('duration'),
|
'duration': int_or_none(info.get('duration')),
|
||||||
'age_limit': age_limit,
|
'age_limit': age_limit,
|
||||||
'upload_date': upload_date,
|
'upload_date': upload_date,
|
||||||
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue