Add files via upload

This commit is contained in:
n3rddd 2023-07-29 19:31:09 +08:00 committed by GitHub
parent e083dfa331
commit 56b1c9352c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 758 additions and 705 deletions

View File

@ -259,6 +259,10 @@ async function play(flag, id, flags) {
var result = jsonParse(id, JSON.parse(res).data);
if (result.url) {
result.parse = 0;
// demo of block hls ads
if (/vip\.lz|hd\.lz/.test(result.url)) {
result.url = await js2Proxy(true, siteType, siteKey, 'lzm3u8/' + base64Encode(result.url), {});
}
return JSON.stringify(result);
}
return JSON.stringify({
@ -275,6 +279,41 @@ async function play(flag, id, flags) {
}
}
async function proxy(segments, headers) {
let what = segments[0];
let url = base64Decode(segments[1]);
if (what == 'lzm3u8') {
const resp = await req(url, {});
let hls = resp.content;
const jsBase = await js2Proxy(false, siteType, siteKey, 'lzm3u8/', {});
const baseUrl = url.substr(0, url.lastIndexOf('/') + 1);
console.log(hls.length);
hls = hls.replace(/#EXT-X-DISCONTINUITY\r*\n*#EXTINF:6.433333,[\s\S]*?#EXT-X-DISCONTINUITY/, '');
console.log(hls.length);
hls = hls.replace(/(#EXT-X-KEY\S+URI=")(\S+)("\S+)/g, function (match, p1, p2, p3) {
let up = (!p2.startsWith('http') ? baseUrl : '') + p2;
return p1 + up + p3;
});
hls = hls.replace(/(#EXT-X-STREAM-INF:.*\n)(.*)/g, function (match, p1, p2) {
let up = (!p2.startsWith('http') ? baseUrl : '') + p2;
return p1 + jsBase + base64Encode(up);
});
hls = hls.replace(/(#EXTINF:.*\n)(.*)/g, function (match, p1, p2) {
let up = (!p2.startsWith('http') ? baseUrl : '') + p2;
return p1 + up;
});
return JSON.stringify({
code: resp.code,
content: hls,
headers: resp.headers,
});
}
return JSON.stringify({
code: 500,
content: '',
});
}
async function search(wd, quick) {
let data = JSON.parse(await request(url + '/api.php/Search/getSearch', { key: wd, type_id: 0, p: 1 })).data;
let videos = [];
@ -291,6 +330,14 @@ async function search(wd, quick) {
});
}
function base64Encode(text) {
return Crypto.enc.Base64.stringify(Crypto.enc.Utf8.parse(text));
}
function base64Decode(text) {
return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
}
const charStr = 'abacdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789';
function randStr(len, withNum) {
var _str = '';
@ -359,6 +406,7 @@ export function __jsEvalReturn() {
category: category,
detail: detail,
play: play,
proxy: proxy,
search: search,
};
}

View File

@ -70,6 +70,7 @@ async function init(cfg) {
device.ua = 'Dalvik/2.1.0 (Linux; U; Android ' + device.release + '; ' + device.model + ' Build/' + device.buildId + ')';
await local.set(key, deviceKey, JSON.stringify(device));
}
await request(url + '/api.php/provide/getDomain');
await request(url + '/api.php/provide/config');
await request(url + '/api.php/provide/checkUpgrade');
@ -255,10 +256,12 @@ async function play(flag, id, flags) {
}
}
async function search(wd, quick) {
let data = JSON.parse(await request(url + '/api.php/provide/searchVideo?searchName=' + wd + '&pg=1', 'okhttp/3.12.0')).data;
async function search(wd, quick, pg) {
let page = pg || 1;
if (page == 0) page = 1;
let data = JSON.parse(await request(url + '/api.php/provide/searchVideo?searchName=' + wd + '&pg=' + page, 'okhttp/3.12.0'));
let videos = [];
for (const vod of data) {
for (const vod of data.data) {
videos.push({
vod_id: vod.id,
vod_name: vod.videoName,
@ -267,6 +270,8 @@ async function search(wd, quick) {
});
}
return JSON.stringify({
page: page,
pagecount: data.pages,
list: videos,
});
}