drpy.js 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. import ch from './cheerio.min.js';
  2. // import 'http://192.168.10.99:5705/txt/pluto/drT.js';
  3. // import 'http://192.168.3.239:5705/txt/pluto/drT.js';
  4. import 'http://gitcode.net/qq_32394351/dr_py/-/raw/master/txt/pluto/drT.js';
  5. // import 模板 from 'https://gitcode.net/qq_32394351/dr_py/-/raw/master/js/模板.js'
  6. // var rule = Object.assign(模板.首图2,{
  7. // host: 'https://www.zbkk.net',
  8. // });
  9. const key = 'drpy_zbk';
  10. function init_test(){
  11. console.log("init_test_start");
  12. // clearItem(RULE_CK);
  13. console.log(JSON.stringify(rule));
  14. // console.log(request('https://www.baidu.com',{withHeaders:true}));
  15. // console.log(request('https://www.baidu.com/favicon.ico',{toBase64:true}));
  16. // require('http://192.168.10.99:5705/txt/pluto/drT.js');
  17. // console.log(typeof(drT));
  18. // console.log(drT.renderText('{{fl.cate}},hi, {{fl}}哈哈.{{fl}}',{sort: 1,cate:'movie'},'fl'));
  19. console.log("init_test_end");
  20. }
  21. let rule = {
  22. title: '真不卡',
  23. host: 'https://www.zbkk.net',
  24. // url: '/vodshow/fyclass--------fypage---.html',
  25. url:'/vodshow/fyclass-fyfilter',
  26. filter_url:'{{fl.地区}}-{{fl.排序}}-{{fl.剧情}}-{{fl.语言}}-{{fl.字母}}---fypage---{{fl.年份}}.html',
  27. searchUrl:'/vodsearch/**----------fypage---.html',
  28. filter:{'1': [{'key': '剧情', 'name': '按剧情', 'value': [{'n': '全部', 'v': ''}, {'n': '喜剧', 'v': '%E5%96%9C%E5%89%A7'}, {'n': '爱情', 'v': '%E7%88%B1%E6%83%85'}, {'n': '恐怖', 'v': '%E6%81%90%E6%80%96'}, {'n': '动作', 'v': '%E5%8A%A8%E4%BD%9C'}, {'n': '科幻', 'v': '%E7%A7%91%E5%B9%BB'}, {'n': '剧情', 'v': '%E5%89%A7%E6%83%85'}, {'n': '战争', 'v': '%E6%88%98%E4%BA%89'}, {'n': '警匪', 'v': '%E8%AD%A6%E5%8C%AA'}, {'n': '犯罪', 'v': '%E7%8A%AF%E7%BD%AA'}, {'n': '动画', 'v': '%E5%8A%A8%E7%94%BB'}, {'n': '奇幻', 'v': '%E5%A5%87%E5%B9%BB'}, {'n': '武侠', 'v': '%E6%AD%A6%E4%BE%A0'}, {'n': '冒险', 'v': '%E5%86%92%E9%99%A9'}, {'n': '枪战', 'v': '%E6%9E%AA%E6%88%98'}, {'n': '恐怖', 'v': '%E6%81%90%E6%80%96'}, {'n': '悬疑', 'v': '%E6%82%AC%E7%96%91'}, {'n': '惊悚', 'v': '%E6%83%8A%E6%82%9A'}, {'n': '经典', 'v': '%E7%BB%8F%E5%85%B8'}, {'n': '青春', 'v': '%E9%9D%92%E6%98%A5'}, {'n': '文艺', 'v': '%E6%96%87%E8%89%BA'}, {'n': '微电影', 'v': '%E5%BE%AE%E7%94%B5%E5%BD%B1'}, {'n': '古装', 'v': '%E5%8F%A4%E8%A3%85'}, {'n': '历史', 'v': '%E5%8E%86%E5%8F%B2'}, {'n': '运动', 'v': '%E8%BF%90%E5%8A%A8'}, {'n': '农村', 'v': '%E5%86%9C%E6%9D%91'}, {'n': '儿童', 'v': '%E5%84%BF%E7%AB%A5'}, {'n': '网络电影', 'v': '%E7%BD%91%E7%BB%9C%E7%94%B5%E5%BD%B1'}]}, {'key': '地区', 'name': '按地区', 'value': [{'n': '全部', 'v': ''}, {'n': '大陆', 'v': '%E5%A4%A7%E9%99%86'}, {'n': '香港', 'v': '%E9%A6%99%E6%B8%AF'}, {'n': '台湾', 'v': '%E5%8F%B0%E6%B9%BE'}, {'n': '美国', 'v': '%E7%BE%8E%E5%9B%BD'}, {'n': '法国', 'v': '%E6%B3%95%E5%9B%BD'}, {'n': '英国', 'v': '%E8%8B%B1%E5%9B%BD'}, {'n': '日本', 'v': '%E6%97%A5%E6%9C%AC'}, {'n': '韩国', 'v': '%E9%9F%A9%E5%9B%BD'}, {'n': '德国', 'v': '%E5%BE%B7%E5%9B%BD'}, {'n': '泰国', 'v': '%E6%B3%B0%E5%9B%BD'}, {'n': '印度', 'v': '%E5%8D%B0%E5%BA%A6'}, {'n': '意大利', 'v': '%E6%84%8F%E5%A4%A7%E5%88%A9'}, {'n': '西班牙', 'v': '%E8%A5%BF%E7%8F%AD%E7%89%99'}, {'n': '加拿大', 'v': '%E5%8A%A0%E6%8B%BF%E5%A4%A7'}, {'n': '其他', 'v': '%E5%85%B6%E4%BB%96'}]}, {'key': '年份', 'name': '按年份', 'value': [{'n': '全部', 'v': ''}, {'n': '2022', 'v': '2022'}, {'n': '2021', 'v': '2021'}, {'n': '2020', 'v': '2020'}, {'n': '2019', 'v': '2019'}, {'n': '2018', 'v': '2018'}, {'n': '2017', 'v': '2017'}, {'n': '2016', 'v': '2016'}, {'n': '2015', 'v': '2015'}, {'n': '2014', 'v': '2014'}, {'n': '2013', 'v': '2013'}, {'n': '2012', 'v': '2012'}, {'n': '2011', 'v': '2011'}, {'n': '2010', 'v': '2010'}]}, {'key': '语言', 'name': '按语言', 'value': [{'n': '全部', 'v': ''}, {'n': '国语', 'v': '%E5%9B%BD%E8%AF%AD'}, {'n': '英语', 'v': '%E8%8B%B1%E8%AF%AD'}, {'n': '粤语', 'v': '%E7%B2%A4%E8%AF%AD'}, {'n': '闽南语', 'v': '%E9%97%BD%E5%8D%97%E8%AF%AD'}, {'n': '韩语', 'v': '%E9%9F%A9%E8%AF%AD'}, {'n': '日语', 'v': '%E6%97%A5%E8%AF%AD'}, {'n': '法语', 'v': '%E6%B3%95%E8%AF%AD'}, {'n': '德语', 'v': '%E5%BE%B7%E8%AF%AD'}, {'n': '其它', 'v': '%E5%85%B6%E5%AE%83'}]}, {'key': '字母', 'name': '按字母', 'value': [{'n': '全部', 'v': ''}, {'n': 'A', 'v': 'A'}, {'n': 'B', 'v': 'B'}, {'n': 'C', 'v': 'C'}, {'n': 'D', 'v': 'D'}, {'n': 'E', 'v': 'E'}, {'n': 'F', 'v': 'F'}, {'n': 'G', 'v': 'G'}, {'n': 'H', 'v': 'H'}, {'n': 'I', 'v': 'I'}, {'n': 'J', 'v': 'J'}, {'n': 'K', 'v': 'K'}, {'n': 'L', 'v': 'L'}, {'n': 'M', 'v': 'M'}, {'n': 'N', 'v': 'N'}, {'n': 'O', 'v': 'O'}, {'n': 'P', 'v': 'P'}, {'n': 'Q', 'v': 'Q'}, {'n': 'R', 'v': 'R'}, {'n': 'S', 'v': 'S'}, {'n': 'T', 'v': 'T'}, {'n': 'U', 'v': 'U'}, {'n': 'V', 'v': 'V'}, {'n': 'W', 'v': 'W'}, {'n': 'X', 'v': 'X'}, {'n': 'Y', 'v': 'Y'}, {'n': 'Z', 'v': 'Z'}, {'n': '0-9', 'v': '09'}]}], '2': [{'key': '剧情', 'name': '按剧情', 'value': [{'n': '全部', 'v': ''}, {'n': '古装', 'v': '%E5%8F%A4%E8%A3%85'}, {'n': '战争', 'v': '%E6%88%98%E4%BA%89'}, {'n': '青春偶像', 'v': '%E9%9D%92%E6%98%A5%E5%81%B6%E5%83%8F'}, {'n': '喜剧', 'v': '%E5%96%9C%E5%89%A7'}, {'n': '家庭', 'v': '%E5%AE%B6%E5%BA%AD'}, {'n': '犯罪', 'v': '%E7%8A%AF%E7%BD%AA'}, {'n': '动作', 'v': '%E5%8A%A8%E4%BD%9C'}, {'n': '奇幻', 'v': '%E5%A5%87%E5%B9%BB'}, {'n': '剧情', 'v': '%E5%89%A7%E6%83%85'}, {'n': '历史', 'v': '%E5%8E%86%E5%8F%B2'}, {'n': '经典', 'v': '%E7%BB%8F%E5%85%B8'}, {'n': '乡村', 'v': '%E4%B9%A1%E6%9D%91'}, {'n': '情景', 'v': '%E6%83%85%E6%99%AF'}, {'n': '商战', 'v': '%E5%95%86%E6%88%98'}, {'n': '网剧', 'v': '%E7%BD%91%E5%89%A7'}, {'n': '其他', 'v': '%E5%85%B6%E4%BB%96'}]}, {'key': '地区', 'name': '按地区', 'value': [{'n': '全部', 'v': ''}, {'n': '内地', 'v': '%E5%86%85%E5%9C%B0'}, {'n': '韩国', 'v': '%E9%9F%A9%E5%9B%BD'}, {'n': '香港', 'v': '%E9%A6%99%E6%B8%AF'}, {'n': '台湾', 'v': '%E5%8F%B0%E6%B9%BE'}, {'n': '日本', 'v': '%E6%97%A5%E6%9C%AC'}, {'n': '美国', 'v': '%E7%BE%8E%E5%9B%BD'}, {'n': '泰国', 'v': '%E6%B3%B0%E5%9B%BD'}, {'n': '英国', 'v': '%E8%8B%B1%E5%9B%BD'}, {'n': '新加坡', 'v': '%E6%96%B0%E5%8A%A0%E5%9D%A1'}, {'n': '其他', 'v': '%E5%85%B6%E4%BB%96'}]}, {'key': '年份', 'name': '按年份', 'value': [{'n': '全部', 'v': ''}, {'n': '2022', 'v': '2022'}, {'n': '2021', 'v': '2021'}, {'n': '2020', 'v': '2020'}, {'n': '2019', 'v': '2019'}, {'n': '2018', 'v': '2018'}, {'n': '2017', 'v': '2017'}, {'n': '2016', 'v': '2016'}, {'n': '2015', 'v': '2015'}, {'n': '2014', 'v': '2014'}, {'n': '2013', 'v': '2013'}, {'n': '2012', 'v': '2012'}, {'n': '2011', 'v': '2011'}, {'n': '2010', 'v': '2010'}]}, {'key': '语言', 'name': '按语言', 'value': [{'n': '全部', 'v': ''}, {'n': '国语', 'v': '%E5%9B%BD%E8%AF%AD'}, {'n': '英语', 'v': '%E8%8B%B1%E8%AF%AD'}, {'n': '粤语', 'v': '%E7%B2%A4%E8%AF%AD'}, {'n': '闽南语', 'v': '%E9%97%BD%E5%8D%97%E8%AF%AD'}, {'n': '韩语', 'v': '%E9%9F%A9%E8%AF%AD'}, {'n': '日语', 'v': '%E6%97%A5%E8%AF%AD'}, {'n': '其它', 'v': '%E5%85%B6%E5%AE%83'}]}, {'key': '字母', 'name': '按字母', 'value': [{'n': '全部', 'v': ''}, {'n': 'A', 'v': 'A'}, {'n': 'B', 'v': 'B'}, {'n': 'C', 'v': 'C'}, {'n': 'D', 'v': 'D'}, {'n': 'E', 'v': 'E'}, {'n': 'F', 'v': 'F'}, {'n': 'G', 'v': 'G'}, {'n': 'H', 'v': 'H'}, {'n': 'I', 'v': 'I'}, {'n': 'J', 'v': 'J'}, {'n': 'K', 'v': 'K'}, {'n': 'L', 'v': 'L'}, {'n': 'M', 'v': 'M'}, {'n': 'N', 'v': 'N'}, {'n': 'O', 'v': 'O'}, {'n': 'P', 'v': 'P'}, {'n': 'Q', 'v': 'Q'}, {'n': 'R', 'v': 'R'}, {'n': 'S', 'v': 'S'}, {'n': 'T', 'v': 'T'}, {'n': 'U', 'v': 'U'}, {'n': 'V', 'v': 'V'}, {'n': 'W', 'v': 'W'}, {'n': 'X', 'v': 'X'}, {'n': 'Y', 'v': 'Y'}, {'n': 'Z', 'v': 'Z'}, {'n': '0-9', 'v': '09'}]}], '3': [{'key': '剧情', 'name': '按剧情', 'value': [{'n': '全部', 'v': ''}, {'n': '选秀', 'v': '%E9%80%89%E7%A7%80'}, {'n': '情感', 'v': '%E6%83%85%E6%84%9F'}, {'n': '访谈', 'v': '%E8%AE%BF%E8%B0%88'}, {'n': '播报', 'v': '%E6%92%AD%E6%8A%A5'}, {'n': '旅游', 'v': '%E6%97%85%E6%B8%B8'}, {'n': '音乐', 'v': '%E9%9F%B3%E4%B9%90'}, {'n': '美食', 'v': '%E7%BE%8E%E9%A3%9F'}, {'n': '纪实', 'v': '%E7%BA%AA%E5%AE%9E'}, {'n': '曲艺', 'v': '%E6%9B%B2%E8%89%BA'}, {'n': '生活', 'v': '%E7%94%9F%E6%B4%BB'}, {'n': '游戏互动', 'v': '%E6%B8%B8%E6%88%8F%E4%BA%92%E5%8A%A8'}, {'n': '财经', 'v': '%E8%B4%A2%E7%BB%8F'}, {'n': '求职', 'v': '%E6%B1%82%E8%81%8C'}]}, {'key': '地区', 'name': '按地区', 'value': [{'n': '全部', 'v': ''}, {'n': '内地', 'v': '%E5%86%85%E5%9C%B0'}, {'n': '港台', 'v': '%E6%B8%AF%E5%8F%B0'}, {'n': '日韩', 'v': '%E6%97%A5%E9%9F%A9'}, {'n': '欧美', 'v': '%E6%AC%A7%E7%BE%8E'}]}, {'key': '年份', 'name': '按年份', 'value': [{'n': '全部', 'v': ''}, {'n': '2022', 'v': '2022'}, {'n': '2021', 'v': '2021'}, {'n': '2020', 'v': '2020'}, {'n': '2019', 'v': '2019'}, {'n': '2018', 'v': '2018'}, {'n': '2017', 'v': '2017'}, {'n': '2016', 'v': '2016'}, {'n': '2015', 'v': '2015'}, {'n': '2014', 'v': '2014'}, {'n': '2013', 'v': '2013'}, {'n': '2012', 'v': '2012'}, {'n': '2011', 'v': '2011'}, {'n': '2010', 'v': '2010'}]}, {'key': '语言', 'name': '按语言', 'value': [{'n': '全部', 'v': ''}, {'n': '国语', 'v': '%E5%9B%BD%E8%AF%AD'}, {'n': '英语', 'v': '%E8%8B%B1%E8%AF%AD'}, {'n': '粤语', 'v': '%E7%B2%A4%E8%AF%AD'}, {'n': '闽南语', 'v': '%E9%97%BD%E5%8D%97%E8%AF%AD'}, {'n': '韩语', 'v': '%E9%9F%A9%E8%AF%AD'}, {'n': '日语', 'v': '%E6%97%A5%E8%AF%AD'}, {'n': '其它', 'v': '%E5%85%B6%E5%AE%83'}]}, {'key': '字母', 'name': '按字母', 'value': [{'n': '全部', 'v': ''}, {'n': 'A', 'v': 'A'}, {'n': 'B', 'v': 'B'}, {'n': 'C', 'v': 'C'}, {'n': 'D', 'v': 'D'}, {'n': 'E', 'v': 'E'}, {'n': 'F', 'v': 'F'}, {'n': 'G', 'v': 'G'}, {'n': 'H', 'v': 'H'}, {'n': 'I', 'v': 'I'}, {'n': 'J', 'v': 'J'}, {'n': 'K', 'v': 'K'}, {'n': 'L', 'v': 'L'}, {'n': 'M', 'v': 'M'}, {'n': 'N', 'v': 'N'}, {'n': 'O', 'v': 'O'}, {'n': 'P', 'v': 'P'}, {'n': 'Q', 'v': 'Q'}, {'n': 'R', 'v': 'R'}, {'n': 'S', 'v': 'S'}, {'n': 'T', 'v': 'T'}, {'n': 'U', 'v': 'U'}, {'n': 'V', 'v': 'V'}, {'n': 'W', 'v': 'W'}, {'n': 'X', 'v': 'X'}, {'n': 'Y', 'v': 'Y'}, {'n': 'Z', 'v': 'Z'}, {'n': '0-9', 'v': '09'}]}], '4': [{'key': '剧情', 'name': '按剧情', 'value': [{'n': '全部', 'v': ''}, {'n': '情感', 'v': '%E6%83%85%E6%84%9F'}, {'n': '科幻', 'v': '%E7%A7%91%E5%B9%BB'}, {'n': '热血', 'v': '%E7%83%AD%E8%A1%80'}, {'n': '推理', 'v': '%E6%8E%A8%E7%90%86'}, {'n': '搞笑', 'v': '%E6%90%9E%E7%AC%91'}, {'n': '冒险', 'v': '%E5%86%92%E9%99%A9'}, {'n': '萝莉', 'v': '%E8%90%9D%E8%8E%89'}, {'n': '校园', 'v': '%E6%A0%A1%E5%9B%AD'}, {'n': '动作', 'v': '%E5%8A%A8%E4%BD%9C'}, {'n': '机战', 'v': '%E6%9C%BA%E6%88%98'}, {'n': '运动', 'v': '%E8%BF%90%E5%8A%A8'}, {'n': '战争', 'v': '%E6%88%98%E4%BA%89'}, {'n': '少年', 'v': '%E5%B0%91%E5%B9%B4'}, {'n': '少女', 'v': '%E5%B0%91%E5%A5%B3'}, {'n': '社会', 'v': '%E7%A4%BE%E4%BC%9A'}, {'n': '原创', 'v': '%E5%8E%9F%E5%88%9B'}, {'n': '亲子', 'v': '%E4%BA%B2%E5%AD%90'}, {'n': '益智', 'v': '%E7%9B%8A%E6%99%BA'}, {'n': '励志', 'v': '%E5%8A%B1%E5%BF%97'}, {'n': '其他', 'v': '%E5%85%B6%E4%BB%96'}]}, {'key': '地区', 'name': '按地区', 'value': [{'n': '全部', 'v': ''}, {'n': '国产', 'v': '%E5%9B%BD%E4%BA%A7'}, {'n': '日本', 'v': '%E6%97%A5%E6%9C%AC'}, {'n': '欧美', 'v': '%E6%AC%A7%E7%BE%8E'}, {'n': '其他', 'v': '%E5%85%B6%E4%BB%96'}]}, {'key': '年份', 'name': '按年份', 'value': [{'n': '全部', 'v': ''}, {'n': '2022', 'v': '2022'}, {'n': '2021', 'v': '2021'}, {'n': '2020', 'v': '2020'}, {'n': '2019', 'v': '2019'}, {'n': '2018', 'v': '2018'}, {'n': '2017', 'v': '2017'}, {'n': '2016', 'v': '2016'}, {'n': '2015', 'v': '2015'}, {'n': '2014', 'v': '2014'}, {'n': '2013', 'v': '2013'}, {'n': '2012', 'v': '2012'}, {'n': '2011', 'v': '2011'}, {'n': '2010', 'v': '2010'}]}, {'key': '语言', 'name': '按语言', 'value': [{'n': '全部', 'v': ''}, {'n': '国语', 'v': '%E5%9B%BD%E8%AF%AD'}, {'n': '英语', 'v': '%E8%8B%B1%E8%AF%AD'}, {'n': '粤语', 'v': '%E7%B2%A4%E8%AF%AD'}, {'n': '闽南语', 'v': '%E9%97%BD%E5%8D%97%E8%AF%AD'}, {'n': '韩语', 'v': '%E9%9F%A9%E8%AF%AD'}, {'n': '日语', 'v': '%E6%97%A5%E8%AF%AD'}, {'n': '其它', 'v': '%E5%85%B6%E5%AE%83'}]}, {'key': '字母', 'name': '按字母', 'value': [{'n': '全部', 'v': ''}, {'n': 'A', 'v': 'A'}, {'n': 'B', 'v': 'B'}, {'n': 'C', 'v': 'C'}, {'n': 'D', 'v': 'D'}, {'n': 'E', 'v': 'E'}, {'n': 'F', 'v': 'F'}, {'n': 'G', 'v': 'G'}, {'n': 'H', 'v': 'H'}, {'n': 'I', 'v': 'I'}, {'n': 'J', 'v': 'J'}, {'n': 'K', 'v': 'K'}, {'n': 'L', 'v': 'L'}, {'n': 'M', 'v': 'M'}, {'n': 'N', 'v': 'N'}, {'n': 'O', 'v': 'O'}, {'n': 'P', 'v': 'P'}, {'n': 'Q', 'v': 'Q'}, {'n': 'R', 'v': 'R'}, {'n': 'S', 'v': 'S'}, {'n': 'T', 'v': 'T'}, {'n': 'U', 'v': 'U'}, {'n': 'V', 'v': 'V'}, {'n': 'W', 'v': 'W'}, {'n': 'X', 'v': 'X'}, {'n': 'Y', 'v': 'Y'}, {'n': 'Z', 'v': 'Z'}, {'n': '0-9', 'v': '09'}]}]},
  29. // headers: {
  30. // 'User-Agent': MOBILE_UA
  31. // },
  32. // play_parse:true,
  33. // lazy:'',
  34. class_parse: 'body&&.stui-header__menu .dropdown li:gt(0):lt(5);a&&Text;a&&href;.*/(.*?).html',
  35. 一级: '.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
  36. 推荐:'ul.stui-vodlist.clearfix;body&&li;a&&title;.lazyload&&data-original;.pic-text&&Text;a&&href',
  37. 二级:{"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"},
  38. double:true, // 推荐内容是否双层定位
  39. //搜索:'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',
  40. 搜索:'body&&ul.stui-vodlist__media&&li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
  41. // cate_exclude: '首页|留言|APP|下载|资讯|新闻|动态',
  42. // tab_exclude: '猜你|喜欢|APP|下载|剧情',
  43. }
  44. /****上面才是pluto的drpy源,支持import外部模板来继承修改
  45. * 已知问题记录:
  46. * 自动补body逻辑可能有Bug,二级选集列表现在不正常了会报错
  47. * 1.pdfa没法正确获取非body开头的直接定位列表,比如 推荐 body&&ul.stui-vodlist.clearfix 和 ul.stui-vodlist.clearfix 获取出来的列表不一样,建议自动补body(已解决)
  48. * 2. pd函数有问题,没法正确的urljoin来源链接,比如分类页获取到数据href为/zbkdetail/63174.html应该自动与rule.url拼接后才返回给二级完整链接 (已解决)
  49. * .stui-pannel_hd h3 这个pdfa都没法识别?
  50. * pdf 系列不支持eq定位?
  51. * 解析播放问题,parse返回的1怎么下面不出解析选项 ?? 不过可以通免
  52. * urljoin问题,求求了这个函数很重要,还要pd函数内部需要自动urljoin (已解决)
  53. * 请求重复问题,调试日志一个console总是打印两次??(待解决)
  54. * 筛选功能暂未实现,搜索验证码暂未实现
  55. * quickjs发生一次崩溃后除非重启软件,否则该源后续操作点击二级都没有数据
  56. * setItem系列存在问题,用的公用变量实现没法持久化,需要一个数据库存储持久化,下次进来也能获取储存的cookie
  57. * 电脑看日志调试
  58. adb tcpip 5555
  59. adb connect 192.168.10.192
  60. adb devices -l
  61. adb logcat -c
  62. adb logcat | grep -i QuickJS
  63. * ***/
  64. /*** 以下是内置变量和解析方法 **/
  65. const MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36';
  66. const PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36';
  67. const UA = 'Mozilla/5.0';
  68. 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';
  69. 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';
  70. const RULE_CK = 'cookie'; // 源cookie的key值
  71. const KEY = typeof(key)!=='undefined'&&key?key:'drpy_'+rule.title; // 源的唯一标识
  72. const CATE_EXCLUDE = '首页|留言|APP|下载|资讯|新闻|动态';
  73. const TAB_EXCLUDE = '猜你|喜欢|APP|下载|剧情|热播';
  74. const OCR_RETRY = 3;//ocr验证重试次数
  75. // const OCR_API = 'http://dm.mudery.com:10000';//ocr在线识别接口
  76. const OCR_API = 'http://192.168.3.239:5705/parse/ocr';//ocr在线识别接口
  77. var MY_URL; // 全局注入变量,pd函数需要
  78. var VODS = [];// 一级或者搜索需要的数据列表
  79. var vod = {};//二级用单个影片详情
  80. /** 处理一下 rule规则关键字段没传递的情况 **/
  81. let rule_cate_excludes = (rule.cate_exclude||'').split('|').filter(it=>it.trim());
  82. let rule_tab_excludes = (rule.tab_exclude||'').split('|').filter(it=>it.trim());
  83. rule_cate_excludes = rule_cate_excludes.concat(CATE_EXCLUDE.split('|').filter(it=>it.trim()));
  84. rule_tab_excludes = rule_tab_excludes.concat(TAB_EXCLUDE.split('|').filter(it=>it.trim()));
  85. rule.cate_exclude = rule_cate_excludes.join('\n');
  86. rule.tab_exclude = rule_tab_excludes.join('\n');
  87. rule.host = rule.host||'';
  88. rule.url = rule.url||'';
  89. rule.homeUrl = rule.homeUrl||'';
  90. rule.searchUrl = rule.searchUrl||'';
  91. /*** 后台需要实现的java方法并注入到js中 ***/
  92. /**
  93. * 读取本地文件->应用程序目录
  94. * @param filePath
  95. * @returns {string}
  96. */
  97. function readFile(filePath){
  98. filePath = filePath||'./uri.min.js';
  99. var fd = os.open(filePath);
  100. var buffer = new ArrayBuffer(1024);
  101. var len = os.read(fd, buffer, 0, 1024);
  102. console.log(len);
  103. let text = String.fromCharCode.apply(null, new Uint8Array(buffer));
  104. console.log(text);
  105. return text
  106. }
  107. /**
  108. * 验证码识别逻辑,需要java实现(js没有bytes类型,无法调用后端的传递图片二进制获取验证码文本的接口)
  109. * @type {{api: string, classification: (function(*=): string)}}
  110. */
  111. var OcrApi={
  112. api:OCR_API,
  113. classification:function (img){ // img是byte类型,这里不方便搞啊
  114. let code = '';
  115. try {
  116. let html = request(this.api,{data:{img:img},headers:{'User-Agent':PC_UA},'method':'POST'});
  117. html = JSON.parse(html);
  118. code = html.url||'';
  119. }catch (e) {}
  120. return code
  121. }
  122. };
  123. /**
  124. * 验证码识别,暂未实现
  125. * @param url 验证码图片链接
  126. * @returns {string} 验证成功后的cookie
  127. */
  128. function verifyCode(url){
  129. let cnt = 0;
  130. let host = getHome(url);
  131. let cookie = '';
  132. while (cnt < OCR_RETRY){
  133. try{
  134. // let obj = {headers:headers,timeout:timeout};
  135. let yzm_url = `${host}/index.php/verify/index.html`;
  136. console.log(`验证码链接:${yzm_url}`);
  137. let hhtml = request(yzm_url,{withHeaders:true,toBase64:true});
  138. let json = JSON.parse(hhtml);
  139. if(!cookie){
  140. cookie = json['set-cookie']?json['set-cookie'].split(';')[0]:'';
  141. }
  142. // console.log(hhtml);
  143. console.log('cookie:'+cookie);
  144. let img = json.body;
  145. // console.log(img);
  146. let code = OcrApi.classification(img);
  147. console.log(`第${cnt+1}次验证码识别结果:${code}`);
  148. let submit_url = `${host}/index.php/ajax/verify_check?type=search&verify=${code}`;
  149. console.log(submit_url);
  150. let html = request(submit_url,{headers:{Cookie:cookie,'User-Agent':MOBILE_UA},'method':'POST'});
  151. // console.log(html);
  152. html = JSON.parse(html);
  153. if(html.msg === 'ok'){
  154. console.log(`第${cnt+1}次验证码提交成功`);
  155. return cookie // 需要返回cookie
  156. }else if(html.msg!=='ok'&&cnt+1>=OCR_RETRY){
  157. cookie = ''; // 需要清空返回cookie
  158. }
  159. }catch (e) {
  160. console.log(`第${cnt+1}次验证码提交失败:${e.message}`);
  161. if(cnt+1>=OCR_RETRY){
  162. cookie = '';
  163. }
  164. }
  165. cnt+=1
  166. }
  167. return cookie
  168. }
  169. /**
  170. * 存在数据库配置表里, key字段对应值value,没有就新增,有就更新,调用此方法会清除key对应的内存缓存
  171. * @param k 键
  172. * @param v 值
  173. */
  174. function setItem(k,v){
  175. local.set(KEY,k,v);
  176. console.log(`规则${KEY}设置${k} => ${v}`)
  177. }
  178. /**
  179. * 获取数据库配置表对应的key字段的value,没有这个key就返回value默认传参.需要有缓存,第一次获取后会存在内存里
  180. * @param k 键
  181. * @param v 值
  182. * @returns {*}
  183. */
  184. function getItem(k,v){
  185. return local.get(KEY,k) || v;
  186. }
  187. /**
  188. * 删除数据库key对应的一条数据,并清除此key对应的内存缓存
  189. * @param k
  190. */
  191. function clearItem(k){
  192. local.delete(KEY,k);
  193. }
  194. /**
  195. * url拼接(暂未实现)
  196. * @param fromPath 初始当前页面url
  197. * @param nowPath 相对当前页面url
  198. * @returns {*}
  199. */
  200. function urljoin(fromPath, nowPath) {
  201. fromPath = fromPath||'';
  202. nowPath = nowPath||'';
  203. return joinUrl(fromPath, nowPath);
  204. // try {
  205. // // import Uri from './uri.min.js';
  206. // // var Uri = require('./uri.min.js');
  207. // // eval(request('https://cdn.bootcdn.net/ajax/libs/URI.js/1.19.11/URI.min.js'));
  208. // // let new_uri = URI(nowPath, fromPath);
  209. // let new_uri = Uri(nowPath, fromPath);
  210. // new_uri = new_uri.toString();
  211. // // console.log(new_uri);
  212. // // return fromPath + nowPath
  213. // return new_uri
  214. // }
  215. // catch (e) {
  216. // console.log('urljoin发生错误:'+e.message);
  217. // if(nowPath.startsWith('http')){
  218. // return nowPath
  219. // }if(nowPath.startsWith('/')){
  220. // return getHome(fromPath)+nowPath
  221. // }
  222. // return fromPath+nowPath
  223. // }
  224. }
  225. /**
  226. * 重写pd方法-增加自动urljoin(没法重写,改个名继续骗)
  227. * @param html
  228. * @param parse
  229. * @param uri
  230. * @returns {*}
  231. */
  232. function pD(html,parse,uri){
  233. let ret = pdfh(html,parse);
  234. if(typeof(uri)==='undefined'||!uri){
  235. uri = '';
  236. }
  237. // MY_URL = getItem('MY_URL',MY_URL);
  238. // console.log(`规则${KEY}打印MY_URL:${MY_URL},uri:${uri}`);
  239. return urljoin(MY_URL,ret)
  240. }
  241. /*** js自封装的方法 ***/
  242. /**
  243. * 获取链接的host(带http协议的完整链接)
  244. * @param url 任意一个正常完整的Url,自动提取根
  245. * @returns {string}
  246. */
  247. function getHome(url){
  248. if(!url){
  249. return ''
  250. }
  251. let tmp = url.split('//');
  252. url = tmp[0] + '//' + tmp[1].split('/')[0];
  253. return url
  254. }
  255. /**
  256. * get参数编译链接,类似python params字典自动拼接
  257. * @param url 访问链接
  258. * @param obj 参数字典
  259. * @returns {*}
  260. */
  261. function buildUrl(url,obj){
  262. obj = obj||{};
  263. if(url.indexOf('?')<0){
  264. url += '?'
  265. }
  266. let param_list = [];
  267. let keys = Object.keys(obj);
  268. keys.forEach(it=>{
  269. param_list.push(it+'='+obj[it])
  270. });
  271. let prs = param_list.join('&');
  272. if(keys.length > 0 && !url.endsWith('?')){
  273. url += '&'
  274. }
  275. url+=prs;
  276. return url
  277. }
  278. /**
  279. * 远程依赖执行函数
  280. * @param url 远程js地址
  281. */
  282. function require(url){
  283. eval(request(url));
  284. }
  285. /**
  286. * 海阔网页请求函数完整封装
  287. * @param url 请求链接
  288. * @param obj 请求对象 {headers:{},method:'',timeout:5000,body:'',withHeaders:false}
  289. * @returns {string|string|DocumentFragment|*}
  290. */
  291. function request(url,obj){
  292. if(typeof(obj)==='undefined'||!obj||obj==={}){
  293. obj = {
  294. headers:{
  295. 'User-Agent':MOBILE_UA,
  296. 'Referer':getHome(url),
  297. }
  298. }
  299. }else{
  300. let headers = obj.headers||{};
  301. let keys = Object.keys(headers).map(it=>it.toLowerCase());
  302. if(!keys.includes('user-agent')){
  303. headers['User-Agent'] = MOBILE_UA;
  304. }if(!keys.includes('referer')){
  305. headers['Referer'] = getHome(url);
  306. }
  307. obj.headers = headers;
  308. }
  309. console.log(JSON.stringify(obj.headers));
  310. if(typeof(obj.headers.body)!='undefined'&&obj.headers.body&&typeof (obj.headers.body)==='string'){
  311. let data = {};
  312. obj.headers.body.split('&').forEach(it=>{
  313. data[it.split('=')[0]] = it.split('=')[1]
  314. });
  315. obj.data = data;
  316. delete obj.headers.body
  317. }
  318. if(!url){
  319. return obj.withHeaders?'{}':''
  320. }
  321. if(obj.toBase64){ // 返回base64,用于请求图片
  322. obj.buffer = 2;
  323. delete obj.toBase64
  324. }
  325. let res = req(url, obj);
  326. let html = res.content||'';
  327. if(obj.withHeaders){
  328. let htmlWithHeaders = res.headers;
  329. htmlWithHeaders.body = html;
  330. return JSON.stringify(htmlWithHeaders);
  331. }else{
  332. return html
  333. }
  334. }
  335. /**
  336. * 检查宝塔验证并自动跳过获取正确源码
  337. * @param html 之前获取的html
  338. * @param url 之前的来源url
  339. * @param obj 来源obj
  340. * @returns {string|DocumentFragment|*}
  341. */
  342. function checkHtml(html,url,obj){
  343. if(/\?btwaf=/.test(html)){
  344. let btwaf = html.match(/btwaf(.*?)"/)[1];
  345. url = url.split('#')[0]+'?btwaf'+btwaf;
  346. html = request(url,obj);
  347. }
  348. return html
  349. }
  350. /**
  351. * 带一次宝塔验证的源码获取
  352. * @param url 请求链接
  353. * @param obj 请求参数
  354. * @returns {string|DocumentFragment}
  355. */
  356. function getCode(url,obj){
  357. let html = request(url,obj);
  358. html = checkHtml(html,url,obj);
  359. return html
  360. }
  361. /**
  362. * 源rule专用的请求方法,自动注入cookie
  363. * @param url 请求链接
  364. * @returns {string|DocumentFragment}
  365. */
  366. function getHtml(url){
  367. let obj = {};
  368. if(rule.headers){
  369. obj.headers = rule.headers;
  370. }
  371. let cookie = getItem(RULE_CK,'');
  372. if(cookie){
  373. if(obj.headers && ! Object.keys(obj.headers).map(it=>it.toLowerCase()).includes('cookie')){
  374. obj.headers['Cookie'] = cookie;
  375. }else if(!obj.headers){
  376. obj.headers = {Cookie:cookie};
  377. }
  378. }
  379. let html = getCode(url,obj);
  380. return html
  381. }
  382. /**
  383. * 首页分类解析,筛选暂未实现
  384. * @param homeObj 首页传参对象
  385. * @returns {string}
  386. */
  387. function homeParse(homeObj) {
  388. let classes = [];
  389. if (homeObj.class_name && homeObj.class_url) {
  390. let names = homeObj.class_name.split('&');
  391. let urls = homeObj.class_url.split('&');
  392. let cnt = Math.min(names.length, urls.length);
  393. for (let i = 0; i < cnt; i++) {
  394. classes.push({
  395. 'type_id': urls[i],
  396. 'type_name': names[i]
  397. });
  398. }
  399. }
  400. if (homeObj.class_parse) {
  401. let p = homeObj.class_parse.split(';');
  402. if (p.length >= 4) {
  403. try {
  404. let html = getHtml(homeObj.MY_URL);
  405. if (html) {
  406. let list = pdfa(html, p[0]);
  407. if (list && list.length > 0) {
  408. list.forEach(it => {
  409. try {
  410. let name = pdfh(it, p[1]);
  411. if (homeObj.cate_exclude && (new RegExp(homeObj.cate_exclude).test(name))) {
  412. return;
  413. }
  414. let url = pdfh(it, p[2]);
  415. if (p[3]) {
  416. let exp = new RegExp(p[3]);
  417. url = url.match(exp)[1];
  418. }
  419. classes.push({
  420. 'type_id': url,
  421. 'type_name': name
  422. });
  423. } catch (e) {
  424. console.log(e.message);
  425. }
  426. });
  427. }
  428. }
  429. } catch (e) {
  430. console.log(e.message);
  431. }
  432. }
  433. }
  434. let resp = {
  435. 'class': classes
  436. };
  437. if(homeObj.filter){
  438. resp.filters = homeObj.filter;
  439. }
  440. console.log(JSON.stringify(resp));
  441. return JSON.stringify(resp);
  442. }
  443. /**
  444. * 首页推荐列表解析
  445. * @param homeVodObj
  446. * @returns {string}
  447. */
  448. function homeVodParse(homeVodObj){
  449. let d = [];
  450. MY_URL = homeVodObj.homeUrl;
  451. // setItem('MY_URL',MY_URL);
  452. console.log(MY_URL);
  453. let p = homeVodObj.推荐;
  454. if(!p){
  455. return '{}'
  456. }
  457. if(typeof(p)==='string'&&p.trim().startsWith('js:')){
  458. const TYPE = 'home';
  459. var input = MY_URL;
  460. const HOST = rule.host;
  461. eval(p.trim().replace('js:',''));
  462. d = VODS;
  463. }else {
  464. p = p.split(';');
  465. if (!homeVodObj.double && p.length < 5) {
  466. return '{}'
  467. } else if (homeVodObj.double && p.length < 6) {
  468. return '{}'
  469. }
  470. let html = getHtml(MY_URL);
  471. try {
  472. console.log('double:' + homeVodObj.double);
  473. if (homeVodObj.double) {
  474. p[0] = p[0].trim().startsWith('json:') ? p[0].replace('json:', '') : p[0];
  475. // console.log(p[0]);
  476. let items = pdfa(html, p[0]);
  477. // console.log(items.length);
  478. for (let item of items) {
  479. // console.log(p[1]);
  480. let items2 = pdfa(item, p[1]);
  481. // console.log(items2.length);
  482. for (let item2 of items2) {
  483. try {
  484. let title = pdfh(item2, p[2]);
  485. let img = '';
  486. try {
  487. img = pD(item2, p[3])
  488. } catch (e) {
  489. }
  490. let desc = pdfh(item2, p[4]);
  491. let links = [];
  492. for (let p5 of p[5].split('+')) {
  493. let link = !homeVodObj.detailUrl ? pD(item2, p5, MY_URL) : pdfh(item2, p5);
  494. links.push(link);
  495. }
  496. let vod = {
  497. vod_name: title,
  498. vod_pic: img,
  499. vod_remarks: desc,
  500. vod_id: links.join('$')
  501. };
  502. d.push(vod);
  503. } catch (e) {
  504. }
  505. }
  506. }
  507. } else {
  508. p[0] = p[0].trim().startsWith('json:') ? p[0].replace('json:', '') : p[0];
  509. let items = pdfa(html, p[0]);
  510. for (let item of items) {
  511. try {
  512. let title = pdfh(item, p[1]);
  513. let img = '';
  514. try {
  515. img = pD(item, p[2], MY_URL);
  516. } catch (e) {
  517. }
  518. let desc = pdfh(item, p[3]);
  519. let links = [];
  520. for (let p5 of p[4].split('+')) {
  521. let link = !homeVodObj.detailUrl ? pD(item, p5, MY_URL) : pdfh(item, p5);
  522. links.push(link);
  523. }
  524. let vod = {
  525. vod_name: title,
  526. vod_pic: img,
  527. vod_remarks: desc,
  528. vod_id: links.join('$')
  529. };
  530. d.push(vod);
  531. } catch (e) {
  532. }
  533. }
  534. }
  535. } catch (e) {
  536. }
  537. }
  538. // console.log(JSON.stringify(d));
  539. return JSON.stringify({
  540. list:d
  541. })
  542. }
  543. /**
  544. * 一级分类页数据解析
  545. * @param cateObj
  546. * @returns {string}
  547. */
  548. function categoryParse(cateObj) {
  549. let p = cateObj.一级;
  550. let d = [];
  551. // let url = cateObj.url.replaceAll('fyclass', cateObj.tid).replaceAll('fypage', cateObj.pg);
  552. let url = cateObj.url.replaceAll('fyclass', cateObj.tid);
  553. if(rule.filter_url){
  554. if(!/fyfilter/.test(url)){
  555. if(!url.endsWith('&')&&!rule.filter_url.startsWith('&')){
  556. url+='&'
  557. }
  558. url+=rule.filter_url;
  559. }else{
  560. url = url.replace('fyfilter', rule.filter_url);
  561. }
  562. // console.log('filter:'+cateObj.filter);
  563. let fl = cateObj.filter?cateObj.extend:{};
  564. url = drT.renderText(url,fl);
  565. }
  566. if(/fypage/.test(url)){
  567. if(url.includes('(')&&url.includes(')')){
  568. let url_rep = url.match(/.*?\((.*)\)/)[1];
  569. let cnt_page = url_rep.replaceAll('fypage', cateObj.pg);
  570. eval(`let cnt_pg=${cnt_page}`);
  571. url = url.replaceAll(url_rep,cnt_pg).replaceAll('(','').replaceAll(')','');
  572. }else{
  573. url = url.replaceAll('fypage',cateObj.pg);
  574. }
  575. }
  576. if(cateObj.pg === 1 && url.includes('[')&&url.includes(']')){
  577. url = url.split('[')[1].split(']')[0];
  578. }
  579. MY_URL = url;
  580. // setItem('MY_URL',MY_URL);
  581. console.log(MY_URL);
  582. if(typeof(p)==='string'&&p.trim().startsWith('js:')){
  583. const MY_CATE = cateObj.tid;
  584. const MY_FL = cateObj.extend;
  585. const TYPE = 'cate';
  586. var input = MY_URL;
  587. const MY_PAGE = cateObj.pg;
  588. eval(p.trim().replace('js:',''));
  589. d = VODS;
  590. }else {
  591. p = p.split(';');
  592. if (p.length < 5) {
  593. return '{}'
  594. }
  595. try {
  596. let html = getHtml(MY_URL);
  597. if (html) {
  598. let list = pdfa(html, p[0]);
  599. list.forEach(it => {
  600. d.push({
  601. 'vod_id': pD(it, p[4],MY_URL),
  602. 'vod_name': pdfh(it, p[1]),
  603. 'vod_pic': pD(it, p[2],MY_URL),
  604. 'vod_remarks': pdfh(it, p[3]),
  605. });
  606. });
  607. }
  608. } catch (e) {
  609. console.log(e.message);
  610. }
  611. }
  612. return d.length<1?'{}':JSON.stringify({
  613. 'page': parseInt(cateObj.pg),
  614. 'pagecount': 999,
  615. 'limit': 20,
  616. 'total': 999,
  617. 'list': d,
  618. });
  619. }
  620. /**
  621. * 搜索列表数据解析
  622. * @param searchObj
  623. * @returns {string}
  624. */
  625. function searchParse(searchObj) {
  626. let d = [];
  627. if(!searchObj.searchUrl){
  628. return '{}'
  629. }
  630. let p = searchObj.搜索==='*'&&rule.一级 ? rule.一级 : searchObj.搜索;
  631. let url = searchObj.searchUrl.replaceAll('**', searchObj.wd).replaceAll('fypage', searchObj.pg);
  632. MY_URL = url;
  633. console.log(MY_URL);
  634. // setItem('MY_URL',MY_URL);
  635. if(typeof(p)==='string'&&p.trim().startsWith('js:')){
  636. const TYPE = 'search';
  637. const MY_PAGE = searchObj.pg;
  638. const KEY = searchObj.wd;
  639. var input = MY_URL;
  640. var detailUrl = rule.detailUrl||'';
  641. eval(p.trim().replace('js:',''));
  642. d = VODS;
  643. }else{
  644. p = p.split(';');
  645. if (p.length < 5) {
  646. return '{}'
  647. }
  648. try {
  649. let html = getHtml(MY_URL);
  650. if (html) {
  651. if(/系统安全验证|输入验证码/.test(html)){
  652. let cookie = verifyCode(MY_URL);
  653. if(cookie){
  654. console.log(`本次成功过验证,cookie:${cookie}`);
  655. setItem(RULE_CK,cookie);
  656. }else{
  657. console.log(`本次自动过搜索验证失败,cookie:${cookie}`);
  658. }
  659. // obj.headers['Cookie'] = cookie;
  660. html = getHtml(MY_URL);
  661. }
  662. if(!html.includes(searchObj.wd)){
  663. console.log('搜索结果源码未包含关键字,疑似搜索失败,正为您打印结果源码');
  664. console.log(html);
  665. }
  666. let list = pdfa(html, p[0]);
  667. list.forEach(it => {
  668. let ob = {
  669. 'vod_id': pD(it, p[4],MY_URL),
  670. 'vod_name': pdfh(it, p[1]),
  671. 'vod_pic': pD(it, p[2],MY_URL),
  672. 'vod_remarks': pdfh(it, p[3]),
  673. };
  674. if (p.length > 5 && p[5]) {
  675. ob.vod_content = pdfh(it, p[5]);
  676. }
  677. d.push(ob);
  678. });
  679. }
  680. } catch (e) {
  681. return '{}'
  682. }
  683. return JSON.stringify({
  684. 'page': parseInt(searchObj.pg),
  685. 'pagecount': 10,
  686. 'limit': 20,
  687. 'total': 100,
  688. 'list': d,
  689. });
  690. }
  691. }
  692. /**
  693. * 二级详情页数据解析
  694. * @param detailObj
  695. * @returns {string}
  696. */
  697. function detailParse(detailObj){
  698. let vod = {
  699. vod_id: "id",
  700. vod_name: "片名",
  701. vod_pic: "",
  702. type_name: "剧情",
  703. vod_year: "年份",
  704. vod_area: "地区",
  705. vod_remarks: "更新信息",
  706. vod_actor: "主演",
  707. vod_director: "导演",
  708. vod_content: "简介"
  709. };
  710. let p = detailObj.二级;
  711. let url = detailObj.url;
  712. let detailUrl = detailObj.detailUrl;
  713. let fyclass = detailObj.fyclass;
  714. let tab_exclude = detailObj.tab_exclude;
  715. let html = detailObj.html||'';
  716. MY_URL = url;
  717. console.log(MY_URL);
  718. // setItem('MY_URL',MY_URL);
  719. if(p==='*'){
  720. vod.vod_play_from = '道长在线';
  721. vod.vod_remarks = detailUrl;
  722. vod.vod_actor = '没有二级,只有一级链接直接嗅探播放';
  723. vod.vod_content = MY_URL;
  724. vod.vod_play_url = '嗅探播放$' + MY_URL;
  725. }else if(typeof(p)==='string'&&p.trim().startsWith('js:')){
  726. const TYPE = 'detail';
  727. var input = MY_URL;
  728. eval(p.trim().replace('js:',''));
  729. }else if(p&&typeof(p)==='object'){
  730. if(!html){
  731. html = getHtml(MY_URL);
  732. }
  733. if(p.title){
  734. let p1 = p.title.split(';');
  735. vod.vod_name = pdfh(html, p1[0]).replaceAll('\n', ' ').trim();
  736. let type_name = p1.length > 1 ? pdfh(html, p1[1]).replaceAll('\n', ' ').trim():'';
  737. vod.type_name = type_name||vod.type_name;
  738. }
  739. if(p.desc){
  740. try{
  741. let p1 = p.desc.split(';');
  742. vod.vod_remarks = pdfh(html, p1[0]).replaceAll('\n', ' ').trim();
  743. vod.vod_year = p1.length > 1 ? pdfh(html, p1[1]).replaceAll('\n', ' ').trim():'';
  744. vod.vod_area = p1.length > 2 ? pdfh(html, p1[2]).replaceAll('\n', ' ').trim():'';
  745. vod.vod_actor = p1.length > 3 ? pdfh(html, p1[3]).replaceAll('\n', ' ').trim():'';
  746. vod.vod_director = p1.length > 4 ? pdfh(html, p1[4]).replaceAll('\n', ' ').trim():'';
  747. }
  748. catch (e) {
  749. }
  750. }
  751. if(p.content){
  752. try{
  753. let p1 = p.content.split(';');
  754. vod.vod_content = pdfh(html, p1[0]).replaceAll('\n', ' ').trim();
  755. }
  756. catch (e) {}
  757. }
  758. if(p.img){
  759. try{
  760. let p1 = p.img.split(';');
  761. vod.vod_pic = pD(html, p1[0],MY_URL);
  762. }
  763. catch (e) {}
  764. }
  765. let vod_play_from = '$$$';
  766. let playFrom = [];
  767. if(p.重定向&&p.重定向.startsWith('js:')){
  768. html = eval(p.重定向.replace('js:',''));
  769. }
  770. // console.log(2);
  771. if(p.tabs){
  772. let p_tab = p.tabs.split(';')[0];
  773. console.log(p_tab);
  774. let vHeader = pdfa(html, p_tab);
  775. console.log(vHeader.length);
  776. for(let v of vHeader){
  777. let v_title = pdfh(v,'body&&Text');
  778. console.log(v_title);
  779. if(tab_exclude&& (new RegExp(tab_exclude)).test(v_title)){
  780. continue;
  781. }
  782. playFrom.push(v_title);
  783. }
  784. console.log(JSON.stringify(playFrom));
  785. }else{
  786. playFrom = ['道长在线']
  787. }
  788. vod.vod_play_from = playFrom.join(vod_play_from);
  789. // console.log(3);
  790. let vod_play_url = '$$$';
  791. let vod_tab_list = [];
  792. if(p.lists){
  793. for(let i=0;i<playFrom.length;i++){
  794. let tab_name = playFrom[i];
  795. let tab_ext = p.tabs.split(';').length > 1 ? p.tabs.split(';')[1] : '';
  796. let p1 = p.lists.replaceAll('#idv', tab_name).replaceAll('#id', i);
  797. tab_ext = tab_ext.replaceAll('#idv', tab_name).replaceAll('#id', i);
  798. console.log(p1);
  799. // console.log(html);
  800. let vodList = [];
  801. try {
  802. vodList = pdfa(html, p1);
  803. console.log('len(vodList):'+vodList.length);
  804. }catch (e) {
  805. // console.log(e.message);
  806. }
  807. let new_vod_list = [];
  808. let tabName = tab_ext?pdfh(html, tab_ext):tab_name;
  809. console.log(tabName);
  810. vodList.forEach(it=>{
  811. new_vod_list.push(pdfh(it,'body&&Text')+'$'+pD(it,'a&&href',MY_URL));
  812. });
  813. let vlist = new_vod_list.join('#');
  814. vod_tab_list.push(vlist);
  815. }
  816. }
  817. vod.vod_play_url = vod_tab_list.join(vod_play_url);
  818. }
  819. // console.log(JSON.stringify(vod));
  820. return JSON.stringify({
  821. list: [vod]
  822. })
  823. }
  824. /**
  825. * 选集播放点击事件解析
  826. * @param playObj
  827. * @returns {string}
  828. */
  829. function playParse(playObj){
  830. MY_URL = playObj.url;
  831. var input = MY_URL;
  832. let common_play = {
  833. parse:1,
  834. url:MY_URL
  835. };
  836. let lazy_play;
  837. if(!rule.play_parse||!rule.lazy){
  838. lazy_play = common_play;
  839. }else if(rule.play_parse&&rule.lazy&&typeof(rule.lazy)==='string'){
  840. try {
  841. eval(rule.lazy.replace('js:').trim());
  842. lazy_play = typeof(input) === 'object'?input:{
  843. parse:1,
  844. jx:1,
  845. url:input
  846. };
  847. }catch (e) {
  848. lazy_play = common_play;
  849. }
  850. }else{
  851. lazy_play = common_play;
  852. }
  853. console.log(JSON.stringify(lazy_play));
  854. return JSON.stringify(lazy_play);
  855. }
  856. /**
  857. * js源预处理特定返回对象中的函数
  858. * @param ext
  859. */
  860. function init(ext) {
  861. console.log("init");
  862. try {
  863. init_test();
  864. }catch (e) {
  865. console.log('init_test发生错误:'+e.message);
  866. }
  867. }
  868. /**
  869. * js源获取首页分类和筛选特定返回对象中的函数
  870. * @param filter 筛选条件字典对象
  871. * @returns {string}
  872. */
  873. function home(filter) {
  874. console.log("home");
  875. let homeObj = {
  876. filter:rule.filter||false,
  877. MY_URL: rule.host,
  878. class_name: rule.class_name || '',
  879. class_url: rule.class_url || '',
  880. class_parse: rule.class_parse || '',
  881. cate_exclude: rule.cate_exclude,
  882. };
  883. return homeParse(homeObj);
  884. }
  885. /**
  886. * js源获取首页推荐数据列表特定返回对象中的函数
  887. * @param params
  888. * @returns {string}
  889. */
  890. function homeVod(params) {
  891. let homeUrl = rule.host&&rule.homeUrl?urljoin(rule.host,rule.homeUrl):(rule.homeUrl||rule.host);
  892. let detailUrl = rule.host&&rule.detailUrl?urljoin(rule.host,rule.detailUrl):rule.detailUrl;
  893. let homeVodObj = {
  894. 推荐:rule.推荐,
  895. double:rule.double,
  896. homeUrl:homeUrl,
  897. detailUrl:detailUrl
  898. };
  899. return homeVodParse(homeVodObj)
  900. // return "{}";
  901. }
  902. /**
  903. * js源获取分类页一级数据列表特定返回对象中的函数
  904. * @param tid 分类id
  905. * @param pg 页数
  906. * @param filter 当前选中的筛选条件
  907. * @param extend 扩展
  908. * @returns {string}
  909. */
  910. function category(tid, pg, filter, extend) {
  911. let cateObj = {
  912. url: urljoin(rule.host, rule.url),
  913. 一级: rule.一级,
  914. tid: tid,
  915. pg: parseInt(pg),
  916. filter: filter,
  917. extend: extend
  918. };
  919. // console.log(JSON.stringify(extend));
  920. return categoryParse(cateObj)
  921. }
  922. /**
  923. * js源获取二级详情页数据特定返回对象中的函数
  924. * @param vod_url 一级列表中的vod_id或者是带分类的自拼接 vod_id 如 fyclass$vod_id
  925. * @returns {string}
  926. */
  927. function detail(vod_url) {
  928. let fyclass = '';
  929. if(vod_url.indexOf('$')>-1){
  930. let tmp = vod_url.split('$');
  931. fyclass = tmp[0];
  932. vod_url = tmp[1];
  933. }
  934. let detailUrl = vod_url;
  935. let url;
  936. rule.homeUrl = urljoin(rule.host,rule.homeUrl);
  937. rule.detailUrl = urljoin(rule.host,rule.detailUrl);
  938. if(!detailUrl.startsWith('http')&&!detailUrl.includes('/')){
  939. url = rule.detailUrl.replaceAll('fyid', detailUrl).replaceAll('fyclass',fyclass);
  940. }else if(detailUrl.includes('/')){
  941. url = urljoin(rule.homeUrl,detailUrl);
  942. }else{
  943. url = detailUrl
  944. }
  945. let detailObj = {
  946. url:url,
  947. 二级:rule.二级,
  948. detailUrl:detailUrl,
  949. fyclass:fyclass,
  950. tab_exclude:rule.tab_exclude,
  951. }
  952. return detailParse(detailObj)
  953. }
  954. /**
  955. * js源选集按钮播放点击事件特定返回对象中的函数
  956. * @param flag 线路名
  957. * @param id 播放按钮的链接
  958. * @param flags 全局配置的flags是否需要解析的标识列表
  959. * @returns {string}
  960. */
  961. function play(flag, id, flags) {
  962. let playObj = {
  963. url:id,
  964. flag:flag,
  965. flags:flags
  966. }
  967. return playParse(playObj);
  968. }
  969. /**
  970. * js源搜索返回的数据列表特定返回对象中的函数
  971. * @param wd 搜索关键字
  972. * @param quick 是否来自快速搜索
  973. * @returns {string}
  974. */
  975. function search(wd, quick) {
  976. let searchObj = {
  977. searchUrl: urljoin(rule.host, rule.searchUrl),
  978. 搜索: rule.搜索,
  979. wd: wd,
  980. //pg: pg,
  981. pg: 1,
  982. quick: quick,
  983. };
  984. // console.log(JSON.stringify(searchObj));
  985. return searchParse(searchObj)
  986. }
  987. function DRPY(){//导出函数
  988. return {
  989. init: init,
  990. home: home,
  991. homeVod: homeVod,
  992. category: category,
  993. detail: detail,
  994. play: play,
  995. search: search,
  996. }
  997. }
  998. // 导出函数对象
  999. export default {
  1000. init: init,
  1001. home: home,
  1002. homeVod: homeVod,
  1003. category: category,
  1004. detail: detail,
  1005. play: play,
  1006. search: search,
  1007. DRPY:DRPY
  1008. }