Skip to content

Instantly share code, notes, and snippets.

@Christopher-CO
Last active November 17, 2020 10:57
Show Gist options
  • Save Christopher-CO/8f2c1cf9ffbf309c59aa14239945da03 to your computer and use it in GitHub Desktop.
Save Christopher-CO/8f2c1cf9ffbf309c59aa14239945da03 to your computer and use it in GitHub Desktop.
// To test this, copy and past into the dev console of Google Chorme.
// credit:
// https://gist.github.com/geuis/8b1b2ea57d7f9a9ae22f80d4fbf5b97f#gistcomment-3436392
(async () => {
html = await fetch(window.location.href).then(resp => resp.text()).then(text => text);
startStr = 'ytplayer.config = {';
start = html.indexOf(startStr) + startStr.length - 1;
end = html.indexOf('};', start) + 1;
playerObj = JSON.parse(html.slice(start, end));
playerObj.args.player_response = JSON.parse(playerObj.args.player_response);
videoUrls = playerObj.args.player_response.streamingData.formats[1].url;
videoUrls = videoUrls.replace('"', 'r');
return console.log(videoUrls);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment