update HQ

This commit is contained in:
qist
2024-03-06 16:19:01 +08:00
parent cc37a7611e
commit 6b2cffb95f
122 changed files with 6252 additions and 2900 deletions
+53 -20
View File
@@ -5,7 +5,7 @@ import { initAli, detailContent, playContent } from './lib/ali.js';
let siteKey = 'pansearch';
let siteType = 0;
let siteUrl = 'https://www.pansearch.me';
let patternAli = /(https:\/\/www\.aliyundrive\.com\/s\/[^"]+)/
let patternAli = /(https:\/\/www\.(aliyundrive|alipan)\.com\/s\/[^"]+)/
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';
@@ -66,37 +66,70 @@ async function play(flag, id, flags) {
async function search(wd, quick, pg) {
if (pg <= 0) pg = 1;
const limit = 10;
let offsetParam = '';
const offset = (pg - 1) * limit;
if (offset > 0) {
offsetParam = '&offset=' + offset;
}
const html = await request(siteUrl);
const $ = load(html);
const script = $('script#__NEXT_DATA__')[0];
const data = script.children[0].data;
const buildId = JSON.parse(data).buildId;
const url = siteUrl + "/_next/data/" + buildId + "/search.json?keyword=" + encodeURIComponent(wd) + "&pan=aliyundrive";
const url = siteUrl + "/_next/data/" + buildId + "/search.json?keyword=" + encodeURIComponent(wd) + offsetParam + "&pan=aliyundrive";
const result = await requestRaw(url, getSearchHeader());
const array = JSON.parse(result.content).pageProps.data.data;
const json = JSON.parse(result.content).pageProps.data;
const total = json.total;
const videoIdSet = new Set();
const videos = _.map(array, (item) => {
const videos = [];
for (const item of json.data) {
const content = item.content;
const $ = load(content);
const split = content.split('\n');
if (split.length == 0) return undefined;
const vodId = $('a').attr('href');
if (videoIdSet.has(vodId)) return undefined;
videoIdSet.add(vodId);
const img = item.image || "https://inews.gtimg.com/newsapp_bt/0/13263837859/1000"
const name = split[0].replaceAll(/<\/?[^>]+>/g, "").replace('名称:', '');
return {
vod_id: vodId,
vod_name: name,
vod_pic: img,
vod_remarks: item.time
};
});
const img = item.image || siteUrl + "/favicon.png";
const splits = content.split('\n');
if (_.isEmpty(splits)) continue;
if (content.includes('1、')) {
for (const line of splits) {
if (_.isEmpty(line)) continue;
const vodId = parseVideo(line, videoIdSet);
if (!vodId) continue;
videos.push({
vod_id: vodId,
vod_name: line.replaceAll(/<\/?[^>]+>/g, "").replace(/[0-9]*、/g, '').replace(/:http.*/g, ''),
vod_pic: img,
vod_remarks: item.time
});
}
} else {
const vodId = parseVideo(content, videoIdSet);
if (!vodId) continue;
videos.push({
vod_id: vodId,
vod_name: splits[0].replaceAll(/<\/?[^>]+>/g, "").replace('名称:', ''),
vod_pic: img,
vod_remarks: item.time
});
}
}
const pgCount = parseInt(total / limit) + 1;
return JSON.stringify({
list: videos.filter(item => item !== undefined),
page: parseInt(pg),
pagecount: pgCount,
limit: limit,
total: total,
list: videos,
});
}
function parseVideo(content, videoIdSet) {
const matches = content.match(patternAli);
if (_.isEmpty(matches)) return;
const vodId = matches[1];
if (videoIdSet.has(vodId)) return;
videoIdSet.add(vodId);
return vodId;
}
function getSearchHeader() {
return {
"x-nextjs-data": "1",