From 3ae936e2ba9570c9a3830210ea3cbee9c051ab80 Mon Sep 17 00:00:00 2001 From: hjdhnx Date: Thu, 29 Sep 2022 11:20:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0drpy=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- base/custom.conf | 2 +- ...\350\257\225\347\233\270\345\205\263.bash" | 5 + "txt/muban/drpy\346\250\241\346\235\277.js" | 281 ++++++++++++++---- 3 files changed, 222 insertions(+), 66 deletions(-) create mode 100644 "txt/muban/adb\350\260\203\350\257\225\347\233\270\345\205\263.bash" diff --git a/base/custom.conf b/base/custom.conf index b426a6d..814f2b6 100644 --- a/base/custom.conf +++ b/base/custom.conf @@ -20,7 +20,7 @@ "filterable":0 }, # 缓存js - +{"key":"drpy_zbk","name":"真不卡(drpy)","type":3,"api":"js_drpy_zbk","searchable":1,"quickSearch":1,"filterable":1,"ext":"{{host}}/txt/muban/drpy模板.js"}, {"key": "dr_MXONE", "name": "MXONE(道长)", "type": 1, "api": "{{host}}/vod?rule=MXONE&ext=txt/js/tg/MXONE.js", "searchable": 2, "quickSearch": 0, "filterable": 0}, {"key": "dr_Nike影视", "name": "Nike影视(道长)", "type": 1, "api": "{{host}}/vod?rule=Nike影视&ext=txt/js/tg/Nike影视.js", "searchable": 2, "quickSearch": 0, "filterable": 0}, {"key": "dr_TV云播", "name": "TV云播(道长)", "type": 1, "api": "{{host}}/vod?rule=TV云播&ext=txt/js/tg/TV云播.js", "searchable": 2, "quickSearch": 0, "filterable": 0}, diff --git "a/txt/muban/adb\350\260\203\350\257\225\347\233\270\345\205\263.bash" "b/txt/muban/adb\350\260\203\350\257\225\347\233\270\345\205\263.bash" new file mode 100644 index 0000000..77af87d --- /dev/null +++ "b/txt/muban/adb\350\260\203\350\257\225\347\233\270\345\205\263.bash" @@ -0,0 +1,5 @@ +# 需要cmder +adb connect 192.168.10.192 +adb devices -l +adb logcat -c +adb logcat | grep -i QuickJS \ No newline at end of file diff --git "a/txt/muban/drpy\346\250\241\346\235\277.js" "b/txt/muban/drpy\346\250\241\346\235\277.js" index 9fb25f5..1f4be5b 100644 --- "a/txt/muban/drpy\346\250\241\346\235\277.js" +++ "b/txt/muban/drpy\346\250\241\346\235\277.js" @@ -3,7 +3,10 @@ // var rule =Object.assign(模板.首图2,{ // host: 'https://www.zbkk.net', // }); -var rule = { + +const key = 'drpy_zbk'; + +let rule = { title: '真不卡', host: 'https://www.zbkk.net', url: '/vodshow/fyclass--------fypage---.html', @@ -15,17 +18,34 @@ var rule = { // lazy:'', class_parse: 'body&&.stui-header__menu .dropdown li:gt(0):lt(5);a&&Text;a&&href;.*/(.*?).html', 一级: 'body&&.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href', - 推荐:'ul.stui-vodlist.clearfix;li;a&&title;.lazyload&&data-original;.pic-text&&Text;a&&href', - 二级:{"title":".stui-content__detail .title&&Text;.stui-content__detail p:eq(-2)&&Text","img":".stui-content__thumb .lazyload&&data-original","desc":".stui-content__detail p:eq(0)&&Text;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text","content":".detail&&Text","tabs":".stui-vodlist__head h3","lists":".stui-content__playlist:eq(#id) li"}, + 推荐:'body&&ul.stui-vodlist.clearfix;body&&li;a&&title;.lazyload&&data-original;.pic-text&&Text;a&&href', + 二级:{"title":".stui-content__detail .title&&Text;.stui-content__detail p:eq(-2)&&Text","img":".stui-content__thumb .lazyload&&data-original","desc":".stui-content__detail p:eq(0)&&Text;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text","content":".detail&&Text","tabs":"body&&h3.title","lists":".stui-content__playlist,#id&&li"}, double:true, // 推荐内容是否双层定位 //搜索:'ul.stui-vodlist__media:eq(0) li,ul.stui-vodlist:eq(0) li,#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text', - 搜索:'body&&ul.stui-vodlist__media:eq(0) li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text', + 搜索:'body&&ul.stui-vodlist__media&&li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text', // cate_exclude: '首页|留言|APP|下载|资讯|新闻|动态', // tab_exclude: '猜你|喜欢|APP|下载|剧情', } -/****上面才是pluto的drpy源,支持import外部模板来继承修改***/ +/****上面才是pluto的drpy源,支持import外部模板来继承修改 + * 已知问题记录: + * 1.pdfa没法正确获取非body开头的直接定位列表,比如 推荐 body&&ul.stui-vodlist.clearfix 和 ul.stui-vodlist.clearfix 获取出来的列表不一样,建议自动补body + * 2.pd函数有问题,没法正确的urljoin来源链接,比如分类页获取到数据href为/zbkdetail/63174.html应该自动与rule.url拼接后才返回给二级完整链接 + * .stui-pannel_hd h3 这个pdfa都没法识别? + * pdf 系列不支持eq定位? + * 解析播放问题,parse返回的1怎么下面不出解析选项 ?? 不过可以通免 + * urljoin问题,求求了这个函数很重要,还要pd函数内部需要自动urljoin + * 请求重复问题,调试日志一个console总是打印两次?? + * 筛选功能暂未实现,搜索验证码暂未实现 + * quickjs发生一次崩溃后除非重启软件,否则该源后续操作点击二级都没有数据 + * 电脑看日志调试 + adb connect 192.168.10.192 + adb devices -l + adb logcat -c + adb logcat | grep -i QuickJS + * ***/ + /*** 以下是内置变量和解析方法 **/ @@ -34,65 +54,89 @@ const PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHT const UA = 'Mozilla/5.0'; const UC_UA = 'Mozilla/5.0 (Linux; U; Android 9; zh-CN; MI 9 Build/PKQ1.181121.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.5.5.1035 Mobile Safari/537.36'; const IOS_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 RULE_CK = 'cookie_'+rule.title; // 源cookie +const RULE_CK = 'cookie'; // 源cookie的key值 +const KEY = typeof(key)!=='undefined'&&key?key:'drpy_'+rule.title; // 源的唯一标识 const CATE_EXCLUDE = '首页|留言|APP|下载|资讯|新闻|动态'; const TAB_EXCLUDE = '猜你|喜欢|APP|下载|剧情'; +/** 处理一下 rule规则关键字段没传递的情况 **/ rule.cate_exclude = (rule.cate_exclude||'')+CATE_EXCLUDE; rule.tab_exclude = (rule.tab_exclude||'')+TAB_EXCLUDE; +rule.host = rule.host||''; +rule.url = rule.url||''; +rule.homeUrl = rule.homeUrl||''; +rule.searchUrl = rule.searchUrl||''; /*** 后台需要实现的java方法并注入到js中 ***/ -function verifyCode(url){ // 验证码识别,暂未实现 + +/** + * 验证码识别,暂未实现 + * @param url 验证码图片链接 + * @returns {string} 验证成功后的cookie + */ +function verifyCode(url){ let cookie = ''; return cookie } -function setItem(key,value){ - /** 存在数据库配置表里, key字段对应值value,没有就新增,有就更新,调用此方法会清除内存缓存 - * - */ - +/** + * 存在数据库配置表里, key字段对应值value,没有就新增,有就更新,调用此方法会清除key对应的内存缓存 + * @param k 键 + * @param v 值 + */ +function setItem(k,v){ + local.set(KEY,k,v); } -function getItem(key,value){ - /** 获取数据库配置表对应的key字段的value,没有这个key就返回value默认传参.需要有缓存,第一次获取后会存在内存里 - * - */ - - return value +/** + * 获取数据库配置表对应的key字段的value,没有这个key就返回value默认传参.需要有缓存,第一次获取后会存在内存里 + * @param k 键 + * @param v 值 + * @returns {*} + */ +function getItem(k,v){ + return local.get(KEY,k) || v; } -function clearItem(key){ - /** 删除数据库key对应的一条数据,并清除此key对应的内存缓存 - * - */ - +/** + * 删除数据库key对应的一条数据,并清除此key对应的内存缓存 + * @param k + */ +function clearItem(k){ + local.delete(KEY,k); } +/** + * url拼接(暂未实现) + * @param fromPath 初始当前页面url + * @param nowPath 相对当前页面url + * @returns {*} + */ function urljoin(fromPath, nowPath) { - /** url拼接(暂未实现) - * - */ return fromPath + nowPath } /*** js自封装的方法 ***/ + +/** + * 获取链接的host(带http协议的完整链接) + * @param url 任意一个正常完整的Url,自动提取根 + * @returns {string} + */ function getHome(url){ - /** 获取链接的host - * 带http协议的完整链接 - * @type {*|string[]} - */ let tmp = url.split('//'); url = tmp[0] + '//' + tmp[1].split('/')[0]; return url } +/** + * get参数编译链接,类似python params字典自动拼接 + * @param url 访问链接 + * @param obj 参数字典 + * @returns {*} + */ function buildUrl(url,obj){ - /** get参数编译链接,类似python params字典自动拼接 - * - * @type {{}} - */ obj = obj||{}; if(url.indexOf('?')<0){ url += '?' @@ -110,10 +154,13 @@ function buildUrl(url,obj){ return url } +/** + * 海阔网页请求函数完整封装 + * @param url 请求链接 + * @param obj 请求对象 {headers:{},method:'',timeout:5000,body:'',withHeaders:false} + * @returns {string|string|DocumentFragment|*} + */ function request(url,obj){ - /** 海阔网页请求函数完整封装 - * - */ if(typeof(obj)==='undefined'||!obj||obj==={}){ obj = { headers:{ @@ -127,7 +174,7 @@ function request(url,obj){ if(!keys.includes('user-agent')){ headers['User-Agent'] = MOBILE_UA; }if(!keys.includes('referer')){ - headers['referer'] = getHome(url); + headers['Referer'] = getHome(url); } obj.headers = headers; } @@ -144,7 +191,14 @@ function request(url,obj){ return html } -function checkHtml(html,url,obj){ //检查宝塔验证 +/** + * 检查宝塔验证并自动跳过获取正确源码 + * @param html 之前获取的html + * @param url 之前的来源url + * @param obj 来源obj + * @returns {string|DocumentFragment|*} + */ +function checkHtml(html,url,obj){ if(/\?btwaf=/.test(html)){ let btwaf = html.match(/btwaf(.*?)"/)[1]; url = url.split('#')[0]+'?btwaf'+btwaf; @@ -153,21 +207,24 @@ function checkHtml(html,url,obj){ //检查宝塔验证 return html } +/** + * 带一次宝塔验证的源码获取 + * @param url 请求链接 + * @param obj 请求参数 + * @returns {string|DocumentFragment} + */ function getCode(url,obj){ - /** 带一次宝塔验证的源码获取 - * - * @type {string|DocumentFragment|string} - */ let html = request(url,obj); html = checkHtml(html,url,obj); return html } +/** + * 源rule专用的请求方法,自动注入cookie + * @param url 请求链接 + * @returns {string|DocumentFragment} + */ function getHtml(url){ - /** 源rule专用的请求方法,自动注入cookie - * - * @type {{}} - */ let obj = {}; if(rule.headers){ obj.headers = rule.headers; @@ -184,7 +241,12 @@ function getHtml(url){ return html } -function homeParse(homeObj) {//首页分类解析,筛选暂未实现 +/** + * 首页分类解析,筛选暂未实现 + * @param homeObj 首页传参对象 + * @returns {string} + */ +function homeParse(homeObj) { let classes = []; if (homeObj.class_name && homeObj.class_url) { let names = homeObj.class_name.split('&'); @@ -241,6 +303,11 @@ function homeParse(homeObj) {//首页分类解析,筛选暂未实现 } +/** + * 首页推荐列表解析 + * @param homeVodObj + * @returns {string} + */ function homeVodParse(homeVodObj){ let p = homeVodObj.推荐 ? homeVodObj.推荐.split(';') : []; if (!homeVodObj.double && p.length < 5) { @@ -249,13 +316,19 @@ function homeVodParse(homeVodObj){ return '{}' } let d = []; + console.log(homeVodObj.homeUrl); let html = getHtml(homeVodObj.homeUrl); try { + console.log('double:'+homeVodObj.double); if(homeVodObj.double){ p[0] = p[0].trim().startsWith('json:')?p[0].replace('json:',''):p[0]; + console.log(p[0]); let items = pdfa(html, p[0]); + console.log(items.length); for(let item of items){ + console.log(p[1]); let items2 = pdfa(item,p[1]); + console.log(items2.length); for(let item2 of items2){ try { let title = pdfh(item2, p[2]); @@ -301,7 +374,7 @@ function homeVodParse(homeVodObj){ } let desc = pdfh(item, p[3]); let links = []; - for(let p5 of p4.split('+')){ + for(let p5 of p[4].split('+')){ let link = !homeVodObj.detailUrl?pd(item, p5):pdfh(item, p5); links.push(link); } @@ -324,13 +397,19 @@ function homeVodParse(homeVodObj){ }catch (e) { } + // console.log(JSON.stringify(d)); return JSON.stringify({ list:d }) } -function categoryParse(cateObj) {//一级分类页数据解析 +/** + * 一级分类页数据解析 + * @param cateObj + * @returns {string} + */ +function categoryParse(cateObj) { let p = cateObj.一级 ? cateObj.一级.split(';') : []; if (p.length < 5) { return '{}' @@ -350,6 +429,7 @@ function categoryParse(cateObj) {//一级分类页数据解析 'vod_remarks': pdfh(it, p[3]), }); }); + // console.log(JSON.stringify(d)); return JSON.stringify({ 'page': parseInt(cateObj.pg), 'pagecount': 999, @@ -364,7 +444,12 @@ function categoryParse(cateObj) {//一级分类页数据解析 return '{}' } -function searchParse(searchObj) {//搜索列表数据解析 +/** + * 搜索列表数据解析 + * @param searchObj + * @returns {string} + */ +function searchParse(searchObj) { let p = searchObj.搜索 ? searchObj.搜索.split(';') : []; if (p.length < 5) { return '{}' @@ -377,9 +462,9 @@ function searchParse(searchObj) {//搜索列表数据解析 if (html) { if(/系统安全验证|输入验证码/.test(html)){ let cookie = verifyCode(url); - setItem('cookie_'+rule.title,cookie); - obj.headers['Cookie'] = cookie; - html = getCode(url,obj); + setItem(RULE_CK,cookie); + // obj.headers['Cookie'] = cookie; + html = getHtml(url); } if(!html.includes(searchObj.wd)){ console.log('搜索结果源码未包含关键字,疑似搜索失败,正为您打印结果源码'); @@ -411,6 +496,11 @@ function searchParse(searchObj) {//搜索列表数据解析 return '{}' } +/** + * 二级详情页数据解析 + * @param detailObj + * @returns {string} + */ function detailParse(detailObj){ let vod = { vod_id: "id", @@ -430,6 +520,7 @@ function detailParse(detailObj){ let fyclass = detailObj.fyclass; let tab_exclude = detailObj.tab_exclude; let html = detailObj.html||''; + console.log(url); if(p==='*'){ vod.vod_play_from = '道长在线'; vod.vod_remarks = detailUrl; @@ -479,20 +570,29 @@ function detailParse(detailObj){ if(p.重定向&&p.重定向.startsWith('js:')){ html = eval(p.重定向.replace('js:','')); } + +console.log(2); if(p.tabs){ - let vHeader = pdfa(html, p.tabs.split(';')[0]); - for(let v in vHeader){ + let p_tab = p.tabs.split(';')[0]; + console.log(p_tab); + let vHeader = pdfa(html, p_tab); + + console.log(vHeader.length); + for(let v of vHeader){ let v_title = pdfh(v,'body&&Text'); + console.log(v_title); if(tab_exclude&& (new RegExp(tab_exclude)).test(v_title)){ - continue + continue; } playFrom.push(v_title); } + console.log(JSON.stringify(playFrom)); }else{ playFrom = ['道长在线'] } vod.vod_play_from = playFrom.join(vod_play_from); +console.log(3); let vod_play_url = '$$$'; let vod_tab_list = []; if(p.lists){ @@ -501,24 +601,34 @@ function detailParse(detailObj){ let tab_ext = p.tabs.split(';').length > 1 ? p.tabs.split(';')[1] : ''; let p1 = p.lists.replaceAll('#idv', tab_name).replaceAll('#id', i); tab_ext = tab_ext.replaceAll('#idv', tab_name).replaceAll('#id', i); + console.log(p1); let vodList = pdfa(html, p1); + console.log('len(vodList):'+vodList.length); let new_vod_list = []; let tabName = tab_ext?pdfh(html, tab_ext):tab_name; vodList.forEach(it=>{ new_vod_list.push(tabName+'$'+pd(it,'a&&href')); }); - let vlist = vodList.join('#'); + let vlist = new_vod_list.join('#'); vod_tab_list.push(vlist); } } vod.vod_play_url = vod_tab_list.join(vod_play_url); } - return JSON.stringify(vod) +console.log(JSON.stringify(vod)); + return JSON.stringify({ + list: [vod] + }) } +/** + * 选集播放点击事件解析 + * @param playObj + * @returns {string} + */ function playParse(playObj){ let common_play = { - parse:0, + parse:1, url:playObj.url }; let lazy_play; @@ -528,7 +638,7 @@ function playParse(playObj){ try { eval(rule.lazy.replace('js:').trim()); lazy_play = typeof(input) === 'object'?input:{ - parse:0, + parse:1, url:input }; }catch (e) { @@ -537,15 +647,23 @@ function playParse(playObj){ }else{ lazy_play = common_play; } + console.log(JSON.stringify(lazy_play)); return JSON.stringify(lazy_play); } -// 以上是内置变量和解析方法 - +/** + * js源预处理特定返回对象中的函数 + * @param ext + */ function init(ext) { console.log("init"); } +/** + * js源获取首页分类和筛选特定返回对象中的函数 + * @param filter 筛选条件字典对象 + * @returns {string} + */ function home(filter) { console.log("home"); let homeObj = { @@ -558,6 +676,11 @@ function home(filter) { return homeParse(homeObj); } +/** + * js源获取首页推荐数据列表特定返回对象中的函数 + * @param params + * @returns {string} + */ function homeVod(params) { let homeUrl = rule.host&&rule.homeUrl?urljoin(rule.host,rule.homeUrl):(rule.homeUrl||rule.host); let detailUrl = rule.host&&rule.detailUrl?urljoin(rule.host,rule.detailUrl):rule.detailUrl; @@ -571,6 +694,14 @@ function homeVod(params) { // return "{}"; } +/** + * js源获取分类页一级数据列表特定返回对象中的函数 + * @param tid 分类id + * @param pg 页数 + * @param filter 当前选中的筛选条件 + * @param extend 扩展 + * @returns {string} + */ function category(tid, pg, filter, extend) { let cateObj = { url: urljoin(rule.host, rule.url), @@ -583,6 +714,11 @@ function category(tid, pg, filter, extend) { return categoryParse(cateObj) } +/** + * js源获取二级详情页数据特定返回对象中的函数 + * @param vod_url 一级列表中的vod_id或者是带分类的自拼接 vod_id 如 fyclass$vod_id + * @returns {string} + */ function detail(vod_url) { let fyclass = ''; if(vod_url.indexOf('$')>-1){ @@ -592,8 +728,8 @@ function detail(vod_url) { } let detailUrl = vod_url; let url; - rule.homeUrl = urljoin(rule.host,rule.homeUrl||''); - rule.detailUrl = urljoin(rule.host,rule.detailUrl||''); + rule.homeUrl = urljoin(rule.host,rule.homeUrl); + rule.detailUrl = urljoin(rule.host,rule.detailUrl); if(!detailUrl.startsWith('http')&&!detailUrl.includes('/')){ url = rule.detailUrl.replaceAll('fyid', detailUrl).replaceAll('fyclass',fyclass); }else if(detailUrl.includes('/')){ @@ -611,7 +747,15 @@ function detail(vod_url) { return detailParse(detailObj) } +/** + * js源选集按钮播放点击事件特定返回对象中的函数 + * @param flag 线路名 + * @param id 播放按钮的链接 + * @param flags 全局配置的flags是否需要解析的标识列表 + * @returns {string} + */ function play(flag, id, flags) { + id = id.startsWith('http')?id:urljoin(rule.host,id); let playObj = { url:id, flag:flag, @@ -620,6 +764,12 @@ function play(flag, id, flags) { return playParse(playObj); } +/** + * js源搜索返回的数据列表特定返回对象中的函数 + * @param wd 搜索关键字 + * @param quick 是否来自快速搜索 + * @returns {string} + */ function search(wd, quick) { let searchObj = { searchUrl: urljoin(rule.host, rule.searchUrl), @@ -632,6 +782,7 @@ function search(wd, quick) { return searchParse(searchObj) } +// 导出函数对象 export default { init: init, home: home, -- GitLab