T
T
tendkuh2019-05-24 10:14:21
YouTube
tendkuh, 2019-05-24 10:14:21

Is it possible to download YouTube videos using DevTools?

How can I download YouTube videos using DevTools in Chrome or Firefox?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Sokolov, 2019-05-24
@tendkuh

There is such a "secret" link: www.youtube.com/get_video_info?video_id=XXXXXX
Instead XXXXXX, substitute the hash of the video, which is in the link to the video, such as youtu.be/BWCiWZtrWXUafter the slash.
This (first) link will return URL-encoded data. Unpack them and take the parameter url_encoded_fmt_stream_map. Its value again needs to be unpacked as URL parameters. And extract the parameter from the result url- this is a link to a single downloadable video file.
For example, in the browser console:

function getUrlParams(search) {
    let hashes = search.slice(search.indexOf('?') + 1).split('&')
    let params = {}
    hashes.map(hash => {
        let [key, val] = hash.split('=')
        params[key] = decodeURIComponent(val)
    })

    return params
}
var s = '------'; // здесь длиннющая строка из ответа /get_video_info
var a = getUrlParams(s);
var b = getUrlParams(a.url_encoded_fmt_stream_map);
console.log(b.url); // эту ссылку открываем в браузере - это скачиваемый видеофайл

I really hope that you will delve into this data in more detail, figure out how to get direct links to download files in all formats and sizes that YouTube offers, and write a short material on Habr based on the results, and also publish a gist with working code for the browser console .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question