Skip to content

Instantly share code, notes, and snippets.

@tennisonchan
Created November 5, 2016 02:45
Show Gist options
  • Save tennisonchan/13472ab83a170809e499b593208bd32d to your computer and use it in GitHub Desktop.
Save tennisonchan/13472ab83a170809e499b593208bd32d to your computer and use it in GitHub Desktop.
get youtube video stream url in different qualities and formats
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