Created
November 5, 2016 02:45
-
-
Save tennisonchan/13472ab83a170809e499b593208bd32d to your computer and use it in GitHub Desktop.
get youtube video stream url in different qualities and formats
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
let videoUrls = ytplayer.config.args.url_encoded_fmt_stream_map | |
.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 + ':' + curr.type.split(';')[0]]: curr | |
}), {}); | |
console.log(videoUrls); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment