diff --git a/src/match/matches.ts b/src/match/matches.ts index 38f359f..8689848 100644 --- a/src/match/matches.ts +++ b/src/match/matches.ts @@ -83,7 +83,6 @@ class Mixdrop implements Match { async match(match: RegExpMatchArray): Promise { let unpacked = unPack(match[0]) let url = unpacked.match(/(?<=MDCore.wurl=").*(?=")/)[0] - return `https:${url}` } } @@ -102,7 +101,6 @@ class Mp4Upload implements Match { let unpacked = unPack(match[0]) console.log(unpacked) let url = unpacked.match(/(?<=player.src\(").*(?=")/)[0] - console.log(url) return url } } @@ -160,14 +158,16 @@ class Streamzz implements Match { class Upstream implements Match { name = 'Upstream' id = 'upstream' - reliability = Reliability.NORMAL + reliability = Reliability.HIGH domains = [ 'upstream.to' ] - regex = new RegExp(/(?<=\|)\w{2,}/gms) + regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms) async match(match: RegExpMatchArray): Promise { - return `https://${match[49]}.upstreamcdn.co/hls/${match[148]}/master.m3u8` + let unpacked = unPack(match[0]) + let url = unpacked.match(/(?<=file:").*(?=")/)[0] + return url } } @@ -223,8 +223,9 @@ class Kwik implements Match { regex = new RegExp(/eval\(function\(p,a,c,k,e,d\).*?(?=\<\/script\>)/gms) async match(match: RegExpMatchArray): Promise { - let unpacked = unPack(match[0]) + let unpacked = unPack(match[0]) let url = unpacked.match(/(?<=source=').*(?=')/)[0] + console.log(url) return url } } diff --git a/src/match/unpack.ts b/src/match/unpack.ts index 44f5351..0fbaf36 100644 --- a/src/match/unpack.ts +++ b/src/match/unpack.ts @@ -1,60 +1,19 @@ -export const unPack = (packed: String): String => { - // Use eval() for the unPack script because else the `env` variable will not be in scope when the eval in the script is called - const scriptlet = String.raw` - ////////////////////////////////////////// - // Un pack the code from the /packer/ // - // By matthew@matthewfl.com // - // http://matthewfl.com/unPacker.html // - ////////////////////////////////////////// - // version 1.2 - - - (function (code) { - function indent (code) { - try { - var tabs = 0, old=-1, add=''; - for(var i=0;i 0) { - add += "\t"; - old--; - } - old = tabs; - } - - code[i] = add + code[i]; - } - } finally { - tabs = null; - old = null; - add = null; - } - return code; - } - - var env = { - eval: function (c) { - code = c; - }, - window: {}, - document: {} - }; - - eval("with(env) {" + code + "}"); - - code = (code+"").replace(/;/g, ";\n").replace(/{/g, "\n{\n").replace(/}/g, "\n}\n").replace(/\n;\n/g, ";\n").replace(/\n\\n/g, "\n"); - - code = code.split("\n"); - code = indent(code); - - code = code.join("\n"); - return code; - })(${'String.raw`'}` + packed + String.raw`${'`'})` - - return eval(scriptlet); +export const unPack = (packed: String): any => { + // Adapted from http://matthewfl.com/unPacker.html by matthew@matthewfl.com + + let context = ` + { + eval: function (c) { + packed = c; + }, + window: {}, + document: {} + } + ` + + eval(`with(${context}) { ` + packed + '}') + + packed = (packed+"").replace(/;/g, ";\n").replace(/{/g, "\n{\n").replace(/}/g, "\n}\n").replace(/\n;\n/g, ";\n").replace(/\n\\n/g, "\n"); + + return packed } diff --git a/src/ui/player/player.ts b/src/ui/player/player.ts index a258208..7e43355 100644 --- a/src/ui/player/player.ts +++ b/src/ui/player/player.ts @@ -44,7 +44,7 @@ async function main() { } document.title = `Stream Bypass (${domain})` - new URL(url).pathname.contains('.m3u8') ? await play_hls(url) : await play_native(url) + new URL(url).pathname.endsWith('.m3u8') ? await play_hls(url) : await play_native(url) } main()