Answer the question
In order to leave comments, you need to log in
How to get a direct link to a YouTube video?
Good day. Tell me how to get a direct link (or how to send a request via cURL) to a YouTube video.
Now I do this, I get meta information like this https://www.youtube.com/get_video_info?video_id=ay... with the help of
$data = file_get_contents("https://www.youtube.com/get_video_info?video_id=айди_видео");
{"playabilityStatus":{"status":"UNPLAYABLE","reason":"Это видео недоступно.","errorScreen":{"playerErrorMessageRenderer":{"reason":{"simpleText":"Это видео недоступно."},"proceedButton":{"buttonRenderer":{"style":"STYLE_PRIMARY","size":"SIZE_DEFAULT","isDisabled":false,"text":{"simpleText":"Посмотреть на YouTube"},"trackingParams":"CAQQ8FsiEwjU34jNju_oAhWNdbIKHSxYDQA="}},"thumbnail":{"thumbnails":[{"url":"//s.ytimg.com/yts/img/meh7-vflGevej7.png","width":140,"height":100}]},"icon":{"iconType":"ERROR_OUTLINE"}}},"contextParams":"Q0FFU0FnZ0M="},"videoDetails"
Answer the question
In order to leave comments, you need to log in
As you were answered in the comments in a simple way, you will not be able to download a video file from YouTube. YouTube is simply not profitable and it prevents this in every possible way.
There is an arms race going on here: Google comes up with countermeasures, and enthusiasts come up with workarounds.
By asking the question, it was not clear what you really need and what kind of direct link to the video you needed to get.
If we are talking about downloading videos from YouTube, then there is a wonderful Python utility youtube-dl .
It is convenient to use it with the help of docker: https://hub.docker.com/r/wernight/youtube-dl
This eliminates problems with updates and dependencies.
I use it to download stuff from youtube for "watch later" before it gets deleted.
On a cheap VDS, a bot is running that listens to YouTube URLs from me, and replies with links to download the file when it uploads it itself. Convenient. I will not share the bot yet.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question