drpy2.js 112 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022
  1. import cheerio from 'assets://js/lib/cheerio.min.js';
  2. import 'assets://js/lib/crypto-js.js';
  3. import './jsencrypt.js';
  4. import './pako.min.js';
  5. // import JSEncrypt from './jsencrypt.js'; // 会导致壳子崩溃的
  6. import 模板 from './模板.js'
  7. import {gbkTool} from './gbk.js'
  8. // import cheerio from "https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/cheerio.min.js";
  9. // import "https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/crypto-js.js";
  10. // import 模板 from"https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/js/模板.js";
  11. // import {gbkTool} from 'https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/gbk.js'
  12. function init_test(){
  13. // console.log(typeof(CryptoJS));
  14. console.log("init_test_start");
  15. // print(模板);
  16. // print(typeof(模板.getMubans));
  17. console.log("当前版本号:"+VERSION);
  18. console.log('本地代理地址:'+getProxyUrl());
  19. console.log(RKEY);
  20. // console.log('Uint8Array:'+typeof(Uint8Array)+' '+'Uint16Array:'+typeof(Uint16Array));
  21. // console.log('encodeURIComponent:'+typeof(encodeURIComponent)+' '+'decodeURIComponent:'+typeof(decodeURIComponent));
  22. // console.log('atob:'+typeof(atob)+' '+'btoa:'+typeof(btoa));
  23. // log('typeof (JSEncrypt):'+typeof (JSEncrypt));
  24. // log('typeof (pako):'+typeof (pako));
  25. // let b64_str = btoa('hello hipy');
  26. // let str = atob(b64_str);
  27. // console.log(`btoa加密文本:${b64_str},atob解密文本:${str}`)
  28. // let gzip_str = gzip('{"a":"电影","b":"电影","c":"电影","d":"电影","e":"电影","f":"电影"}');
  29. // let ungzip_str = ungzip(gzip_str);
  30. // console.log(`gzip加密文本:${gzip_str},长度:${gzip_str.length},ungzip解密文本:${ungzip_str},长度:${ungzip_str.length}`);
  31. // let a = {"1":[{"key":"类型","name":"类型","value":[{"n":"全部","v":""},{"n":"Netflix","v":"NETFLIX"},{"n":"剧情","v":"剧情"},{"n":"喜剧","v":"喜剧"},{"n":"动作","v":"动作"},{"n":"爱情","v":"爱情"},{"n":"恐怖","v":"恐怖"},{"n":"惊悚","v":"惊悚"},{"n":"犯罪","v":"犯罪"},{"n":"科幻","v":"科幻"},{"n":"悬疑","v":"悬疑"},{"n":"奇幻","v":"奇幻"},{"n":"冒险","v":"冒险"},{"n":"战争","v":"战争"},{"n":"历史","v":"历史"},{"n":"古装","v":"古装"},{"n":"家庭","v":"家庭"},{"n":"传记","v":"传记"},{"n":"武侠","v":"武侠"},{"n":"歌舞","v":"歌舞"},{"n":"短片","v":"短片"},{"n":"动画","v":"动画"},{"n":"儿童","v":"儿童"},{"n":"职场","v":"职场"}]},{"key":"地区","name":"地区","value":[{"n":"全部","v":""},{"n":"大陆","v":"中国大陆"},{"n":"香港","v":"中国香港"},{"n":"台湾","v":"中国台湾"},{"n":"美国","v":"美国"},{"n":"日本","v":"日本"},{"n":"韩国","v":"韩国"},{"n":"英国","v":"英国"},{"n":"法国","v":"法国"},{"n":"德国","v":"德国"},{"n":"印度","v":"印度"},{"n":"泰国","v":"泰国"},{"n":"丹麦","v":"丹麦"},{"n":"瑞典","v":"瑞典"},{"n":"巴西","v":"巴西"},{"n":"加拿大","v":"加拿大"},{"n":"俄罗斯","v":"俄罗斯"},{"n":"意大利","v":"意大利"},{"n":"比利时","v":"比利时"},{"n":"爱尔兰","v":"爱尔兰"},{"n":"西班牙","v":"西班牙"},{"n":"澳大利亚","v":"澳大利亚"},{"n":"其他","v":"其他"}]},{"key":"语言","name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"粤语","v":"粤语"},{"n":"英语","v":"英语"},{"n":"日语","v":"日语"},{"n":"韩语","v":"韩语"},{"n":"法语","v":"法语"},{"n":"其他","v":"其他"}]},{"key":"年份","name":"年份","value":[{"n":"全部","v":""},{"n":"2024","v":"2024"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"10年代","v":"2010_2019"},{"n":"00年代","v":"2000_2009"},{"n":"90年代","v":"1990_1999"},{"n":"80年代","v":"1980_1989"},{"n":"更早","v":"0_1979"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"},{"n":"评分","v":"4"}]}],"2":[{"key":"类型","name":"类型","value":[{"n":"全部","v":""},{"n":"Netflix","v":"Netflix"},{"n":"剧情","v":"剧情"},{"n":"爱情","v":"爱情"},{"n":"喜剧","v":"喜剧"},{"n":"犯罪","v":"犯罪"},{"n":"悬疑","v":"悬疑"},{"n":"古装","v":"古装"},{"n":"动作","v":"动作"},{"n":"家庭","v":"家庭"},{"n":"惊悚","v":"惊悚"},{"n":"奇幻","v":"奇幻"},{"n":"美剧","v":"美剧"},{"n":"科幻","v":"科幻"},{"n":"历史","v":"历史"},{"n":"战争","v":"战争"},{"n":"韩剧","v":"韩剧"},{"n":"武侠","v":"武侠"},{"n":"言情","v":"言情"},{"n":"恐怖","v":"恐怖"},{"n":"冒险","v":"冒险"},{"n":"都市","v":"都市"},{"n":"职场","v":"职场"}]},{"key":"地区","name":"地区","value":[{"n":"地区","v":""},{"n":"大陆","v":"中国大陆"},{"n":"香港","v":"中国香港"},{"n":"韩国","v":"韩国"},{"n":"美国","v":"美国"},{"n":"日本","v":"日本"},{"n":"法国","v":"法国"},{"n":"英国","v":"英国"},{"n":"德国","v":"德国"},{"n":"台湾","v":"中国台湾"},{"n":"泰国","v":"泰国"},{"n":"印度","v":"印度"},{"n":"其他","v":"其他"}]},{"key":"语言","name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"粤语","v":"粤语"},{"n":"英语","v":"英语"},{"n":"日语","v":"日语"},{"n":"韩语","v":"韩语"},{"n":"法语","v":"法语"},{"n":"其他","v":"其他"}]},{"key":"年份","name":"年份","value":[{"n":"全部","v":""},{"n":"2024","v":"2024"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"10年代","v":"2010_2019"},{"n":"00年代","v":"2000_2009"},{"n":"90年代","v":"1990_1999"},{"n":"80年代","v":"1980_1989"},{"n":"更早","v":"0_1979"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"},{"n":"评分","v":"4"}]}],"3":[{"key":"类型","name":"类型","value":[{"n":"全部","v":""},{"n":"Netflix","v":"Netflix"},{"n":"动态漫画","v":"动态漫画"},{"n":"剧情","v":"剧情"},{"n":"动画","v":"动画"},{"n":"喜剧","v":"喜剧"},{"n":"冒险","v":"冒险"},{"n":"动作","v":"动作"},{"n":"奇幻","v":"奇幻"},{"n":"科幻","v":"科幻"},{"n":"儿童","v":"儿童"},{"n":"搞笑","v":"搞笑"},{"n":"爱情","v":"爱情"},{"n":"家庭","v":"家庭"},{"n":"短片","v":"短片"},{"n":"热血","v":"热血"},{"n":"益智","v":"益智"},{"n":"悬疑","v":"悬疑"},{"n":"经典","v":"经典"},{"n":"校园","v":"校园"},{"n":"Anime","v":"Anime"},{"n":"运动","v":"运动"},{"n":"亲子","v":"亲子"},{"n":"青春","v":"青春"},{"n":"恋爱","v":"恋爱"},{"n":"武侠","v":"武侠"},{"n":"惊悚","v":"惊悚"}]},{"key":"地区","name":"地区","value":[{"n":"全部","v":""},{"n":"日本","v":"日本"},{"n":"大陆","v":"中国大陆"},{"n":"台湾","v":"中国台湾"},{"n":"美国","v":"美国"},{"n":"香港","v":"中国香港"},{"n":"韩国","v":"韩国"},{"n":"英国","v":"英国"},{"n":"法国","v":"法国"},{"n":"德国","v":"德国"},{"n":"印度","v":"印度"},{"n":"泰国","v":"泰国"},{"n":"丹麦","v":"丹麦"},{"n":"瑞典","v":"瑞典"},{"n":"巴西","v":"巴西"},{"n":"加拿大","v":"加拿大"},{"n":"俄罗斯","v":"俄罗斯"},{"n":"意大利","v":"意大利"},{"n":"比利时","v":"比利时"},{"n":"爱尔兰","v":"爱尔兰"},{"n":"西班牙","v":"西班牙"},{"n":"澳大利亚","v":"澳大利亚"},{"n":"其他","v":"其他"}]},{"key":"语言","name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"粤语","v":"粤语"},{"n":"英语","v":"英语"},{"n":"日语","v":"日语"},{"n":"韩语","v":"韩语"},{"n":"法语","v":"法语"},{"n":"其他","v":"其他"}]},{"key":"年份","name":"年份","value":[{"n":"全部","v":""},{"n":"2024","v":"2024"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"10年代","v":"2010_2019"},{"n":"00年代","v":"2000_2009"},{"n":"90年代","v":"1990_1999"},{"n":"80年代","v":"1980_1989"},{"n":"更早","v":"0_1979"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"},{"n":"评分","v":"4"}]}],"4":[{"key":"类型","name":"类型","value":[{"n":"全部","v":""},{"n":"纪录","v":"纪录"},{"n":"真人秀","v":"真人秀"},{"n":"记录","v":"记录"},{"n":"脱口秀","v":"脱口秀"},{"n":"剧情","v":"剧情"},{"n":"历史","v":"历史"},{"n":"喜剧","v":"喜剧"},{"n":"传记","v":"传记"},{"n":"相声","v":"相声"},{"n":"节目","v":"节目"},{"n":"歌舞","v":"歌舞"},{"n":"冒险","v":"冒险"},{"n":"运动","v":"运动"},{"n":"Season","v":"Season"},{"n":"犯罪","v":"犯罪"},{"n":"短片","v":"短片"},{"n":"搞笑","v":"搞笑"},{"n":"晚会","v":"晚会"}]},{"key":"地区","name":"地区","value":[{"n":"全部","v":""},{"n":"大陆","v":"中国大陆"},{"n":"香港","v":"中国香港"},{"n":"台湾","v":"中国台湾"},{"n":"美国","v":"美国"},{"n":"日本","v":"日本"},{"n":"韩国","v":"韩国"},{"n":"其他","v":"其他"}]},{"key":"语言","name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"粤语","v":"粤语"},{"n":"英语","v":"英语"},{"n":"日语","v":"日语"},{"n":"韩语","v":"韩语"},{"n":"法语","v":"法语"},{"n":"其他","v":"其他"}]},{"key":"年份","name":"年份","value":[{"n":"全部","v":""},{"n":"2024","v":"2024"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"10年代","v":"2010_2019"},{"n":"00年代","v":"2000_2009"},{"n":"90年代","v":"1990_1999"},{"n":"80年代","v":"1980_1989"},{"n":"更早","v":"0_1979"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"},{"n":"评分","v":"4"}]}],"6":[{"key":"类型","name":"类型","value":[{"n":"类型","v":""},{"n":"逆袭","v":"逆袭"},{"n":"甜宠","v":"甜宠"},{"n":"虐恋","v":"虐恋"},{"n":"穿越","v":"穿越"},{"n":"重生","v":"重生"},{"n":"剧情","v":"剧情"},{"n":"科幻","v":"科幻"},{"n":"武侠","v":"武侠"},{"n":"爱情","v":"爱情"},{"n":"动作","v":"动作"},{"n":"战争","v":"战争"},{"n":"冒险","v":"冒险"},{"n":"其它","v":"其它"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"}]}]};
  32. // log(gzip(JSON.stringify(a)));
  33. console.log(JSON.stringify(rule));
  34. console.log("init_test_end");
  35. // log('typeof (JSEncrypt):'+typeof (JSEncrypt));
  36. // let publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwEc7wBMtYKkxvrQNI3+ITBZwAkPkGvsv4TsAHFskKGZWz9eYl3scivhmlEfWHlEkdyb0m82CmB1qAgef+pD4cZu+Cdmm2e9lnExhLwm8cBgpkAen9QRNdjojZgxM0W+JcReH4W6pw+uFXiLRn4AIQkDftWGNLg6wlNS+39Z/RvP9zyATJLZ9AKDdHp62XMxEK1KZvWBuIg+Oa5UzgA9jy+2XyIqwhBtO8tPbUl21t2pvTzHoLUjSkPNm2LurcUk6+jQ2r6aiS2CN1NXIucPJU6mkuIQ821SjvkYPtIdRMntW4y2u4cyiqVEEQwlzWVMHh+/vfrWAQr9fgjDuYYtvPQIDAQAB';
  37. // let privateKey = 'MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDARzvAEy1gqTG+tA0jf4hMFnACQ+Qa+y/hOwAcWyQoZlbP15iXexyK+GaUR9YeUSR3JvSbzYKYHWoCB5/6kPhxm74J2abZ72WcTGEvCbxwGCmQB6f1BE12OiNmDEzRb4lxF4fhbqnD64VeItGfgAhCQN+1YY0uDrCU1L7f1n9G8/3PIBMktn0AoN0enrZczEQrUpm9YG4iD45rlTOAD2PL7ZfIirCEG07y09tSXbW3am9PMegtSNKQ82bYu6txSTr6NDavpqJLYI3U1ci5w8lTqaS4hDzbVKO+Rg+0h1Eye1bjLa7hzKKpUQRDCXNZUweH7+9+tYBCv1+CMO5hi289AgMBAAECggEBAIRbRJUWXmEwdq64kGbELlV6CIZ2p3mvOSlIjO34Cy7IK7AMz9xOgbpj/XDK9miOIJTouu7ZC7GcZdGZ4BUCYBMMS0fKjGFuurpZlXhkslNTPqEHtCUkXhIpOR7RDrwIlErGEOIsZC4aXQcM3tF1t7mroJLh4OY4dHMu82lv5NM4hhFMNvHzXVvrPXeTzw26gddHVG/ke0WUYOcB5j3cPp8xaVp7JV8bdxtGtkqIfBLY/dIczzJu/3F3cBpU2nNwt8uVUF/w/HKlr7j8FqqFHXWh182beU0n5AIdRyRJBrRUAEhdtsUnvJOVBDqzZa+9DJ5395F7V8KRlQptxETdhCECgYEA4x/2HM9fnVIhG6wTbEt1LhGTKYb/igMAHLqquEMfRsB44tobI8gVNwR3qJQY/nKXxcQemQV29PcdqpENCKyXUXGD8SI1UPg15rHFBI8CIqlCXfzJybdHjmzlhaA9I5lofIVh+5MW7WkvHZoRy7NeDMhHUuaiveuqC4OJ8n+dD2kCgYEA2LkmUVef3WkBBwUBRdkyoog3DMwR+/ubb0ncJVYy3ItYVJltQ4HqmrRiJc8xBAoFnG8rbiqDnmTnDR3WbuxU1G2hml09fqId+rQds2UfESswCXHU43A4f77m1XyA6PprBxpozVIcmK69N4rR9jOXflLWo3O+p2ipUbmNpId7+rUCgYBSpcbBJRT+AmzZzPwkZDD32p1ady114zGfQq3s7z/qVw+mPQezNZPCuXVxerK9pKVl6b/Ynwxyh5nb/3xms6c8k7oXfQM5u5ihof63cfKs+jqUSPCE3pTDVw0OWwjkc2Z6KW9GRHgLXEMw2mevYE3RCPArUpHV2nO+TNddzuIwQQKBgQDOZwdnUNygMfEYjlu3+jOPN8u2FGTMZ8SRKPbRWFb4VH27lKPLN2AIFuOivsEf56uQYRAry7GumMq0Y0ZmPg5Mglz2dvaqNBv5OLFQuW3tHAST+iWWtroYb+fISts7B8QG79AAO8OgZksvKrbslBYj6SEiaomZRsR7YQzVNXOOQQKBgQCovElZ50c8ZJ6m9D9fw3Nes7u9vshpyyac5tt4tZ7yfU4l5pWGrIUqCE703qZp4NAqEvlZUCJbj9kkysaj/2MfFb2b9jSvdNB+V/YW9Cwg+5TziYoOcQzN1z2u4p4goTAv0S+pTNSr3qWaTUI4TXUXQajif45Fexv+MrP5AAXQyw=='
  38. // // let text = '你好';
  39. // let text = '[{"vod_name":"兔小贝原创儿歌","vod_pic":"https://resource-cdn.tuxiaobei.com/video-album/FnQ8ieJHgsbgCKWXNBg4uoOmKgG5.jpg","vod_remarks":"共229首","vod_content":"","vod_id":"/subject/17@@兔小贝原创儿歌@@https://resource-cdn.tuxiaobei.com/video-album/FnQ8ieJHgsbgCKWXNBg4uoOmKgG5.jpg"},{"vod_name":"英文儿歌","vod_pic":"https://resource-cdn.tuxiaobei.com/video-album/Fqjpx2H_-QaYNAYn2MekRuDpeyUv.jpg","vod_remarks":"共10首","vod_content":"","vod_id":"/subject/23@@英文儿歌@@https://resource-cdn.tuxiaobei.com/video-album/Fqjpx2H_-QaYNAYn2MekRuDpeyUv.jpg"}]';
  40. // let str = RSA.encode(text, publicKey);
  41. // console.log("加密数据:" + str);
  42. // let str1 = 'Wa2c/868VOm0PgpGG2s2aMrDbGOlJRdZXlSGswjFgywd3nZNB7ND8kVMdNB/OsNFoQXJXSJMvPaE73BH7rs8fz54JGdYQK+qTgfQRqQZvomCjbzseSR4bm4NOrtIOOslL3WqxlzOuU0M1P1eERmkLEVU2WSyc3RGtJro3b3MOWYCNdKMoZdncfOHJndkl4wm9V3GGc3uH98hs6OxLvBWgXoW9jZQ3n0vR2FtS2KYrPGuSuKGkxlt9Kw5TD6nri142NOimz05WK55Xe04YUQ1VZd51t0wzJGXolWgfzIQaK2zzhk5Zjlm+IQJxXqEWiJ2+O6TJ+lIttvsDSaUflcDXQ==';
  43. // let str2 = 'R86mW9DzBw05pxBSh9ECh1stXxINmnudgZBbzU/cz1EcFgrEgdk0Zk4ruAiJZB2fP5c7d3gMmN8+Dv19IfARWSzw85xCEjUhpdcMJ0jn6ZE5H+muadND9LzjeVisojqwYxot3YVdKof7HMhPFN8QR0jfzqhjmnGFTlY1jMXzJK0MSOLNRLDar480CdKNb/cxALC8+xKIlhM9E4B31t8J4rNMUWSCAr49lbZ3jx3PxieBpTQUdDJz96AttR93Pc+c51wrxh0Ch/Mt4Rs09HGMXwIpNV+CxsGwSGRQUlyJo2k3d0WqsVzpz6S8A4VGEMTRLGI3IjEt+eWt7wM3nAXarg==';
  44. // let str3 = 'D4eOsRqua+jYA5+ZOR9PLI2PExKjKfArQfv9/wGeG50bQSjWypShJPY6RQfO+rghyf0juzHIUSxqH91OxinhCFkONaF2Vod2QVyphyn9eh73dAcEFKIFFKGXoPCjbMWrr3p4d+hgVrHzrFeGqkRq8JFOvG2L5XDxVfWbV8KmUA0DKuz6QwWg7P4kesy+C7BbLALy5W/wfZchD3gnsBvx/pjFoe11VfAify9isLxg9a15jj52xr6lzQ9kge9C2JcV8yq85bFKaUpJWgobzz+BSIv3lVMU6vgcldmOrhkyiETpFGFGGF00DphGCEoK6uAyyNDh7+Jn8P17zf/DW1wV3A==';
  45. // let uncrypted = RSA.decode(str, privateKey);
  46. // log('解密数据:'+uncrypted);
  47. // uncrypted = RSA.decode(str1, privateKey);
  48. // log('解密数据1:'+uncrypted);
  49. // uncrypted = RSA.decode(str2, privateKey);
  50. // log('解密数据2:'+uncrypted);
  51. // uncrypted = RSA.decode(str3, privateKey);
  52. // log('解密数据3:'+uncrypted);
  53. // log('rsax:'+typeof(rsax));
  54. // log('rsaX:'+typeof(rsaX));
  55. // let data = base64Encode('你好');
  56. // let publicKey = 'dzyyds';
  57. // console.log(typeof (RSA.encode));
  58. // let encryptBase64Data = RSA.encode(data,publicKey);
  59. // log('encryptBase64Data:'+encryptBase64Data);
  60. // let str = RSA.decode(data,publicKey);
  61. // log('str:'+str);
  62. }
  63. /**
  64. * 执行预处理代码
  65. */
  66. function pre(){
  67. if(typeof(rule.预处理) === 'string' && rule.预处理 && rule.预处理.trim()){
  68. let code = rule.预处理.trim();
  69. console.log("执行预处理代码:"+code);
  70. if(code.startsWith('js:')){
  71. code = code.replace('js:','');
  72. }
  73. try {
  74. // code里可以进行get 或者 post请求cookie并改变rule.headers 里的cookie
  75. // 直接操作 rule_fetch_params 这个变量 .headers.Cookie
  76. eval(code);
  77. }catch (e) {
  78. console.log('预处理执行失败:'+e.message);
  79. }
  80. }
  81. }
  82. let rule = {};
  83. let vercode = typeof(pdfl) ==='function'?'drpy2.1':'drpy2';
  84. const VERSION = vercode+' 3.9.50beta6 202400504';
  85. /** 已知问题记录
  86. * 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
  87. * Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
  88. * 2.import es6py.js但是里面的函数没有被装载进来.比如drpy规则报错setResult2 is undefiend(合并文件了可以不管了)
  89. * 3.无法重复导入cheerio(怎么解决drpy和parseTag里都需要导入cheerio的问题) 无法在副文件导入cheerio (现在是全部放在drpy一个文件里了,凑合解决?)
  90. * 4.有个错误不知道哪儿来的 executeScript: com.quickjs.JSObject$Undefined cannot be cast to java.lang.String 在 点击选集播放打印init_test_end后面打印(貌似不影响使用)
  91. * 5.需要实现 stringify 函数,比起JSON.strifngify函数,它会原封不动保留中文不会编码unicode
  92. * 6.base64Encode,base64Decode,md5函数还没有实现 (抄影魔代码实现了)
  93. * 7.eval(getCryptoJS());还没有实现 (可以空实现了,以后遇到能忽略)
  94. * done: jsp:{pdfa,pdfh,pd},json:{pdfa,pdfh,pd},jq:{pdfa,pdfh,pd}
  95. * 8.req函数不支持传递字符串的data参数 {'content-type':'text/plain'} 类型数据,因此无法直接调用alist的ocr接口
  96. * * 电脑看日志调试
  97. adb tcpip 5555
  98. adb connect 192.168.10.192
  99. adb devices -l
  100. adb logcat -c
  101. adb logcat | grep -i QuickJS
  102. adb logcat -c -b events
  103. adb logcat -c -b main -b events -b radio -b system
  104. adb logcat > 2.log DRPY:E | grep -i QuickJS
  105. * **/
  106. /*** 以下是内置变量和解析方法 **/
  107. 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';
  108. 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';
  109. const UA = 'Mozilla/5.0';
  110. 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';
  111. 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';
  112. const RULE_CK = 'cookie'; // 源cookie的key值
  113. // const KEY = typeof(key)!=='undefined'&&key?key:'drpy_' + (rule.title || rule.host); // 源的唯一标识
  114. const CATE_EXCLUDE = '首页|留言|APP|下载|资讯|新闻|动态';
  115. const TAB_EXCLUDE = '猜你|喜欢|下载|剧情|热播';
  116. const OCR_RETRY = 3;//ocr验证重试次数
  117. // const OCR_API = 'http://dm.mudery.com:10000';//ocr在线识别接口
  118. // const OCR_API = 'http://192.168.3.239:5705/parse/ocr';//ocr在线识别接口
  119. // const OCR_API = 'http://cms.nokia.press/parse/ocr';//ocr在线识别接口
  120. // const OCR_API = 'http://cms.nokia.press:5707/parse/ocr';//ocr在线识别接口
  121. const OCR_API = 'http://drpy.nokia.press:8028/ocr/drpy/text';//ocr在线识别接口
  122. if(typeof(MY_URL)==='undefined'){
  123. var MY_URL; // 全局注入变量,pd函数需要
  124. }
  125. var HOST;
  126. var RKEY; // 源的唯一标识
  127. var fetch;
  128. var print;
  129. var log;
  130. var rule_fetch_params;
  131. var fetch_params; // 每个位置单独的
  132. var oheaders;
  133. // var play_url; // 二级详情页注入变量,为了适配js模式0 (不在这里定义了,直接二级里定义了个空字符串)
  134. var _pdfh;
  135. var _pdfa;
  136. var _pd;
  137. // const DOM_CHECK_ATTR = ['url', 'src', 'href', 'data-original', 'data-src'];
  138. const DOM_CHECK_ATTR = /(url|src|href|-original|-src|-play|-url|style)$/;
  139. // 过滤特殊链接,不走urlJoin
  140. const SPECIAL_URL = /^(ftp|magnet|thunder|ws):/;
  141. const NOADD_INDEX = /:eq|:lt|:gt|:first|:last|^body$|^#/; // 不自动加eq下标索引
  142. const URLJOIN_ATTR = /(url|src|href|-original|-src|-play|-url|style)$/; // 需要自动urljoin的属性
  143. const SELECT_REGEX = /:eq|:lt|:gt|#/g;
  144. const SELECT_REGEX_A = /:eq|:lt|:gt/g;
  145. // 增加$js工具,支持$js.toString(()=>{});
  146. const $js = {
  147. toString(func) {
  148. let strfun = func.toString();
  149. return strfun.replace(/^\(\)(\s+)?=>(\s+)?\{/, "js:").replace(/\}$/,'');
  150. }
  151. };
  152. function window_b64(){
  153. let b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  154. let base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
  155. function btoa(str) {
  156. var out, i, len;
  157. var c1, c2, c3;
  158. len = str.length;
  159. i = 0;
  160. out = "";
  161. while (i < len) {
  162. c1 = str.charCodeAt(i++) & 0xff;
  163. if (i == len) {
  164. out += b64map.charAt(c1 >> 2);
  165. out += b64map.charAt((c1 & 0x3) << 4);
  166. out += "==";
  167. break;
  168. }
  169. c2 = str.charCodeAt(i++);
  170. if (i == len) {
  171. out += b64map.charAt(c1 >> 2);
  172. out += b64map.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  173. out += b64map.charAt((c2 & 0xF) << 2);
  174. out += "=";
  175. break;
  176. }
  177. c3 = str.charCodeAt(i++);
  178. out += b64map.charAt(c1 >> 2);
  179. out += b64map.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  180. out += b64map.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
  181. out += b64map.charAt(c3 & 0x3F);
  182. }
  183. return out;
  184. }
  185. function atob(str) {
  186. var c1, c2, c3, c4;
  187. var i, len, out;
  188. len = str.length;
  189. i = 0;
  190. out = "";
  191. while (i < len) {
  192. do {
  193. c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
  194. } while (i < len && c1 == -1);
  195. if (c1 == -1) break;
  196. do {
  197. c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
  198. } while (i < len && c2 == -1);
  199. if (c2 == -1) break;
  200. out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
  201. do {
  202. c3 = str.charCodeAt(i++) & 0xff;
  203. if (c3 == 61) return out;
  204. c3 = base64DecodeChars[c3];
  205. } while (i < len && c3 == -1);
  206. if (c3 == -1) break;
  207. out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
  208. do {
  209. c4 = str.charCodeAt(i++) & 0xff;
  210. if (c4 == 61) return out;
  211. c4 = base64DecodeChars[c4];
  212. } while (i < len && c4 == -1);
  213. if (c4 == -1) break;
  214. out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
  215. }
  216. return out;
  217. }
  218. return {
  219. atob,
  220. btoa
  221. }
  222. }
  223. /**
  224. es6py扩展
  225. */
  226. if(typeof atob != 'function' || typeof btoa!='function'){
  227. var {atob,btoa} = window_b64();
  228. }
  229. if (typeof Object.assign != 'function') {
  230. Object.assign = function () {
  231. let target = arguments[0];
  232. for (let i = 1; i < arguments.length; i++) {
  233. let source = arguments[i];
  234. for (let key in source) {
  235. if (Object.prototype.hasOwnProperty.call(source, key)) {
  236. target[key] = source[key];
  237. }
  238. }
  239. }
  240. return target;
  241. };
  242. }
  243. if (!String.prototype.includes) {
  244. String.prototype.includes = function (search, start) {
  245. if (typeof start !== 'number') {
  246. start = 0;
  247. }
  248. if (start + search.length > this.length) {
  249. return false;
  250. } else {
  251. return this.indexOf(search, start) !== -1;
  252. }
  253. };
  254. }
  255. if (!Array.prototype.includes) {
  256. Object.defineProperty(Array.prototype, 'includes', {
  257. value: function (searchElement, fromIndex) {
  258. if (this == null) {//this是空或者未定义,抛出错误
  259. throw new TypeError('"this" is null or not defined');
  260. }
  261. var o = Object(this);//将this转变成对象
  262. var len = o.length >>> 0;//无符号右移0位,获取对象length属性,如果未定义就会变成0
  263. if (len === 0) {//length为0直接返回false未找到目标值
  264. return false;
  265. }
  266. var n = fromIndex | 0;//查找起始索引
  267. var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);//计算正确起始索引,因为有可能是负值
  268. while (k < len) {//从起始索引处开始循环
  269. if (o[k] === searchElement) {//如果某一位置与寻找目标相等,返回true,找到了
  270. return true;
  271. }
  272. k++;
  273. }
  274. return false;//未找到,返回false
  275. }
  276. });
  277. }
  278. if (typeof String.prototype.startsWith != 'function') {
  279. String.prototype.startsWith = function (prefix){
  280. return this.slice(0, prefix.length) === prefix;
  281. };
  282. }
  283. if (typeof String.prototype.endsWith != 'function') {
  284. String.prototype.endsWith = function(suffix) {
  285. return this.indexOf(suffix, this.length - suffix.length) !== -1;
  286. };
  287. }
  288. Object.prototype.myValues=function(obj){
  289. if(obj ==null) {
  290. throw new TypeError("Cannot convert undefined or null to object");
  291. }
  292. var res=[]
  293. for(var k in obj){
  294. if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
  295. res.push(obj[k]);
  296. }
  297. }
  298. return res;
  299. }
  300. if (typeof Object.prototype.values != 'function') {
  301. Object.prototype.values=function(obj){
  302. if(obj ==null) {
  303. throw new TypeError("Cannot convert undefined or null to object");
  304. }
  305. var res=[]
  306. for(var k in obj){
  307. if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
  308. res.push(obj[k]);
  309. }
  310. }
  311. return res;
  312. }
  313. }
  314. if (typeof Array.prototype.join != 'function') {
  315. Array.prototype.join = function (emoji) {
  316. // emoji = emoji||',';
  317. emoji = emoji||'';
  318. let self = this;
  319. let str = "";
  320. let i = 0;
  321. if (!Array.isArray(self)) {throw String(self)+'is not Array'}
  322. if(self.length===0){return ''}
  323. if (self.length === 1){return String(self[0])}
  324. i = 1;
  325. str = this[0];
  326. for (; i < self.length; i++) {
  327. str += String(emoji)+String(self[i]);
  328. }
  329. return str;
  330. };
  331. }
  332. if (typeof Array.prototype.toReversed != 'function') {
  333. Array.prototype.toReversed = function () {
  334. const clonedList = this.slice();
  335. // 倒序新数组
  336. const reversedList = clonedList.reverse();
  337. return reversedList;
  338. };
  339. }
  340. String.prototype.rstrip = function (chars) {
  341. let regex = new RegExp(chars + "$");
  342. return this.replace(regex, "");
  343. };
  344. Array.prototype.append = Array.prototype.push;
  345. String.prototype.strip = String.prototype.trim;
  346. function 是否正版(vipUrl){
  347. let flag = new RegExp('qq\.com|iqiyi\.com|youku\.com|mgtv\.com|bilibili\.com|sohu\.com|ixigua\.com|pptv\.com|miguvideo\.com|le\.com|1905\.com|fun\.tv');
  348. return flag.test(vipUrl);
  349. }
  350. function urlDeal(vipUrl){
  351. if(!vipUrl){
  352. return ''
  353. }
  354. if(!是否正版(vipUrl)){
  355. return vipUrl
  356. }
  357. if(!/miguvideo/.test(vipUrl)){
  358. vipUrl=vipUrl.split('#')[0].split('?')[0];
  359. }
  360. return vipUrl
  361. }
  362. function setResult(d){
  363. if(!Array.isArray(d)){
  364. return []
  365. }
  366. VODS = [];
  367. // print(d);
  368. d.forEach(function (it){
  369. let obj = {
  370. vod_id:it.url||'',
  371. vod_name: it.title||'',
  372. vod_remarks: it.desc||'',
  373. vod_content: it.content||'',
  374. vod_pic: it.pic_url||it.img||'',
  375. };
  376. let keys = Object.keys(it);
  377. if(keys.includes('tname')){
  378. obj.type_name = it.tname||'';
  379. }
  380. if(keys.includes('tid')){
  381. obj.type_id = it.tid||'';
  382. }
  383. if(keys.includes('year')){
  384. obj.vod_year = it.year||'';
  385. }
  386. if(keys.includes('actor')){
  387. obj.vod_actor = it.actor||'';
  388. }
  389. if(keys.includes('director')){
  390. obj.vod_director = it.director||'';
  391. }
  392. if(keys.includes('area')){
  393. obj.vod_area = it.area||'';
  394. }
  395. VODS.push(obj);
  396. });
  397. return VODS
  398. }
  399. function setResult2(res){
  400. VODS = res.list||[];
  401. return VODS
  402. }
  403. function setHomeResult(res){
  404. if(!res||typeof(res)!=='object'){
  405. return []
  406. }
  407. return setResult(res.list);
  408. }
  409. // 猫了个咪
  410. function rc(js) {
  411. if (js === 'maomi_aes.js') {
  412. var a = CryptoJS.enc.Utf8.parse("625222f9149e961d");
  413. var t = CryptoJS.enc.Utf8.parse("5efdtf6060e2o330");
  414. return {
  415. De: function (word) {
  416. word = CryptoJS.enc.Hex.parse(word)
  417. return CryptoJS.AES.decrypt(CryptoJS.enc.Base64.stringify(word), a, {
  418. iv: t,
  419. mode: CryptoJS.mode.CBC,
  420. padding: CryptoJS.pad.Pkcs7
  421. }).toString(CryptoJS.enc.Utf8)
  422. },
  423. En: function (word) {
  424. // print(a);
  425. // print(word);
  426. var Encrypted = CryptoJS.AES.encrypt(word, a, {
  427. iv: t,
  428. mode: CryptoJS.mode.CBC,
  429. padding: CryptoJS.pad.Pkcs7
  430. });
  431. return Encrypted.ciphertext.toString();
  432. }
  433. };
  434. }
  435. return {};
  436. }
  437. // 千万不要用for in 推荐 forEach (for in 会打乱顺序)
  438. //猫函数
  439. function maoss(jxurl, ref, key) {
  440. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  441. eval(getCryptoJS());
  442. try {
  443. var getVideoInfo = function (text) {
  444. return CryptoJS.AES.decrypt(text, key, {iv: iv, padding: CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8);
  445. };
  446. var token_key = key == undefined ? 'dvyYRQlnPRCMdQSe' : key;
  447. if (ref) {
  448. var html = request(jxurl, {
  449. headers: {
  450. 'Referer': ref
  451. }
  452. });
  453. } else {
  454. var html = request(jxurl);
  455. }
  456. // print(html);
  457. if (html.indexOf('&btwaf=') != -1) {
  458. html = request(jxurl + '&btwaf' + html.match(/&btwaf(.*?)"/)[1], {
  459. headers: {
  460. 'Referer': ref
  461. }
  462. })
  463. }
  464. var token_iv = html.split('_token = "')[1].split('"')[0];
  465. var key = CryptoJS.enc.Utf8.parse(token_key);
  466. var iv = CryptoJS.enc.Utf8.parse(token_iv);
  467. // log("iv:"+iv);
  468. // log(html);
  469. // print(key);
  470. // print(iv);
  471. eval(html.match(/var config = {[\s\S]*?}/)[0] + '');
  472. // config.url = config.url.replace(/,/g,'');
  473. // print(config.url);
  474. if (!config.url.startsWith('http')) {
  475. //config.url = decodeURIComponent(AES(config.url, key, iv));
  476. config.url = CryptoJS.AES.decrypt(config.url, key, {
  477. iv: iv,
  478. padding: CryptoJS.pad.Pkcs7
  479. }).toString(CryptoJS.enc.Utf8)
  480. }
  481. return config.url;
  482. } catch (e) {
  483. return '';
  484. }
  485. }
  486. function urlencode (str) {
  487. str = (str + '').toString();
  488. return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
  489. replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
  490. }
  491. function base64Encode(text){
  492. return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(text));
  493. // return text
  494. }
  495. function base64Decode(text){
  496. return CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(text));
  497. // return text
  498. }
  499. function md5(text) {
  500. return CryptoJS.MD5(text).toString();
  501. }
  502. function uint8ArrayToBase64(uint8Array) {
  503. let binaryString = String.fromCharCode.apply(null, Array.from(uint8Array));
  504. return btoa(binaryString);
  505. }
  506. function Utf8ArrayToStr(array) {
  507. var out, i, len, c;
  508. var char2, char3;
  509. out = "";
  510. len = array.length;
  511. i = 0;
  512. while (i < len) {
  513. c = array[i++];
  514. switch (c >> 4) {
  515. case 0:
  516. case 1:
  517. case 2:
  518. case 3:
  519. case 4:
  520. case 5:
  521. case 6:
  522. case 7:
  523. out += String.fromCharCode(c);
  524. break;
  525. case 12:
  526. case 13:
  527. char2 = array[i++];
  528. out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f));
  529. break;
  530. case 14:
  531. char2 = array[i++];
  532. char3 = array[i++];
  533. out += String.fromCharCode(
  534. ((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0)
  535. );
  536. break;
  537. }
  538. }
  539. return out;
  540. }
  541. /**
  542. * gzip压缩base64|压缩率80%+
  543. * @param str
  544. * @returns {string}
  545. */
  546. function gzip(str) {
  547. let arr = pako.gzip(str, {
  548. to: 'string'
  549. });
  550. return uint8ArrayToBase64(arr)
  551. }
  552. /**
  553. * gzip解压base64数据
  554. * @param b64Data
  555. * @returns {string}
  556. */
  557. function ungzip(b64Data) {
  558. let strData = atob(b64Data);
  559. const charData = strData.split('').map(function(x) {
  560. return x.charCodeAt(0);
  561. });
  562. const binData = new Uint8Array(charData);
  563. const data = pako.inflate(binData);
  564. return Utf8ArrayToStr(data);
  565. }
  566. /**
  567. * 字符串按指定编码
  568. * @param input
  569. * @param encoding
  570. * @returns {*}
  571. */
  572. function encodeStr(input,encoding){
  573. encoding = encoding||'gbk';
  574. if(encoding.startsWith('gb')){
  575. const strTool = gbkTool();
  576. input = strTool.encode(input);
  577. }
  578. return input
  579. }
  580. /**
  581. * 字符串指定解码
  582. * @param input
  583. * @param encoding
  584. * @returns {*}
  585. */
  586. function decodeStr(input,encoding){
  587. encoding = encoding||'gbk';
  588. if(encoding.startsWith('gb')){
  589. const strTool = gbkTool();
  590. input = strTool.decode(input);
  591. }
  592. return input
  593. }
  594. function getCryptoJS(){
  595. // return request('https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/crypto-hiker.js');
  596. return 'console.log("CryptoJS已装载");'
  597. }
  598. // 封装的RSA加解密类
  599. const RSA = {
  600. decode: function (data, key, option) {
  601. option = option || {};
  602. if (typeof (JSEncrypt) === 'function') {
  603. let chunkSize = option.chunkSize || 117; // 默认分段长度为117
  604. let privateKey = this.getPrivateKey(key); // 获取私钥
  605. const decryptor = new JSEncrypt(); //创建解密对象实例
  606. decryptor.setPrivateKey(privateKey); //设置秘钥
  607. let uncrypted = '';
  608. // uncrypted = decryptor.decrypt(data);
  609. uncrypted = decryptor.decryptUnicodeLong(data);
  610. return uncrypted;
  611. } else {
  612. return false
  613. }
  614. },
  615. encode: function (data, key, option) {
  616. option = option || {};
  617. if (typeof (JSEncrypt) === 'function') {
  618. let chunkSize = option.chunkSize || 117; // 默认分段长度为117
  619. let publicKey = this.getPublicKey(key); // 获取公钥
  620. const encryptor = new JSEncrypt();
  621. encryptor.setPublicKey(publicKey); // 设置公钥
  622. let encrypted = ''; // 加密结果
  623. // const textLen = data.length; // 待加密文本长度
  624. // let offset = 0; // 分段偏移量
  625. // // 分段加密
  626. // while (offset < textLen) {
  627. // let chunk = data.slice(offset, chunkSize); // 提取分段数据
  628. // let enc = encryptor.encrypt(chunk); // 加密分段数据
  629. // encrypted += enc; // 连接加密结果
  630. // offset += chunkSize; // 更新偏移量
  631. // }
  632. encrypted = encryptor.encryptUnicodeLong(data);
  633. return encrypted
  634. } else {
  635. return false
  636. }
  637. },
  638. fixKey(key, prefix, endfix) {
  639. if (!key.includes(prefix)) {
  640. key = prefix + key;
  641. }
  642. if (!key.includes(endfix)) {
  643. key += endfix
  644. }
  645. return key
  646. },
  647. getPrivateKey(key) {
  648. let prefix = '-----BEGIN RSA PRIVATE KEY-----';
  649. let endfix = '-----END RSA PRIVATE KEY-----';
  650. return this.fixKey(key, prefix, endfix);
  651. },
  652. getPublicKey(key) {
  653. let prefix = '-----BEGIN PUBLIC KEY-----';
  654. let endfix = '-----END PUBLIC KEY-----';
  655. return this.fixKey(key, prefix, endfix);
  656. }
  657. };
  658. /**
  659. * 获取壳子返回的代理地址
  660. * @returns {string|*}
  661. */
  662. function getProxyUrl(){
  663. if(typeof(getProxy)==='function'){//判断壳子里有getProxy函数就执行取返回结果。否则取默认的本地
  664. return getProxy(true)
  665. }else{
  666. return 'http://127.0.0.1:9978/proxy?do=js'
  667. }
  668. }
  669. /**
  670. * 根据正则处理原始m3u8里的广告ts片段,自动修复相对链接
  671. * @param m3u8_text m3u8原始文本,里面是最末级的只含ts片段的。不支持嵌套m3u8链接
  672. * @param m3u8_url m3u8原始地址
  673. * @param ad_remove 正则表达式如: reg:/video/adjump(.*?)ts
  674. * @returns {string|DocumentFragment|*|string}
  675. */
  676. function fixAdM3u8(m3u8_text, m3u8_url, ad_remove) {
  677. if ((!m3u8_text && !m3u8_url) || (!m3u8_text && m3u8_url && !m3u8_url.startsWith('http'))) {
  678. return ''
  679. }
  680. if (!m3u8_text) {
  681. log('m3u8_url:' + m3u8_url);
  682. m3u8_text = request(m3u8_url);
  683. }
  684. log('len(m3u8_text):' + m3u8_text.length);
  685. if (!ad_remove) {
  686. return m3u8_text
  687. }
  688. if (ad_remove.startsWith('reg:')) {
  689. ad_remove = ad_remove.slice(4)
  690. } else if (ad_remove.startsWith('js:')) {
  691. ad_remove = ad_remove.slice(3)
  692. }
  693. let m3u8_start = m3u8_text.slice(0, m3u8_text.indexOf('#EXTINF')).trim();
  694. let m3u8_body = m3u8_text.slice(m3u8_text.indexOf('#EXTINF'), m3u8_text.indexOf('#EXT-X-ENDLIST')).trim();
  695. let m3u8_end = m3u8_text.slice(m3u8_text.indexOf('#EXT-X-ENDLIST')).trim();
  696. let murls = [];
  697. let m3_body_list = m3u8_body.split('\n');
  698. let m3_len = m3_body_list.length;
  699. let i = 0;
  700. while (i < m3_len) {
  701. let mi = m3_body_list[i];
  702. let mi_1 = m3_body_list[i + 1];
  703. if (mi.startsWith('#EXTINF')) {
  704. murls.push([mi, mi_1].join('&'));
  705. i += 2
  706. } else if (mi.startsWith('#EXT-X-DISCONTINUITY')) {
  707. let mi_2 = m3_body_list[i + 2];
  708. murls.push([mi, mi_1, mi_2].join('&'));
  709. i += 3
  710. } else {
  711. break;
  712. }
  713. }
  714. let new_m3u8_body = [];
  715. for (let murl of murls) {
  716. if (ad_remove && new RegExp(ad_remove).test(murl)) {
  717. } else {
  718. let murl_list = murl.split('&');
  719. if (!murl_list[murl_list.length - 1].startsWith('http') && m3u8_url.startsWith('http')) {
  720. murl_list[murl_list.length - 1] = urljoin(m3u8_url, murl_list[murl_list.length - 1]);
  721. }
  722. murl_list.forEach((it) => {
  723. new_m3u8_body.push(it);
  724. });
  725. }
  726. }
  727. new_m3u8_body = new_m3u8_body.join('\n').trim();
  728. m3u8_text = [m3u8_start, new_m3u8_body, m3u8_end].join('\n').trim();
  729. return m3u8_text
  730. }
  731. /**
  732. * 智能对比去除广告。支持嵌套m3u8。只需要传入播放地址
  733. * @param m3u8_url m3u8播放地址
  734. * @returns {string}
  735. */
  736. function fixAdM3u8Ai(m3u8_url) {
  737. let ts = new Date().getTime();
  738. function b(s1, s2) {
  739. let i = 0;
  740. while (i < s1.length) {
  741. if (s1[i] !== s2[i]) {
  742. break
  743. }
  744. i++
  745. }
  746. return i;
  747. }
  748. function reverseString(str) {
  749. return str.split('').reverse().join('');
  750. }
  751. //log('播放的地址:' + m3u8_url);
  752. let m3u8 = request(m3u8_url);
  753. //log('m3u8处理前:' + m3u8);
  754. m3u8 = m3u8.trim().split('\n').map(it => it.startsWith('#') ? it : urljoin(m3u8_url, it)).join('\n');
  755. //log('m3u8处理后:============:' + m3u8);
  756. // 获取嵌套m3u8地址
  757. m3u8=m3u8.replace(/\n\n/ig,'\n');//删除多余的换行符
  758. let last_url= m3u8.split('\n').slice(-1)[0];
  759. if (last_url.length<5){
  760. last_url= m3u8.split('\n').slice(-2)[0];
  761. }
  762. if (last_url.includes('.m3u8') && last_url !== m3u8_url) {
  763. m3u8_url = urljoin2(m3u8_url,last_url);
  764. log('嵌套的m3u8_url:' + m3u8_url);
  765. m3u8 = request(m3u8_url);
  766. }
  767. //log('----处理有广告的地址----');
  768. let s = m3u8.trim().split('\n').filter(it => it.trim()).join('\n');
  769. let ss = s.split('\n')
  770. //找出第一条播放地址
  771. let firststr = ss.find(x => !x.startsWith('#'));
  772. let maxl = 0;//最大相同字符
  773. let firststrlen = firststr.length;
  774. //log('字符串长度:' + firststrlen);
  775. let ml = Math.round(ss.length / 2).toString().length;//取数据的长度的位数
  776. //log('数据条数的长度:' + ml);
  777. //找出最后一条播放地址
  778. let maxc=0;
  779. let laststr = ss.toReversed().find((x) => {
  780. if (!x.startsWith('#')) {
  781. let k = b(reverseString(firststr), reverseString(x));
  782. maxl = b(firststr, x);
  783. maxc++;
  784. if (firststrlen - maxl <= ml + k || maxc>10) {
  785. return true
  786. }
  787. }
  788. return false
  789. });
  790. log('最后一条切片:' + laststr);
  791. //log('最小相同字符长度:' + maxl);
  792. let ad_urls = [];
  793. for (let i = 0; i < ss.length; i++) {
  794. let s = ss[i];
  795. if (!s.startsWith('#')) {
  796. if (b(firststr, s) < maxl) {
  797. ad_urls.push(s); // 广告地址加入列表
  798. ss.splice(i - 1, 2);
  799. i = i - 2;
  800. } else {
  801. ss[i] = urljoin(m3u8_url, s);
  802. }
  803. } else {
  804. ss[i] = s.replace(/URI=\"(.*)\"/, 'URI=\"' + urljoin(m3u8_url, '$1') + '\"');
  805. }
  806. }
  807. log('处理的m3u8地址:' + m3u8_url);
  808. log('----广告地址----');
  809. log(ad_urls);
  810. m3u8 = ss.join('\n');
  811. //log('处理完成');
  812. log('处理耗时:' + (new Date().getTime() - ts).toString());
  813. return m3u8
  814. }
  815. /**
  816. * 强制正序算法
  817. * @param lists 待正序列表
  818. * @param key 正序键
  819. * @param option 单个元素处理函数
  820. * @returns {*}
  821. */
  822. function forceOrder(lists,key,option){
  823. let start = Math.floor(lists.length/2);
  824. let end = Math.min(lists.length-1,start+1);
  825. if(start >= end){
  826. return lists;
  827. }
  828. let first = lists[start];
  829. let second = lists[end];
  830. if(key){
  831. try {
  832. first = first[key];
  833. second = second[key];
  834. }catch (e) {}
  835. }
  836. if(option && typeof(option)==='function'){
  837. try {
  838. first = option(first);
  839. second = option(second);
  840. }catch (e) {}
  841. }
  842. first+='';
  843. second+='';
  844. // console.log(first,second);
  845. if(first.match(/(\d+)/)&&second.match(/(\d+)/)){
  846. let num1 = Number(first.match(/(\d+)/)[1]);
  847. let num2 = Number(second.match(/(\d+)/)[1]);
  848. if (num1 > num2){
  849. lists.reverse();
  850. }
  851. }
  852. return lists
  853. }
  854. let VODS = [];// 一级或者搜索需要的数据列表
  855. let VOD = {};// 二级的单个数据
  856. let TABS = [];// 二级的自定义线路列表 如: TABS=['道长在线','道长在线2']
  857. let LISTS = [];// 二级的自定义选集播放列表 如: LISTS=[['第1集$http://1.mp4','第2集$http://2.mp4'],['第3集$http://1.mp4','第4集$http://2.mp4']]
  858. globalThis.encodeUrl = urlencode;
  859. globalThis.urlencode = urlencode;
  860. /**
  861. * 获取链接的query请求转为js的object字典对象
  862. * @param url
  863. * @returns {{}}
  864. */
  865. function getQuery(url) {
  866. try {
  867. let arr = url.split("?")[1].split("#")[0].split("&");
  868. const resObj = {};
  869. arr.forEach(item => { let [key, value = ''] = item.split("=")
  870. resObj[key] = value })
  871. return resObj
  872. }catch (e) {
  873. log('getQuery发生错误:'+e.message)
  874. return {}
  875. }
  876. }
  877. /**
  878. * url拼接
  879. * @param fromPath 初始当前页面url
  880. * @param nowPath 相对当前页面url
  881. * @returns {*}
  882. */
  883. function urljoin(fromPath, nowPath) {
  884. fromPath = fromPath||'';
  885. nowPath = nowPath||'';
  886. return joinUrl(fromPath, nowPath);
  887. // try {
  888. // // import Uri from './uri.min.js';
  889. // // var Uri = require('./uri.min.js');
  890. // // eval(request('https://cdn.bootcdn.net/ajax/libs/URI.js/1.19.11/URI.min.js'));
  891. // // let new_uri = URI(nowPath, fromPath);
  892. // let new_uri = Uri(nowPath, fromPath);
  893. // new_uri = new_uri.toString();
  894. // // console.log(new_uri);
  895. // // return fromPath + nowPath
  896. // return new_uri
  897. // }
  898. // catch (e) {
  899. // console.log('urljoin发生错误:'+e.message);
  900. // if(nowPath.startsWith('http')){
  901. // return nowPath
  902. // }if(nowPath.startsWith('/')){
  903. // return getHome(fromPath)+nowPath
  904. // }
  905. // return fromPath+nowPath
  906. // }
  907. }
  908. var urljoin2 = urljoin;
  909. // 内置 pdfh,pdfa,pd
  910. const defaultParser = {
  911. pdfh:pdfh,
  912. pdfa:pdfa,
  913. pd:pd,
  914. };
  915. /**
  916. * pdfh原版优化,能取style属性里的图片链接
  917. * @param html 源码
  918. * @param parse 解析表达式
  919. * @returns {string|*}
  920. */
  921. function pdfh2(html,parse){
  922. let html2 = html;
  923. try {
  924. if(typeof(html)!=='string'){
  925. html2 = html.rr(html.ele).toString();
  926. }
  927. }catch (e) {
  928. print('html对象转文本发生了错误:'+e.message);
  929. }
  930. let result = defaultParser.pdfh(html2,parse);
  931. let option = parse.includes('&&')?parse.split('&&').slice(-1)[0]:parse.split(' ').slice(-1)[0];
  932. if(/style/.test(option.toLowerCase())&&/url\(/.test(result)){
  933. try {
  934. result = result.match(/url\((.*?)\)/)[1];
  935. // 2023/07/28新增 style取内部链接自动去除首尾单双引号
  936. result = result.replace(/^['|"](.*)['|"]$/, "$1");
  937. }catch (e) {}
  938. }
  939. return result
  940. }
  941. /**
  942. * pdfa原版优化,可以转换jq的html对象
  943. * @param html
  944. * @param parse
  945. * @returns {*}
  946. */
  947. function pdfa2(html,parse){
  948. let html2 = html;
  949. try {
  950. if(typeof(html)!=='string'){
  951. html2 = html.rr(html.ele).toString();
  952. }
  953. }catch (e) {
  954. print('html对象转文本发生了错误:'+e.message);
  955. }
  956. return defaultParser.pdfa(html2,parse);
  957. }
  958. /**
  959. * pd原版方法重写-增加自动urljoin
  960. * @param html
  961. * @param parse
  962. * @param uri
  963. * @returns {*}
  964. */
  965. function pd2(html,parse,uri){
  966. let ret = pdfh2(html,parse);
  967. if(typeof(uri)==='undefined'||!uri){
  968. uri = '';
  969. }
  970. if(DOM_CHECK_ATTR.test(parse) && !SPECIAL_URL.test(ret)){
  971. if(/http/.test(ret)){
  972. ret = ret.slice(ret.indexOf('http'));
  973. }else{
  974. ret = urljoin(MY_URL,ret)
  975. }
  976. }
  977. // MY_URL = getItem('MY_URL',MY_URL);
  978. // console.log(`规则${RKEY}打印MY_URL:${MY_URL},uri:${uri}`);
  979. return ret
  980. }
  981. const parseTags = {
  982. jsp:{
  983. pdfh:pdfh2,
  984. pdfa:pdfa2,
  985. pd:pd2,
  986. },
  987. json:{
  988. pdfh(html, parse) {
  989. if (!parse || !parse.trim()){
  990. return '';
  991. }
  992. if (typeof(html) === 'string'){
  993. // print('jsonpath:pdfh字符串转dict');
  994. html = JSON.parse(html);
  995. }
  996. parse = parse.trim();
  997. if (!parse.startsWith('$.')){
  998. parse = '$.' + parse;
  999. }
  1000. parse = parse.split('||');
  1001. for (let ps of parse) {
  1002. let ret = cheerio.jp(ps, html);
  1003. if (Array.isArray(ret)){
  1004. ret = ret[0] || '';
  1005. } else{
  1006. ret = ret || ''
  1007. }
  1008. if (ret && typeof (ret) !== 'string'){
  1009. ret = ret.toString();
  1010. }
  1011. if(ret){
  1012. return ret
  1013. }
  1014. }
  1015. return '';
  1016. },
  1017. pdfa(html, parse) {
  1018. if (!parse || !parse.trim()){
  1019. return '';
  1020. }
  1021. if (typeof(html) === 'string'){
  1022. // print('jsonpath:pdfa字符串转dict');
  1023. html = JSON.parse(html);
  1024. }
  1025. parse = parse.trim()
  1026. if (!parse.startsWith('$.')){
  1027. parse = '$.' + parse;
  1028. }
  1029. let ret = cheerio.jp(parse, html);
  1030. if (Array.isArray(ret) && Array.isArray(ret[0]) && ret.length === 1){
  1031. return ret[0] || []
  1032. }
  1033. return ret || []
  1034. },
  1035. pd(html,parse){
  1036. let ret = parseTags.json.pdfh(html,parse);
  1037. if(ret){
  1038. return urljoin(MY_URL,ret);
  1039. }
  1040. return ret
  1041. },
  1042. },
  1043. jq:{
  1044. pdfh(html, parse) {
  1045. if (!html||!parse || !parse.trim()) {
  1046. return ''
  1047. }
  1048. parse = parse.trim();
  1049. let result = defaultParser.pdfh(html,parse);
  1050. // print(`pdfh解析${parse}=>${result}`);
  1051. return result;
  1052. },
  1053. pdfa(html, parse) {
  1054. if (!html||!parse || !parse.trim()) {
  1055. return [];
  1056. }
  1057. parse = parse.trim();
  1058. let result = defaultParser.pdfa(html,parse);
  1059. // print(result);
  1060. print(`pdfa解析${parse}=>${result.length}`);
  1061. return result;
  1062. },
  1063. pd(html,parse,base_url){
  1064. if (!html||!parse || !parse.trim()) {
  1065. return ''
  1066. }
  1067. parse = parse.trim();
  1068. base_url = base_url||MY_URL;
  1069. return defaultParser.pd(html, parse, base_url);
  1070. },
  1071. },
  1072. getParse(p0){//非js开头的情况自动获取解析标签
  1073. if(p0.startsWith('jsp:')){
  1074. return this.jsp
  1075. }else if(p0.startsWith('json:')){
  1076. return this.json
  1077. }else if(p0.startsWith('jq:')){
  1078. return this.jq
  1079. }else {
  1080. return this.jq
  1081. }
  1082. }
  1083. };
  1084. const stringify = JSON.stringify;
  1085. const jsp = parseTags.jsp;
  1086. const jq = parseTags.jq;
  1087. /*** 后台需要实现的java方法并注入到js中 ***/
  1088. /**
  1089. * 读取本地文件->应用程序目录
  1090. * @param filePath
  1091. * @returns {string}
  1092. */
  1093. function readFile(filePath){
  1094. filePath = filePath||'./uri.min.js';
  1095. var fd = os.open(filePath);
  1096. var buffer = new ArrayBuffer(1024);
  1097. var len = os.read(fd, buffer, 0, 1024);
  1098. console.log(len);
  1099. let text = String.fromCharCode.apply(null, new Uint8Array(buffer));
  1100. console.log(text);
  1101. return text
  1102. }
  1103. /**
  1104. * 处理返回的json数据
  1105. * @param html
  1106. * @returns {*}
  1107. */
  1108. function dealJson(html) {
  1109. try {
  1110. // html = html.match(/[\w|\W|\s|\S]*?(\{[\w|\W|\s|\S]*\})/).group[1];
  1111. html = html.trim();
  1112. if(!((html.startsWith('{') && html.endsWith('}'))||(html.startsWith('[') && html.endsWith(']')))){
  1113. html = '{'+html.match(/.*?\{(.*)\}/m)[1]+'}';
  1114. }
  1115. } catch (e) {
  1116. }
  1117. try {
  1118. html = JSON.parse(html);
  1119. }catch (e) {}
  1120. // console.log(typeof(html));
  1121. return html;
  1122. }
  1123. /**
  1124. * 验证码识别逻辑,需要java实现(js没有bytes类型,无法调用后端的传递图片二进制获取验证码文本的接口)
  1125. * @type {{api: string, classification: (function(*=): string)}}
  1126. */
  1127. var OcrApi={
  1128. api:OCR_API,
  1129. classification:function (img){ // img是byte类型,这里不方便搞啊
  1130. let code = '';
  1131. try {
  1132. // let html = request(this.api,{data:{img:img},headers:{'User-Agent':PC_UA},'method':'POST'},true);
  1133. // html = JSON.parse(html);
  1134. // code = html.url||'';
  1135. log('通过drpy_ocr验证码接口过验证...');
  1136. let html = request(OCR_API,{data:{img:img},headers:{'User-Agent':PC_UA},'method':'POST'},true);
  1137. code = html||'';
  1138. }catch (e) {
  1139. log(`OCR识别验证码发生错误:${e.message}`)
  1140. }
  1141. return code
  1142. }
  1143. };
  1144. /**
  1145. * 验证码识别,暂未实现
  1146. * @param url 验证码图片链接
  1147. * @returns {string} 验证成功后的cookie
  1148. */
  1149. function verifyCode(url){
  1150. let cnt = 0;
  1151. let host = getHome(url);
  1152. let cookie = '';
  1153. while (cnt < OCR_RETRY){
  1154. try{
  1155. // let obj = {headers:headers,timeout:timeout};
  1156. let yzm_url = `${host}/index.php/verify/index.html`;
  1157. console.log(`验证码链接:${yzm_url}`);
  1158. let hhtml = request(yzm_url,{withHeaders:true,toBase64:true},true);
  1159. let json = JSON.parse(hhtml);
  1160. if(!cookie){
  1161. // print(json);
  1162. let setCk = Object.keys(json).find(it=>it.toLowerCase()==='set-cookie');
  1163. // cookie = json['set-cookie']?json['set-cookie'].split(';')[0]:'';
  1164. cookie = setCk?json[setCk].split(';')[0]:'';
  1165. }
  1166. // console.log(hhtml);
  1167. console.log('cookie:'+cookie);
  1168. let img = json.body;
  1169. // console.log(img);
  1170. let code = OcrApi.classification(img);
  1171. console.log(`第${cnt+1}次验证码识别结果:${code}`);
  1172. let submit_url = `${host}/index.php/ajax/verify_check?type=search&verify=${code}`;
  1173. console.log(submit_url);
  1174. let html = request(submit_url,{headers:{Cookie:cookie,'User-Agent':MOBILE_UA},'method':'POST'});
  1175. // console.log(html);
  1176. html = JSON.parse(html);
  1177. if(html.msg === 'ok'){
  1178. console.log(`第${cnt+1}次验证码提交成功`);
  1179. return cookie // 需要返回cookie
  1180. }else if(html.msg!=='ok'&&cnt+1>=OCR_RETRY){
  1181. cookie = ''; // 需要清空返回cookie
  1182. }
  1183. }catch (e) {
  1184. console.log(`第${cnt+1}次验证码提交失败:${e.message}`);
  1185. if(cnt+1>=OCR_RETRY){
  1186. cookie = '';
  1187. }
  1188. }
  1189. cnt+=1
  1190. }
  1191. return cookie
  1192. }
  1193. /**
  1194. * 存在数据库配置表里, key字段对应值value,没有就新增,有就更新,调用此方法会清除key对应的内存缓存
  1195. * @param k 键
  1196. * @param v 值
  1197. */
  1198. function setItem(k,v){
  1199. local.set(RKEY,k,v);
  1200. console.log(`规则${RKEY}设置${k} => ${v}`)
  1201. }
  1202. /**
  1203. * 获取数据库配置表对应的key字段的value,没有这个key就返回value默认传参.需要有缓存,第一次获取后会存在内存里
  1204. * @param k 键
  1205. * @param v 值
  1206. * @returns {*}
  1207. */
  1208. function getItem(k,v){
  1209. return local.get(RKEY,k) || v;
  1210. }
  1211. /**
  1212. * 删除数据库key对应的一条数据,并清除此key对应的内存缓存
  1213. * @param k
  1214. */
  1215. function clearItem(k){
  1216. local.delete(RKEY,k);
  1217. }
  1218. /*** js自封装的方法 ***/
  1219. /**
  1220. * 获取链接的host(带http协议的完整链接)
  1221. * @param url 任意一个正常完整的Url,自动提取根
  1222. * @returns {string}
  1223. */
  1224. function getHome(url){
  1225. if(!url){
  1226. return ''
  1227. }
  1228. let tmp = url.split('//');
  1229. url = tmp[0] + '//' + tmp[1].split('/')[0];
  1230. try {
  1231. url = decodeURIComponent(url);
  1232. }catch (e) {}
  1233. return url
  1234. }
  1235. /**
  1236. * get参数编译链接,类似python params字典自动拼接
  1237. * @param url 访问链接
  1238. * @param obj 参数字典
  1239. * @returns {*}
  1240. */
  1241. function buildUrl(url,obj){
  1242. obj = obj||{};
  1243. if(url.indexOf('?')<0){
  1244. url += '?'
  1245. }
  1246. let param_list = [];
  1247. let keys = Object.keys(obj);
  1248. keys.forEach(it=>{
  1249. param_list.push(it+'='+obj[it])
  1250. });
  1251. let prs = param_list.join('&');
  1252. if(keys.length > 0 && !url.endsWith('?')){
  1253. url += '&'
  1254. }
  1255. url+=prs;
  1256. return url
  1257. }
  1258. /**
  1259. * 远程依赖执行函数
  1260. * @param url 远程js地址
  1261. */
  1262. function $require(url){
  1263. eval(request(url));
  1264. }
  1265. /**
  1266. * 海阔网页请求函数完整封装
  1267. * @param url 请求链接
  1268. * @param obj 请求对象 {headers:{},method:'',timeout:5000,body:'',withHeaders:false}
  1269. * @param ocr_flag 标识此flag是用于请求ocr识别的,自动过滤content-type指定编码
  1270. * @returns {string|string|DocumentFragment|*}
  1271. */
  1272. function request(url,obj,ocr_flag){
  1273. ocr_flag = ocr_flag||false;
  1274. if(typeof(obj)==='undefined'||!obj||obj==={}){
  1275. if(!fetch_params||!fetch_params.headers){
  1276. let headers = {
  1277. 'User-Agent':MOBILE_UA,
  1278. };
  1279. if(rule.headers){
  1280. Object.assign(headers,rule.headers);
  1281. }
  1282. if(!fetch_params){
  1283. fetch_params = {};
  1284. }
  1285. fetch_params.headers = headers;
  1286. }
  1287. if(!fetch_params.headers.Referer){
  1288. fetch_params.headers.Referer = getHome(url)
  1289. }
  1290. obj = fetch_params;
  1291. }else{
  1292. let headers = obj.headers||{};
  1293. let keys = Object.keys(headers).map(it=>it.toLowerCase());
  1294. if(!keys.includes('user-agent')){
  1295. headers['User-Agent'] = MOBILE_UA;
  1296. }if(!keys.includes('referer')){
  1297. headers['Referer'] = getHome(url);
  1298. }
  1299. obj.headers = headers;
  1300. }
  1301. if(rule.encoding&&rule.encoding!=='utf-8'&&!ocr_flag){
  1302. if(!obj.headers.hasOwnProperty('Content-Type')&&!obj.headers.hasOwnProperty('content-type')){ // 手动指定了就不管
  1303. obj.headers["Content-Type"] = 'text/html; charset='+rule.encoding;
  1304. }
  1305. }
  1306. if(typeof(obj.body)!='undefined'&&obj.body&&typeof (obj.body)==='string'){
  1307. // let data = {};
  1308. // obj.body.split('&').forEach(it=>{
  1309. // data[it.split('=')[0]] = it.split('=')[1]
  1310. // });
  1311. // obj.data = data;
  1312. // delete obj.body
  1313. // 传body加 "Content-Type":"application/x-www-form-urlencoded;" 即可post form
  1314. if(!obj.headers.hasOwnProperty('Content-Type')&&!obj.headers.hasOwnProperty('content-type')){ // 手动指定了就不管
  1315. obj.headers["Content-Type"] = 'application/x-www-form-urlencoded; charset='+rule.encoding;
  1316. }
  1317. }else if(typeof(obj.body)!='undefined'&&obj.body&&typeof (obj.body)==='object'){
  1318. obj.data = obj.body;
  1319. delete obj.body
  1320. }
  1321. if(!url){
  1322. return obj.withHeaders?'{}':''
  1323. }
  1324. if(obj.toBase64){ // 返回base64,用于请求图片
  1325. obj.buffer = 2;
  1326. delete obj.toBase64
  1327. }
  1328. if(obj.redirect===false){
  1329. obj.redirect = 0;
  1330. }
  1331. console.log(JSON.stringify(obj.headers));
  1332. // console.log('request:'+url+' obj:'+JSON.stringify(obj));
  1333. console.log('request:'+url+`|method:${obj.method||'GET'}|body:${obj.body||''}`);
  1334. let res = req(url, obj);
  1335. let html = res.content||'';
  1336. // console.log(html);
  1337. if(obj.withHeaders){
  1338. let htmlWithHeaders = res.headers;
  1339. htmlWithHeaders.body = html;
  1340. return JSON.stringify(htmlWithHeaders);
  1341. }else{
  1342. return html
  1343. }
  1344. }
  1345. /**
  1346. * 快捷post请求
  1347. * @param url 地址
  1348. * @param obj 对象
  1349. * @returns {string|DocumentFragment|*}
  1350. */
  1351. function post(url,obj){
  1352. obj.method = 'POST';
  1353. return request(url,obj);
  1354. }
  1355. fetch = request;
  1356. print = function (data){
  1357. data = data||'';
  1358. if(typeof(data)=='object'&&Object.keys(data).length>0){
  1359. try {
  1360. data = JSON.stringify(data);
  1361. console.log(data);
  1362. }catch (e) {
  1363. // console.log('print:'+e.message);
  1364. console.log(typeof(data)+':'+data.length);
  1365. return
  1366. }
  1367. }else if(typeof(data)=='object'&&Object.keys(data).length<1){
  1368. console.log('null object');
  1369. }else{
  1370. console.log(data);
  1371. }
  1372. }
  1373. log = print;
  1374. /**
  1375. * 检查宝塔验证并自动跳过获取正确源码
  1376. * @param html 之前获取的html
  1377. * @param url 之前的来源url
  1378. * @param obj 来源obj
  1379. * @returns {string|DocumentFragment|*}
  1380. */
  1381. function checkHtml(html,url,obj){
  1382. if(/\?btwaf=/.test(html)){
  1383. let btwaf = html.match(/btwaf(.*?)"/)[1];
  1384. url = url.split('#')[0]+'?btwaf'+btwaf;
  1385. print('宝塔验证访问链接:'+url);
  1386. html = request(url,obj);
  1387. }
  1388. return html
  1389. }
  1390. /**
  1391. * 带一次宝塔验证的源码获取
  1392. * @param url 请求链接
  1393. * @param obj 请求参数
  1394. * @returns {string|DocumentFragment}
  1395. */
  1396. function getCode(url,obj){
  1397. let html = request(url,obj);
  1398. html = checkHtml(html,url,obj);
  1399. return html
  1400. }
  1401. /**
  1402. * 源rule专用的请求方法,自动注入cookie
  1403. * @param url 请求链接
  1404. * @returns {string|DocumentFragment}
  1405. */
  1406. function getHtml(url){
  1407. let obj = {};
  1408. if(rule.headers){
  1409. obj.headers = rule.headers;
  1410. }
  1411. let cookie = getItem(RULE_CK,'');
  1412. if(cookie){
  1413. // log('有cookie:'+cookie);
  1414. if(obj.headers && ! Object.keys(obj.headers).map(it=>it.toLowerCase()).includes('cookie')){
  1415. log('历史无cookie,新增过验证后的cookie');
  1416. obj.headers['Cookie'] = cookie;
  1417. }else if(obj.headers && obj.headers.cookie && obj.headers.cookie!==cookie){
  1418. obj.headers['Cookie'] = cookie;
  1419. log('历史有小写过期的cookie,更新过验证后的cookie');
  1420. }else if(obj.headers && obj.headers.Cookie && obj.headers.Cookie!==cookie){
  1421. obj.headers['Cookie'] = cookie;
  1422. log('历史有大写过期的cookie,更新过验证后的cookie');
  1423. }else if(!obj.headers){
  1424. obj.headers = {Cookie:cookie};
  1425. log('历史无headers,更新过验证后的含cookie的headers');
  1426. }
  1427. }
  1428. let html = getCode(url,obj);
  1429. return html
  1430. }
  1431. /**
  1432. * 首页分类解析,筛选暂未实现
  1433. * @param homeObj 首页传参对象
  1434. * @returns {string}
  1435. */
  1436. function homeParse(homeObj) {
  1437. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  1438. let classes = [];
  1439. if (homeObj.class_name && homeObj.class_url) {
  1440. let names = homeObj.class_name.split('&');
  1441. let urls = homeObj.class_url.split('&');
  1442. let cnt = Math.min(names.length, urls.length);
  1443. for (let i = 0; i < cnt; i++) {
  1444. classes.push({
  1445. 'type_id': urls[i],
  1446. 'type_name': names[i]
  1447. });
  1448. }
  1449. }
  1450. if (homeObj.class_parse) {
  1451. if(homeObj.class_parse.startsWith('js:')) {
  1452. var input = homeObj.MY_URL;
  1453. try {
  1454. eval(homeObj.class_parse.replace('js:', ''));
  1455. if (Array.isArray(input)) {
  1456. classes = input;
  1457. }
  1458. }catch(e){
  1459. log('通过js动态获取分类发生了错误:'+e.message);
  1460. }
  1461. }else {
  1462. let p = homeObj.class_parse.split(';');
  1463. let p0 = p[0];
  1464. let _ps = parseTags.getParse(p0);
  1465. let is_json = p0.startsWith('json:');
  1466. _pdfa = _ps.pdfa;
  1467. _pdfh = _ps.pdfh;
  1468. _pd = _ps.pd;
  1469. MY_URL = rule.url;
  1470. if(is_json){
  1471. try {
  1472. let cms_cate_url = homeObj.MY_URL.replace('ac=detail','ac=list');
  1473. let html = getHtml(cms_cate_url);
  1474. if (html) {
  1475. if(cms_cate_url === homeObj.MY_URL){
  1476. homeHtmlCache = html;
  1477. }
  1478. let list = _pdfa(html, p0.replace('json:',''));
  1479. if (list && list.length > 0) {
  1480. classes = list;
  1481. }
  1482. }
  1483. } catch (e) {
  1484. console.log(e.message);
  1485. }
  1486. } else if(p.length >= 3 && !is_json) { // 可以不写正则
  1487. try {
  1488. let html = getHtml(homeObj.MY_URL);
  1489. if (html) {
  1490. homeHtmlCache = html;
  1491. let list = _pdfa(html, p0);
  1492. if (list && list.length > 0) {
  1493. list.forEach((it, idex) => {
  1494. try {
  1495. let name = _pdfh(it, p[1]);
  1496. if (homeObj.cate_exclude && (new RegExp(homeObj.cate_exclude).test(name))) {
  1497. return;
  1498. }
  1499. // let url = pdfh(it, p[2]);
  1500. let url = _pd(it, p[2]);
  1501. if (p.length > 3 && p[3]) {
  1502. let exp = new RegExp(p[3]);
  1503. url = url.match(exp)[1];
  1504. }
  1505. classes.push({
  1506. 'type_id': url.trim(),
  1507. 'type_name': name.trim()
  1508. });
  1509. } catch (e) {
  1510. console.log(`分类列表定位第${idex}个元素正常报错:${e.message}`);
  1511. }
  1512. });
  1513. }
  1514. }
  1515. } catch (e) {
  1516. console.log(e.message);
  1517. }
  1518. }
  1519. }
  1520. }
  1521. // 排除分类
  1522. classes = classes.filter(it=>!homeObj.cate_exclude || !(new RegExp(homeObj.cate_exclude).test(it.type_name)));
  1523. let resp = {
  1524. 'class': classes
  1525. };
  1526. if(homeObj.filter){
  1527. resp.filters = homeObj.filter;
  1528. }
  1529. console.log(JSON.stringify(resp));
  1530. return JSON.stringify(resp);
  1531. }
  1532. /**
  1533. * 推荐和搜索单字段继承一级
  1534. * @param p 推荐或搜索的解析分割;列表
  1535. * @param pn 自身列表序号
  1536. * @param pp 一级解析分割;列表
  1537. * @param ppn 继承一级序号
  1538. * @returns {*}
  1539. */
  1540. function getPP(p, pn, pp, ppn){
  1541. try {
  1542. let ps = p[pn] === '*' && pp.length > ppn ?pp[ppn]:p[pn]
  1543. return ps
  1544. }catch (e) {
  1545. return ''
  1546. }
  1547. }
  1548. /**
  1549. * 首页推荐列表解析
  1550. * @param homeVodObj
  1551. * @returns {string}
  1552. */
  1553. function homeVodParse(homeVodObj){
  1554. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  1555. let d = [];
  1556. MY_URL = homeVodObj.homeUrl;
  1557. // setItem('MY_URL',MY_URL);
  1558. console.log(MY_URL);
  1559. let t1 = (new Date()).getTime();
  1560. let p = homeVodObj.推荐;
  1561. print('p:'+p);
  1562. if(p==='*' && rule.一级){
  1563. p = rule.一级;
  1564. homeVodObj.double = false;
  1565. }
  1566. if(!p||typeof(p)!=='string'){
  1567. return '{}'
  1568. }
  1569. p = p.trim();
  1570. let pp = rule.一级.split(';');
  1571. if(p.startsWith('js:')){
  1572. const TYPE = 'home';
  1573. var input = MY_URL;
  1574. HOST = rule.host;
  1575. eval(p.replace('js:',''));
  1576. d = VODS;
  1577. }else {
  1578. p = p.split(';');
  1579. if (!homeVodObj.double && p.length < 5) {
  1580. return '{}'
  1581. } else if (homeVodObj.double && p.length < 6) {
  1582. return '{}'
  1583. }
  1584. let p0 = getPP(p,0,pp,0)
  1585. let _ps = parseTags.getParse(p0);
  1586. _pdfa = _ps.pdfa;
  1587. _pdfh = _ps.pdfh;
  1588. _pd = _ps.pd;
  1589. let is_json = p0.startsWith('json:');
  1590. p0 = p0.replace(/^(jsp:|json:|jq:)/,'');
  1591. // print(p[0]);
  1592. let html = homeHtmlCache || getHtml(MY_URL);
  1593. homeHtmlCache = undefined;
  1594. if(is_json){
  1595. // print('是json,开始处理');
  1596. html = dealJson(html);
  1597. }
  1598. try {
  1599. console.log('double:' + homeVodObj.double);
  1600. if (homeVodObj.double) {
  1601. let items = _pdfa(html, p0);
  1602. // console.log(items.length);
  1603. let p1 = getPP(p,1,pp,0);
  1604. let p2 = getPP(p,2,pp,1);
  1605. let p3 = getPP(p,3,pp,2);
  1606. let p4 = getPP(p,4,pp,3);
  1607. let p5 = getPP(p,5,pp,4);
  1608. let p6 = getPP(p,6,pp,5);
  1609. for (let item of items) {
  1610. // console.log(p[1]);
  1611. let items2 = _pdfa(item, p1);
  1612. // console.log(items2.length);
  1613. for (let item2 of items2) {
  1614. try {
  1615. let title = _pdfh(item2, p2);
  1616. let img = '';
  1617. try {
  1618. img = _pd(item2, p3);
  1619. } catch (e) {}
  1620. let desc = '';
  1621. try {
  1622. desc = _pdfh(item2, p4);
  1623. }catch (e) {}
  1624. let links = [];
  1625. for (let _p5 of p5.split('+')) {
  1626. let link = !homeVodObj.detailUrl ? _pd(item2, _p5, MY_URL) : _pdfh(item2, _p5);
  1627. links.push(link);
  1628. }
  1629. let content;
  1630. if(p.length > 6 && p[6]){
  1631. content = _pdfh(item2, p6);
  1632. } else{
  1633. content = '';
  1634. }
  1635. let vid = links.join('$');
  1636. if(rule.二级==='*'){
  1637. vid = vid+'@@'+title+'@@'+img;
  1638. }
  1639. let vod = {
  1640. vod_name: title,
  1641. vod_pic: img,
  1642. vod_remarks: desc,
  1643. vod_content: content,
  1644. vod_id: vid
  1645. };
  1646. // print(vod);
  1647. d.push(vod);
  1648. } catch (e) {
  1649. console.log('首页列表双层定位处理发生错误:'+e.message);
  1650. }
  1651. }
  1652. }
  1653. } else {
  1654. let items = _pdfa(html, p0);
  1655. let p1 = getPP(p,1,pp,1);
  1656. let p2 = getPP(p,2,pp,2);
  1657. let p3 = getPP(p,3,pp,3);
  1658. let p4 = getPP(p,4,pp,4);
  1659. let p5 = getPP(p,5,pp,5);
  1660. for (let item of items) {
  1661. try {
  1662. let title = _pdfh(item, p1);
  1663. let img = '';
  1664. try {
  1665. img = _pd(item, p2, MY_URL);
  1666. } catch (e) {}
  1667. let desc = '';
  1668. try {
  1669. desc = _pdfh(item, p3);
  1670. }catch (e) {}
  1671. let links = [];
  1672. for (let _p5 of p4.split('+')) {
  1673. let link = !homeVodObj.detailUrl ? _pd(item, _p5, MY_URL) : _pdfh(item, _p5);
  1674. links.push(link);
  1675. }
  1676. let content;
  1677. if(p.length > 5 && p[5]){
  1678. content = _pdfh(item, p5);
  1679. }else{
  1680. content = ''
  1681. }
  1682. let vid = links.join('$');
  1683. if(rule.二级==='*'){
  1684. vid = vid+'@@'+title+'@@'+img;
  1685. }
  1686. let vod = {
  1687. vod_name: title,
  1688. vod_pic: img,
  1689. vod_remarks: desc,
  1690. vod_content: content,
  1691. vod_id: vid
  1692. };
  1693. d.push(vod);
  1694. } catch (e) {
  1695. console.log('首页列表单层定位处理发生错误:'+e.message);
  1696. }
  1697. }
  1698. }
  1699. } catch (e) {
  1700. }
  1701. }
  1702. let t2 = (new Date()).getTime();
  1703. console.log('加载首页推荐耗时:'+(t2-t1)+'毫秒');
  1704. // console.log(JSON.stringify(d));
  1705. if(rule.图片替换 && rule.图片替换.includes('=>')){
  1706. let replace_from = rule.图片替换.split('=>')[0];
  1707. let replace_to = rule.图片替换.split('=>')[1];
  1708. d.forEach(it=>{
  1709. if(it.vod_pic&&it.vod_pic.startsWith('http')){
  1710. it.vod_pic = it.vod_pic.replace(replace_from,replace_to);
  1711. }
  1712. });
  1713. }
  1714. if(rule.图片来源){
  1715. d.forEach(it=>{
  1716. if(it.vod_pic&&it.vod_pic.startsWith('http')){
  1717. it.vod_pic = it.vod_pic + rule.图片来源;
  1718. }
  1719. });
  1720. }
  1721. if(d.length>0){
  1722. print(d.slice(0,2));
  1723. }
  1724. return JSON.stringify({
  1725. list:d
  1726. })
  1727. }
  1728. /**
  1729. * 一级分类页数据解析
  1730. * @param cateObj
  1731. * @returns {string}
  1732. */
  1733. function categoryParse(cateObj) {
  1734. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  1735. let p = cateObj.一级;
  1736. if(!p||typeof(p)!=='string'){
  1737. return '{}'
  1738. }
  1739. let d = [];
  1740. // let url = cateObj.url.replaceAll('fyclass', cateObj.tid).replaceAll('fypage', cateObj.pg);
  1741. let url = cateObj.url.replaceAll('fyclass', cateObj.tid);
  1742. if(cateObj.pg === 1 && url.includes('[')&&url.includes(']')){
  1743. url = url.split('[')[1].split(']')[0];
  1744. }else if(cateObj.pg > 1 && url.includes('[')&&url.includes(']')){
  1745. url = url.split('[')[0];
  1746. }
  1747. if(rule.filter_url){
  1748. if(!/fyfilter/.test(url)){
  1749. if(!url.endsWith('&')&&!rule.filter_url.startsWith('&')){
  1750. url+='&'
  1751. }
  1752. url+=rule.filter_url;
  1753. }else{
  1754. url = url.replace('fyfilter', rule.filter_url);
  1755. }
  1756. // filter_url支持fyclass
  1757. url = url.replaceAll('fyclass', cateObj.tid);
  1758. // console.log('filter:'+cateObj.filter);
  1759. let fl = cateObj.filter?cateObj.extend:{};
  1760. // 自动合并 不同分类对应的默认筛选
  1761. if(rule.filter_def && typeof(rule.filter_def)==='object'){
  1762. try {
  1763. if(Object.keys(rule.filter_def).length>0 && rule.filter_def.hasOwnProperty(cateObj.tid)){
  1764. let self_fl_def = rule.filter_def[cateObj.tid];
  1765. if(self_fl_def && typeof(self_fl_def)==='object'){
  1766. // 引用传递转值传递,避免污染self变量
  1767. let fl_def = JSON.parse(JSON.stringify(self_fl_def));
  1768. fl = Object.assign(fl_def,fl);
  1769. }
  1770. }
  1771. }catch (e) {
  1772. print('合并不同分类对应的默认筛选出错:'+e.message);
  1773. }
  1774. }
  1775. let new_url;
  1776. new_url = cheerio.jinja2(url,{fl:fl});
  1777. // console.log('jinjia2执行后的new_url类型为:'+typeof(new_url));
  1778. url = new_url;
  1779. }
  1780. if(/fypage/.test(url)){
  1781. if(url.includes('(')&&url.includes(')')){
  1782. let url_rep = url.match(/.*?\((.*)\)/)[1];
  1783. // console.log(url_rep);
  1784. let cnt_page = url_rep.replaceAll('fypage', cateObj.pg);
  1785. // console.log(cnt_page);
  1786. let cnt_pg = eval(cnt_page);
  1787. // console.log(cnt_pg);
  1788. url = url.replaceAll(url_rep,cnt_pg).replaceAll('(','').replaceAll(')','');
  1789. }else{
  1790. url = url.replaceAll('fypage',cateObj.pg);
  1791. }
  1792. }
  1793. MY_URL = url;
  1794. // setItem('MY_URL',MY_URL);
  1795. console.log(MY_URL);
  1796. p = p.trim();
  1797. const MY_CATE = cateObj.tid;
  1798. if(p.startsWith('js:')){
  1799. var MY_FL = cateObj.extend;
  1800. const TYPE = 'cate';
  1801. var input = MY_URL;
  1802. const MY_PAGE = cateObj.pg;
  1803. var desc = '';
  1804. eval(p.trim().replace('js:',''));
  1805. d = VODS;
  1806. }else {
  1807. p = p.split(';');
  1808. if (p.length < 5) {
  1809. return '{}'
  1810. }
  1811. let _ps = parseTags.getParse(p[0]);
  1812. _pdfa = _ps.pdfa;
  1813. _pdfh = _ps.pdfh;
  1814. _pd = _ps.pd;
  1815. let is_json = p[0].startsWith('json:');
  1816. p[0] = p[0].replace(/^(jsp:|json:|jq:)/,'');
  1817. try {
  1818. let html = getHtml(MY_URL);
  1819. if (html) {
  1820. if(is_json){
  1821. html = dealJson(html);
  1822. }
  1823. let list = _pdfa(html, p[0]);
  1824. list.forEach(it => {
  1825. let links = p[4].split('+').map(p4=>{
  1826. return !rule.detailUrl?_pd(it, p4,MY_URL):_pdfh(it, p4);
  1827. });
  1828. let link = links.join('$');
  1829. let vod_id = rule.detailUrl?MY_CATE+'$'+link:link;
  1830. let vod_name = _pdfh(it, p[1]).replace(/\n|\t/g,'').trim();
  1831. let vod_pic = _pd(it, p[2],MY_URL);
  1832. if(rule.二级==='*'){
  1833. vod_id = vod_id+'@@'+vod_name+'@@'+vod_pic;
  1834. }
  1835. d.push({
  1836. 'vod_id': vod_id,
  1837. 'vod_name': vod_name,
  1838. 'vod_pic': vod_pic,
  1839. 'vod_remarks': _pdfh(it, p[3]).replace(/\n|\t/g,'').trim(),
  1840. });
  1841. });
  1842. }
  1843. } catch (e) {
  1844. console.log(e.message);
  1845. }
  1846. }
  1847. if(rule.图片替换 && rule.图片替换.includes('=>')){
  1848. let replace_from = rule.图片替换.split('=>')[0];
  1849. let replace_to = rule.图片替换.split('=>')[1];
  1850. d.forEach(it=>{
  1851. if(it.vod_pic&&it.vod_pic.startsWith('http')){
  1852. it.vod_pic = it.vod_pic.replace(replace_from,replace_to);
  1853. }
  1854. });
  1855. }
  1856. if(rule.图片来源){
  1857. d.forEach(it=>{
  1858. if(it.vod_pic&&it.vod_pic.startsWith('http')){
  1859. it.vod_pic = it.vod_pic + rule.图片来源;
  1860. }
  1861. });
  1862. }
  1863. // print(d);
  1864. if(d.length>0){
  1865. print(d.slice(0,2));
  1866. }
  1867. let pagecount = 0;
  1868. if(rule.pagecount && typeof(rule.pagecount) === 'object' && rule.pagecount.hasOwnProperty(MY_CATE)){
  1869. print(`MY_CATE:${MY_CATE},pagecount:${JSON.stringify(rule.pagecount)}`);
  1870. pagecount = parseInt(rule.pagecount[MY_CATE]);
  1871. }
  1872. let nodata = {
  1873. list:[{vod_name:'无数据,防无限请求',vod_id:'no_data',vod_remarks:'不要点,会崩的',vod_pic:'https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/404.jpg'}],
  1874. total:1,pagecount:1,page:1,limit:1
  1875. };
  1876. let vod = d.length<1?JSON.stringify(nodata):JSON.stringify({
  1877. 'page': parseInt(cateObj.pg),
  1878. 'pagecount': pagecount||999,
  1879. 'limit': 20,
  1880. 'total': 999,
  1881. 'list': d,
  1882. });
  1883. // print(vod);
  1884. return vod
  1885. }
  1886. /**
  1887. * 搜索列表数据解析
  1888. * @param searchObj
  1889. * @returns {string}
  1890. */
  1891. function searchParse(searchObj) {
  1892. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  1893. let d = [];
  1894. if(!searchObj.searchUrl){
  1895. return '{}'
  1896. }
  1897. let p = searchObj.搜索==='*'&&rule.一级 ? rule.一级 : searchObj.搜索;
  1898. if(!p||typeof(p)!=='string'){
  1899. return '{}'
  1900. }
  1901. p = p.trim();
  1902. let pp = rule.一级.split(';');
  1903. let url = searchObj.searchUrl.replaceAll('**', searchObj.wd);
  1904. if(searchObj.pg === 1 && url.includes('[')&&url.includes(']')&&!url.includes('#')){
  1905. url = url.split('[')[1].split(']')[0];
  1906. }else if(searchObj.pg > 1 && url.includes('[')&&url.includes(']')&&!url.includes('#')){
  1907. url = url.split('[')[0];
  1908. }
  1909. if(/fypage/.test(url)){
  1910. if(url.includes('(')&&url.includes(')')){
  1911. let url_rep = url.match(/.*?\((.*)\)/)[1];
  1912. // console.log(url_rep);
  1913. let cnt_page = url_rep.replaceAll('fypage', searchObj.pg);
  1914. // console.log(cnt_page);
  1915. let cnt_pg = eval(cnt_page);
  1916. // console.log(cnt_pg);
  1917. url = url.replaceAll(url_rep,cnt_pg).replaceAll('(','').replaceAll(')','');
  1918. }else{
  1919. url = url.replaceAll('fypage',searchObj.pg);
  1920. }
  1921. }
  1922. MY_URL = url;
  1923. console.log(MY_URL);
  1924. // log(searchObj.搜索);
  1925. // setItem('MY_URL',MY_URL);
  1926. if(p.startsWith('js:')){
  1927. const TYPE = 'search';
  1928. const MY_PAGE = searchObj.pg;
  1929. const KEY = searchObj.wd;
  1930. var input = MY_URL;
  1931. var detailUrl = rule.detailUrl||'';
  1932. eval(p.trim().replace('js:',''));
  1933. d = VODS;
  1934. }else{
  1935. p = p.split(';');
  1936. if (p.length < 5) {
  1937. return '{}'
  1938. }
  1939. let p0 = getPP(p,0,pp,0);
  1940. let _ps = parseTags.getParse(p0);
  1941. _pdfa = _ps.pdfa;
  1942. _pdfh = _ps.pdfh;
  1943. _pd = _ps.pd;
  1944. let is_json = p0.startsWith('json:');
  1945. p0 = p0.replace(/^(jsp:|json:|jq:)/,'');
  1946. // print('1381 p0:'+p0);
  1947. try {
  1948. let req_method = MY_URL.split(';').length>1?MY_URL.split(';')[1].toLowerCase():'get';
  1949. let html;
  1950. if(req_method==='post'){
  1951. let rurls = MY_URL.split(';')[0].split('#')
  1952. let rurl = rurls[0]
  1953. let params = rurls.length > 1 ?rurls[1]:'';
  1954. print(`post=》rurl:${rurl},params:${params}`);
  1955. // let new_dict = {};
  1956. // let new_tmp = params.split('&');
  1957. // new_tmp.forEach(i=>{
  1958. // new_dict[i.split('=')[0]] = i.split('=')[1];
  1959. // });
  1960. // html = post(rurl,{body:new_dict});
  1961. let _fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  1962. let postData = {body:params};
  1963. Object.assign(_fetch_params,postData);
  1964. html = post(rurl,_fetch_params);
  1965. }else if(req_method==='postjson'){
  1966. let rurls = MY_URL.split(';')[0].split('#')
  1967. let rurl = rurls[0]
  1968. let params = rurls.length > 1 ?rurls[1]:'';
  1969. print(`postjson-》rurl:${rurl},params:${params}`);
  1970. try{
  1971. params = JSON.parse(params);
  1972. }catch (e) {
  1973. params = '{}'
  1974. }
  1975. let _fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  1976. let postData = {body:params};
  1977. Object.assign(_fetch_params,postData);
  1978. html = post(rurl,_fetch_params);
  1979. }else{
  1980. html = getHtml(MY_URL);
  1981. }
  1982. if (html) {
  1983. if(/系统安全验证|输入验证码/.test(html)){
  1984. let cookie = verifyCode(MY_URL);
  1985. if(cookie){
  1986. console.log(`本次成功过验证,cookie:${cookie}`);
  1987. setItem(RULE_CK,cookie);
  1988. }else{
  1989. console.log(`本次自动过搜索验证失败,cookie:${cookie}`);
  1990. }
  1991. // obj.headers['Cookie'] = cookie;
  1992. html = getHtml(MY_URL);
  1993. }
  1994. if(!html.includes(searchObj.wd)){
  1995. console.log('搜索结果源码未包含关键字,疑似搜索失败,正为您打印结果源码');
  1996. console.log(html);
  1997. }
  1998. if(is_json){
  1999. // console.log(html);
  2000. html = dealJson(html);
  2001. // console.log(JSON.stringify(html));
  2002. }
  2003. // console.log(html);
  2004. let list = _pdfa(html, p0);
  2005. // print(list.length);
  2006. // print(list);
  2007. let p1 = getPP(p, 1, pp, 1);
  2008. let p2 = getPP(p, 2, pp, 2);
  2009. let p3 = getPP(p, 3, pp, 3);
  2010. let p4 = getPP(p, 4, pp, 4);
  2011. let p5 = getPP(p,5,pp,5);
  2012. list.forEach(it => {
  2013. let links = p4.split('+').map(_p4=>{
  2014. return !rule.detailUrl?_pd(it, _p4,MY_URL):_pdfh(it, _p4)
  2015. });
  2016. let link = links.join('$');
  2017. let content;
  2018. if(p.length > 5 && p[5]){
  2019. content = _pdfh(it, p5);
  2020. }else{
  2021. content = '';
  2022. }
  2023. let vod_id = link;
  2024. let vod_name = _pdfh(it, p1).replace(/\n|\t/g,'').trim();
  2025. let vod_pic = _pd(it, p2,MY_URL);
  2026. if(rule.二级==='*'){
  2027. vod_id = vod_id+'@@'+vod_name+'@@'+vod_pic;
  2028. }
  2029. let ob = {
  2030. 'vod_id': vod_id,
  2031. 'vod_name': vod_name,
  2032. 'vod_pic': vod_pic,
  2033. 'vod_remarks': _pdfh(it, p3).replace(/\n|\t/g,'').trim(),
  2034. 'vod_content': content.replace(/\n|\t/g,'').trim(),
  2035. };
  2036. d.push(ob);
  2037. });
  2038. }
  2039. } catch (e) {
  2040. print('搜索发生错误:'+e.message);
  2041. return '{}'
  2042. }
  2043. }
  2044. if(rule.图片替换 && rule.图片替换.includes('=>')){
  2045. let replace_from = rule.图片替换.split('=>')[0];
  2046. let replace_to = rule.图片替换.split('=>')[1];
  2047. d.forEach(it=>{
  2048. if(it.vod_pic&&it.vod_pic.startsWith('http')){
  2049. it.vod_pic = it.vod_pic.replace(replace_from,replace_to);
  2050. }
  2051. });
  2052. }
  2053. if(rule.图片来源){
  2054. d.forEach(it=>{
  2055. if(it.vod_pic&&it.vod_pic.startsWith('http')){
  2056. it.vod_pic = it.vod_pic + rule.图片来源;
  2057. }
  2058. });
  2059. }
  2060. // print(d);
  2061. return JSON.stringify({
  2062. 'page': parseInt(searchObj.pg),
  2063. 'pagecount': 10,
  2064. 'limit': 20,
  2065. 'total': 100,
  2066. 'list': d,
  2067. });
  2068. }
  2069. /**
  2070. * 二级详情页数据解析
  2071. * @param detailObj
  2072. * @returns {string}
  2073. */
  2074. function detailParse(detailObj){
  2075. let t1 = (new Date()).getTime();
  2076. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  2077. let orId = detailObj.orId;
  2078. let vod_name = '片名';
  2079. let vod_pic = '';
  2080. let vod_id = orId;
  2081. if(rule.二级==='*'){
  2082. // vod_id = orId.split('@@')[0]; // 千万不能分割
  2083. let extra = orId.split('@@');
  2084. vod_name = extra.length>1?extra[1]:vod_name;
  2085. vod_pic = extra.length>2?extra[2]:vod_pic;
  2086. }
  2087. // print(vod_pic);
  2088. let vod = {
  2089. vod_id: vod_id, //"id",
  2090. vod_name: vod_name,
  2091. vod_pic: vod_pic,
  2092. type_name: "类型",
  2093. vod_year: "年份",
  2094. vod_area: "地区",
  2095. vod_remarks: "更新信息",
  2096. vod_actor: "主演",
  2097. vod_director: "导演",
  2098. vod_content: "简介"
  2099. };
  2100. let p = detailObj.二级;
  2101. let url = detailObj.url;
  2102. let detailUrl = detailObj.detailUrl;
  2103. let fyclass = detailObj.fyclass;
  2104. let tab_exclude = detailObj.tab_exclude;
  2105. let html = detailObj.html||'';
  2106. MY_URL = url;
  2107. if(detailObj.二级访问前){
  2108. try {
  2109. print(`尝试在二级访问前执行代码:${detailObj.二级访问前}`);
  2110. eval(detailObj.二级访问前.trim().replace('js:',''));
  2111. }catch (e) {
  2112. print(`二级访问前执行代码出现错误:${e.message}`)
  2113. }
  2114. }
  2115. // console.log(MY_URL);
  2116. // setItem('MY_URL',MY_URL);
  2117. if(p==='*'){
  2118. vod.vod_play_from = '道长在线';
  2119. vod.vod_remarks = detailUrl;
  2120. vod.vod_actor = '没有二级,只有一级链接直接嗅探播放';
  2121. vod.vod_content = MY_URL;
  2122. vod.vod_play_url = '嗅探播放$' + MY_URL.split('@@')[0];
  2123. }else if(typeof(p)==='string'&&p.trim().startsWith('js:')){
  2124. const TYPE = 'detail';
  2125. var input = MY_URL;
  2126. var play_url = '';
  2127. eval(p.trim().replace('js:',''));
  2128. vod = VOD;
  2129. console.log(JSON.stringify(vod));
  2130. }else if(p&&typeof(p)==='object'){
  2131. let tt1 = (new Date()).getTime();
  2132. if(!html){
  2133. html = getHtml(MY_URL);
  2134. }
  2135. print(`二级${MY_URL}仅获取源码耗时:${(new Date()).getTime()-tt1}毫秒`);
  2136. let _ps;
  2137. if(p.is_json){
  2138. print('二级是json');
  2139. _ps = parseTags.json;
  2140. html = dealJson(html);
  2141. }else if(p.is_jsp){
  2142. print('二级是jsp');
  2143. _ps = parseTags.jsp;
  2144. }else if(p.is_jq){
  2145. print('二级是jq');
  2146. _ps = parseTags.jq;
  2147. }else{
  2148. print('二级默认jq');
  2149. _ps = parseTags.jq;
  2150. // print('二级默认jsp');
  2151. // _ps = parseTags.jsp;
  2152. }
  2153. let tt2 = (new Date()).getTime();
  2154. print(`二级${MY_URL}获取并装载源码耗时:${tt2-tt1}毫秒`);
  2155. _pdfa = _ps.pdfa;
  2156. _pdfh = _ps.pdfh;
  2157. _pd = _ps.pd;
  2158. if(p.title){
  2159. let p1 = p.title.split(';');
  2160. vod.vod_name = _pdfh(html, p1[0]).replace(/\n|\t/g,'').trim();
  2161. let type_name = p1.length > 1 ? _pdfh(html, p1[1]).replace(/\n|\t/g,'').replace(/ /g,'').trim():'';
  2162. vod.type_name = type_name||vod.type_name;
  2163. }
  2164. if(p.desc){
  2165. try{
  2166. let p1 = p.desc.split(';');
  2167. vod.vod_remarks = _pdfh(html, p1[0]).replace(/\n|\t/g,'').trim();
  2168. vod.vod_year = p1.length > 1 ? _pdfh(html, p1[1]).replace(/\n|\t/g,'').trim():'';
  2169. vod.vod_area = p1.length > 2 ? _pdfh(html, p1[2]).replace(/\n|\t/g,'').trim():'';
  2170. // vod.vod_actor = p1.length > 3 ? _pdfh(html, p1[3]).replaceAll('\n', ' ').trim():'';
  2171. vod.vod_actor = p1.length > 3 ? _pdfh(html, p1[3]).replace(/\n|\t/g,'').trim():'';
  2172. vod.vod_director = p1.length > 4 ? _pdfh(html, p1[4]).replace(/\n|\t/g,'').trim():'';
  2173. }
  2174. catch (e) {
  2175. }
  2176. }
  2177. if(p.content){
  2178. try{
  2179. let p1 = p.content.split(';');
  2180. vod.vod_content = _pdfh(html, p1[0]).replace(/\n|\t/g,'').trim();
  2181. }
  2182. catch (e) {}
  2183. }
  2184. if(p.img){
  2185. try{
  2186. let p1 = p.img.split(';');
  2187. vod.vod_pic = _pd(html, p1[0],MY_URL);
  2188. }
  2189. catch (e) {}
  2190. }
  2191. let vod_play_from = '$$$';
  2192. let playFrom = [];
  2193. if(p.重定向&&p.重定向.startsWith('js:')){
  2194. print('开始执行重定向代码:'+p.重定向);
  2195. html = eval(p.重定向.replace('js:',''));
  2196. }
  2197. // console.log(2);
  2198. if(p.tabs){
  2199. if(p.tabs.startsWith('js:')){
  2200. print('开始执行tabs代码:'+p.tabs);
  2201. var input = MY_URL;
  2202. eval(p.tabs.replace('js:',''));
  2203. playFrom = TABS;
  2204. }else{
  2205. let p_tab = p.tabs.split(';')[0];
  2206. // console.log(p_tab);
  2207. let vHeader = _pdfa(html, p_tab);
  2208. console.log(vHeader.length);
  2209. let tab_text = p.tab_text||'body&&Text';
  2210. // print('tab_text:'+tab_text);
  2211. let new_map = {};
  2212. for(let v of vHeader){
  2213. let v_title = _pdfh(v,tab_text).trim();
  2214. if(!v_title){
  2215. v_title = '线路空'
  2216. }
  2217. console.log(v_title);
  2218. if(tab_exclude&& (new RegExp(tab_exclude)).test(v_title)){
  2219. continue;
  2220. }
  2221. if(!new_map.hasOwnProperty(v_title)){
  2222. new_map[v_title] = 1;
  2223. }else{
  2224. new_map[v_title] += 1;
  2225. }
  2226. if(new_map[v_title]>1){
  2227. v_title+=Number(new_map[v_title]-1);
  2228. }
  2229. playFrom.push(v_title);
  2230. }
  2231. }
  2232. console.log(JSON.stringify(playFrom));
  2233. }else{
  2234. playFrom = ['道长在线']
  2235. }
  2236. vod.vod_play_from = playFrom.join(vod_play_from);
  2237. // console.log(3);
  2238. let vod_play_url = '$$$';
  2239. let vod_tab_list = [];
  2240. if(p.lists){
  2241. if(p.lists.startsWith('js:')){
  2242. print('开始执行lists代码:'+p.lists);
  2243. try {
  2244. var input = MY_URL;
  2245. var play_url = '';
  2246. eval(p.lists.replace('js:',''));
  2247. for(let i in LISTS){
  2248. if(LISTS.hasOwnProperty(i)){
  2249. // print(i);
  2250. try {
  2251. LISTS[i] = LISTS[i].map(it=>it.split('$').slice(0,2).join('$'));
  2252. }catch (e) {
  2253. print('格式化LISTS发生错误:'+e.message);
  2254. }
  2255. }
  2256. }
  2257. vod_play_url = LISTS.map(it=>it.join('#')).join(vod_play_url);
  2258. }catch (e) {
  2259. print('js执行lists: 发生错误:'+e.message);
  2260. }
  2261. }else{
  2262. let list_text = p.list_text||'body&&Text';
  2263. let list_url = p.list_url||'a&&href';
  2264. // print('list_text:'+list_text);
  2265. // print('list_url:'+list_url);
  2266. // print('list_parse:'+p.lists);
  2267. let is_tab_js = p.tabs.trim().startsWith('js:');
  2268. for(let i=0;i<playFrom.length;i++){
  2269. let tab_name = playFrom[i];
  2270. let tab_ext = p.tabs.split(';').length > 1 && !is_tab_js ? p.tabs.split(';')[1] : '';
  2271. let p1 = p.lists.replaceAll('#idv', tab_name).replaceAll('#id', i);
  2272. tab_ext = tab_ext.replaceAll('#idv', tab_name).replaceAll('#id', i);
  2273. let tabName = tab_ext?_pdfh(html, tab_ext):tab_name;
  2274. console.log(tabName);
  2275. // print('tab_ext:'+tab_ext);
  2276. let new_vod_list = [];
  2277. let tt1 = (new Date()).getTime();
  2278. // print('pdfl:'+typeof (pdfl));
  2279. if(typeof (pdfl) ==='function'){
  2280. new_vod_list = pdfl(html, p1, list_text, list_url, MY_URL);
  2281. }else {
  2282. let vodList = [];
  2283. try {
  2284. vodList = _pdfa(html, p1);
  2285. console.log('len(vodList):'+vodList.length);
  2286. }catch (e) {
  2287. // console.log(e.message);
  2288. }
  2289. for (let i = 0; i < vodList.length; i++) {
  2290. let it = vodList[i];
  2291. new_vod_list.push(_pdfh(it, list_text).trim() + '$' + _pd(it, list_url, MY_URL));
  2292. }
  2293. }
  2294. if(new_vod_list.length>0){
  2295. new_vod_list = forceOrder(new_vod_list,'',x=>x.split('$')[0]);
  2296. console.log(`drpy影响性能代码共计列表数循环次数:${new_vod_list.length},耗时:${(new Date()).getTime()-tt1}毫秒`);
  2297. }
  2298. // print(new_vod_list);
  2299. let vlist = new_vod_list.join('#');
  2300. vod_tab_list.push(vlist);
  2301. }
  2302. vod_play_url = vod_tab_list.join(vod_play_url);
  2303. }
  2304. }
  2305. vod.vod_play_url = vod_play_url;
  2306. }
  2307. if(rule.图片替换 && rule.图片替换.includes('=>')){
  2308. let replace_from = rule.图片替换.split('=>')[0];
  2309. let replace_to = rule.图片替换.split('=>')[1];
  2310. vod.vod_pic = vod.vod_pic.replace(replace_from,replace_to);
  2311. }
  2312. if(rule.图片来源 && vod.vod_pic && vod.vod_pic.startsWith('http')){
  2313. vod.vod_pic = vod.vod_pic + rule.图片来源;
  2314. }
  2315. if(!vod.vod_id||(vod_id.includes('$')&&vod.vod_id!==vod_id)){
  2316. vod.vod_id = vod_id;
  2317. }
  2318. let t2 = (new Date()).getTime();
  2319. console.log(`加载二级界面${MY_URL}耗时:${t2-t1}毫秒`);
  2320. // print(vod);
  2321. vod = vodDeal(vod);
  2322. // print(vod);
  2323. return JSON.stringify({
  2324. list: [vod]
  2325. })
  2326. }
  2327. /**
  2328. * 获取二级待返回的播放线路没处理时的索引关系
  2329. * @param vod
  2330. * @returns {{}}
  2331. */
  2332. function get_tab_index(vod){
  2333. let obj = {};
  2334. vod.vod_play_from.split('$$$').forEach((it,index)=>{
  2335. obj[it] = index;
  2336. });
  2337. return obj
  2338. }
  2339. /**
  2340. * 处理待返回的vod数据|线路去除,排序,重命名
  2341. * @param vod
  2342. * @returns {*}
  2343. */
  2344. function vodDeal(vod){
  2345. let vod_play_from = vod.vod_play_from.split('$$$');
  2346. let vod_play_url = vod.vod_play_url.split('$$$');
  2347. // 移除指定线路后的列表
  2348. let tab_removed_list = vod_play_from;
  2349. // 排序后的线路列表
  2350. let tab_ordered_list = vod_play_from;
  2351. // 线路重命名后的列表
  2352. let tab_renamed_list = vod_play_from;
  2353. // 定义实际要返回线路
  2354. let tab_list = vod_play_from;
  2355. // 选集列表根据线路排序
  2356. let play_ordered_list = vod_play_url;
  2357. // 判断有移除线路或者线路排序
  2358. if((rule.tab_remove&&rule.tab_remove.length>0)||(rule.tab_order&&rule.tab_order.length>0)){
  2359. // 获取原来线路的索引下标
  2360. let tab_index_dict = get_tab_index(vod);
  2361. if(rule.tab_remove&&rule.tab_remove.length>0){
  2362. tab_removed_list = vod_play_from.filter(it=>!rule.tab_remove.includes(it));
  2363. tab_list = tab_removed_list;
  2364. }
  2365. if(rule.tab_order&&rule.tab_order.length>0){
  2366. let tab_order = rule.tab_order;
  2367. tab_ordered_list = tab_removed_list.sort((a, b) => {
  2368. return (tab_order.indexOf(a)===-1?9999:tab_order.indexOf(a)) - (tab_order.indexOf(b)===-1?9999:tab_order.indexOf(b))
  2369. });
  2370. tab_list = tab_ordered_list;
  2371. }
  2372. play_ordered_list = tab_list.map(it=>vod_play_url[tab_index_dict[it]]);
  2373. }
  2374. if(rule.tab_rename&&typeof(rule.tab_rename)==='object'&Object.keys(rule.tab_rename).length>0){
  2375. tab_renamed_list = tab_list.map(it=>rule.tab_rename[it]||it);
  2376. tab_list = tab_renamed_list;
  2377. }
  2378. vod.vod_play_from = tab_list.join('$$$');
  2379. vod.vod_play_url = play_ordered_list.join('$$$');
  2380. return vod
  2381. }
  2382. /**
  2383. * 判断是否需要解析
  2384. * @param url
  2385. * @returns {number|number}
  2386. */
  2387. function tellIsJx(url){
  2388. try {
  2389. let is_vip = !/\.(m3u8|mp4|m4a)$/.test(url.split('?')[0]) && 是否正版(url);
  2390. return is_vip?1:0
  2391. }catch (e) {
  2392. return 1
  2393. }
  2394. }
  2395. /**
  2396. * 选集播放点击事件解析
  2397. * @param playObj
  2398. * @returns {string}
  2399. */
  2400. function playParse(playObj){
  2401. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  2402. MY_URL = playObj.url;
  2403. var MY_FLAG = playObj.flag;
  2404. if(!/http/.test(MY_URL)){
  2405. try {
  2406. MY_URL = base64Decode(MY_URL);
  2407. }catch (e) {}
  2408. }
  2409. MY_URL = decodeURIComponent(MY_URL);
  2410. var input = MY_URL;//注入给免嗅js
  2411. var flag = MY_FLAG;//注入播放线路名称给免嗅js
  2412. let common_play = {
  2413. parse:1,
  2414. url:input,
  2415. flag:flag,
  2416. // url:urlencode(input),
  2417. jx:tellIsJx(input)
  2418. };
  2419. let lazy_play;
  2420. if(!rule.play_parse||!rule.lazy){
  2421. lazy_play = common_play;
  2422. }else if(rule.play_parse&&rule.lazy&&typeof(rule.lazy)==='string'){
  2423. try {
  2424. let lazy_code = rule.lazy.trim();
  2425. if(lazy_code.startsWith('js:')){
  2426. lazy_code = lazy_code.replace('js:','').trim();
  2427. }
  2428. print('开始执行js免嗅=>'+lazy_code);
  2429. eval(lazy_code);
  2430. lazy_play = typeof(input) === 'object'?input:{
  2431. parse:1,
  2432. jx:tellIsJx(input),
  2433. url:input
  2434. };
  2435. }catch (e) {
  2436. print('js免嗅错误:'+e.message);
  2437. lazy_play = common_play;
  2438. }
  2439. }else{
  2440. lazy_play = common_play;
  2441. }
  2442. // print('play_json:'+typeof(rule.play_json));
  2443. // console.log(Array.isArray(rule.play_json));
  2444. if(Array.isArray(rule.play_json) && rule.play_json.length >0){ // 数组情况判断长度大于0
  2445. let web_url = lazy_play.url;
  2446. for(let pjson of rule.play_json){
  2447. if(pjson.re && (pjson.re==='*'||web_url.match(new RegExp(pjson.re)))){
  2448. if(pjson.json && typeof(pjson.json)==='object'){
  2449. let base_json = pjson.json;
  2450. // print('开始合并:');
  2451. // print(base_json);
  2452. lazy_play = Object.assign(lazy_play,base_json);
  2453. break;
  2454. }
  2455. }
  2456. }
  2457. }else if(rule.play_json && !Array.isArray(rule.play_json)){ // 其他情况 非[] 判断true/false
  2458. let base_json = {
  2459. jx:1,
  2460. parse:1,
  2461. };
  2462. lazy_play = Object.assign(lazy_play,base_json);
  2463. }else if(!rule.play_json){ // 不解析传0
  2464. let base_json = {
  2465. jx:0,
  2466. parse:1,
  2467. };
  2468. lazy_play = Object.assign(lazy_play,base_json);
  2469. }
  2470. console.log(JSON.stringify(lazy_play));
  2471. return JSON.stringify(lazy_play);
  2472. }
  2473. /**
  2474. * 本地代理解析规则
  2475. * @param params
  2476. */
  2477. function proxyParse(proxyObj){
  2478. var input = proxyObj.params;
  2479. if(proxyObj.proxy_rule){
  2480. log('准备执行本地代理规则:\n'+proxyObj.proxy_rule);
  2481. try {
  2482. eval(proxyObj.proxy_rule);
  2483. if(input && input!== proxyObj.params && Array.isArray(input) &&input.length===3){
  2484. return input
  2485. }else{
  2486. return [404,'text/plain','Not Found']
  2487. }
  2488. }catch (e) {
  2489. return [500,'text/plain','代理规则错误:'+e.message]
  2490. }
  2491. }else{
  2492. return [404,'text/plain','Not Found']
  2493. }
  2494. }
  2495. /**
  2496. * 辅助嗅探解析规则
  2497. * @param isVideoObj
  2498. * @returns {boolean}
  2499. */
  2500. function isVideoParse(isVideoObj){
  2501. var input = isVideoObj.url;
  2502. if(!isVideoObj.t){ // t为假代表默认传的正则字符串
  2503. let re_matcher = new RegExp(isVideoObj.isVideo,'i'); // /g匹配多个,/i不区分大小写,/m匹配多行
  2504. return re_matcher.test(input);
  2505. }else{
  2506. // 执行js
  2507. try {
  2508. eval(isVideoObj.isVideo);
  2509. if(typeof(input)==='boolean'){
  2510. return input
  2511. }else{
  2512. return false
  2513. }
  2514. }catch (e) {
  2515. log('执行嗅探规则发生错误:'+e.message);
  2516. return false
  2517. }
  2518. }
  2519. }
  2520. /**
  2521. * js源预处理特定返回对象中的函数
  2522. * @param ext
  2523. */
  2524. function init(ext) {
  2525. console.log('init');
  2526. try {
  2527. // make shared jsContext happy muban不能import,不然会造成换源继承后变量被篡改
  2528. // if (typeof (globalThis.mubanJs) === 'undefined') {
  2529. // let mubanJs = request('https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/js/模板.js', { 'User-Agent': MOBILE_UA });
  2530. // mubanJs = mubanJs.replace('export default', '(function() {return muban;}()) // export default');
  2531. // // console.log(mubanJs);
  2532. // globalThis.mubanJs = mubanJs;
  2533. // }
  2534. // let muban = eval(globalThis.mubanJs);
  2535. let muban = 模板.getMubans();
  2536. // print(typeof (muban));
  2537. // print(muban);
  2538. if (typeof ext == 'object'){
  2539. rule = ext;
  2540. } else if (typeof ext == 'string') {
  2541. if (ext.startsWith('http')) {
  2542. let query = getQuery(ext); // 获取链接传参
  2543. let js = request(ext,{'method':'GET'});
  2544. if (js){
  2545. eval(js.replace('var rule', 'rule'));
  2546. }
  2547. if(query.type==='url' && query.params){ // 指定type是链接并且传了params支持简写如 ./xx.json
  2548. rule.params = urljoin(ext,query.params);
  2549. }else if(query.params){ // 没指定type直接视为字符串
  2550. rule.params = query.params;
  2551. }
  2552. } else {
  2553. eval(ext.replace('var rule', 'rule'));
  2554. }
  2555. }
  2556. if (rule.模板 && muban.hasOwnProperty(rule.模板)) {
  2557. print('继承模板:'+rule.模板);
  2558. rule = Object.assign(muban[rule.模板], rule);
  2559. }
  2560. /** 处理一下 rule规则关键字段没传递的情况 **/
  2561. let rule_cate_excludes = (rule.cate_exclude||'').split('|').filter(it=>it.trim());
  2562. let rule_tab_excludes = (rule.tab_exclude||'').split('|').filter(it=>it.trim());
  2563. rule_cate_excludes = rule_cate_excludes.concat(CATE_EXCLUDE.split('|').filter(it=>it.trim()));
  2564. rule_tab_excludes = rule_tab_excludes.concat(TAB_EXCLUDE.split('|').filter(it=>it.trim()));
  2565. rule.cate_exclude = rule_cate_excludes.join('|');
  2566. rule.tab_exclude = rule_tab_excludes.join('|');
  2567. rule.host = (rule.host||'').rstrip('/');
  2568. HOST = rule.host;
  2569. if(rule.hostJs){
  2570. console.log(`检测到hostJs,准备执行...`);
  2571. try {
  2572. eval(rule.hostJs);
  2573. rule.host = HOST.rstrip('/');
  2574. }catch (e) {
  2575. console.log(`执行${rule.hostJs}获取host发生错误:`+e.message);
  2576. }
  2577. }
  2578. rule.url = rule.url||'';
  2579. rule.double = rule.double||false;
  2580. rule.homeUrl = rule.homeUrl||'';
  2581. rule.detailUrl = rule.detailUrl||'';
  2582. rule.searchUrl = rule.searchUrl||'';
  2583. rule.homeUrl = rule.host&&rule.homeUrl?urljoin(rule.host,rule.homeUrl):(rule.homeUrl||rule.host);
  2584. rule.homeUrl = cheerio.jinja2(rule.homeUrl,{rule:rule});
  2585. rule.detailUrl = rule.host&&rule.detailUrl?urljoin(rule.host,rule.detailUrl):rule.detailUrl;
  2586. rule.二级访问前 = rule.二级访问前||'';
  2587. if(rule.url.includes('[')&&rule.url.includes(']')){
  2588. let u1 = rule.url.split('[')[0]
  2589. let u2 = rule.url.split('[')[1].split(']')[0]
  2590. rule.url = rule.host && rule.url?urljoin(rule.host,u1)+'['+urljoin(rule.host,u2)+']':rule.url;
  2591. }else{
  2592. rule.url = rule.host && rule.url ? urljoin(rule.host,rule.url) : rule.url;
  2593. }
  2594. if(rule.searchUrl.includes('[')&&rule.searchUrl.includes(']')&&!rule.searchUrl.includes('#')){
  2595. let u1 = rule.searchUrl.split('[')[0]
  2596. let u2 = rule.searchUrl.split('[')[1].split(']')[0]
  2597. rule.searchUrl = rule.host && rule.searchUrl?urljoin(rule.host,u1)+'['+urljoin(rule.host,u2)+']':rule.searchUrl;
  2598. }else{
  2599. rule.searchUrl = rule.host && rule.searchUrl ? urljoin(rule.host,rule.searchUrl) : rule.searchUrl;
  2600. }
  2601. rule.timeout = rule.timeout||5000;
  2602. rule.encoding = rule.编码||rule.encoding||'utf-8';
  2603. rule.search_encoding = rule.搜索编码||rule.search_encoding||'';
  2604. rule.图片来源 = rule.图片来源||'';
  2605. rule.图片替换 = rule.图片替换||'';
  2606. rule.play_json = rule.hasOwnProperty('play_json')?rule.play_json:[];
  2607. rule.pagecount = rule.hasOwnProperty('pagecount')?rule.pagecount:{};
  2608. rule.proxy_rule = rule.hasOwnProperty('proxy_rule')?rule.proxy_rule:'';
  2609. rule.sniffer = rule.hasOwnProperty('sniffer')?rule.sniffer:'';
  2610. rule.sniffer = !!(rule.sniffer && rule.sniffer!=='0' && rule.sniffer!=='false');
  2611. rule.isVideo = rule.hasOwnProperty('isVideo')?rule.isVideo:'';
  2612. rule.tab_remove = rule.hasOwnProperty('tab_remove')?rule.tab_remove:[];
  2613. rule.tab_order = rule.hasOwnProperty('tab_order')?rule.tab_order:[];
  2614. rule.tab_rename = rule.hasOwnProperty('tab_rename')?rule.tab_rename:{};
  2615. if(rule.headers && typeof(rule.headers) === 'object'){
  2616. try {
  2617. let header_keys = Object.keys(rule.headers);
  2618. for(let k of header_keys){
  2619. if(k.toLowerCase() === 'user-agent'){
  2620. let v = rule.headers[k];
  2621. console.log(v);
  2622. if(['MOBILE_UA','PC_UA','UC_UA','IOS_UA','UA'].includes(v)){
  2623. rule.headers[k] = eval(v);
  2624. }
  2625. }else if(k.toLowerCase() === 'cookie'){
  2626. let v = rule.headers[k];
  2627. if(v && v.startsWith('http')){
  2628. console.log(v);
  2629. try {
  2630. v = fetch(v);
  2631. console.log(v);
  2632. rule.headers[k] = v;
  2633. }catch (e) {
  2634. console.log(`从${v}获取cookie发生错误:`+e.message);
  2635. }
  2636. }
  2637. }
  2638. }
  2639. }catch (e) {
  2640. console.log('处理headers发生错误:'+e.message);
  2641. }
  2642. }
  2643. // print(rule.headers);
  2644. rule_fetch_params = {'headers': rule.headers||false, 'timeout': rule.timeout, 'encoding': rule.encoding};
  2645. oheaders = rule.headers||{};
  2646. RKEY = typeof(key)!=='undefined'&&key?key:'drpy_' + (rule.title || rule.host);
  2647. pre(); // 预处理
  2648. init_test();
  2649. }catch (e) {
  2650. console.log('init_test发生错误:'+e.message);
  2651. }
  2652. }
  2653. let homeHtmlCache = undefined;
  2654. /**
  2655. * js源获取首页分类和筛选特定返回对象中的函数
  2656. * @param filter 筛选条件字典对象
  2657. * @returns {string}
  2658. */
  2659. function home(filter) {
  2660. console.log("home");
  2661. if(typeof(rule.filter) === 'string' && rule.filter.trim().length > 0){
  2662. try {
  2663. let filter_json = ungzip(rule.filter.trim());
  2664. rule.filter = JSON.parse(filter_json);
  2665. }catch (e) {
  2666. rule.filter = {};
  2667. }
  2668. }
  2669. let homeObj = {
  2670. filter:rule.filter||false,
  2671. MY_URL: rule.homeUrl,
  2672. class_name: rule.class_name || '',
  2673. class_url: rule.class_url || '',
  2674. class_parse: rule.class_parse || '',
  2675. cate_exclude: rule.cate_exclude,
  2676. };
  2677. return homeParse(homeObj);
  2678. }
  2679. /**
  2680. * js源获取首页推荐数据列表特定返回对象中的函数
  2681. * @param params
  2682. * @returns {string}
  2683. */
  2684. function homeVod(params) {
  2685. console.log("homeVod");
  2686. let homeVodObj = {
  2687. 推荐:rule.推荐,
  2688. double:rule.double,
  2689. homeUrl:rule.homeUrl,
  2690. detailUrl:rule.detailUrl
  2691. };
  2692. return homeVodParse(homeVodObj)
  2693. // return "{}";
  2694. }
  2695. /**
  2696. * js源获取分类页一级数据列表特定返回对象中的函数
  2697. * @param tid 分类id
  2698. * @param pg 页数
  2699. * @param filter 当前选中的筛选条件
  2700. * @param extend 扩展
  2701. * @returns {string}
  2702. */
  2703. function category(tid, pg, filter, extend) {
  2704. let cateObj = {
  2705. url: rule.url,
  2706. 一级: rule.一级,
  2707. tid: tid,
  2708. pg: parseInt(pg),
  2709. filter: filter,
  2710. extend: extend
  2711. };
  2712. // console.log(JSON.stringify(extend));
  2713. return categoryParse(cateObj)
  2714. }
  2715. /**
  2716. * js源获取二级详情页数据特定返回对象中的函数
  2717. * @param vod_url 一级列表中的vod_id或者是带分类的自拼接 vod_id 如 fyclass$vod_id
  2718. * @returns {string}
  2719. */
  2720. function detail(vod_url) {
  2721. let orId = vod_url;
  2722. let fyclass = '';
  2723. log('orId:'+orId);
  2724. if(vod_url.indexOf('$')>-1){
  2725. let tmp = vod_url.split('$');
  2726. fyclass = tmp[0];
  2727. vod_url = tmp[1];
  2728. }
  2729. let detailUrl = vod_url.split('@@')[0];
  2730. let url;
  2731. if(!detailUrl.startsWith('http')&&!detailUrl.includes('/')){
  2732. url = rule.detailUrl.replaceAll('fyid', detailUrl).replaceAll('fyclass',fyclass);
  2733. }else if(detailUrl.includes('/')){
  2734. url = urljoin(rule.homeUrl,detailUrl);
  2735. }else{
  2736. url = detailUrl
  2737. }
  2738. let detailObj = {
  2739. orId: orId,
  2740. url:url,
  2741. 二级:rule.二级,
  2742. 二级访问前:rule.二级访问前,
  2743. detailUrl:detailUrl,
  2744. fyclass:fyclass,
  2745. tab_exclude:rule.tab_exclude,
  2746. }
  2747. return detailParse(detailObj)
  2748. }
  2749. /**
  2750. * js源选集按钮播放点击事件特定返回对象中的函数
  2751. * @param flag 线路名
  2752. * @param id 播放按钮的链接
  2753. * @param flags 全局配置的flags是否需要解析的标识列表
  2754. * @returns {string}
  2755. */
  2756. function play(flag, id, flags) {
  2757. let playObj = {
  2758. url:id,
  2759. flag:flag,
  2760. flags:flags
  2761. }
  2762. return playParse(playObj);
  2763. }
  2764. /**
  2765. * js源搜索返回的数据列表特定返回对象中的函数
  2766. * @param wd 搜索关键字
  2767. * @param quick 是否来自快速搜索
  2768. * @returns {string}
  2769. */
  2770. function search(wd, quick, pg) {
  2771. if(rule.search_encoding){
  2772. if(rule.search_encoding.toLowerCase()!=='utf-8'){
  2773. // 按搜索编码进行编码
  2774. wd = encodeStr(wd,rule.search_encoding);
  2775. }
  2776. }else if(rule.encoding && rule.encoding.toLowerCase()!=='utf-8'){
  2777. // 按全局编码进行编码
  2778. wd = encodeStr(wd,rule.encoding);
  2779. }
  2780. let searchObj = {
  2781. searchUrl: rule.searchUrl,
  2782. 搜索: rule.搜索,
  2783. wd: wd,
  2784. //pg: pg,
  2785. pg: pg||1,
  2786. quick: quick,
  2787. };
  2788. // console.log(JSON.stringify(searchObj));
  2789. return searchParse(searchObj)
  2790. }
  2791. /**
  2792. * js源本地代理返回的数据列表特定返回对象中的函数
  2793. * @param params 代理链接参数比如 /proxy?do=js&url=https://wwww.baidu.com => params就是 {do:'js','url':'https://wwww.baidu.com'}
  2794. * @returns {*}
  2795. */
  2796. function proxy(params){
  2797. if(rule.proxy_rule&&rule.proxy_rule.trim()){
  2798. rule.proxy_rule = rule.proxy_rule.trim();
  2799. }
  2800. if(rule.proxy_rule.startsWith('js:')){
  2801. rule.proxy_rule = rule.proxy_rule.replace('js:','');
  2802. }
  2803. let proxyObj = {
  2804. params:params,
  2805. proxy_rule:rule.proxy_rule
  2806. };
  2807. return proxyParse(proxyObj)
  2808. }
  2809. /**
  2810. * 是否启用辅助嗅探功能,启用后可以根据isVideo函数进行手动识别为视频的链接地址。默认为false
  2811. * @returns {*|boolean|boolean}
  2812. */
  2813. function sniffer(){
  2814. let enable_sniffer = rule.sniffer || false;
  2815. if(enable_sniffer){
  2816. // log('准备执行辅助嗅探代理规则:\n'+rule.isVideo);
  2817. log('开始执行辅助嗅探代理规则...');
  2818. }
  2819. return enable_sniffer
  2820. }
  2821. /**
  2822. * 启用辅助嗅探功能后根据次函数返回的值识别地址是否为视频,返回true/false
  2823. * @param url
  2824. */
  2825. function isVideo(url){
  2826. let t = 0;
  2827. let is_video;
  2828. if(rule.isVideo &&rule.isVideo.trim()){
  2829. is_video = rule.isVideo.trim();
  2830. }
  2831. if(is_video.startsWith('js:')){
  2832. is_video = is_video.replace('js:','');
  2833. t = 1;
  2834. }
  2835. let isVideoObj = {
  2836. url:url,
  2837. isVideo:is_video,
  2838. t:t,
  2839. };
  2840. let result = isVideoParse(isVideoObj);
  2841. if(result){
  2842. log('成功执行辅助嗅探规则并检测到视频地址:\n'+rule.isVideo);
  2843. }
  2844. return result
  2845. }
  2846. function DRPY(){//导出函数
  2847. return {
  2848. init: init,
  2849. home: home,
  2850. homeVod: homeVod,
  2851. category: category,
  2852. detail: detail,
  2853. play: play,
  2854. search: search,
  2855. proxy:proxy,
  2856. sniffer:sniffer,
  2857. isVideo:isVideo
  2858. }
  2859. }
  2860. /**
  2861. * 导出函数无法简写成下面的形式:
  2862. export default {
  2863. ...DRPY,
  2864. DRPY
  2865. }
  2866. */
  2867. // 导出函数对象
  2868. export default {
  2869. init,
  2870. home,
  2871. homeVod,
  2872. category,
  2873. detail,
  2874. play,
  2875. search,
  2876. proxy,
  2877. sniffer,
  2878. isVideo,
  2879. DRPY,
  2880. }