mirror of
https://github.com/bytedream/stream-bypass.git
synced 2025-06-27 10:30:31 +02:00
use packer for upstream
This commit is contained in:
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@ -225,6 +225,7 @@ class Kwik implements Match {
|
||||
async match(match: RegExpMatchArray): Promise<string> {
|
||||
let unpacked = unPack(match[0])
|
||||
let url = unpacked.match(/(?<=source=').*(?=')/)[0]
|
||||
console.log(url)
|
||||
return url
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
export const unPack = (packed: String): any => {
|
||||
// Adapted from http://matthewfl.com/unPacker.html by matthew@matthewfl.com
|
||||
|
||||
|
||||
(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 = {
|
||||
let context = `
|
||||
{
|
||||
eval: function (c) {
|
||||
code = c;
|
||||
packed = c;
|
||||
},
|
||||
window: {},
|
||||
document: {}
|
||||
};
|
||||
}
|
||||
`
|
||||
|
||||
eval("with(env) {" + code + "}");
|
||||
eval(`with(${context}) { ` + packed + '}')
|
||||
|
||||
code = (code+"").replace(/;/g, ";\n").replace(/{/g, "\n{\n").replace(/}/g, "\n}\n").replace(/\n;\n/g, ";\n").replace(/\n\\n/g, "\n");
|
||||
packed = (packed+"").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);
|
||||
return packed
|
||||
}
|
||||
|
@ -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()
|
||||
|
Reference in New Issue
Block a user