use packer for upstream

This commit is contained in:
sdaqo
2023-04-09 07:44:21 +02:00
parent 544adfa7b2
commit 0d4f22bcf7
3 changed files with 26 additions and 66 deletions

View File

@ -83,7 +83,6 @@ class Mixdrop implements Match {
async match(match: RegExpMatchArray): Promise<string> {
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<string> {
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<string> {
let unpacked = unPack(match[0])
let unpacked = unPack(match[0])
let url = unpacked.match(/(?<=source=').*(?=')/)[0]
console.log(url)
return url
}
}

View File

@ -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<code.length;i++) {
if(code[i].indexOf("{") != -1) tabs++;
if(code[i].indexOf("}") != -1) tabs--;
if(old != tabs) {
old = tabs;
add = "";
while (old > 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
}

View File

@ -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()