Skip to content

Instantly share code, notes, and snippets.

@joshbtn
Last active November 5, 2019 04:26
Show Gist options
  • Save joshbtn/dbd043c7634c7812ce526bf37b1c1938 to your computer and use it in GitHub Desktop.
Save joshbtn/dbd043c7634c7812ce526bf37b1c1938 to your computer and use it in GitHub Desktop.
quick check of yt compatible formats
//type and url dictionary
ytplayer.config.args.adaptive_fmts
.split(',')
.map((format) => format.split('&'))
.reduce((a, cv) => {
a[decodeURIComponent(cv[0].split("=")[1])] = decodeURIComponent(cv[1].split("=")[1]);
return a;
}, {})
// All props as arrays
ytplayer.config.args.adaptive_fmts
.split(',')
.map((format) => format
.split('&')
.map((prop) => prop.split("="))
.reduce((agr, cv) => {
cv.every((e, i, a) => {
agr[decodeURIComponent(e)] = decodeURIComponent(a[1])
});
return agr;
}, {}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment