summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/whowatch.py
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/extractor/whowatch.py')
-rw-r--r--yt_dlp/extractor/whowatch.py21
1 files changed, 10 insertions, 11 deletions
diff --git a/yt_dlp/extractor/whowatch.py b/yt_dlp/extractor/whowatch.py
index 492891d..9ca5c3b 100644
--- a/yt_dlp/extractor/whowatch.py
+++ b/yt_dlp/extractor/whowatch.py
@@ -1,5 +1,4 @@
from .common import InfoExtractor
-from ..compat import compat_str
from ..utils import (
ExtractorError,
int_or_none,
@@ -21,8 +20,8 @@ class WhoWatchIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
self._download_webpage(url, video_id)
- metadata = self._download_json('https://api.whowatch.tv/lives/%s' % video_id, video_id)
- live_data = self._download_json('https://api.whowatch.tv/lives/%s/play' % video_id, video_id)
+ metadata = self._download_json(f'https://api.whowatch.tv/lives/{video_id}', video_id)
+ live_data = self._download_json(f'https://api.whowatch.tv/lives/{video_id}/play', video_id)
title = try_call(
lambda: live_data['share_info']['live_title'][1:-1],
@@ -37,7 +36,7 @@ class WhoWatchIE(InfoExtractor):
formats = []
for i, fmt in enumerate(live_data.get('streams') or []):
- name = fmt.get('quality') or fmt.get('name') or compat_str(i)
+ name = fmt.get('quality') or fmt.get('name') or str(i)
hls_url = fmt.get('hls_url')
rtmp_url = fmt.get('rtmp_url')
audio_only = fmt.get('audio_only')
@@ -45,7 +44,7 @@ class WhoWatchIE(InfoExtractor):
if hls_url:
hls_fmts = self._extract_m3u8_formats(
- hls_url, video_id, ext='mp4', m3u8_id='hls-%s' % name, quality=quality)
+ hls_url, video_id, ext='mp4', m3u8_id=f'hls-{name}', quality=quality)
formats.extend(hls_fmts)
else:
hls_fmts = []
@@ -54,7 +53,7 @@ class WhoWatchIE(InfoExtractor):
if rtmp_url and not audio_only:
formats.append({
'url': rtmp_url,
- 'format_id': 'rtmp-%s' % name,
+ 'format_id': f'rtmp-{name}',
'ext': 'mp4',
'protocol': 'rtmp_ffmpeg', # ffmpeg can, while rtmpdump can't
'vcodec': 'h264',
@@ -71,12 +70,12 @@ class WhoWatchIE(InfoExtractor):
hls_url, video_id, ext='mp4', m3u8_id='hls'))
self._remove_duplicate_formats(formats)
- uploader_url = try_get(metadata, lambda x: x['live']['user']['user_path'], compat_str)
+ uploader_url = try_get(metadata, lambda x: x['live']['user']['user_path'], str)
if uploader_url:
- uploader_url = 'https://whowatch.tv/profile/%s' % uploader_url
- uploader_id = compat_str(try_get(metadata, lambda x: x['live']['user']['id'], int))
- uploader = try_get(metadata, lambda x: x['live']['user']['name'], compat_str)
- thumbnail = try_get(metadata, lambda x: x['live']['latest_thumbnail_url'], compat_str)
+ uploader_url = f'https://whowatch.tv/profile/{uploader_url}'
+ uploader_id = str(try_get(metadata, lambda x: x['live']['user']['id'], int))
+ uploader = try_get(metadata, lambda x: x['live']['user']['name'], str)
+ thumbnail = try_get(metadata, lambda x: x['live']['latest_thumbnail_url'], str)
timestamp = int_or_none(try_get(metadata, lambda x: x['live']['started_at'], int), scale=1000)
view_count = try_get(metadata, lambda x: x['live']['total_view_count'], int)
comment_count = try_get(metadata, lambda x: x['live']['comment_count'], int)