mirror of
https://github.com/qist/tvbox.git
synced 2025-10-27 18:22:47 +00:00
update FM
This commit is contained in:
@@ -1,13 +1,12 @@
|
||||
// 自动从 地址发布页 获取&跳转url地址
|
||||
import { Crypto, load, _ } from './lib/cat.js';
|
||||
|
||||
let key = 'czzy';
|
||||
let host = 'https://www.czzy.site'; // 厂长地址发布页
|
||||
// let url = 'https://cz01.cc';
|
||||
let url = '';
|
||||
let url = 'https://cz01.cc';
|
||||
let siteKey = '';
|
||||
let siteType = 0;
|
||||
|
||||
const UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
|
||||
|
||||
const cookie = {};
|
||||
|
||||
async function request(reqUrl, referer, mth, data, hd) {
|
||||
@@ -49,15 +48,13 @@ async function request(reqUrl, referer, mth, data, hd) {
|
||||
async function init(cfg) {
|
||||
siteKey = cfg.skey;
|
||||
siteType = cfg.stype;
|
||||
let html = await request(host);
|
||||
url = html.match(/推荐访问<a href="(.*)"/)[1];
|
||||
console.debug('厂长跳转地址 =====>' + url); // js_debug.log
|
||||
}
|
||||
|
||||
async function home(filter) {
|
||||
let filterObj = {};
|
||||
const html = await request(url + '/movie_bt');
|
||||
const $ = load(html);
|
||||
const series = $('div#beautiful-taxonomy-filters-tax-movie_bt_series > a[cat-url*=movie_bt_series]');
|
||||
const tags = $('div#beautiful-taxonomy-filters-tax-movie_bt_tags > a');
|
||||
let tag = {
|
||||
key: 'tag',
|
||||
@@ -69,7 +66,6 @@ async function home(filter) {
|
||||
}),
|
||||
};
|
||||
tag['init'] = tag.value[0].v;
|
||||
const series = $('div#beautiful-taxonomy-filters-tax-movie_bt_series > a[cat-url*=movie_bt_series]');
|
||||
let classes = _.map(series, (s) => {
|
||||
let typeId = s.attribs['cat-url'];
|
||||
typeId = typeId.substring(typeId.lastIndexOf('/') + 1);
|
||||
@@ -137,6 +133,7 @@ async function detail(id) {
|
||||
const detail = $('ul.moviedteail_list > li');
|
||||
let vod = {
|
||||
vod_id: id,
|
||||
vod_name: $('div.moviedteail_tt > h1').text().trim(),
|
||||
vod_pic: $('div.dyimg img:first').attr('src'),
|
||||
vod_remarks: '',
|
||||
vod_content: stripHtmlTag($('div.yp_context').html()).trim(),
|
||||
|
||||
@@ -12,7 +12,6 @@ async function request(reqUrl, agentSp) {
|
||||
method: 'get',
|
||||
headers: {
|
||||
'User-Agent': agentSp || UA,
|
||||
'referer': url
|
||||
},
|
||||
});
|
||||
return res.content;
|
||||
@@ -55,22 +54,7 @@ async function home(filter) {
|
||||
}
|
||||
|
||||
async function homeVod() {
|
||||
const html = await request(url);
|
||||
const $ = load(html);
|
||||
const items = $('div.v-list a.item');
|
||||
var jsBase = await js2Proxy(true, siteType, siteKey, 'img/', {});
|
||||
let videos = _.map(items, (item) => {
|
||||
const img = $(item).find('img:first')[0];
|
||||
return {
|
||||
vod_id: item.attribs.href,
|
||||
vod_name: img.attribs.alt,
|
||||
vod_pic: jsBase + base64Encode(img.attribs['data-src']),
|
||||
vod_remarks: '',
|
||||
};
|
||||
});
|
||||
return JSON.stringify({
|
||||
list: videos,
|
||||
});
|
||||
return '{}';
|
||||
}
|
||||
|
||||
async function category(tid, pg, filter, extend) {
|
||||
@@ -101,85 +85,50 @@ async function category(tid, pg, filter, extend) {
|
||||
}
|
||||
|
||||
async function detail(id) {
|
||||
const html = await request(url + id);
|
||||
const $ = load(html);
|
||||
var jsBase = await js2Proxy(true, siteType, siteKey, 'img/', {});
|
||||
const detail = $('div.detail');
|
||||
const remarks = $('span#line-tips').text();
|
||||
let vod = {
|
||||
vod_id: id,
|
||||
vod_pic: jsBase + base64Encode($('div.item-root > img')[0].attribs['data-src']),
|
||||
vod_remarks: '',
|
||||
vod_content: remarks || '',
|
||||
vod_name: $(detail).find('h2').text().trim(),
|
||||
vod_year: $(detail).find('h3:nth-child(3)').text(),
|
||||
vod_area: $(detail).find('h3:nth-child(4)').text(),
|
||||
vod_actor: $(detail).find('h3:nth-child(5)').text(),
|
||||
};
|
||||
const res = await req(url + '/api/getResN?videoId=' + id.substring(id.lastIndexOf('/') + 1) + '&mtype=2', {
|
||||
headers: {
|
||||
Referer: 'play',
|
||||
'User-Agent': UA,
|
||||
},
|
||||
});
|
||||
const list = JSON.parse(res.content).data.list;
|
||||
let playlist = {};
|
||||
let arr = []
|
||||
for (const l of list) {
|
||||
const flagData = JSON.parse(l.resData);
|
||||
for (const f of flagData) {
|
||||
const from = f.flag;
|
||||
const urls = f.url;
|
||||
if (!from || !urls) continue;
|
||||
if (playlist[from]) continue;
|
||||
playlist[from] = urls;
|
||||
}
|
||||
}
|
||||
for (var key in playlist) {
|
||||
if ('kuaikan' == key) {
|
||||
arr.push({
|
||||
flag: '快看',
|
||||
url: playlist[key],
|
||||
sort: 1
|
||||
})
|
||||
} else if ('bfzym3u8' == key) {
|
||||
arr.push({
|
||||
flag: '暴风',
|
||||
url: playlist[key],
|
||||
sort: 2
|
||||
})
|
||||
} else if ('ffm3u8' == key) {
|
||||
arr.push({
|
||||
flag: '非凡',
|
||||
url: playlist[key],
|
||||
sort: 3
|
||||
})
|
||||
} else if ('lzm3u8' == key) {
|
||||
arr.push({
|
||||
flag: '量子',
|
||||
url: playlist[key],
|
||||
sort: 4
|
||||
})
|
||||
} else {
|
||||
arr.push({
|
||||
flag: key,
|
||||
url: playlist[key],
|
||||
sort: 5
|
||||
})
|
||||
}
|
||||
}
|
||||
arr.sort((a, b) => a.sort - b.sort);
|
||||
let playFrom = [];
|
||||
let playList = [];
|
||||
arr.map(val => {
|
||||
playFrom.push(val.flag);
|
||||
playList.push(val.url);
|
||||
})
|
||||
vod.vod_play_from = playFrom.join("$$$");
|
||||
vod.vod_play_url = playList.join("$$$");
|
||||
return JSON.stringify({
|
||||
list: [vod],
|
||||
});
|
||||
const html = await request(url + id);
|
||||
const $ = load(html);
|
||||
var jsBase = await js2Proxy(true, siteType, siteKey, 'img/', {});
|
||||
const detail = $('div.detail > .meta');
|
||||
let vod = {
|
||||
vod_id: id,
|
||||
vod_pic: jsBase + base64Encode($('div.item-root > img')[0].attribs['data-src']),
|
||||
vod_remarks: '',
|
||||
};
|
||||
for (const info of detail) {
|
||||
if ($(info).hasClass('title')) {
|
||||
vod.vod_name = info.children[0].data;
|
||||
} else if ($(info).hasClass('year')) {
|
||||
vod.vod_area = info.children[0].data;
|
||||
} else if ($(info).hasClass('country')) {
|
||||
vod.vod_area = info.children[0].data;
|
||||
} else if ($(info).hasClass('celebrity')) {
|
||||
vod.vod_actor = info.children[0].data;
|
||||
}
|
||||
}
|
||||
|
||||
const res = await req(url + '/api/getResN?videoId=' + id.substring(id.lastIndexOf('/') + 1) + '&mtype=2', {
|
||||
headers: {
|
||||
Referer: url,
|
||||
'User-Agent': UA,
|
||||
},
|
||||
});
|
||||
const list = JSON.parse(res.content).data.list;
|
||||
let playlist = {};
|
||||
for (const l of list) {
|
||||
const flagData = JSON.parse(l.resData);
|
||||
for (const f of flagData) {
|
||||
const from = f.flag;
|
||||
const urls = f.url;
|
||||
if (!from || !urls) continue;
|
||||
if (playlist[from]) continue;
|
||||
playlist[from] = urls;
|
||||
}
|
||||
}
|
||||
vod.vod_play_from = _.keys(playlist).join('$$$');
|
||||
vod.vod_play_url = _.values(playlist).join('$$$');
|
||||
return JSON.stringify({
|
||||
list: [vod],
|
||||
});
|
||||
}
|
||||
|
||||
function base64Encode(text) {
|
||||
@@ -221,28 +170,21 @@ async function play(flag, id, flags) {
|
||||
});
|
||||
}
|
||||
|
||||
async function search(wd, quick, pg) {
|
||||
if (pg <= 0 || typeof(pg) == 'undefined') pg = 1;
|
||||
const html = await request(url + '/search?q=' + wd + '&p=' + pg);
|
||||
async function search(wd, quick) {
|
||||
const html = await request(url + '/search?q=' + wd);
|
||||
const $ = load(html);
|
||||
const items = $('div.media');
|
||||
const items = $('div.media > div.media-left > a');
|
||||
var jsBase = await js2Proxy(true, siteType, siteKey, 'img/', {});
|
||||
let videos = _.map(items, (item) => {
|
||||
const a = $(item).find('a:first')[0];
|
||||
const img = $(item).find('img:first')[0];
|
||||
const remarks = $($(item).find('span.label')[0]).text().trim();
|
||||
return {
|
||||
vod_id: a.attribs.href,
|
||||
vod_id: item.attribs.href,
|
||||
vod_name: img.attribs.alt,
|
||||
vod_pic: jsBase + base64Encode(img.attribs['data-src']),
|
||||
vod_remarks: remarks || '',
|
||||
vod_remarks: '',
|
||||
};
|
||||
});
|
||||
const hasMore = $('div.page-more > a:contains(下一页)').length > 0;
|
||||
const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
|
||||
return JSON.stringify({
|
||||
page: parseInt(pg),
|
||||
pagecount: pgCount,
|
||||
list: videos,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user