import tempfile import yt_dlp def download_social(url): output = tempfile.NamedTemporaryFile( delete=False, suffix=".mp4" ).name ydl_opts = { "outtmpl": output, "format": "mp4", "quiet": True } with yt_dlp.YoutubeDL(ydl_opts) as ydl: ydl.download([url]) return output