lundi 7 septembre 2020

Anyway i can download video dirctly from web rather than terminal in python

I have written a script for downloading videos from Facebook, but the problem is that it is downloading videos through terminal which I think will not work when I host this web application on web. Is there any way I can download videos from browser directly?

file_size_request = requests.get(video_url, allow_redirects=True, stream=True)
    print(file_size_request.headers)
    file_size = int(file_size_request.headers['Content-Length'])
    block_size = 1024
    filename = datetime.strftime(datetime.now(), '%Y-%m-%d-%H-%M-%S')
    t = tqdm(
        total=file_size, unit='B', unit_scale=True, desc=filename, ascii=True
        )
    with open(filename + '.mp4', 'wb') as f:
        for data in file_size_request.iter_content(block_size):
            t.update(len(data))
            f.write(data)
    t.close()



Aucun commentaire:

Enregistrer un commentaire