I have tried searching for my issue but have found no results similar
I have been experimenting around with yt_dlp and tried downloading to the io buffer using {'outtmpl': '-'} but unfortunately I don't know how to extract the stream buffer data from there.
My question is how would I do this in python?
Here is what I came up with
def download_video_to_buffer(url):
buffer = io.BytesIO()
output = StringIO()
ydl_opts = {
'format': 'best',
'quiet': True,
'noplaylist': True,
'outtmpl': buffer
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
os.system("clear")
print(output.read())
but unfortunately I alway get and error like this: AttributeError: '_io.BytesIO' object has no attribute 'replace'
I was expecting the function to return a bytearray of stream data but it didn't happen. My goal is to be able to do this without having to save any file to the filesystem but rather all in memory.`