Forked from geuis/gist:8b1b2ea57d7f9a9ae22f80d4fbf5b97f
Created
June 1, 2018 07:47
-
-
Save amitkhare/892ba2bbc7ce7d88d507cec8c4d7d82a to your computer and use it in GitHub Desktop.
Get Youtube video urls
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Run from the dev tools console of any Youtube video | |
// Accurate as of June 23, 2017. | |
// ES6 version | |
const videoUrls = ytplayer.config.args.adaptive_fmts | |
.split(',') | |
.map(item => item | |
.split('&') | |
.reduce((prev, curr) => (curr = curr.split('='), | |
Object.assign(prev, {[curr[0]]: decodeURIComponent(curr[1])}) | |
), {}) | |
) | |
.reduce((prev, curr) => Object.assign(prev, { | |
[curr.quality_label || curr.type]: curr | |
}), {}); | |
console.log(videoUrls); | |
// ES5 version | |
var videoUrls = ytplayer.config.args.adaptive_fmts | |
.split(',') | |
.map(function (item) { | |
return item | |
.split('&') | |
.reduce(function (prev, curr) { | |
curr = curr.split('='); | |
return Object.assign(prev, {[curr[0]]: decodeURIComponent(curr[1])}) | |
}, {}); | |
}) | |
.reduce(function (prev, curr) { | |
return Object.assign(prev, { | |
[curr.quality_label || curr.type]: curr | |
}); | |
}, {}); | |
console.log(videoUrls); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment