// 本代码仅用于个人学习,请勿用于其他作用,下载后请24小时内删除,代码虽然是公开学习的,但请尊重作者,应留下说明 // 获取一级数据 function getYiData(jkdata) { let fllists; let vodlists; let error = {}; let api_name = jkdata.name || ""; let api_type = jkdata.type || ""; let api_url = jkdata.url || ""; let api_ua = jkdata.ua || "MOBILE_UA"; api_ua = api_ua == "MOBILE_UA" ? MOBILE_UA : api_ua == "PC_UA" ? PC_UA : api_ua; let headers = { 'User-Agent': api_ua }; let vodurlhead, classurl, listurl, listnode, extdata; //分类变量 let fold = getMyVar('SrcJu_dianbo$fold', "0");//是否展开小分类筛选 let cate_id = getMyVar('SrcJu_dianbo$分类', ''); let type_id = ''; let fl = storage0.getMyVar('SrcJu_dianbo$flCache') || {}; //基础链接拼接 if (api_type == "v1") { let date = new Date(); let mm = date.getMonth() + 1; let dd = date.getDate(); let key = (mm < 10 ? "0" + mm : mm) + "" + (dd < 10 ? "0" + dd : dd); vodurlhead = api_url + '/detail?&key=' + key + '&vod_id='; classurl = api_url + "/types"; listurl = api_url + '?key=' + key + '&page='; listnode = "json.data.list"; } else if (api_type == "app") { vodurlhead = api_url + 'video_detail?id='; classurl = api_url + "nav"; listurl = api_url + 'video?tid=@type_id&pg='; listnode = "json.list"; } else if (api_type == "v2") { vodurlhead = api_url + 'video_detail?id='; classurl = api_url + "nav"; listurl = api_url + 'video?tid=@type_id&pg='; listnode = "json.data"; } else if (api_type == "iptv") { vodurlhead = api_url + '?ac=detail&ids='; classurl = api_url + "?ac=flitter"; listurl = api_url + '?ac=list&page='; listnode = "json.data"; } else if (api_type == "cms") { api_url = api_url.replace('?ac=list',''); vodurlhead = api_url + '?ac=videolist&ids='; classurl = api_url + "?ac=list"; listurl = api_url + '?ac=videolist&pg='; listnode = "json.list"; } else if (/XBPQ|XPath|XYQ/.test(api_type)) { extdata = extDataCache(jkdata) if ($.type(extdata) == 'object') { if (api_type == "XBPQ") { let host = extdata["主页url"] || ''; classurl = extdata["分类"]; extdata["分类url"] = extdata["分类url"] ? extdata["分类url"].split(';;')[0].split('[')[0] : ""; listurl = extdata["分类url"] ? /^http/.test(extdata["分类url"]) ? extdata["分类url"] : host + extdata["分类url"] : ""; } else if (api_type == "XPath") { let host = extdata["homeUrl"] || ''; classurl = host; extdata["cateUrl"] = extdata["cateUrl"] ? extdata["cateUrl"].split(';;')[0].split('[')[0] : ""; listurl = extdata["cateUrl"] ? /^http/.test(extdata["cateUrl"]) ? extdata["cateUrl"] : host + extdata["cateUrl"] : ""; } else if (api_type == "XYQ") { if (extdata["请求头参数"]) { if (extdata["请求头参数"].includes('#') || extdata["请求头参数"].includes('$')) { extdata["请求头参数"].split('#').forEach(v => { headers[v.split('$')[0]] = v.split('$')[1]; }) } else { headers["User-Agent"] = extdata["请求头参数"] || headers["User-Agent"]; } } headers["User-Agent"] = (headers["User-Agent"] == "电脑" || headers["User-Agent"] == "PC_UA") ? PC_UA : MOBILE_UA; let host = extdata["首页推荐链接"] || ''; classurl = host; extdata["分类链接"] = extdata["分类链接"] ? extdata["分类链接"].split(';;')[0].split('[')[0] : ""; listurl = extdata["分类链接"] ? /^http/.test(extdata["分类链接"]) ? extdata["分类链接"] : host + extdata["分类链接"] : ""; } vodurlhead = getHome(listurl); } } else { log(api_type + '>api类型错误'); } //一级第1页生成分类数据 if (MY_PAGE == 1) { if (classurl) { MY_URL = classurl; let 推荐 = []; let 分类 = []; let 筛选; let cate_exclude = ['主页', '求片/留言']; const Color = "#3399cc"; let classCache = storage0.getMyVar('SrcJu_dianbo$classCache'); if (classCache) { 推荐 = classCache.推荐; 分类 = classCache.分类; 筛选 = classCache.筛选; } else { try { if (api_type == "XYQ") { if (extdata['是否开启获取首页数据'] && extdata['首页列表数组规则']) { let gethtml = getHtml(classurl, headers); let 首页列表数组 = pdfa(gethtml, extdata['首页列表数组规则']); 首页列表数组.forEach(it => { pdfa(it, extdata['首页片单列表数组规则']).forEach(v => { if (extdata['首页片单是否Jsoup写法'] == "1") { let vodid = pd(v, extdata['首页片单链接'] || extdata['分类片单链接'], vodurlhead); let vodname = pdfh(v, extdata['首页片单标题'] || extdata['分类片单标题']); let vodpic = pdfh(v, extdata['首页片单图片'] || extdata['分类片单图片']); let voddesc = pdfh(v, extdata['首页片单副标题'] || extdata['分类片单副标题']); if (vodid && vodname) { 推荐.push({ "vod_url": vodid, "vod_name": vodname, "vod_desc": voddesc, "vod_pic": vodpic }); } } }) }) } let typenames = extdata['分类名称'] ? extdata['分类名称'].split('&') : []; let typeids = extdata['分类名称替换词'] ? extdata['分类名称替换词'].split('&') : []; for (let i in typeids) { if (cate_exclude.indexOf(typenames[i]) == -1) { 分类.push(typenames[i] + '$' + typeids[i]); } } if ($.type(extdata['筛选数据']) == "string" && extdata['筛选数据'] == "ext") { let 筛选循环 = ["子分类", "类型", "地区", "年份", "语言", "排序"]; let 筛选循环id = ["cateId", "class", "area", "year", "lang", "by"]; 筛选循环.forEach((it, id) => { if (extdata['筛选' + it + '名称'] && extdata['筛选' + it + '替换词']) { extdata['筛选' + it + '替换词'] = extdata['筛选' + it + '替换词'] == "*" ? extdata['筛选' + it + '名称'] : extdata['筛选' + it + '替换词']; let catenames = extdata['筛选' + it + '名称'].split('||'); let cateids = extdata['筛选' + it + '替换词'].split('||'); if (it == "排序") { for (let i = 0; i < typeids.length; i++) { catenames = catenames.concat(catenames); cateids = cateids.concat(cateids); } } cateids.forEach((x, i) => { let value = []; let names = catenames[i].split('&'); let ids = cateids[i].split('&'); for (let j in names) { value.push({ n: names[j], v: ids[j] }); } if (value.length > 0) { if (it != "排序") { value.unshift({ n: "全部", v: "" }); } 筛选 = 筛选 || {}; 筛选[typeids[i]] = 筛选[typeids[i]] || []; 筛选[typeids[i]].push({ "key": 筛选循环id[id], "name": it, "value": value }); } }) } }) } } else if (api_type == "XPath") { let gethtml = getHtml(classurl, headers); let typenames = xpathArray(gethtml, extdata['cateNode'] + extdata['cateName']); let typeids = xpathArray(gethtml, extdata['cateNode'] + extdata['cateId']); if (extdata['cateIdR']) { typeids = typeids.map(x => { return x.match(extdata['cateIdR'])[1]; }) } for (let i in typeids) { if (cate_exclude.indexOf(typenames[i]) == -1) { 分类.push(typenames[i] + '$' + typeids[i]); } } } else if (api_type == "XBPQ") { if (extdata["分类"].indexOf('$') > -1) { 分类 = extdata["分类"].split('#'); } else if (extdata["分类"].indexOf('&') > -1 && extdata["分类值"]) { let typenames = extdata["分类"].split('&'); let typeids = extdata["分类值"].split('&'); for (let i in typeids) { if (cate_exclude.indexOf(typenames[i]) == -1) { 分类.push(typenames[i] + '$' + typeids[i]); } } } 筛选 = extdata["筛选"]; } else { let gethtml = getHtml(classurl, headers); if (api_type == "v1") { let typehtml = JSON.parse(gethtml); let typelist = typehtml.data.list || typehtml.data.typelist; typelist.map((it) => { 分类.push(it.type_name + '$' + it.type_id); }) } else if (/app|v2/.test(api_type)) { let typehtml = JSON.parse(gethtml); let typelist = typehtml.list || typehtml.data; typelist.forEach(it => { 分类.push(it.type_name + '$' + it.type_id); }) if(api_type=="app"){ try{ let gettjhtml = getHtml(jkdata.url+'index_video?token=', headers); let tjlist = JSON.parse(gettjhtml).list; tjlist.forEach(it=>{ it.vlist.forEach(v=>{ 推荐.push({ "vod_url": vodurlhead + v.vod_id, "vod_name": v.vod_name, "vod_desc": v.vod_remarks, "vod_pic": v.vod_pic }); }) }) }catch(e){} } } else if (api_type == "iptv") { let type_dict = { comic: '动漫', movie: '电影', tvplay: '电视剧', tvshow: '综艺', movie_4k: '4k', hanguoju: '韩剧', oumeiju: '欧美剧', tiyu: '体育' }; let typelist = JSON.parse(gethtml); typelist.forEach((it) => { if (type_dict[it]) { 分类.push(type_dict[it] + '$' + it); } }) } else if (api_type == "cms") { if (/<\?xml/.test(gethtml)) { let typelist = pdfa(gethtml, 'class&&ty'); if (jkdata.categories) { for (var i = 0; i < typelist.length; i++) { if (jkdata.categories.indexOf(String(xpath(typelist[i], `//ty/text()`)).trim()) == -1) { typelist.splice(i, 1); i = i - 1; } } } typelist.forEach((it) => { 分类.push(String(xpath(it, `//ty/text()`)).trim() + '$' + String(xpath(it, `//ty/@id`)).trim()); }) } else { let typehtml = dealJson(gethtml); let typelist = typehtml["class"] || []; if (jkdata.categories) { for (var i = 0; i < typelist.length; i++) { if (jkdata.categories.indexOf(typelist[i].type_name) == -1 && typelist[i].type_pid!=0) { typelist.splice(i, 1); i = i - 1; } } } typelist.forEach((it) => { if(it.type_name && it.type_id){ if(!it.type_pid){ 分类.push(it.type_name + '$' + it.type_id); }else if (it.type_pid==0) { let value = []; typelist.forEach((itit) => { if (itit.type_pid == it.type_id) { value.push({ n: itit.type_name, v: itit.type_id }); } }) if (value.length > 0) { 筛选 = 筛选 || {}; 筛选[it.type_id] = [{ "key": "cateId", "name": it.type_name, "value": value }]; } } } }) } } } } catch (e) { error.fl = 1; log(api_name + '>获取分类数据异常>' + e.message + " 错误行#" + e.lineNumber); } if (分类.length > 0) { storage0.putMyVar('SrcJu_dianbo$classCache', { 分类: 分类, 筛选: 筛选, 推荐: 推荐 }); } } if (分类.length > 0) { fllists = []; try { cate_id = getMyVar('SrcJu_dianbo$分类', 推荐.length > 0 ? 'tj' : 分类[0].split('$')[1]); if (筛选 && api_type != 'cms' && cate_id != 'tj') { fllists.push({ title: fold === '1' ? '““””∨' : '““””∧', url: $('#noLoading#').lazyRule((fold) => { putMyVar('SrcJu_dianbo$fold', fold === '1' ? '0' : '1'); clearMyVar('SrcJu_dianbo$flCache'); refreshPage(false); return "hiker://empty"; }, fold), col_type: 'scroll_button', }) } putMyVar('SrcJu_dianbo$分类', cate_id); if (推荐.length > 0) { if (cate_id == 'tj') { vodlists = 推荐;//当前分类为推荐,取推荐列表 } fllists.push({ title: cate_id == 'tj' ? '““””' + '推荐' + '' : '推荐', url: $('#noLoading#').lazyRule(() => { putMyVar('SrcJu_dianbo$分类', 'tj'); refreshPage(true); return "hiker://empty"; }), col_type: 'scroll_button' }); } 分类.forEach((it, i) => { let itname = it.split('$')[0]; let itid = it.split('$')[1]; fllists.push({ title: cate_id == itid ? '““””' + itname + '' : itname, url: $('#noLoading#').lazyRule((itid) => { putMyVar('SrcJu_dianbo$分类', itid); clearMyVar('SrcJu_dianbo$flCache'); refreshPage(true); return "hiker://empty"; }, itid), col_type: 'scroll_button' }); }) fllists.push({ col_type: "blank_block" }); if (筛选 && (fold == '1' || api_type == 'cms')) { Object.entries(筛选).forEach(([key, value]) => { //console.log(`Key: ${key}, Value: ${value}`); if (key == cate_id) { value.forEach(it => { if (it.value.length > 0) { fl[it.key] = fl[it.key] || it.value[0].v; it.value.forEach((itit) => { fllists.push({ title: fl[it.key] == itit.v ? '““””' + itit.n + '' : itit.n, url: $('#noLoading#').lazyRule((flkey, itid) => { let fl = storage0.getMyVar('SrcJu_dianbo$flCache') || {}; fl[flkey] = itid; storage0.putMyVar('SrcJu_dianbo$flCache', fl); refreshPage(true); return "hiker://empty"; }, it.key, itit.v), col_type: 'scroll_button' }); }) fllists.push({ col_type: "blank_block" }); } }) } }); } storage0.putMyVar('SrcJu_dianbo$flCache', fl); } catch (e) { error.fl = 1; log(api_name + '>生成分类数据异常>' + e.message + " 错误行#" + e.lineNumber); } } } } if (listurl && cate_id!="tj" && !error.fl) { try { fl.cateId = fl.cateId || cate_id; //拼接生成分类页url链接 if (api_type == "XYQ") { fl.catePg = MY_PAGE; let execStrs = getExecStrs(listurl); execStrs.forEach(k => { if (!fl[k]) { listurl = listurl.replace('/' + k + '/{' + k + '}', ''); } }) listurl = listurl.replace('{catePg}', MY_PAGE).replace(/{/g, '${fl.').replace(/}/g, ' || ""}'); eval(`listurl = \`${listurl}\`;`); MY_URL = listurl; } else if (api_type == "XPath") { fl.catePg = MY_PAGE; let execStrs = getExecStrs(listurl); execStrs.forEach(k => { if (!fl[k]) { listurl = listurl.replace('/' + k + '/{' + k + '}', ''); } }) listurl = listurl.replace('{catePg}', MY_PAGE).replace(/{/g, '${fl.').replace(/}/g, ' || ""}'); eval(`listurl = \`${listurl}\`;`); MY_URL = listurl; } else if (api_type == "XBPQ") { fl.catePg = MY_PAGE; let execStrs = getExecStrs(listurl); execStrs.forEach(k => { if (!fl[k]) { listurl = listurl.replace('/' + k + '/{' + k + '}', ''); } }) listurl = listurl.replace('{catePg}', extdata["起始页"] ? MY_PAGE > extdata["起始页"] ? MY_PAGE : extdata["起始页"] : MY_PAGE).replace(/{/g, '${fl.').replace(/}/g, ' || ""}'); eval(`listurl = \`${listurl}\`;`); MY_URL = listurl; } else { MY_URL = listurl + MY_PAGE; type_id = fl.cateId || ""; if (api_type == "v2" || api_type == "app") { MY_URL = MY_URL.replace('@type_id', type_id); } else if (api_type == "v1") { MY_URL = MY_URL + '&type=' + type_id; } else if (api_type == "iptv") { MY_URL = MY_URL + '&class=' + type_id; } else { MY_URL = MY_URL + '&t=' + type_id; } } vodlists = []; let vod_name, vod_pic, vod_url, vod_desc; if (api_type == "XYQ") { let gethtml = getHtml(MY_URL, headers); if (extdata['分类片单是否Jsoup写法'] == "1" && extdata['分类列表数组规则']) { pdfa(gethtml, extdata['分类列表数组规则']).forEach(it => { let vodname = pdfh(it, extdata['分类片单标题']); let vodid = pd(it, extdata['分类片单链接'], vodurlhead); let vodimg = pdfh(it, extdata['分类片单图片']); let voddesc = pdfh(it, extdata['分类片单副标题']); if (vodname && vodid) { let arr = { "vod_url": vodid, "vod_name": vodname, "vod_desc": voddesc, "vod_pic": vodimg }; vodlists.push(arr); } }) } } else if (api_type == "XPath") { let gethtml = getHtml(MY_URL, headers); let vodnames = xpathArray(gethtml, extdata["homeVodNode"] + extdata["homeVodName"]); let vodids = xpathArray(gethtml, extdata["homeVodNode"] + extdata["homeVodId"]); let vodimgs = xpathArray(gethtml, extdata["homeVodNode"] + extdata["homeVodImg"]); let vodmarks = xpathArray(gethtml, extdata["homeVodNode"] + extdata["homeVodMark"]); for (let i in vodids) { if (vodids[i] && vodnames[i]) { let arr = { "vod_url": vodurlhead + vodids[i], "vod_name": vodnames[i], "vod_desc": vodmarks[i], "vod_pic": vodimgs[i] }; vodlists.push(arr); } } } else if (api_type == "XBPQ") { let gethtml = getHtml(MY_URL, headers); extdata["二次截取"] = extdata["二次截取"] || (gethtml.indexOf(`