import { Crypto, load, _ } from './lib/cat.js'; /** * 爱看资源 * author:Leospring * 公众号:蚂蚁科技杂谈 */ var charStr = 'abacdefghjklmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789'; let siteUrl = 'https://ikan6.vip'; let siteKey = ''; let siteType = 0; let COOKIE = 'PHPSESSID=' + randStr(26, true); let headers = { 'User-Agent': 'Mozilla/5.0 (iPad; CPU OS 13_2_3 like Mac OS X) AppleWebKit/537.36 (KHTML, like Gecko) Version/13.0 Mobile/13B14 Safari/537.36', 'Referer': siteUrl + '/', 'Cookie': COOKIE }; async function request(reqUrl, postData, post) { let res = await req(reqUrl, { method: post ? 'post' : 'get', headers: headers, data: postData || {}, postType: post ? '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) { let classes = [{ type_id: '1', type_name: '电影', },{ type_id: '2', type_name: '剧集', },{ type_id: '3', type_name: '综艺', },{ type_id: '4', type_name: '动漫', },{ type_id: '15', type_name: '日韩剧', },{ type_id: '16', type_name: '美剧', },{ type_id: '14', type_name: '港台剧', },{ type_id: '20', type_name: '纪录片', },{ type_id: '25', type_name: '体育赛事', }]; let filterObj = genFilterObj(); return JSON.stringify({ class: classes, filters: filterObj }); } async function homeVod() { let url = siteUrl; const html = await request(url); const $ = load(html); const cards = $('div.public-list-div.public-list-bj > u > a') let videos = _.map(cards, (n) => { let id = $(n).attr('href'); let name = $(n).attr('title'); let pic = $($(n).find('div')[0]).attr('data-original'); let remarks = $($(n).find('span.public-list-prb.hide.ft2')[0]).text().trim(); return { vod_id: id, vod_name: name, vod_pic: pic, vod_remarks: remarks, }; }); return JSON.stringify({ list: videos, }); } async function category(tid, pg, filter, ext) { let url = siteUrl + '/index.php/api/vod'; let nowTime = parseInt(new Date()/1000); if (!pg) pg = 1; if (pg <= 0) pg = 1; let param = { type: tid, pg: pg, time: nowTime, key: Crypto.MD5('DS' + nowTime + 'DCC147D11943AF75').toString().toLowerCase(), }; if(ext['id'] && ext['id'].length > 0) { param['type'] = ext['id']; } if(ext['year'] && ext['year'].length > 0) { param['year'] = ext['year']; } if(ext['area'] && ext['area'].length > 0) { param['area'] = ext['area']; } let d = await request(url, param, true); let res = JSON.parse(d); let videos = []; res['list'].forEach(item => { let pic = item['vod_pic']; if (pic.startsWith('mac')) pic = pic.replaceAll('mac', 'http'); if(!pic.startsWith('http')) pic = siteUrl + '/' + pic; videos.push({ vod_id: '/voddetail/' + item.vod_id, vod_name: item.vod_name, vod_pic: pic, vod_remarks: item.vod_remarks, }); }); return JSON.stringify({ list: videos, page: res.page, limit: res.limit, pagecount: res.pagecount, total: res.total, }); } async function detail(id) { try { const html = await request(siteUrl + id); let $ = load(html); let content = $('#height_limit').text(); let type = _.map($('div.detail-info.rel.flex-auto > div:nth-child(5) > a'), (n) => { return $(n).text(); }).join(' '); let director = _.map($('div.detail-info.rel.flex-auto > div:nth-child(3) > a'), (n) => { return $(n).text(); }).join(' '); let actor = _.map($('div.detail-info.rel.flex-auto > div:nth-child(4) > a'), (n) => { return $(n).text(); }).join(' '); let playFroms = _.map($('u > a.swiper-slide'), (n) => { return $(n).text(); }).join('$$$'); let playUrls = _.map($('div.anthology-list-box.none'), (n) => { return _.map($(n).find('li.box > u > a.hide'), (m) => { return $(m).text() +'$'+$(m).attr('href'); }).join('#'); }).join('$$$'); const video = { vod_play_from: playFroms, vod_play_url: playUrls, vod_content: content, vod_director: director, vod_actor: actor, vod_type: type, }; const list = [video]; const result = { list }; return JSON.stringify(result); } catch (e) { console.log('err', e); } return null; } async function search(wd, quick, pg) { let url = siteUrl + '/vodsearch/-------------/?wd=' + wd; //TODO验证码处理 body > div.box-width > div > div.row-9 > div > div:nth-child(2) const html = await request(url); if (html.indexOf('请输入验证码') >0) { //进行验证码处理 /** * https://akanhd.com/vodsearch/-------------/?wd=xxxx 验证码:https://akanhd.com/verify/index.html?r=random() https://akanhd.com/index.php/ajax/verify_check?type=search&verify=9068 {"code":1002,"msg":"验证码错误"} */ } const $ = load(html); const cards = $('div.search-box.flex.rel') let videos = _.map(cards, (n) => { let id = $($(n).find('div.left > a.public-list-exp')[0]).attr('href'); let name = $($(n).find('div.right > div.thumb-content > div.thumb-txt.cor4.hide')[0]).text(); let pic = $($(n).find('div.left > a.public-list-exp > div')[0]).attr('data-original'); let remarks = $($(n).find('div.left > a.public-list-exp > span.public-list-prb')[0]).text().trim(); return { vod_id: id, vod_name: name, vod_pic: pic, vod_remarks: remarks, }; }); return JSON.stringify({ list: videos, }); } async function play(flag, id, flags) { let playUrl = siteUrl + id; try { const html = await request(playUrl); const $ = load(html); for(const n of $('script')) { if($(n).text().indexOf("var player_data=") >= 0) { let url = unescape(JSON.parse($(n).text().split("var player_data=")[1]).url); //console.log('url', url); if(url.startsWith('http')) { playUrl = url; } else { playUrl = await getRealUrl(url); } return JSON.stringify({ parse: 0, url: playUrl, }); } } } catch (error) { console.log(error); } return JSON.stringify({ parse: 1, url: playUrl, }); } async function getRealUrl(data) { let url = 'https://cms.akanhd.com/ikanbfqmuip/nicaibudaowozainadebfq.php?url=' + data; let html = await request(url); let $ = load(html); let str = $('meta[name="viewport"]').attr('id').replaceAll('now_',''); let idx = $('meta[charset="UTF-8"]').attr('id').replaceAll('now_',''); let enUrl = ''; for(const n of $('script')) { if($(n).text().indexOf("var config = ") >= 0) { let conf = $(n).text().split('var config = ')[1]; enUrl = conf.split('\n')[2].split('"')[3]; } } let d=''; let obj = {}; for(let i=0;i