import { Crypto, load, _ } from './lib/cat.js'; //代理地址 let siteUrl = 'https://gh.7761.cf/https://zz123.com'; let imgUrl = 'https://music.jsbaidu.com'; let siteKey = ''; let siteType = 0; let headers = {}; async function request(reqUrl, postData, agentSp, get) { let res = await req(reqUrl, { method: get ? 'get' : 'post', headers: headers, data: postData || {}, postType: get ? '' : 'form', }); let content = res.content; return content; } async function init(cfg) { siteKey = cfg.skey; siteType = cfg.stype; if (cfg.ext) { siteUrl = cfg.ext; } } async function home(filter) { const html = await request(siteUrl); const $ = load(html); const cates = $('ul.aside-menu-list.channel > li') let classes = _.map(cates, (n) => { let id = n.attribs['data-id']; let name = $($(n).find('a > span')[0]).text(); return { type_id: id, type_name: name }; }); return JSON.stringify({ class: classes }); } async function homeVod() { const html = await request(siteUrl); const $ = load(html); const cards = $('div.page-main-wrap > div > div > div.card-list.d-none.d-md-block > div'); let videos = _.map(cards, (n) => { let id = n.attribs['data-id']; let name = $($(n).find('div.item-info > div > div.songname.text-ellipsis.color-link-content-primary > a')[0]).text(); let pic = $($(n).find('div.item-cover-wrap > a > img')[0]).attr('data-src').replace('/img', imgUrl); let remark = $($(n).find('div.item-cover-wrap > div.item-time')[0]).text(); return { vod_id: id, vod_name: name, vod_pic: pic, vod_remarks: remark }; }); return JSON.stringify({ list: videos }); } async function category(tid, pg, filter, extend) { if (pg <= 0) pg = 1; let url = siteUrl + '/ajax/'; let res = await req(url, { method: 'post', data: { act: 'tag_music', type: 'tuijian', tid: tid, page: pg, lang: '' }, postType: 'form' }); //console.log('catedata:', res); let data = JSON.parse(res.content).data; let videos = []; for(let i=0;i div.card-list.d-none.d-md-block > div') let videos = _.map(cards, (n) => { let id = n.attribs['data-id']; let name = $($(n).find('div.item-info > div > div.songname.text-ellipsis.color-link-content-primary > a')[0]).text(); let pic = $($(n).find('div.item-cover-wrap > a > img')[0]).attr('data-src').replace('/img', imgUrl); let remark = $($(n).find('div.item-cover-wrap > div.item-time')[0]).text(); return { vod_id: id, vod_name: name, vod_pic: pic, vod_remarks: remark, }; }); return JSON.stringify({ list: videos, }); } export function __jsEvalReturn() { return { init: init, home: home, homeVod: homeVod, category: category, detail: detail, play: play, search: search, }; }