S
S
Studentka19962021-08-18 00:19:53
Python
Studentka1996, 2021-08-18 00:19:53

How to download videos from the Internet correctly?

from requests import get
print('Скачиваю видео..')
video_data = get(one_file).content
print(video_data)
if os._exists(os.path.abspath(f'Foto/{num}.mp4')) == False:
    with open(f'Foto/{num}.mp4', 'wb') as handler:
         handler.write(video_data)


The same code downloads the image correctly.

I don't understand what's wrong. The video does not play, the error is "The file cannot be played. The format of this file may not be supported, the file extension is incorrect, or the file is damaged.". Downloading from YouTube, which supports the mp4 format.. Please help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrew, 2021-08-18
@Studentka1996

For downloading from youtube, there is youtube-dl, you can call it through subprocess and use it as a library.
Usage examples are easy to google.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question