summaryrefslogtreecommitdiffstats
path: root/yt_dlp/extractor/yahoo.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:06:11 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-08-05 09:06:11 +0000
commitfd5a06560caab95c71a2e2e805efa8d0f3a696a0 (patch)
treee1c600b8612bc4b301e2f51b875fcd835c5008cc /yt_dlp/extractor/yahoo.py
parentReleasing progress-linux version 2024.05.27-1~progress7.99u1. (diff)
downloadyt-dlp-fd5a06560caab95c71a2e2e805efa8d0f3a696a0.tar.xz
yt-dlp-fd5a06560caab95c71a2e2e805efa8d0f3a696a0.zip
Merging upstream version 2024.07.01.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'yt_dlp/extractor/yahoo.py')
-rw-r--r--yt_dlp/extractor/yahoo.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/yt_dlp/extractor/yahoo.py b/yt_dlp/extractor/yahoo.py
index 24148a0..35e7120 100644
--- a/yt_dlp/extractor/yahoo.py
+++ b/yt_dlp/extractor/yahoo.py
@@ -8,6 +8,7 @@ from ..utils import (
ExtractorError,
clean_html,
int_or_none,
+ join_nonempty,
mimetype2ext,
parse_iso8601,
traverse_obj,
@@ -70,7 +71,7 @@ class YahooIE(InfoExtractor):
'duration': 128,
'timestamp': 1385722202,
'upload_date': '20131129',
- }
+ },
}, {
'url': 'https://www.yahoo.com/movies/v/true-story-trailer-173000497.html',
'md5': '2a9752f74cb898af5d1083ea9f661b58',
@@ -177,7 +178,7 @@ class YahooIE(InfoExtractor):
def _extract_yahoo_video(self, video_id, country):
video = self._download_json(
- 'https://%s.yahoo.com/_td/api/resource/VideoService.videos;view=full;video_ids=["%s"]' % (country, video_id),
+ f'https://{country}.yahoo.com/_td/api/resource/VideoService.videos;view=full;video_ids=["{video_id}"]',
video_id, 'Downloading video JSON metadata')[0]
title = video['title']
@@ -193,7 +194,7 @@ class YahooIE(InfoExtractor):
for fmt in fmts:
media_obj = self._download_json(
'https://video-api.yql.yahoo.com/v1/video/sapi/streams/' + video_id,
- video_id, 'Downloading %s JSON metadata' % fmt,
+ video_id, f'Downloading {fmt} JSON metadata',
headers=self.geo_verification_headers(), query={
'format': fmt,
'region': country.upper(),
@@ -213,7 +214,7 @@ class YahooIE(InfoExtractor):
tbr = int_or_none(s.get('bitrate'))
formats.append({
'url': s_url,
- 'format_id': fmt + ('-%d' % tbr if tbr else ''),
+ 'format_id': join_nonempty(fmt, tbr),
'width': int_or_none(s.get('width')),
'height': int_or_none(s.get('height')),
'tbr': tbr,
@@ -277,9 +278,9 @@ class YahooIE(InfoExtractor):
country = country.split('-')[0]
items = self._download_json(
- 'https://%s.yahoo.com/caas/content/article' % country, display_id,
+ f'https://{country}.yahoo.com/caas/content/article', display_id,
'Downloading content JSON metadata', query={
- 'url': url
+ 'url': url,
})['items'][0]
item = items['data']['partnerData']
@@ -327,7 +328,7 @@ class YahooSearchIE(SearchInfoExtractor):
def _search_results(self, query):
for pagenum in itertools.count(0):
- result_url = 'http://video.search.yahoo.com/search/?p=%s&fr=screen&o=js&gs=0&b=%d' % (urllib.parse.quote_plus(query), pagenum * 30)
+ result_url = f'http://video.search.yahoo.com/search/?p={urllib.parse.quote_plus(query)}&fr=screen&o=js&gs=0&b={pagenum * 30}'
info = self._download_json(result_url, query,
note='Downloading results page ' + str(pagenum + 1))
yield from (self.url_result(result['rurl']) for result in info['results'])
@@ -354,7 +355,7 @@ class YahooJapanNewsIE(InfoExtractor):
},
}, {
'url': 'https://news.yahoo.co.jp/feature/1356',
- 'only_matching': True
+ 'only_matching': True,
}]
def _extract_formats(self, json_data, content_id):
@@ -371,12 +372,13 @@ class YahooJapanNewsIE(InfoExtractor):
url, content_id, 'mp4', 'm3u8_native',
m3u8_id='hls', fatal=False))
else:
+ bitrate = int_or_none(vid.get('bitrate'))
formats.append({
'url': url,
- 'format_id': f'http-{vid.get("bitrate")}',
+ 'format_id': join_nonempty('http', bitrate),
'height': int_or_none(vid.get('height')),
'width': int_or_none(vid.get('width')),
- 'tbr': int_or_none(vid.get('bitrate')),
+ 'tbr': bitrate,
})
self._remove_duplicate_formats(formats)