I am attempting to use the code in this stackoverflow answer to download an MP4 (the second solution with 422 upvotes).
An MP4 file downloads but VLC refuses to open it. I'm getting the following error on VLC:
VLC is unable to open the MRL 'file://path'. Check the log for details. Your input can't be opened.
I tried the accepted answer on the stackoverflow page and it worked, so I don't think it's an issue with permissions. To be clear, I am trying to figure out why this solution doesn't work. I don't care about the other solutions. I read thru the comments under the naswer to no avail.
My Code:
import requests
import shutil
def download_file(url):
local_filename = url.split('/')[-1]
with requests.get(url, stream=True) as r:
with open(local_filename, 'wb') as f:
shutil.copyfileobj(r.raw, f)
return local_filename
url = 'https://www.learningcontainer.com/wp-content/uploads/2020/05/sample-mp4-file.mp4'
download_file(url)