Created
May 4, 2020 10:15
-
-
Save KhunHtetzNaing/8102638f84281097dd32c0aba09bac5d to your computer and use it in GitHub Desktop.
Get all video + audio from facebook dash
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
if (document.body.textContent) { | |
get_all_video(); | |
get_audio(); | |
} | |
function parseURL(url) { | |
if (url == null) { | |
return null; | |
} | |
return url.replace(/amp;/g, ''); | |
} | |
function get_audio() { | |
var regex = /\/>\\x3CBaseURL>(.*?)\\x3C/gm, | |
str = document.body.textContent, | |
m; | |
if ((m = regex.exec(str)) !== null) { | |
return parseURL(m[1]); | |
} | |
return null; | |
} | |
function get_all_video() { | |
var regex = /FBQualityClass=\\"(.*?)\\" ?FBQualityLabel=\\"(.*?)\\">\\x3CBaseURL>(.*?)\\x3C/gm, | |
str = document.body.textContent, | |
m; | |
while ((m = regex.exec(str)) !== null) { | |
// This is necessary to avoid infinite loops with zero-width matches | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} | |
var group = m[1], | |
quality = m[2], | |
url = parseURL(m[3]); | |
console.log(group, quality, url); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment