all repos — FixYouTube-legacy @ 8e6cea5cba756c2a1d1ca5cdea41395ea4b5acbc

A better way to embed YouTube videos everywhere (inspired by FixTweet).

bugfix
Marco Andronaco andronacomarco@gmail.com
Mon, 21 Aug 2023 22:15:39 +0200
commit

8e6cea5cba756c2a1d1ca5cdea41395ea4b5acbc

parent

d7855fbe2c2ad5d51358e6e79b985f2b27989e7f

1 files changed, 4 insertions(+), 2 deletions(-)

jump to
M fxyoutube/yt_info.pyfxyoutube/yt_info.py

@@ -14,18 +14,20 @@ return None # video-only

if format["url"].endswith(".m3u8"): return None # HLS stream + try: if format["filesize"] > c.MAX_SIZE_BYTES: return None # too large except TypeError: - return None + if format["filesize_approx"] > c.MAX_SIZE_BYTES: + return None return format def get_info_ytdl(yt_id: str): info = ydl.extract_info(c.BASE_URL + yt_id, download=False) formats = map(handle_format, info["formats"]) - formats = filter(lambda x: x is not None, formats) + formats = list(filter(lambda x: x is not None, formats)) try: max_format = max(formats, key=lambda x:x["quality"]) except ValueError: