1
0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2025-10-04 19:44:33 -04:00

[ant1newsgr] Add extractor (#1982)

Authored by: zmousm
This commit is contained in:
Zenon Mousmoulas
2022-03-04 23:52:48 +02:00
committed by GitHub
parent 50e93e03a7
commit 27231526ae
6 changed files with 181 additions and 19 deletions

View File

@@ -5271,6 +5271,28 @@ def join_nonempty(*values, delim='-', from_dict=None):
return delim.join(map(str, filter(None, values)))
def scale_thumbnails_to_max_format_width(formats, thumbnails, url_width_re):
"""
Find the largest format dimensions in terms of video width and, for each thumbnail:
* Modify the URL: Match the width with the provided regex and replace with the former width
* Update dimensions
This function is useful with video services that scale the provided thumbnails on demand
"""
_keys = ('width', 'height')
max_dimensions = max(
[tuple(format.get(k) or 0 for k in _keys) for format in formats],
default=(0, 0))
if not max_dimensions[0]:
return thumbnails
return [
merge_dicts(
{'url': re.sub(url_width_re, str(max_dimensions[0]), thumbnail['url'])},
dict(zip(_keys, max_dimensions)), thumbnail)
for thumbnail in thumbnails
]
def parse_http_range(range):
""" Parse value of "Range" or "Content-Range" HTTP header into tuple. """
if not range: