summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/pbs.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:06:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:06:10 +0000
commit137f07c27a88b07df57df5b2cdebebe3c7722bac (patch)
tree4ebdcbea6b540f69c40ba0be6ac766008030d149 /yt_dlp/extractor/pbs.py
parentAdding debian version 2024.05.27-1. (diff)
downloadyt-dlp-137f07c27a88b07df57df5b2cdebebe3c7722bac.tar.xz
yt-dlp-137f07c27a88b07df57df5b2cdebebe3c7722bac.zip
Merging upstream version 2024.07.01.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/extractor/pbs.py')
-rw-r--r--yt_dlp/extractor/pbs.py37
1 files changed, 18 insertions, 19 deletions
diff --git a/yt_dlp/extractor/pbs.py b/yt_dlp/extractor/pbs.py
index f6f5a5c..6867964 100644
--- a/yt_dlp/extractor/pbs.py
+++ b/yt_dlp/extractor/pbs.py
@@ -1,7 +1,6 @@
import re
from .common import InfoExtractor
-from ..compat import compat_str
from ..utils import (
US_RATINGS,
ExtractorError,
@@ -182,18 +181,18 @@ class PBSIE(InfoExtractor):
)
IE_NAME = 'pbs'
- IE_DESC = 'Public Broadcasting Service (PBS) and member stations: %s' % ', '.join(list(zip(*_STATIONS))[1])
+ IE_DESC = 'Public Broadcasting Service (PBS) and member stations: {}'.format(', '.join(list(zip(*_STATIONS))[1]))
_VALID_URL = r'''(?x)https?://
(?:
# Direct video URL
- (?:%s)/(?:(?:vir|port)alplayer|video)/(?P<id>[0-9]+)(?:[?/]|$) |
+ (?:{})/(?:(?:vir|port)alplayer|video)/(?P<id>[0-9]+)(?:[?/]|$) |
# Article with embedded player (or direct video)
- (?:www\.)?pbs\.org/(?:[^/]+/){1,5}(?P<presumptive_id>[^/]+?)(?:\.html)?/?(?:$|[?\#]) |
+ (?:www\.)?pbs\.org/(?:[^/]+/){{1,5}}(?P<presumptive_id>[^/]+?)(?:\.html)?/?(?:$|[?\#]) |
# Player
(?:video|player)\.pbs\.org/(?:widget/)?partnerplayer/(?P<player_id>[^/]+)
)
- ''' % '|'.join(list(zip(*_STATIONS))[0])
+ '''.format('|'.join(next(zip(*_STATIONS))))
_GEO_COUNTRIES = ['US']
@@ -415,7 +414,7 @@ class PBSIE(InfoExtractor):
{
'url': 'https://player.pbs.org/portalplayer/3004638221/?uid=',
'only_matching': True,
- }
+ },
]
_ERRORS = {
101: 'We\'re sorry, but this video is not yet available.',
@@ -518,7 +517,7 @@ class PBSIE(InfoExtractor):
if not video_id:
video_info = self._extract_video_data(
player_page, 'video data', display_id)
- video_id = compat_str(
+ video_id = str(
video_info.get('id') or video_info['contentID'])
else:
video_id = mobj.group('id')
@@ -539,7 +538,7 @@ class PBSIE(InfoExtractor):
if isinstance(video_id, list):
entries = [self.url_result(
- 'http://video.pbs.org/video/%s' % vid_id, 'PBS', vid_id)
+ f'http://video.pbs.org/video/{vid_id}', 'PBS', vid_id)
for vid_id in video_id]
return self.playlist_result(entries, display_id)
@@ -568,11 +567,11 @@ class PBSIE(InfoExtractor):
# Player pages may also serve different qualities
for page in ('widget/partnerplayer', 'portalplayer'):
player = self._download_webpage(
- 'http://player.pbs.org/%s/%s' % (page, video_id),
- display_id, 'Downloading %s page' % page, fatal=False)
+ f'http://player.pbs.org/{page}/{video_id}',
+ display_id, f'Downloading {page} page', fatal=False)
if player:
video_info = self._extract_video_data(
- player, '%s video data' % page, display_id, fatal=False)
+ player, f'{page} video data', display_id, fatal=False)
if video_info:
extract_redirect_urls(video_info)
if not info:
@@ -603,7 +602,7 @@ class PBSIE(InfoExtractor):
redirect_id = redirect.get('eeid')
redirect_info = self._download_json(
- '%s?format=json' % redirect['url'], display_id,
+ '{}?format=json'.format(redirect['url']), display_id,
'Downloading %s video url info' % (redirect_id or num),
headers=self.geo_verification_headers())
@@ -614,7 +613,7 @@ class PBSIE(InfoExtractor):
self.raise_geo_restricted(
msg=message, countries=self._GEO_COUNTRIES)
raise ExtractorError(
- '%s said: %s' % (self.IE_NAME, message), expected=True)
+ f'{self.IE_NAME} said: {message}', expected=True)
format_url = redirect_info.get('url')
if not format_url:
@@ -649,7 +648,7 @@ class PBSIE(InfoExtractor):
f_url = re.sub(r'\d+k|baseline', bitrate + 'k', http_url)
# This may produce invalid links sometimes (e.g.
# http://www.pbs.org/wgbh/frontline/film/suicide-plan)
- if not self._is_valid_url(f_url, display_id, 'http-%sk video' % bitrate):
+ if not self._is_valid_url(f_url, display_id, f'http-{bitrate}k video'):
continue
f = m3u8_format.copy()
f.update({
@@ -671,7 +670,7 @@ class PBSIE(InfoExtractor):
captions = info.get('cc') or {}
for caption_url in captions.values():
subtitles.setdefault('en', []).append({
- 'url': caption_url
+ 'url': caption_url,
})
subtitles = self._merge_subtitles(subtitles, hls_subs)
@@ -715,7 +714,7 @@ class PBSKidsIE(InfoExtractor):
'description': 'md5:d006b2211633685d8ebc8d03b6d5611e',
'categories': ['Episode'],
'upload_date': '20190718',
- }
+ },
},
{
'url': 'https://pbskids.org/video/plum-landing/2365205059',
@@ -730,8 +729,8 @@ class PBSKidsIE(InfoExtractor):
'description': 'md5:657e5fc4356a84ead1c061eb280ff05d',
'categories': ['Episode'],
'upload_date': '20140302',
- }
- }
+ },
+ },
]
def _real_extract(self, url):
@@ -753,5 +752,5 @@ class PBSKidsIE(InfoExtractor):
'series': ('video_obj', 'program_title', {str}),
'title': ('video_obj', 'title', {str}),
'upload_date': ('video_obj', 'air_date', {unified_strdate}),
- })
+ }),
}