Last active
March 8, 2021 14:18
-
-
Save Elorucov/71a80bd71f57236c8028f8b3c6579082 to your computer and use it in GitHub Desktop.
Get video links from m.vk.com
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
| var sources = new Array(); | |
| var hlsParams = new Array(); | |
| let videoSources = document.getElementsByTagName("source"); | |
| for (var i = 0; i < videoSources.length; i++) { | |
| let source = videoSources[i]; | |
| if (source.type === "application/vnd.apple.mpegurl") { | |
| let url = new URL(source.src); | |
| let params = decodeURIComponent(url.search); | |
| let arr = params.substr(1).split("&"); | |
| for (var j = 0; j < arr.length; j++) { | |
| let ps = arr[j].split("="); | |
| hlsParams.push({key: ps[0], value: ps[1]}); | |
| } | |
| let tag = ""; | |
| let extra = ""; | |
| for (var k = 0; k < hlsParams.length; k++) { | |
| let hlsp = hlsParams[k]; | |
| let match = hlsp.key.match("\[[0-9]+\]"); | |
| if (match) { | |
| let res = match[0].substring(1, match[0].length - 1); | |
| sources.push({resolution: parseInt(res), url: hlsp.value}); | |
| } | |
| if (hlsp.key == "tag") tag = hlsp.value; | |
| if (hlsp.key == "extra") extra = hlsp.value; | |
| } | |
| for (var l = 0; l < sources.length; l++) { | |
| sources[l].url = sources[l].url + tag + "." + sources[l].resolution + ".mp4?extra=" + extra; | |
| } | |
| break; | |
| } | |
| } | |
| console.log(sources); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment