S
S
Slanty2019-10-06 13:59:38
YouTube
Slanty, 2019-10-06 13:59:38

How to download a video from a direct link?

I'm trying to download videos from YouTube, for downloading I use the site https://220youtube.com
To download videos through this site, you can use the following link:
https://220youtube.com/video
identifier ? downloaded all videos
There is a code:

import requests #импортируем модуль
url_vidos = input("Enter the Youtube-url\n") # получаем ссылку на видео
f=open(r'file.mp4',"wb") #открываем файл для записи, в режиме wb
ufr = requests.get('https://220youtube.com/'+str(url_vidos[:7])+'?x=22') #делаем запрос
f.write(ufr.content) #записываем содержимое в файл
f.close()

For some reason, not the entire video is downloaded, but only a small part

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Andrey Dugin, 2019-10-06
@Slanty

Because YouTube is how video storage and transmission is organized. And you have to download fragments and then combine them into a whole video. You can get started with the theory, for example, with these articles: MPEG-DASH and HLS .

A
Alexey Cheremisin, 2019-10-06
@leahch

And it all depends on the video format. It can be in hls format, then the video itself is initially broken into small pieces. Then you need to download an index file in m8u format, where all video clips are listed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question