summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/wistia.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
commit7e21328585afda6d66f98ca476301680eeffac32 (patch)
tree266a4e7b20443f94572748781d71fc0375a15037 /yt_dlp/extractor/wistia.py
parentAdding upstream version 2024.05.27. (diff)
downloadyt-dlp-7e21328585afda6d66f98ca476301680eeffac32.tar.xz
yt-dlp-7e21328585afda6d66f98ca476301680eeffac32.zip
Adding upstream version 2024.07.01.upstream/2024.07.01
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/extractor/wistia.py')
-rw-r--r--yt_dlp/extractor/wistia.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/yt_dlp/extractor/wistia.py b/yt_dlp/extractor/wistia.py
index f2256fd..fb2a864 100644
--- a/yt_dlp/extractor/wistia.py
+++ b/yt_dlp/extractor/wistia.py
@@ -24,7 +24,7 @@ class WistiaBaseIE(InfoExtractor):
_EMBED_BASE_URL = 'http://fast.wistia.net/embed/'
def _download_embed_config(self, config_type, config_id, referer):
- base_url = self._EMBED_BASE_URL + '%s/%s' % (config_type, config_id)
+ base_url = self._EMBED_BASE_URL + f'{config_type}/{config_id}'
embed_config = self._download_json(
base_url + '.json', config_id, headers={
'Referer': referer if referer.startswith('http') else base_url, # Some videos require this.
@@ -74,7 +74,7 @@ class WistiaBaseIE(InfoExtractor):
display_name = a.get('display_name')
format_id = atype
if atype and atype.endswith('_video') and display_name:
- format_id = '%s-%s' % (atype[:-6], display_name)
+ format_id = f'{atype[:-6]}-{display_name}'
f = {
'format_id': format_id,
'url': aurl,
@@ -157,7 +157,7 @@ class WistiaBaseIE(InfoExtractor):
class WistiaIE(WistiaBaseIE):
- _VALID_URL = r'(?:wistia:|%s(?:iframe|medias)/)%s' % (WistiaBaseIE._VALID_URL_BASE, WistiaBaseIE._VALID_ID_REGEX)
+ _VALID_URL = rf'(?:wistia:|{WistiaBaseIE._VALID_URL_BASE}(?:iframe|medias)/){WistiaBaseIE._VALID_ID_REGEX}'
_EMBED_REGEX = [
r'''(?x)
<(?:meta[^>]+?content|(?:iframe|script)[^>]+?src)=["\']
@@ -189,7 +189,7 @@ class WistiaIE(WistiaBaseIE):
'duration': 966.0,
'timestamp': 1616614369,
'thumbnail': 'https://embed-ssl.wistia.com/deliveries/53dc60239348dc9b9fba3755173ea4c2.png',
- }
+ },
}, {
'url': 'wistia:5vd7p4bct5',
'md5': 'b9676d24bf30945d97060638fbfe77f0',
@@ -228,7 +228,7 @@ class WistiaIE(WistiaBaseIE):
'description': 'md5:27abc99a758573560be72600ef95cece',
'upload_date': '20210421',
'thumbnail': 'https://embed-ssl.wistia.com/deliveries/6c551820ae950cdee2306d6cbe9ef742.jpg',
- }
+ },
}, {
'url': 'https://study.com/academy/lesson/north-american-exploration-failed-colonies-of-spain-france-england.html#lesson',
'md5': 'b9676d24bf30945d97060638fbfe77f0',
@@ -254,19 +254,19 @@ class WistiaIE(WistiaBaseIE):
urls = list(super()._extract_embed_urls(url, webpage))
for match in cls._extract_wistia_async_embed(webpage):
if match.group('type') != 'wistia_channel':
- urls.append('wistia:%s' % match.group('id'))
+ urls.append('wistia:{}'.format(match.group('id')))
for match in re.finditer(r'(?:data-wistia-?id=["\']|Wistia\.embed\(["\']|id=["\']wistia_)(?P<id>[a-z0-9]{10})',
webpage):
- urls.append('wistia:%s' % match.group('id'))
+ urls.append('wistia:{}'.format(match.group('id')))
if not WistiaChannelIE._extract_embed_urls(url, webpage): # Fallback
media_id = cls._extract_url_media_id(url)
if media_id:
- urls.append('wistia:%s' % match.group('id'))
+ urls.append('wistia:{}'.format(match.group('id')))
return urls
class WistiaPlaylistIE(WistiaBaseIE):
- _VALID_URL = r'%splaylists/%s' % (WistiaBaseIE._VALID_URL_BASE, WistiaBaseIE._VALID_ID_REGEX)
+ _VALID_URL = rf'{WistiaBaseIE._VALID_URL_BASE}playlists/{WistiaBaseIE._VALID_ID_REGEX}'
_TEST = {
'url': 'https://fast.wistia.net/embed/playlists/aodt9etokc',
@@ -291,7 +291,7 @@ class WistiaPlaylistIE(WistiaBaseIE):
class WistiaChannelIE(WistiaBaseIE):
- _VALID_URL = r'(?:wistiachannel:|%schannel/)%s' % (WistiaBaseIE._VALID_URL_BASE, WistiaBaseIE._VALID_ID_REGEX)
+ _VALID_URL = rf'(?:wistiachannel:|{WistiaBaseIE._VALID_URL_BASE}channel/){WistiaBaseIE._VALID_ID_REGEX}'
_TESTS = [{
# JSON Embed API returns 403, should fall back to webpage
@@ -299,7 +299,7 @@ class WistiaChannelIE(WistiaBaseIE):
'info_dict': {
'id': 'yvyvu7wjbg',
'title': 'Copysmith Tutorials and Education!',
- 'description': 'Learn all things Copysmith via short and informative videos!'
+ 'description': 'Learn all things Copysmith via short and informative videos!',
},
'playlist_mincount': 7,
'expected_warnings': ['falling back to webpage'],
@@ -370,7 +370,7 @@ class WistiaChannelIE(WistiaBaseIE):
self.report_warning('Failed to download channel data from API, falling back to webpage.')
webpage = self._download_webpage(f'https://fast.wistia.net/embed/channel/{channel_id}', channel_id)
data = self._parse_json(
- self._search_regex(r'wchanneljsonp-%s\'\]\s*=[^\"]*\"([A-Za-z0-9=/]*)' % channel_id, webpage, 'jsonp', channel_id),
+ self._search_regex(rf'wchanneljsonp-{channel_id}\'\]\s*=[^\"]*\"([A-Za-z0-9=/]*)', webpage, 'jsonp', channel_id),
channel_id, transform_source=lambda x: urllib.parse.unquote_plus(base64.b64decode(x).decode('utf-8')))
# XXX: can there be more than one series?