Last active
November 17, 2020 10:57
-
-
Save Christopher-CO/8f2c1cf9ffbf309c59aa14239945da03 to your computer and use it in GitHub Desktop.
This file contains 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
// 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