mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-30 22:25:19 +00:00 
			
		
		
		
	| @@ -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: | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Zenon Mousmoulas
					Zenon Mousmoulas