drpy2.js 146 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579
  1. import cheerio from 'assets://js/lib/cheerio.min.js';
  2. import 'assets://js/lib/crypto-js.js';
  3. import './jsencrypt.js';
  4. import './node-rsa.js';
  5. import './pako.min.js';
  6. // import JSEncrypt from './jsencrypt.js'; // 会导致壳子崩溃的
  7. import 模板 from './模板.js'
  8. import {gbkTool} from './gbk.js'
  9. import './json5.js'
  10. // 下面是尝试对jinja2库进行更换
  11. import './jinja.js'
  12. const _jinja2 = cheerio.jinja2;
  13. cheerio.jinja2 = function (template, obj) {
  14. try {
  15. return jinja.render(template, obj);
  16. } catch (e) {
  17. console.log('新的jinja2库渲染失败,换回原始cheerio:' + e.message);
  18. return _jinja2(template, obj)
  19. }
  20. };
  21. // import cheerio from "https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/cheerio.min.js";
  22. // import "https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/crypto-js.js";
  23. // import 模板 from"https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/js/模板.js";
  24. // import {gbkTool} from 'https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/gbk.js'
  25. function init_test() {
  26. // console.log(typeof(JSON5));
  27. // let a = `{'SHOW':'10','UK':'43a7dc59-e87b-449e-8b74-ba40db28e674','albumlist':[{'DC_TARGETID':'30965086','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'17294','aartist':'','ad_subtype':'102,103,501,101,301','ad_type':'1,3,5','albumid':'30965086','artist':'小白不做凤尾','artistid':'10442011','artistpic':'http://img4.kuwo.cn/star/starheads/120/92/53/247071944.jpg','color':'[#FFE2F2C6,#FF85A476]','company':'独立发行','content_type':'0','falbum':'','fartist':'小白不做凤尾','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/51/40/547190780.jpg','id':'30965086','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/51/40/547190780.jpg','info':'来听听','isstar':'1','lang':'','musiccnt':'37','name':'我的','new':'0','payvalue':'0','pic':'120/51/40/547190780.jpg','pub':'2022-08-28','score':'0','showtime':'','spPrivilege':'0','startype':'有声小说','timing_online':'0000-00-00 00:00:00','title':'','vip':'0'},{'DC_TARGETID':'28041980','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'0','aartist':'','ad_subtype':'','ad_type':'','albumid':'28041980','artist':'玄琛','artistid':'9688248','artistpic':'http://img4.kuwo.cn/star/starheads/120/96/39/3155308302.jpg','color':'[#FFE2F2C6,#FF85A476]','company':'独立发行','content_type':'0','falbum':'','fartist':'玄琛','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/72/16/2510768590.jpg','id':'28041980','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/72/16/2510768590.jpg','info':'我来诉说我的故事,请你认真聆听,做最好的聆听者','isstar':'1','lang':'','musiccnt':'2','name':'我的','new':'0','payvalue':'0','pic':'120/72/16/2510768590.jpg','pub':'2020-08-18','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'','vip':'0'},{'DC_TARGETID':'17245200','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'5529096','aartist':'','ad_subtype':'','ad_type':'','albumid':'17245200','artist':'我和我的家乡','artistid':'5037564','artistpic':'http://img4.kuwo.cn/star/starheads/0/10/27/3738071257.jpg','color':'[#FFD8F3F1,#FF719794]','company':'中青在线','content_type':'0','falbum':'','fartist':'我和我的家乡','finished':'1','hts_img':'https://img2.kuwo.cn/star/albumcover/240/85/51/1350940634.jpg','id':'17245200','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/85/51/1350940634.jpg','info':'《我和我的家乡2》是融媒体音频节目《我和我的家乡》第二季。为解读中国人的乡土情结,汇聚同心追梦的力量。【歌曲篇】每期节目将推出一个主题城市,邀请一位青春正能量明星,演唱与家乡有关的原创或翻唱歌曲,曲传乡音。','isstar':'1','lang':'','musiccnt':'5','name':'我和我的家乡第二季「歌曲篇」','new':'0','payvalue':'0','pic':'120/85/51/1350940634.jpg','pub':'2020-12-25','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'解读中国人的乡土情结','vip':'0'},{'DC_TARGETID':'12854978','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'21482961','aartist':'','ad_subtype':'','ad_type':'','albumid':'12854978','artist':'佛学听我的','artistid':'3651480','artistpic':'http://img4.kuwo.cn/star/starheads/120/21/42/3683883829.jpg','color':'[#FFD8F3F1,#FF719794]','company':'暂无','content_type':'0','falbum':'','fartist':'佛学听我的','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/99/12/1066669641.jpg','id':'12854978','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/99/12/1066669641.jpg','info':'禅音静心:禅茶一味','isstar':'1','lang':'普通话','musiccnt':'407','name':'禅音静心:禅茶一味','new':'0','payvalue':'0','pic':'120/99/12/1066669641.jpg','pub':'2020-02-23','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'禅音静心:禅茶一味','vip':'0'},{'DC_TARGETID':'13884852','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'17396226','aartist':'','ad_subtype':'','ad_type':'','albumid':'13884852','artist':'佛学听我的','artistid':'3651480','artistpic':'http://img4.kuwo.cn/star/starheads/120/21/42/3683883829.jpg','color':'[#FFD8F3F1,#FF719794]','company':'暂无','content_type':'0','falbum':'','fartist':'佛学听我的','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/91/94/4253604466.jpg','id':'13884852','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/91/94/4253604466.jpg','info':'静心听佛乐','isstar':'1','lang':'普通话','musiccnt':'228','name':'静心听佛乐','new':'0','payvalue':'0','pic':'120/91/94/4253604466.jpg','pub':'2020-04-27','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'静心听佛乐','vip':'0'},{'DC_TARGETID':'17172751','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'553401','aartist':'','ad_subtype':'102,103,101,501','ad_type':'1,5','albumid':'17172751','artist':'我和我的家乡','artistid':'5037564','artistpic':'http://img4.kuwo.cn/star/starheads/0/10/27/3738071257.jpg','color':'[#FFD8F3F1,#FF719794]','company':'中青在线','content_type':'0','falbum':'','fartist':'我和我的家乡','finished':'1','hts_img':'https://img2.kuwo.cn/star/albumcover/240/63/45/3978411674.jpg','id':'17172751','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/63/45/3978411674.jpg','info':'《我和我的家乡2》是融媒体音频节目《我和我的家乡》第二季。为解读中国人的乡土情结,汇聚同心追梦的力量。每期节目将推出一个主题城市,邀请一位青春正能量明星,用笔者独有的乡愁情感,配以讲述者也为此乡人的身份,着力刻画该城市的魅力形象,展现一座城的普通百姓生活和经济社会发展。','isstar':'1','lang':'','musiccnt':'11','name':'我和我的家乡第二季「有声篇」','new':'0','payvalue':'0','pic':'120/63/45/3978411674.jpg','pub':'2020-12-21','score':'0','showtime':'2020-12-20','spPrivilege':'0','startype':'娱乐','timing_online':'2020-12-20 23:40:00','title':'','vip':'0'},{'DC_TARGETID':'18769609','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'69987','aartist':'','ad_subtype':'101,102,103,501','ad_type':'1,5','albumid':'18769609','artist':'你是我的荣耀','artistid':'6998984','artistpic':'http://img4.kuwo.cn/star/starheads/120/41/44/262468637.jpg','color':'[#FFD8F3F1,#FF719794]','company':'暂无','content_type':'0','falbum':'','fartist':'你是我的荣耀','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/44/72/4080853707.jpg','id':'18769609','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/44/72/4080853707.jpg','info':'《你是我的荣耀》是由王之执导,潘粤明、胡可、王彦霖、杨洋、迪丽热巴、郑合惠子主演的都市爱情剧。该剧改编自顾漫创作的同名小说,主要讲述了人气女星乔晶晶在游戏中与曾经的高中同学于途意外重逢后发生的故事。\\\\\\\\\\\\\\\\\\n;跟随《你是我的荣耀》之声,一起见证航天工程师于途与人气女星乔晶晶,携手砥砺前行成为彼此荣耀的爱情故事!\\\\\\\\\\\\\\\\\\n;\\\\\\\\\\\\\\\\\\n;\\\\\\\\\\\\\\\\\\n;\\\\\\\\\\\\\\\\\\n;\\\\\\\\\\\\\\\\\\n;','isstar':'1','lang':'普通话','musiccnt':'1','name':'你是我的荣耀','new':'0','payvalue':'0','pic':'120/44/72/4080853707.jpg','pub':'2021-03-05','score':'0','showtime':'2021-03-09','spPrivilege':'0','startype':'有声小说','timing_online':'2021-03-09 00:00:00','title':'大明星恋上航天工程师 热巴杨洋甜蜜相守','vip':'0'},{'DC_TARGETID':'23641999','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'1292491','aartist':'','ad_subtype':'102,103,501,101,301','ad_type':'1,3,5','albumid':'23641999','artist':'我的存在','artistid':'8102787','artistpic':'http://img4.kuwo.cn/star/starheads/120/31/87/632983033.jpg','color':'[#FFE2F2C6,#FF85A476]','company':'独立发行','content_type':'0','falbum':'','fartist':'我的存在','finished':'1','hts_img':'https://img2.kuwo.cn/star/albumcover/240/50/6/2193571523.jpg','id':'23641999','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/50/6/2193571523.jpg','info':'为给老驸马冲喜,长亭长公主庶孙迎娶陆家女,新娘子当天却吊死在洞房,现代女医生陆漫穿越而来。委屈的某人,我要功成名就,我的生活我作主。陆漫,还你自由,我也自由……','isstar':'1','lang':'','musiccnt':'726','name':'金玉良医(完结)','new':'0','payvalue':'0','pic':'120/50/6/2193571523.jpg','pub':'2021-10-11','score':'0','showtime':'','spPrivilege':'0','startype':'有声小说','timing_online':'0000-00-00 00:00:00','title':'现代女医生陆漫穿越到古代发生的事情','vip':'0'},{'DC_TARGETID':'28177105','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'10448','aartist':'','ad_subtype':'102,103,501,101,301','ad_type':'1,3,5','albumid':'28177105','artist':'我的青糖','artistid':'9650993','artistpic':'http://img4.kuwo.cn/star/starheads/120/40/93/1019968534.jpg','color':'[#FFE2F2C6,#FF85A476]','company':'独立发行','content_type':'0','falbum':'','fartist':'我的青糖','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/62/97/3136446870.jpg','id':'28177105','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/62/97/3136446870.jpg','info':'【字数:16万字】<br>裴子墨和丁辰是一对夫妻,妻子丁辰深爱裴子墨,但裴子墨难以忘怀初恋总是对她若即若离。婚后两年,裴子墨前女友于筝突然回国,使得他和丁辰原本就不稳定的婚姻更加雪上加霜。于筝当初背叛裴子墨,受伤后才意识到裴子墨的好,于是不择手段夺回了裴子墨。丁辰和裴子墨离婚后,裴子墨才意识到两年相处,他早已习惯有丁辰的陪伴。裴子墨决心重新赢回丁辰的心,但此时丁辰身边已经有了一位极其出色的追求者,前景不容乐观……','isstar':'1','lang':'','musiccnt':'80','name':'如果你是我的传说','new':'0','payvalue':'0','pic':'120/62/97/3136446870.jpg','pub':'2022-04-21','score':'0','showtime':'1979-10-05','spPrivilege':'0','startype':'有声小说','timing_online':'2022-05-01 19:26:48','title':'','vip':'0'},{'DC_TARGETID':'12896662','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'2412258','aartist':'','ad_subtype':'','ad_type':'','albumid':'12896662','artist':'佛学听我的','artistid':'3651480','artistpic':'http://img4.kuwo.cn/star/starheads/120/21/42/3683883829.jpg','color':'[#FFD8F3F1,#FF719794]','company':'暂无','content_type':'0','falbum':'','fartist':'佛学听我的','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/93/41/3670973086.jpg','id':'12896662','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/93/41/3670973086.jpg','info':'佛书梵唱100篇','isstar':'1','lang':'普通话','musiccnt':'50','name':'佛书梵唱100篇','new':'0','payvalue':'0','pic':'120/93/41/3670973086.jpg','pub':'2020-02-24','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'佛书梵唱100篇','vip':'0'}],'pn':'0','rn':'10','total':'257'}`;
  28. // log(JSON5.parse(a));
  29. // console.log(typeof(CryptoJS));
  30. console.log("init_test_start");
  31. // print(模板);
  32. // print(typeof(模板.getMubans));
  33. console.log("当前版本号:" + VERSION);
  34. console.log('本地代理地址:' + getProxyUrl());
  35. console.log(RKEY);
  36. // ocr_demo_test();
  37. // rsa_demo_test();
  38. // console.log('Uint8Array:'+typeof(Uint8Array)+' '+'Uint16Array:'+typeof(Uint16Array));
  39. // console.log('encodeURIComponent:'+typeof(encodeURIComponent)+' '+'decodeURIComponent:'+typeof(decodeURIComponent));
  40. // console.log('atob:'+typeof(atob)+' '+'btoa:'+typeof(btoa));
  41. // log('typeof (JSEncrypt):'+typeof (JSEncrypt));
  42. // log('typeof (pako):'+typeof (pako));
  43. // let b64_str = btoa('hello hipy');
  44. // let str = atob(b64_str);
  45. // console.log(`btoa加密文本:${b64_str},atob解密文本:${str}`)
  46. // let gzip_str = gzip('{"a":"电影","b":"电影","c":"电影","d":"电影","e":"电影","f":"电影"}');
  47. // let ungzip_str = ungzip(gzip_str);
  48. // console.log(`gzip加密文本:${gzip_str},长度:${gzip_str.length},ungzip解密文本:${ungzip_str},长度:${ungzip_str.length}`);
  49. // 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"}]}]};
  50. // log(gzip(JSON.stringify(a)));
  51. console.log(JSON.stringify(rule));
  52. console.log("init_test_end");
  53. // log('typeof (JSEncrypt):'+typeof (JSEncrypt));
  54. // let publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwEc7wBMtYKkxvrQNI3+ITBZwAkPkGvsv4TsAHFskKGZWz9eYl3scivhmlEfWHlEkdyb0m82CmB1qAgef+pD4cZu+Cdmm2e9lnExhLwm8cBgpkAen9QRNdjojZgxM0W+JcReH4W6pw+uFXiLRn4AIQkDftWGNLg6wlNS+39Z/RvP9zyATJLZ9AKDdHp62XMxEK1KZvWBuIg+Oa5UzgA9jy+2XyIqwhBtO8tPbUl21t2pvTzHoLUjSkPNm2LurcUk6+jQ2r6aiS2CN1NXIucPJU6mkuIQ821SjvkYPtIdRMntW4y2u4cyiqVEEQwlzWVMHh+/vfrWAQr9fgjDuYYtvPQIDAQAB';
  55. // 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=='
  56. // // let text = '你好';
  57. // 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"}]';
  58. // let str = RSA.encode(text, publicKey);
  59. // console.log("加密数据:" + str);
  60. // let str1 = 'Wa2c/868VOm0PgpGG2s2aMrDbGOlJRdZXlSGswjFgywd3nZNB7ND8kVMdNB/OsNFoQXJXSJMvPaE73BH7rs8fz54JGdYQK+qTgfQRqQZvomCjbzseSR4bm4NOrtIOOslL3WqxlzOuU0M1P1eERmkLEVU2WSyc3RGtJro3b3MOWYCNdKMoZdncfOHJndkl4wm9V3GGc3uH98hs6OxLvBWgXoW9jZQ3n0vR2FtS2KYrPGuSuKGkxlt9Kw5TD6nri142NOimz05WK55Xe04YUQ1VZd51t0wzJGXolWgfzIQaK2zzhk5Zjlm+IQJxXqEWiJ2+O6TJ+lIttvsDSaUflcDXQ==';
  61. // let str2 = 'R86mW9DzBw05pxBSh9ECh1stXxINmnudgZBbzU/cz1EcFgrEgdk0Zk4ruAiJZB2fP5c7d3gMmN8+Dv19IfARWSzw85xCEjUhpdcMJ0jn6ZE5H+muadND9LzjeVisojqwYxot3YVdKof7HMhPFN8QR0jfzqhjmnGFTlY1jMXzJK0MSOLNRLDar480CdKNb/cxALC8+xKIlhM9E4B31t8J4rNMUWSCAr49lbZ3jx3PxieBpTQUdDJz96AttR93Pc+c51wrxh0Ch/Mt4Rs09HGMXwIpNV+CxsGwSGRQUlyJo2k3d0WqsVzpz6S8A4VGEMTRLGI3IjEt+eWt7wM3nAXarg==';
  62. // let str3 = 'D4eOsRqua+jYA5+ZOR9PLI2PExKjKfArQfv9/wGeG50bQSjWypShJPY6RQfO+rghyf0juzHIUSxqH91OxinhCFkONaF2Vod2QVyphyn9eh73dAcEFKIFFKGXoPCjbMWrr3p4d+hgVrHzrFeGqkRq8JFOvG2L5XDxVfWbV8KmUA0DKuz6QwWg7P4kesy+C7BbLALy5W/wfZchD3gnsBvx/pjFoe11VfAify9isLxg9a15jj52xr6lzQ9kge9C2JcV8yq85bFKaUpJWgobzz+BSIv3lVMU6vgcldmOrhkyiETpFGFGGF00DphGCEoK6uAyyNDh7+Jn8P17zf/DW1wV3A==';
  63. // let uncrypted = RSA.decode(str, privateKey);
  64. // log('解密数据:'+uncrypted);
  65. // uncrypted = RSA.decode(str1, privateKey);
  66. // log('解密数据1:'+uncrypted);
  67. // uncrypted = RSA.decode(str2, privateKey);
  68. // log('解密数据2:'+uncrypted);
  69. // uncrypted = RSA.decode(str3, privateKey);
  70. // log('解密数据3:'+uncrypted);
  71. // log('rsax:'+typeof(rsax));
  72. // log('rsaX:'+typeof(rsaX));
  73. // let data = base64Encode('你好');
  74. // let publicKey = 'dzyyds';
  75. // console.log(typeof (RSA.encode));
  76. // let encryptBase64Data = RSA.encode(data,publicKey);
  77. // log('encryptBase64Data:'+encryptBase64Data);
  78. // let str = RSA.decode(data,publicKey);
  79. // log('str:'+str);
  80. }
  81. /**
  82. * 验证码ocr识别的测试案例
  83. */
  84. function ocr_demo_test() {
  85. // 这张图片为4113的验证码
  86. let img_base64 = `iVBORw0KGgoAAAANSUhEUgAAAIAAAAAoBAMAAADEX+97AAAAG1BMVEXz+/4thQTa7N6QwIFFkyNeokKozqDB3b93sWHFR+MEAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABN0lEQVRIie2TQU+DQBCFt9vScvQpxR4xrcSjJCZ67JDGXsX+AdR4B3vpsSYm/m2HXaRLmuySepR3Gdidb/btDAjRq5dT96eCMlfBuzi1QLZUoZy2yz5sOvI+9iomaPEZ6nWnEtxqIyiM1RcAy44GNDhBXUjot/VVNweV1ah68FqWRyjKIOqAcyYF6rGcmpYnHzGt3fycNoMw0d3/THFu7hFSJ/8OXO6iTM8/KSg09obAzIHLO250LgQ0txOZSfgrV4Exdw98uGycJ0ErAeExZGhOmFHV9zHO6qVSj0MpLq7xZON56o++MjlsEgfVhbQWWME+xQX7J4V6zfi9A1Ly9rP1BvEXp+BbVJ/M77n+wfOIDVp51pZ4iBxvmj9AGrtvry6emwfKnVkW+ZRKd5ZNMvob36vXP9YPDmQki8QiCFAAAAAASUVORK5CYII=`;
  87. // 更换api-可以通过这个代码换掉默认的ocr接口
  88. OcrApi.api = OCR_API;
  89. let code = OcrApi.classification(img_base64);
  90. log('测试验证码图片的ocr识别结果为:' + code);
  91. }
  92. /**
  93. * rsa加解密的全方位测试案例
  94. */
  95. function rsa_demo_test() {
  96. let t1 = new Date().getTime();
  97. let pkcs1_public = `
  98. -----BEGIN RSA PUBLIC KEY-----
  99. MEgCQQCrI0pQ/ERRpJ3Ou190XJedFq846nDYP52rOtXyDxlFK5D3p6JJu2RwsKwy
  100. lsQ9xY0xYPpRZUZKMEeR7e9gmRNLAgMBAAE=
  101. -----END RSA PUBLIC KEY-----
  102. `.trim();
  103. let pkcs1_public_pem = `
  104. MEgCQQCrI0pQ/ERRpJ3Ou190XJedFq846nDYP52rOtXyDxlFK5D3p6JJu2RwsKwy
  105. lsQ9xY0xYPpRZUZKMEeR7e9gmRNLAgMBAAE=
  106. `.trim();
  107. let pkcs8_public = `
  108. -----BEGIN PUBLIC KEY-----
  109. MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/
  110. nas61fIPGUUrkPenokm7ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQ==
  111. -----END PUBLIC KEY-----`.trim();
  112. let pkcs8_public_pem = `
  113. MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/
  114. nas61fIPGUUrkPenokm7ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQ==
  115. `.trim();
  116. let pkcs1_private = `
  117. -----BEGIN RSA PRIVATE KEY-----
  118. MIIBOAIBAAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/nas61fIPGUUrkPenokm7
  119. ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQI/b6OV1z65UokQaMvSeRXt
  120. 0Yv6wiYtduQI9qpq5nzy/ytaqsbBfClNTi/HifKPKxlRouWFkc518EQI8LBxoarJ
  121. AiEA4DaONMplV8PQNa3TKn2F+SDEvLOCjdL0kHKdN90Ti28CIQDDZnTBaHgZwZbA
  122. hS7Bbf5yvwjWMhO6Y7l04/Qm7R+35QIgPuQuqXIoUSD080mp1N5WyRW++atksIF+
  123. 5lGv9e6GP/MCICnj8y/rl6Pd7tXDN6zcSeqLrfdNsREKhB3dKOCXgW9JAiAFYtFS
  124. EJNBXVRTK42SNsZ2hJ/9xLwOwnH2epT8Q43s3Q==
  125. -----END RSA PRIVATE KEY-----
  126. `.trim()
  127. let pkcs8_private = `
  128. -----BEGIN PRIVATE KEY-----
  129. MIIBUgIBADANBgkqhkiG9w0BAQEFAASCATwwggE4AgEAAkEAqyNKUPxEUaSdzrtf
  130. dFyXnRavOOpw2D+dqzrV8g8ZRSuQ96eiSbtkcLCsMpbEPcWNMWD6UWVGSjBHke3v
  131. YJkTSwIDAQABAj9vo5XXPrlSiRBoy9J5Fe3Ri/rCJi125Aj2qmrmfPL/K1qqxsF8
  132. KU1OL8eJ8o8rGVGi5YWRznXwRAjwsHGhqskCIQDgNo40ymVXw9A1rdMqfYX5IMS8
  133. s4KN0vSQcp033ROLbwIhAMNmdMFoeBnBlsCFLsFt/nK/CNYyE7pjuXTj9CbtH7fl
  134. AiA+5C6pcihRIPTzSanU3lbJFb75q2SwgX7mUa/17oY/8wIgKePzL+uXo93u1cM3
  135. rNxJ6out902xEQqEHd0o4JeBb0kCIAVi0VIQk0FdVFMrjZI2xnaEn/3EvA7CcfZ6
  136. lPxDjezd
  137. -----END PRIVATE KEY-----
  138. `.trim()
  139. let data = `
  140. NodeRsa
  141. 这是node-rsa 现在修改集成在drpy里使用`.trim();
  142. let encryptedWithPublic = NODERSA.encryptRSAWithPublicKey(data, pkcs1_public, {
  143. // PublicFormat: "pkcs1-public-pem",
  144. outputEncoding: "base64",
  145. options: {environment: "browser", encryptionScheme: 'pkcs1_oaep'},
  146. });
  147. console.log("公钥加密");
  148. console.log(encryptedWithPublic);
  149. let decryptedWithPrivate = NODERSA.decryptRSAWithPrivateKey(encryptedWithPublic, pkcs1_private, {
  150. // PublicFormat: "pkcs1-private",
  151. // outEncoding: "hex"
  152. options: {environment: "browser", encryptionScheme: 'pkcs1_oaep'},
  153. });
  154. console.log("私钥解密");
  155. console.log(decryptedWithPrivate);
  156. // https://www.btool.cn/rsa-sign
  157. let pkcs1_sha256_sign = NODERSA.sign("1", pkcs1_private, {
  158. outputEncoding: "base64",
  159. options: {environment: "browser", encryptionScheme: 'pkcs1', signingScheme: "pkcs1-sha256"},
  160. });
  161. console.log("pkcs1_sha256_sign");
  162. console.log(pkcs1_sha256_sign);
  163. let pkcs1_sha256_sign_verify = NODERSA.verify("1", "Oulx2QrgeipKYBtqEDqFb2s/+ndk2cGQxO4CkhU7iBM1vyNmmvqubpsmeoUuN3waGrYZLknSEdwBkfv0tUMpFQ==", pkcs1_private, {
  164. options: {environment: "browser", encryptionScheme: 'pkcs1', signingScheme: "pkcs1-sha256"},
  165. });
  166. console.log("pkcs1_sha256_sign_verify");
  167. console.log(pkcs1_sha256_sign_verify);
  168. let pkcs1_oaep_sha256 = NODERSA.encryptRSAWithPublicKey(data, `-----BEGIN RSA PUBLIC KEY-----
  169. MIIBCgKCAQEA5KOq1gRNyllLNWKQy8sGpZE3Q1ULLSmzZw+eaAhj9lvqn7IsT1du
  170. SYn08FfoOA2qMwtz+1O2l1mgzNoSVCyVpVabnTG+C9XKeZXAnJHd8aYA7l7Sxhdm
  171. kte+iymYZ0ZBPzijo8938iugtVvqi9UgDmnY3u/NlQDqiL5BGqSxSTd/Sgmy3zD8
  172. PYzEa3wD9vehQ5fZZ45vKIq8GNVh2Z8+IGO85FF1OsN7+b2yGJa/FmDDNn0+HP+m
  173. PfI+kYBqEVpo0Ztbc3UdxgFwGC8O1n8AQyriwHnSOtIiuBH62J/7qyC/3LEAApRb
  174. Dd9YszqzmODjQUddZKHmvc638VW+azc0EwIDAQAB
  175. -----END RSA PUBLIC KEY-----
  176. `, {
  177. outputEncoding: "base64",
  178. options: {
  179. environment: "browser", encryptionScheme: {
  180. scheme: "pkcs1_oaep",
  181. hash: "sha256",
  182. },
  183. }
  184. // options: { environment: "browser", encryptionScheme: 'pkcs1' },
  185. });
  186. console.log("pkcs1_oaep_sha256");
  187. console.log(pkcs1_oaep_sha256);
  188. decryptedWithPrivate = NODERSA.decryptRSAWithPrivateKey("kSZesAAyYh2hdsQnYMdGqb6gKAzTauBKouvBzWcc4+F8RvGd0nwO6mVkUMVilPgUuNxjEauHayHiY8gI3Py45UI3+km0rSGyHrS6dHiHgCkMejXHieglYzAB0IxX3Jkm4z/66bdB/D+GFy0oct5fGCMI1UHPjEAYOsazJDa8lBFNbjiWFeb/qiZtIx3vGM7KYPAZzyRf/zPbbQ8zy9xOmRuOl5nnIxgo0Okp3KO/RIPO4GZOSBA8f2lx1UtNwwrXAMpcNavtoqHVcjJ/9lcotXYQFrn5b299pSIRf2gVm8ZJ31SK6Z8cc14nKtvgnmsgClDzIXJ1o1RcDK+knVAySg==", `-----BEGIN RSA PRIVATE KEY-----
  189. MIIEpAIBAAKCAQEA5KOq1gRNyllLNWKQy8sGpZE3Q1ULLSmzZw+eaAhj9lvqn7Is
  190. T1duSYn08FfoOA2qMwtz+1O2l1mgzNoSVCyVpVabnTG+C9XKeZXAnJHd8aYA7l7S
  191. xhdmkte+iymYZ0ZBPzijo8938iugtVvqi9UgDmnY3u/NlQDqiL5BGqSxSTd/Sgmy
  192. 3zD8PYzEa3wD9vehQ5fZZ45vKIq8GNVh2Z8+IGO85FF1OsN7+b2yGJa/FmDDNn0+
  193. HP+mPfI+kYBqEVpo0Ztbc3UdxgFwGC8O1n8AQyriwHnSOtIiuBH62J/7qyC/3LEA
  194. ApRbDd9YszqzmODjQUddZKHmvc638VW+azc0EwIDAQABAoIBADZ/QGgUzInvsLp/
  195. zO2WbfYm39o/uhNAvk9RbLt1TIZbMFhyOpeKynHi3Swwd9xsfWX/U9zS/lGi/m31
  196. iKrhmaW4OA1G3vqpMcK7TBbFufYwUEaA+ZJX344euH8pIfdzyneMQ4z3Far2dS7l
  197. QsmjuilVV2kEFadveXewiYoVOWCu00w6bN8wy2SIHlQn+kIL6HQhWz12iKKflIKu
  198. eGRdzLHsKmBt6WbY1Wuhx7HU0fAKdlBDPxCHNlI+kybUYE9o5C2vJiaVM5wqJBgZ
  199. 8Dz8kt1QbLJ910JoLXkLVQ8uC8NJKQwFtqQjTGPnEq0+wbgz6Ij599rKZkwW/xq9
  200. l6KoUiECgYEA6Ah42tVdkNW047f03xVYXFH96RgorHRS36mR8Y+ONUq1fwKidovC
  201. WjwVujt4OPf3l1W6iyn/F6cu/bsmvPrSc3HTN0B1V31QK4OjgetxQ2PSbTldH02J
  202. NPzkt+v+cPxXpx/P5mgt7Weefw5txU547KubGrHUV5rBKFtIx9pj16MCgYEA/EF0
  203. o19+D24DZAPwlDS5VbEd7FStnwY4oQ5PqbuNOSbSJLMWU0AqzXcRokp8UTyCZ0X3
  204. ATkS1REq97kShCuR+npTR6a6DlY7sdpPI1SMLNajgB2tkx0EOzX+PfNIbHUd4jpJ
  205. I0ZMAHv/OOtkzQHDaeTWBTrzsWm6/nTiykfduNECgYEA46AMD4HpPECqKAs66e5i
  206. tI6q7JSKskObWVdcmQEfnSAhVOwcvPb2Ptda6UuV8S0xcwDi88rLOUUFUFzc79+P
  207. vTkY38cYVi/VChsluDpk7ptqv0PbGu5Rf+3n4pZdEjI7OvR2W64wAAn67uIUxc7p
  208. yiO/ET0K9rYWb6S9jXGtKMkCgYEA2kPAqoO7zZoBMQ7/oR0lp/HC1HRIbiqx4RlC
  209. 8Lgpb+QZPEwA6zPAVVvLVENi4d+bbcRp/xLlKpraNNJcJSSWAMbLPFoU7sbKjA87
  210. HnTPfRSTEA2d3Ibk3F7Rh8TzS3Ti0JZiJjVzGZAwu41iAMifzwaD8K6boUy80eNN
  211. QH2CaaECgYBUsLYvC/MiYg3w+LGOONuQongoVUXjGqnw2bjVa9RK7lwRdXPUqJ51
  212. MpVO98IkoLvGSI/0sGNP3GKNhC+eMGjJAVwFyEuOn+JsmMv9Y9uStIVi5tIHIhKw
  213. m7mp8il0kaftHdSxTbspG3tZ2fjIiFIZkLEOmRpd7ogWumgOajzUdA==
  214. -----END RSA PRIVATE KEY-----`, {
  215. // PublicFormat: "pkcs1-private",
  216. // outEncoding: "hex"
  217. options: {environment: "browser", encryptionScheme: 'pkcs1_oaep'},
  218. });
  219. console.log('decryptedWithPrivate');
  220. console.log(decryptedWithPrivate);
  221. (() => {
  222. let key = new NODERSA.NodeRSA({b: 1024});
  223. key.setOptions({encryptionScheme: 'pkcs1'})
  224. let text = `你好drpy node-ras`;
  225. let encrypted = key.encrypt(text, 'base64');
  226. console.log('encrypted: ', encrypted);
  227. const decrypted = key.decrypt(encrypted, 'utf8');
  228. console.log('decrypted: ', decrypted);
  229. })();
  230. let t2 = new Date().getTime();
  231. console.log('rsa_demo_test 测试耗时:' + (t2 - t1) + '毫秒');
  232. }
  233. /**
  234. * 执行预处理代码
  235. */
  236. function pre() {
  237. if (typeof (rule.预处理) === 'string' && rule.预处理 && rule.预处理.trim()) {
  238. let code = rule.预处理.trim();
  239. console.log("执行预处理代码:" + code);
  240. if (code.startsWith('js:')) {
  241. code = code.replace('js:', '');
  242. }
  243. try {
  244. // code里可以进行get 或者 post请求cookie并改变rule.headers 里的cookie
  245. // 直接操作 rule_fetch_params 这个变量 .headers.Cookie
  246. eval(code);
  247. } catch (e) {
  248. console.log(`预处理执行失败:${e.message}`);
  249. }
  250. }
  251. }
  252. let rule = {};
  253. let vercode = typeof (pdfl) === 'function' ? 'drpy2.1' : 'drpy2';
  254. const VERSION = vercode + ' 3.9.51beta2 20240711';
  255. /** 已知问题记录
  256. * 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
  257. * Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
  258. * 2.import es6py.js但是里面的函数没有被装载进来.比如drpy规则报错setResult2 is undefiend(合并文件了可以不管了)
  259. * 3.无法重复导入cheerio(怎么解决drpy和parseTag里都需要导入cheerio的问题) 无法在副文件导入cheerio (现在是全部放在drpy一个文件里了,凑合解决?)
  260. * 4.有个错误不知道哪儿来的 executeScript: com.quickjs.JSObject$Undefined cannot be cast to java.lang.String 在 点击选集播放打印init_test_end后面打印(貌似不影响使用)
  261. * 5.需要实现 stringify 函数,比起JSON.strifngify函数,它会原封不动保留中文不会编码unicode
  262. * 6.base64Encode,base64Decode,md5函数还没有实现 (抄影魔代码实现了)
  263. * 7.eval(getCryptoJS());还没有实现 (可以空实现了,以后遇到能忽略)
  264. * done: jsp:{pdfa,pdfh,pd},json:{pdfa,pdfh,pd},jq:{pdfa,pdfh,pd}
  265. * 8.req函数不支持传递字符串的data参数 {'content-type':'text/plain'} 类型数据,因此无法直接调用alist的ocr接口
  266. * * 电脑看日志调试
  267. adb tcpip 5555
  268. adb connect 192.168.10.192
  269. adb devices -l
  270. adb logcat -c
  271. adb logcat | grep -i QuickJS
  272. adb logcat -c -b events
  273. adb logcat -c -b main -b events -b radio -b system
  274. adb logcat > 2.log DRPY:E | grep -i QuickJS
  275. * **/
  276. /*** 以下是内置变量和解析方法 **/
  277. const MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36';
  278. 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';
  279. const UA = 'Mozilla/5.0';
  280. 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';
  281. 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';
  282. const RULE_CK = 'cookie'; // 源cookie的key值
  283. // const KEY = typeof(key)!=='undefined'&&key?key:'drpy_' + (rule.title || rule.host); // 源的唯一标识
  284. const CATE_EXCLUDE = '首页|留言|APP|下载|资讯|新闻|动态';
  285. const TAB_EXCLUDE = '猜你|喜欢|下载|剧情|榜|评论';
  286. const OCR_RETRY = 3;//ocr验证重试次数
  287. // const OCR_API = 'http://drpy.nokia.press:8028/ocr/drpy/text';//ocr在线识别接口
  288. const OCR_API = 'https://api.nn.ci/ocr/b64/text';//ocr在线识别接口
  289. if (typeof (MY_URL) === 'undefined') {
  290. var MY_URL; // 全局注入变量,pd函数需要
  291. }
  292. var HOST;
  293. var RKEY; // 源的唯一标识
  294. var fetch;
  295. var print;
  296. var log;
  297. var rule_fetch_params;
  298. var fetch_params; // 每个位置单独的
  299. var oheaders;
  300. // var play_url; // 二级详情页注入变量,为了适配js模式0 (不在这里定义了,直接二级里定义了个空字符串)
  301. var _pdfh;
  302. var _pdfa;
  303. var _pd;
  304. // const DOM_CHECK_ATTR = ['url', 'src', 'href', 'data-original', 'data-src'];
  305. const DOM_CHECK_ATTR = /(url|src|href|-original|-src|-play|-url|style)$/;
  306. // 过滤特殊链接,不走urlJoin
  307. const SPECIAL_URL = /^(ftp|magnet|thunder|ws):/;
  308. const NOADD_INDEX = /:eq|:lt|:gt|:first|:last|^body$|^#/; // 不自动加eq下标索引
  309. const URLJOIN_ATTR = /(url|src|href|-original|-src|-play|-url|style)$|^(data-|url-|src-)/; // 需要自动urljoin的属性
  310. const SELECT_REGEX = /:eq|:lt|:gt|#/g;
  311. const SELECT_REGEX_A = /:eq|:lt|:gt/g;
  312. // 增加$js工具,支持$js.toString(()=>{});
  313. const $js = {
  314. toString(func) {
  315. let strfun = func.toString();
  316. return strfun.replace(/^\(\)(\s+)?=>(\s+)?\{/, "js:").replace(/\}$/, '');
  317. }
  318. };
  319. function window_b64() {
  320. let b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
  321. 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);
  322. function btoa(str) {
  323. var out, i, len;
  324. var c1, c2, c3;
  325. len = str.length;
  326. i = 0;
  327. out = "";
  328. while (i < len) {
  329. c1 = str.charCodeAt(i++) & 0xff;
  330. if (i == len) {
  331. out += b64map.charAt(c1 >> 2);
  332. out += b64map.charAt((c1 & 0x3) << 4);
  333. out += "==";
  334. break;
  335. }
  336. c2 = str.charCodeAt(i++);
  337. if (i == len) {
  338. out += b64map.charAt(c1 >> 2);
  339. out += b64map.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  340. out += b64map.charAt((c2 & 0xF) << 2);
  341. out += "=";
  342. break;
  343. }
  344. c3 = str.charCodeAt(i++);
  345. out += b64map.charAt(c1 >> 2);
  346. out += b64map.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
  347. out += b64map.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
  348. out += b64map.charAt(c3 & 0x3F);
  349. }
  350. return out;
  351. }
  352. function atob(str) {
  353. var c1, c2, c3, c4;
  354. var i, len, out;
  355. len = str.length;
  356. i = 0;
  357. out = "";
  358. while (i < len) {
  359. do {
  360. c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
  361. } while (i < len && c1 == -1);
  362. if (c1 == -1) break;
  363. do {
  364. c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
  365. } while (i < len && c2 == -1);
  366. if (c2 == -1) break;
  367. out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
  368. do {
  369. c3 = str.charCodeAt(i++) & 0xff;
  370. if (c3 == 61) return out;
  371. c3 = base64DecodeChars[c3];
  372. } while (i < len && c3 == -1);
  373. if (c3 == -1) break;
  374. out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
  375. do {
  376. c4 = str.charCodeAt(i++) & 0xff;
  377. if (c4 == 61) return out;
  378. c4 = base64DecodeChars[c4];
  379. } while (i < len && c4 == -1);
  380. if (c4 == -1) break;
  381. out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
  382. }
  383. return out;
  384. }
  385. return {
  386. atob,
  387. btoa
  388. }
  389. }
  390. /**
  391. es6py扩展
  392. */
  393. if (typeof atob !== 'function' || typeof btoa !== 'function') {
  394. var {atob, btoa} = window_b64();
  395. }
  396. if (typeof Object.assign !== 'function') {
  397. Object.assign = function () {
  398. let target = arguments[0];
  399. for (let i = 1; i < arguments.length; i++) {
  400. let source = arguments[i];
  401. for (let key in source) {
  402. if (Object.prototype.hasOwnProperty.call(source, key)) {
  403. target[key] = source[key];
  404. }
  405. }
  406. }
  407. return target;
  408. };
  409. }
  410. if (!String.prototype.includes) {
  411. String.prototype.includes = function (search, start) {
  412. if (typeof start !== 'number') {
  413. start = 0;
  414. }
  415. if (start + search.length > this.length) {
  416. return false;
  417. } else {
  418. return this.indexOf(search, start) !== -1;
  419. }
  420. };
  421. }
  422. if (!Array.prototype.includes) {
  423. Object.defineProperty(Array.prototype, 'includes', {
  424. value: function (searchElement, fromIndex) {
  425. if (this == null) {//this是空或者未定义,抛出错误
  426. throw new TypeError('"this" is null or not defined');
  427. }
  428. var o = Object(this);//将this转变成对象
  429. var len = o.length >>> 0;//无符号右移0位,获取对象length属性,如果未定义就会变成0
  430. if (len === 0) {//length为0直接返回false未找到目标值
  431. return false;
  432. }
  433. var n = fromIndex | 0;//查找起始索引
  434. var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);//计算正确起始索引,因为有可能是负值
  435. while (k < len) {//从起始索引处开始循环
  436. if (o[k] === searchElement) {//如果某一位置与寻找目标相等,返回true,找到了
  437. return true;
  438. }
  439. k++;
  440. }
  441. return false;//未找到,返回false
  442. },
  443. enumerable: false
  444. });
  445. }
  446. if (typeof String.prototype.startsWith !== 'function') {
  447. String.prototype.startsWith = function (prefix) {
  448. return this.slice(0, prefix.length) === prefix;
  449. };
  450. }
  451. if (typeof String.prototype.endsWith !== 'function') {
  452. String.prototype.endsWith = function (suffix) {
  453. return this.indexOf(suffix, this.length - suffix.length) !== -1;
  454. };
  455. }
  456. Object.defineProperty(Object.prototype, 'myValues', {
  457. value: function (obj) {
  458. if (obj == null) {
  459. throw new TypeError("Cannot convert undefined or null to object");
  460. }
  461. var res = []
  462. for (var k in obj) {
  463. if (obj.hasOwnProperty(k)) {//需判断是否是本身的属性
  464. res.push(obj[k]);
  465. }
  466. }
  467. return res;
  468. },
  469. enumerable: false
  470. });
  471. if (typeof Object.prototype.values !== 'function') {
  472. Object.defineProperty(Object.prototype, 'values', {
  473. value: function (obj) {
  474. if (obj == null) {
  475. throw new TypeError("Cannot convert undefined or null to object");
  476. }
  477. var res = []
  478. for (var k in obj) {
  479. if (obj.hasOwnProperty(k)) {//需判断是否是本身的属性
  480. res.push(obj[k]);
  481. }
  482. }
  483. return res;
  484. },
  485. enumerable: false
  486. });
  487. }
  488. if (typeof Array.prototype.join !== 'function') {
  489. Object.defineProperty(Array.prototype, 'join', {
  490. value: function (emoji) {
  491. // emoji = emoji||',';
  492. emoji = emoji || '';
  493. let self = this;
  494. let str = "";
  495. let i = 0;
  496. if (!Array.isArray(self)) {
  497. throw String(self) + 'is not Array'
  498. }
  499. if (self.length === 0) {
  500. return ''
  501. }
  502. if (self.length === 1) {
  503. return String(self[0])
  504. }
  505. i = 1;
  506. str = this[0];
  507. for (; i < self.length; i++) {
  508. str += String(emoji) + String(self[i]);
  509. }
  510. return str;
  511. },
  512. enumerable: false
  513. });
  514. }
  515. if (typeof Array.prototype.toReversed !== 'function') {
  516. Object.defineProperty(Array.prototype, 'toReversed', {
  517. value: function () {
  518. const clonedList = this.slice();
  519. // 倒序新数组
  520. const reversedList = clonedList.reverse();
  521. return reversedList;
  522. },
  523. enumerable: false
  524. });
  525. }
  526. Object.defineProperty(Array.prototype, 'append', {
  527. value: Array.prototype.push,
  528. enumerable: false
  529. });
  530. Object.defineProperty(String.prototype, 'strip', {
  531. value: String.prototype.trim,
  532. enumerable: false
  533. });
  534. Object.defineProperty(String.prototype, 'rstrip', {
  535. value: function (chars) {
  536. let regex = new RegExp(chars + "$");
  537. return this.replace(regex, "");
  538. },
  539. enumerable: false
  540. });
  541. function 是否正版(vipUrl) {
  542. 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');
  543. return flag.test(vipUrl);
  544. }
  545. function urlDeal(vipUrl) {
  546. if (!vipUrl) {
  547. return ''
  548. }
  549. if (!是否正版(vipUrl)) {
  550. return vipUrl
  551. }
  552. if (!/miguvideo/.test(vipUrl)) {
  553. vipUrl = vipUrl.split('#')[0].split('?')[0];
  554. }
  555. return vipUrl
  556. }
  557. function setResult(d) {
  558. if (!Array.isArray(d)) {
  559. return []
  560. }
  561. VODS = [];
  562. // print(d);
  563. d.forEach(function (it) {
  564. let obj = {
  565. vod_id: it.url || '',
  566. vod_name: it.title || '',
  567. vod_remarks: it.desc || '',
  568. vod_content: it.content || '',
  569. vod_pic: it.pic_url || it.img || '',
  570. };
  571. let keys = Object.keys(it);
  572. if (keys.includes('tname')) {
  573. obj.type_name = it.tname || '';
  574. }
  575. if (keys.includes('tid')) {
  576. obj.type_id = it.tid || '';
  577. }
  578. if (keys.includes('year')) {
  579. obj.vod_year = it.year || '';
  580. }
  581. if (keys.includes('actor')) {
  582. obj.vod_actor = it.actor || '';
  583. }
  584. if (keys.includes('director')) {
  585. obj.vod_director = it.director || '';
  586. }
  587. if (keys.includes('area')) {
  588. obj.vod_area = it.area || '';
  589. }
  590. VODS.push(obj);
  591. });
  592. return VODS
  593. }
  594. function setResult2(res) {
  595. VODS = res.list || [];
  596. return VODS
  597. }
  598. function setHomeResult(res) {
  599. if (!res || typeof (res) !== 'object') {
  600. return []
  601. }
  602. return setResult(res.list);
  603. }
  604. // 猫了个咪
  605. function rc(js) {
  606. if (js === 'maomi_aes.js') {
  607. var a = CryptoJS.enc.Utf8.parse("625222f9149e961d");
  608. var t = CryptoJS.enc.Utf8.parse("5efdtf6060e2o330");
  609. return {
  610. De: function (word) {
  611. word = CryptoJS.enc.Hex.parse(word)
  612. return CryptoJS.AES.decrypt(CryptoJS.enc.Base64.stringify(word), a, {
  613. iv: t,
  614. mode: CryptoJS.mode.CBC,
  615. padding: CryptoJS.pad.Pkcs7
  616. }).toString(CryptoJS.enc.Utf8)
  617. },
  618. En: function (word) {
  619. // print(a);
  620. // print(word);
  621. var Encrypted = CryptoJS.AES.encrypt(word, a, {
  622. iv: t,
  623. mode: CryptoJS.mode.CBC,
  624. padding: CryptoJS.pad.Pkcs7
  625. });
  626. return Encrypted.ciphertext.toString();
  627. }
  628. };
  629. }
  630. return {};
  631. }
  632. // 千万不要用for in 推荐 forEach (for in 会打乱顺序)
  633. //猫函数
  634. function maoss(jxurl, ref, key) {
  635. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  636. eval(getCryptoJS());
  637. try {
  638. var getVideoInfo = function (text) {
  639. return CryptoJS.AES.decrypt(text, key, {iv: iv, padding: CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8);
  640. };
  641. var token_key = key == undefined ? 'dvyYRQlnPRCMdQSe' : key;
  642. if (ref) {
  643. var html = request(jxurl, {
  644. headers: {
  645. 'Referer': ref
  646. }
  647. });
  648. } else {
  649. var html = request(jxurl);
  650. }
  651. // print(html);
  652. if (html.indexOf('&btwaf=') != -1) {
  653. html = request(jxurl + '&btwaf' + html.match(/&btwaf(.*?)"/)[1], {
  654. headers: {
  655. 'Referer': ref
  656. }
  657. })
  658. }
  659. var token_iv = html.split('_token = "')[1].split('"')[0];
  660. var key = CryptoJS.enc.Utf8.parse(token_key);
  661. var iv = CryptoJS.enc.Utf8.parse(token_iv);
  662. // log("iv:"+iv);
  663. // log(html);
  664. // print(key);
  665. // print(iv);
  666. eval(html.match(/var config = {[\s\S]*?}/)[0] + '');
  667. // config.url = config.url.replace(/,/g,'');
  668. // print(config.url);
  669. if (!config.url.startsWith('http')) {
  670. //config.url = decodeURIComponent(AES(config.url, key, iv));
  671. config.url = CryptoJS.AES.decrypt(config.url, key, {
  672. iv: iv,
  673. padding: CryptoJS.pad.Pkcs7
  674. }).toString(CryptoJS.enc.Utf8)
  675. }
  676. return config.url;
  677. } catch (e) {
  678. return '';
  679. }
  680. }
  681. /**
  682. * 将base64编码进行url编译
  683. * @param str
  684. * @returns {string}
  685. */
  686. function urlencode(str) {
  687. str = (str + '').toString();
  688. return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
  689. }
  690. /**
  691. * url编码,同 encodeURI
  692. * @param str
  693. * @returns {string}
  694. */
  695. function encodeUrl(str) {
  696. if (typeof (encodeURI) == 'function') {
  697. return encodeURI(str)
  698. } else {
  699. str = (str + '').toString();
  700. return encodeURIComponent(str).replace(/%2F/g, '/').replace(/%3F/g, '?').replace(/%3A/g, ':').replace(/%40/g, '@').replace(/%3D/g, '=').replace(/%3A/g, ':').replace(/%2C/g, ',').replace(/%2B/g, '+').replace(/%24/g, '$');
  701. }
  702. }
  703. function base64Encode(text) {
  704. return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(text));
  705. // return text
  706. }
  707. function base64Decode(text) {
  708. return CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(text));
  709. // return text
  710. }
  711. function md5(text) {
  712. return CryptoJS.MD5(text).toString();
  713. }
  714. function uint8ArrayToBase64(uint8Array) {
  715. let binaryString = String.fromCharCode.apply(null, Array.from(uint8Array));
  716. return btoa(binaryString);
  717. }
  718. function Utf8ArrayToStr(array) {
  719. var out, i, len, c;
  720. var char2, char3;
  721. out = "";
  722. len = array.length;
  723. i = 0;
  724. while (i < len) {
  725. c = array[i++];
  726. switch (c >> 4) {
  727. case 0:
  728. case 1:
  729. case 2:
  730. case 3:
  731. case 4:
  732. case 5:
  733. case 6:
  734. case 7:
  735. out += String.fromCharCode(c);
  736. break;
  737. case 12:
  738. case 13:
  739. char2 = array[i++];
  740. out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f));
  741. break;
  742. case 14:
  743. char2 = array[i++];
  744. char3 = array[i++];
  745. out += String.fromCharCode(
  746. ((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0)
  747. );
  748. break;
  749. }
  750. }
  751. return out;
  752. }
  753. /**
  754. * gzip压缩base64|压缩率80%+
  755. * @param str
  756. * @returns {string}
  757. */
  758. function gzip(str) {
  759. let arr = pako.gzip(str, {
  760. // to: 'string'
  761. });
  762. return uint8ArrayToBase64(arr)
  763. }
  764. /**
  765. * gzip解压base64数据
  766. * @param b64Data
  767. * @returns {string}
  768. */
  769. function ungzip(b64Data) {
  770. let strData = atob(b64Data);
  771. const charData = strData.split('').map(function (x) {
  772. return x.charCodeAt(0);
  773. });
  774. const binData = new Uint8Array(charData);
  775. const data = pako.inflate(binData);
  776. return Utf8ArrayToStr(data);
  777. }
  778. /**
  779. * 字符串按指定编码
  780. * @param input
  781. * @param encoding
  782. * @returns {*}
  783. */
  784. function encodeStr(input, encoding) {
  785. encoding = encoding || 'gbk';
  786. if (encoding.startsWith('gb')) {
  787. const strTool = gbkTool();
  788. input = strTool.encode(input);
  789. }
  790. return input
  791. }
  792. /**
  793. * 字符串指定解码
  794. * @param input
  795. * @param encoding
  796. * @returns {*}
  797. */
  798. function decodeStr(input, encoding) {
  799. encoding = encoding || 'gbk';
  800. if (encoding.startsWith('gb')) {
  801. const strTool = gbkTool();
  802. input = strTool.decode(input);
  803. }
  804. return input
  805. }
  806. function getCryptoJS() {
  807. // return request('https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/crypto-hiker.js');
  808. return 'console.log("CryptoJS已装载");'
  809. }
  810. // 封装的RSA加解密类
  811. const RSA = {
  812. decode: function (data, key, option) {
  813. option = option || {};
  814. if (typeof (JSEncrypt) === 'function') {
  815. let chunkSize = option.chunkSize || 117; // 默认分段长度为117
  816. let privateKey = this.getPrivateKey(key); // 获取私钥
  817. const decryptor = new JSEncrypt(); //创建解密对象实例
  818. decryptor.setPrivateKey(privateKey); //设置秘钥
  819. let uncrypted = '';
  820. // uncrypted = decryptor.decrypt(data);
  821. uncrypted = decryptor.decryptUnicodeLong(data);
  822. return uncrypted;
  823. } else {
  824. return false
  825. }
  826. },
  827. encode: function (data, key, option) {
  828. option = option || {};
  829. if (typeof (JSEncrypt) === 'function') {
  830. let chunkSize = option.chunkSize || 117; // 默认分段长度为117
  831. let publicKey = this.getPublicKey(key); // 获取公钥
  832. const encryptor = new JSEncrypt();
  833. encryptor.setPublicKey(publicKey); // 设置公钥
  834. let encrypted = ''; // 加密结果
  835. // const textLen = data.length; // 待加密文本长度
  836. // let offset = 0; // 分段偏移量
  837. // // 分段加密
  838. // while (offset < textLen) {
  839. // let chunk = data.slice(offset, chunkSize); // 提取分段数据
  840. // let enc = encryptor.encrypt(chunk); // 加密分段数据
  841. // encrypted += enc; // 连接加密结果
  842. // offset += chunkSize; // 更新偏移量
  843. // }
  844. encrypted = encryptor.encryptUnicodeLong(data);
  845. return encrypted
  846. } else {
  847. return false
  848. }
  849. },
  850. fixKey(key, prefix, endfix) {
  851. if (!key.includes(prefix)) {
  852. key = prefix + key;
  853. }
  854. if (!key.includes(endfix)) {
  855. key += endfix
  856. }
  857. return key
  858. },
  859. getPrivateKey(key) {
  860. let prefix = '-----BEGIN RSA PRIVATE KEY-----';
  861. let endfix = '-----END RSA PRIVATE KEY-----';
  862. return this.fixKey(key, prefix, endfix);
  863. },
  864. getPublicKey(key) {
  865. let prefix = '-----BEGIN PUBLIC KEY-----';
  866. let endfix = '-----END PUBLIC KEY-----';
  867. return this.fixKey(key, prefix, endfix);
  868. }
  869. };
  870. /**
  871. * 获取壳子返回的代理地址
  872. * @returns {string|*}
  873. */
  874. function getProxyUrl() {
  875. if (typeof (getProxy) === 'function') {//判断壳子里有getProxy函数就执行取返回结果。否则取默认的本地
  876. return getProxy(true)
  877. } else {
  878. return 'http://127.0.0.1:9978/proxy?do=js'
  879. }
  880. }
  881. /**
  882. * 根据正则处理原始m3u8里的广告ts片段,自动修复相对链接
  883. * @param m3u8_text m3u8原始文本,里面是最末级的只含ts片段的。不支持嵌套m3u8链接
  884. * @param m3u8_url m3u8原始地址
  885. * @param ad_remove 正则表达式如: reg:/video/adjump(.*?)ts
  886. * @returns {string|DocumentFragment|*|string}
  887. */
  888. function fixAdM3u8(m3u8_text, m3u8_url, ad_remove) {
  889. if ((!m3u8_text && !m3u8_url) || (!m3u8_text && m3u8_url && !m3u8_url.startsWith('http'))) {
  890. return ''
  891. }
  892. if (!m3u8_text) {
  893. log('m3u8_url:' + m3u8_url);
  894. m3u8_text = request(m3u8_url);
  895. }
  896. log('len(m3u8_text):' + m3u8_text.length);
  897. if (!ad_remove) {
  898. return m3u8_text
  899. }
  900. if (ad_remove.startsWith('reg:')) {
  901. ad_remove = ad_remove.slice(4)
  902. } else if (ad_remove.startsWith('js:')) {
  903. ad_remove = ad_remove.slice(3)
  904. }
  905. let m3u8_start = m3u8_text.slice(0, m3u8_text.indexOf('#EXTINF')).trim();
  906. let m3u8_body = m3u8_text.slice(m3u8_text.indexOf('#EXTINF'), m3u8_text.indexOf('#EXT-X-ENDLIST')).trim();
  907. let m3u8_end = m3u8_text.slice(m3u8_text.indexOf('#EXT-X-ENDLIST')).trim();
  908. let murls = [];
  909. let m3_body_list = m3u8_body.split('\n');
  910. let m3_len = m3_body_list.length;
  911. let i = 0;
  912. while (i < m3_len) {
  913. let mi = m3_body_list[i];
  914. let mi_1 = m3_body_list[i + 1];
  915. if (mi.startsWith('#EXTINF')) {
  916. murls.push([mi, mi_1].join('&'));
  917. i += 2
  918. } else if (mi.startsWith('#EXT-X-DISCONTINUITY')) {
  919. let mi_2 = m3_body_list[i + 2];
  920. murls.push([mi, mi_1, mi_2].join('&'));
  921. i += 3
  922. } else {
  923. break;
  924. }
  925. }
  926. let new_m3u8_body = [];
  927. for (let murl of murls) {
  928. if (ad_remove && new RegExp(ad_remove).test(murl)) {
  929. } else {
  930. let murl_list = murl.split('&');
  931. if (!murl_list[murl_list.length - 1].startsWith('http') && m3u8_url.startsWith('http')) {
  932. murl_list[murl_list.length - 1] = urljoin(m3u8_url, murl_list[murl_list.length - 1]);
  933. }
  934. murl_list.forEach((it) => {
  935. new_m3u8_body.push(it);
  936. });
  937. }
  938. }
  939. new_m3u8_body = new_m3u8_body.join('\n').trim();
  940. m3u8_text = [m3u8_start, new_m3u8_body, m3u8_end].join('\n').trim();
  941. return m3u8_text
  942. }
  943. /**
  944. * 智能对比去除广告。支持嵌套m3u8。只需要传入播放地址
  945. * @param m3u8_url m3u8播放地址
  946. * @param headers 自定义访问m3u8的请求头,可以不传
  947. * @returns {string}
  948. */
  949. function fixAdM3u8Ai(m3u8_url, headers) {
  950. let ts = new Date().getTime();
  951. let option = headers ? {headers: headers} : {};
  952. function b(s1, s2) {
  953. let i = 0;
  954. while (i < s1.length) {
  955. if (s1[i] !== s2[i]) {
  956. break
  957. }
  958. i++
  959. }
  960. return i;
  961. }
  962. function reverseString(str) {
  963. return str.split('').reverse().join('');
  964. }
  965. //log('播放的地址:' + m3u8_url);
  966. let m3u8 = request(m3u8_url, option);
  967. //log('m3u8处理前:' + m3u8);
  968. m3u8 = m3u8.trim().split('\n').map(it => it.startsWith('#') ? it : urljoin(m3u8_url, it)).join('\n');
  969. //log('m3u8处理后:============:' + m3u8);
  970. // 获取嵌套m3u8地址
  971. m3u8 = m3u8.replace(/\n\n/ig, '\n');//删除多余的换行符
  972. let last_url = m3u8.split('\n').slice(-1)[0];
  973. if (last_url.length < 5) {
  974. last_url = m3u8.split('\n').slice(-2)[0];
  975. }
  976. if (last_url.includes('.m3u8') && last_url !== m3u8_url) {
  977. m3u8_url = urljoin2(m3u8_url, last_url);
  978. log('嵌套的m3u8_url:' + m3u8_url);
  979. m3u8 = request(m3u8_url, option);
  980. }
  981. //log('----处理有广告的地址----');
  982. let s = m3u8.trim().split('\n').filter(it => it.trim()).join('\n');
  983. let ss = s.split('\n')
  984. //找出第一条播放地址
  985. //let firststr = ss.find(x => !x.startsWith('#'));
  986. let firststr = '';
  987. let maxl = 0;//最大相同字符
  988. let kk = 0;
  989. let kkk = 2;
  990. let secondstr = '';
  991. for (let i = 0; i < ss.length; i++) {
  992. let s = ss[i];
  993. if (!s.startsWith("#")) {
  994. if (kk == 0) firststr = s;
  995. if (kk == 1) maxl = b(firststr, s);
  996. if (kk > 1) {
  997. if (maxl > b(firststr, s)) {
  998. if (secondstr.length < 5) secondstr = s;
  999. kkk = kkk + 2;
  1000. } else {
  1001. maxl = b(firststr, s);
  1002. kkk++;
  1003. }
  1004. }
  1005. kk++;
  1006. if (kk >= 20) break;
  1007. }
  1008. }
  1009. if (kkk > 30) firststr = secondstr;
  1010. let firststrlen = firststr.length;
  1011. //log('字符串长度:' + firststrlen);
  1012. let ml = Math.round(ss.length / 2).toString().length;//取数据的长度的位数
  1013. //log('数据条数的长度:' + ml);
  1014. //找出最后一条播放地址
  1015. let maxc = 0;
  1016. let laststr = ss.toReversed().find((x) => {
  1017. if (!x.startsWith('#')) {
  1018. let k = b(reverseString(firststr), reverseString(x));
  1019. maxl = b(firststr, x);
  1020. maxc++;
  1021. if (firststrlen - maxl <= ml + k || maxc > 10) {
  1022. return true
  1023. }
  1024. }
  1025. return false
  1026. });
  1027. log('最后一条切片:' + laststr);
  1028. //log('最小相同字符长度:' + maxl);
  1029. let ad_urls = [];
  1030. for (let i = 0; i < ss.length; i++) {
  1031. let s = ss[i];
  1032. if (!s.startsWith('#')) {
  1033. if (b(firststr, s) < maxl) {
  1034. ad_urls.push(s); // 广告地址加入列表
  1035. ss.splice(i - 1, 2);
  1036. i = i - 2;
  1037. } else {
  1038. ss[i] = urljoin(m3u8_url, s);
  1039. }
  1040. } else {
  1041. ss[i] = s.replace(/URI=\"(.*)\"/, 'URI=\"' + urljoin(m3u8_url, '$1') + '\"');
  1042. }
  1043. }
  1044. log('处理的m3u8地址:' + m3u8_url);
  1045. log('----广告地址----');
  1046. log(ad_urls);
  1047. m3u8 = ss.join('\n');
  1048. //log('处理完成');
  1049. log('处理耗时:' + (new Date().getTime() - ts).toString());
  1050. return m3u8
  1051. }
  1052. /**
  1053. * 强制正序算法
  1054. * @param lists 待正序列表
  1055. * @param key 正序键
  1056. * @param option 单个元素处理函数
  1057. * @returns {*}
  1058. */
  1059. function forceOrder(lists, key, option) {
  1060. let start = Math.floor(lists.length / 2);
  1061. let end = Math.min(lists.length - 1, start + 1);
  1062. if (start >= end) {
  1063. return lists;
  1064. }
  1065. let first = lists[start];
  1066. let second = lists[end];
  1067. if (key) {
  1068. try {
  1069. first = first[key];
  1070. second = second[key];
  1071. } catch (e) {
  1072. }
  1073. }
  1074. if (option && typeof (option) === 'function') {
  1075. try {
  1076. first = option(first);
  1077. second = option(second);
  1078. } catch (e) {
  1079. }
  1080. }
  1081. first += '';
  1082. second += '';
  1083. // console.log(first,second);
  1084. if (first.match(/(\d+)/) && second.match(/(\d+)/)) {
  1085. let num1 = Number(first.match(/(\d+)/)[1]);
  1086. let num2 = Number(second.match(/(\d+)/)[1]);
  1087. if (num1 > num2) {
  1088. lists.reverse();
  1089. }
  1090. }
  1091. return lists
  1092. }
  1093. let VODS = [];// 一级或者搜索需要的数据列表
  1094. let VOD = {};// 二级的单个数据
  1095. let TABS = [];// 二级的自定义线路列表 如: TABS=['道长在线','道长在线2']
  1096. let LISTS = [];// 二级的自定义选集播放列表 如: LISTS=[['第1集$http://1.mp4','第2集$http://2.mp4'],['第3集$http://1.mp4','第4集$http://2.mp4']]
  1097. /**
  1098. * 获取链接的query请求转为js的object字典对象
  1099. * @param url
  1100. * @returns {{}}
  1101. */
  1102. function getQuery(url) {
  1103. try {
  1104. if (url.indexOf('?') > -1) {
  1105. url = url.slice(url.indexOf('?') + 1);
  1106. }
  1107. let arr = url.split("#")[0].split("&");
  1108. const resObj = {};
  1109. arr.forEach(item => {
  1110. let arr1 = item.split("=");
  1111. let key = arr1[0];
  1112. let value = arr1.slice(1).join('=');
  1113. resObj[key] = value;
  1114. });
  1115. return resObj;
  1116. } catch (err) {
  1117. log(`getQuery发生错误:${e.message}`)
  1118. return {};
  1119. }
  1120. }
  1121. /**
  1122. * url拼接
  1123. * @param fromPath 初始当前页面url
  1124. * @param nowPath 相对当前页面url
  1125. * @returns {*}
  1126. */
  1127. function urljoin(fromPath, nowPath) {
  1128. fromPath = fromPath || '';
  1129. nowPath = nowPath || '';
  1130. return joinUrl(fromPath, nowPath);
  1131. // try {
  1132. // // import Uri from './uri.min.js';
  1133. // // var Uri = require('./uri.min.js');
  1134. // // eval(request('https://cdn.bootcdn.net/ajax/libs/URI.js/1.19.11/URI.min.js'));
  1135. // // let new_uri = URI(nowPath, fromPath);
  1136. // let new_uri = Uri(nowPath, fromPath);
  1137. // new_uri = new_uri.toString();
  1138. // // console.log(new_uri);
  1139. // // return fromPath + nowPath
  1140. // return new_uri
  1141. // }
  1142. // catch (e) {
  1143. // console.log('urljoin发生错误:'+e.message);
  1144. // if(nowPath.startsWith('http')){
  1145. // return nowPath
  1146. // }if(nowPath.startsWith('/')){
  1147. // return getHome(fromPath)+nowPath
  1148. // }
  1149. // return fromPath+nowPath
  1150. // }
  1151. }
  1152. var urljoin2 = urljoin;
  1153. // 内置 pdfh,pdfa,pd
  1154. const defaultParser = {
  1155. pdfh: pdfh,
  1156. pdfa: pdfa,
  1157. pd: pd,
  1158. };
  1159. /**
  1160. * pdfh原版优化,能取style属性里的图片链接
  1161. * @param html 源码
  1162. * @param parse 解析表达式
  1163. * @returns {string|*}
  1164. */
  1165. function pdfh2(html, parse) {
  1166. let html2 = html;
  1167. try {
  1168. if (typeof (html) !== 'string') {
  1169. html2 = html.rr(html.ele).toString();
  1170. }
  1171. } catch (e) {
  1172. print(`html对象转文本发生了错误:${e.message}`);
  1173. }
  1174. let result = defaultParser.pdfh(html2, parse);
  1175. let option = parse.includes('&&') ? parse.split('&&').slice(-1)[0] : parse.split(' ').slice(-1)[0];
  1176. if (/style/.test(option.toLowerCase()) && /url\(/.test(result)) {
  1177. try {
  1178. result = result.match(/url\((.*?)\)/)[1];
  1179. // 2023/07/28新增 style取内部链接自动去除首尾单双引号
  1180. result = result.replace(/^['|"](.*)['|"]$/, "$1");
  1181. } catch (e) {
  1182. }
  1183. }
  1184. return result
  1185. }
  1186. /**
  1187. * pdfa原版优化,可以转换jq的html对象
  1188. * @param html
  1189. * @param parse
  1190. * @returns {*}
  1191. */
  1192. function pdfa2(html, parse) {
  1193. let html2 = html;
  1194. try {
  1195. if (typeof (html) !== 'string') {
  1196. html2 = html.rr(html.ele).toString();
  1197. }
  1198. } catch (e) {
  1199. print(`html对象转文本发生了错误:${e.message}`);
  1200. }
  1201. return defaultParser.pdfa(html2, parse);
  1202. }
  1203. /**
  1204. * pd原版方法重写-增加自动urljoin
  1205. * @param html
  1206. * @param parse
  1207. * @param uri
  1208. * @returns {*}
  1209. */
  1210. function pd2(html, parse, uri) {
  1211. let ret = pdfh2(html, parse);
  1212. if (typeof (uri) === 'undefined' || !uri) {
  1213. uri = '';
  1214. }
  1215. if (DOM_CHECK_ATTR.test(parse) && !SPECIAL_URL.test(ret)) {
  1216. if (/http/.test(ret)) {
  1217. ret = ret.slice(ret.indexOf('http'));
  1218. } else {
  1219. ret = urljoin(MY_URL, ret)
  1220. }
  1221. }
  1222. // MY_URL = getItem('MY_URL',MY_URL);
  1223. // console.log(`规则${RKEY}打印MY_URL:${MY_URL},uri:${uri}`);
  1224. return ret
  1225. }
  1226. const parseTags = {
  1227. jsp: {
  1228. pdfh: pdfh2,
  1229. pdfa: pdfa2,
  1230. pd: pd2,
  1231. },
  1232. json: {
  1233. pdfh(html, parse) {
  1234. if (!parse || !parse.trim()) {
  1235. return '';
  1236. }
  1237. if (typeof (html) === 'string') {
  1238. // print('jsonpath:pdfh字符串转dict');
  1239. html = JSON.parse(html);
  1240. }
  1241. parse = parse.trim();
  1242. if (!parse.startsWith('$.')) {
  1243. parse = '$.' + parse;
  1244. }
  1245. parse = parse.split('||');
  1246. for (let ps of parse) {
  1247. let ret = cheerio.jp(ps, html);
  1248. if (Array.isArray(ret)) {
  1249. ret = ret[0] || '';
  1250. } else {
  1251. ret = ret || ''
  1252. }
  1253. if (ret && typeof (ret) !== 'string') {
  1254. ret = ret.toString();
  1255. }
  1256. if (ret) {
  1257. return ret
  1258. }
  1259. }
  1260. return '';
  1261. },
  1262. pdfa(html, parse) {
  1263. if (!parse || !parse.trim()) {
  1264. return '';
  1265. }
  1266. if (typeof (html) === 'string') {
  1267. // print('jsonpath:pdfa字符串转dict');
  1268. html = JSON.parse(html);
  1269. }
  1270. parse = parse.trim()
  1271. if (!parse.startsWith('$.')) {
  1272. parse = '$.' + parse;
  1273. }
  1274. let ret = cheerio.jp(parse, html);
  1275. if (Array.isArray(ret) && Array.isArray(ret[0]) && ret.length === 1) {
  1276. return ret[0] || []
  1277. }
  1278. return ret || []
  1279. },
  1280. pd(html, parse) {
  1281. let ret = parseTags.json.pdfh(html, parse);
  1282. if (ret) {
  1283. return urljoin(MY_URL, ret);
  1284. }
  1285. return ret
  1286. },
  1287. },
  1288. jq: {
  1289. pdfh(html, parse) {
  1290. if (!html || !parse || !parse.trim()) {
  1291. return ''
  1292. }
  1293. parse = parse.trim();
  1294. let result = defaultParser.pdfh(html, parse);
  1295. // print(`pdfh解析${parse}=>${result}`);
  1296. return result;
  1297. },
  1298. pdfa(html, parse) {
  1299. if (!html || !parse || !parse.trim()) {
  1300. return [];
  1301. }
  1302. parse = parse.trim();
  1303. let result = defaultParser.pdfa(html, parse);
  1304. // print(result);
  1305. print(`pdfa解析${parse}=>${result.length}`);
  1306. return result;
  1307. },
  1308. pd(html, parse, base_url) {
  1309. if (!html || !parse || !parse.trim()) {
  1310. return ''
  1311. }
  1312. parse = parse.trim();
  1313. base_url = base_url || MY_URL;
  1314. return defaultParser.pd(html, parse, base_url);
  1315. },
  1316. },
  1317. getParse(p0) {//非js开头的情况自动获取解析标签
  1318. if (p0.startsWith('jsp:')) {
  1319. return this.jsp
  1320. } else if (p0.startsWith('json:')) {
  1321. return this.json
  1322. } else if (p0.startsWith('jq:')) {
  1323. return this.jq
  1324. } else {
  1325. return this.jq
  1326. }
  1327. }
  1328. };
  1329. const stringify = JSON.stringify;
  1330. const jsp = parseTags.jsp;
  1331. const jq = parseTags.jq;
  1332. /*** 后台需要实现的java方法并注入到js中 ***/
  1333. /**
  1334. * 读取本地文件->应用程序目录
  1335. * @param filePath
  1336. * @returns {string}
  1337. */
  1338. function readFile(filePath) {
  1339. filePath = filePath || './uri.min.js';
  1340. var fd = os.open(filePath);
  1341. var buffer = new ArrayBuffer(1024);
  1342. var len = os.read(fd, buffer, 0, 1024);
  1343. console.log(len);
  1344. let text = String.fromCharCode.apply(null, new Uint8Array(buffer));
  1345. console.log(text);
  1346. return text
  1347. }
  1348. /**
  1349. * 处理返回的json数据
  1350. * @param html
  1351. * @returns {*}
  1352. */
  1353. function dealJson(html) {
  1354. try {
  1355. // html = html.match(/[\w|\W|\s|\S]*?(\{[\w|\W|\s|\S]*\})/).group[1];
  1356. html = html.trim();
  1357. if (!((html.startsWith('{') && html.endsWith('}')) || (html.startsWith('[') && html.endsWith(']')))) {
  1358. html = '{' + html.match(/.*?\{(.*)\}/m)[1] + '}';
  1359. }
  1360. } catch (e) {
  1361. }
  1362. try {
  1363. html = JSON.parse(html);
  1364. } catch (e) {
  1365. }
  1366. // console.log(typeof(html));
  1367. return html;
  1368. }
  1369. /**
  1370. * 验证码识别逻辑,需要java实现(js没有bytes类型,无法调用后端的传递图片二进制获取验证码文本的接口)
  1371. * @type {{api: string, classification: (function(*=): string)}}
  1372. */
  1373. var OcrApi = {
  1374. api: OCR_API,
  1375. classification: function (img) { // img是byte类型,这里不方便搞啊
  1376. let code = '';
  1377. try {
  1378. // let html = request(this.api,{data:{img:img},headers:{'User-Agent':PC_UA},'method':'POST'},true);
  1379. // html = JSON.parse(html);
  1380. // code = html.url||'';
  1381. log('通过drpy_ocr验证码接口过验证...');
  1382. let html = '';
  1383. if (this.api.endsWith('drpy/text')) {
  1384. html = request(this.api, {data: {img: img}, headers: {'User-Agent': PC_UA}, 'method': 'POST'}, true);
  1385. } else {
  1386. html = post(this.api, {body: img});
  1387. }
  1388. code = html || '';
  1389. } catch (e) {
  1390. log(`OCR识别验证码发生错误:${e.message}`)
  1391. }
  1392. return code
  1393. }
  1394. };
  1395. /**
  1396. * 验证码识别,暂未实现
  1397. * @param url 验证码图片链接
  1398. * @returns {string} 验证成功后的cookie
  1399. */
  1400. function verifyCode(url) {
  1401. let cnt = 0;
  1402. let host = getHome(url);
  1403. let cookie = '';
  1404. while (cnt < OCR_RETRY) {
  1405. try {
  1406. // let obj = {headers:headers,timeout:timeout};
  1407. let yzm_url = `${host}/index.php/verify/index.html`;
  1408. console.log(`验证码链接:${yzm_url}`);
  1409. let hhtml = request(yzm_url, {withHeaders: true, toBase64: true}, true);
  1410. let json = JSON.parse(hhtml);
  1411. if (!cookie) {
  1412. // print(json);
  1413. let setCk = Object.keys(json).find(it => it.toLowerCase() === 'set-cookie');
  1414. // cookie = json['set-cookie']?json['set-cookie'].split(';')[0]:'';
  1415. cookie = setCk ? json[setCk].split(';')[0] : '';
  1416. }
  1417. // console.log(hhtml);
  1418. console.log('cookie:' + cookie);
  1419. let img = json.body;
  1420. // console.log(img);
  1421. let code = OcrApi.classification(img);
  1422. console.log(`第${cnt + 1}次验证码识别结果:${code}`);
  1423. let submit_url = `${host}/index.php/ajax/verify_check?type=search&verify=${code}`;
  1424. console.log(submit_url);
  1425. let html = request(submit_url, {headers: {Cookie: cookie}, 'method': 'POST'});
  1426. // console.log(html);
  1427. html = JSON.parse(html);
  1428. if (html.msg === 'ok') {
  1429. console.log(`第${cnt + 1}次验证码提交成功`);
  1430. return cookie // 需要返回cookie
  1431. } else if (html.msg !== 'ok' && cnt + 1 >= OCR_RETRY) {
  1432. cookie = ''; // 需要清空返回cookie
  1433. }
  1434. } catch (e) {
  1435. console.log(`第${cnt + 1}次验证码提交失败:${e.message}`);
  1436. if (cnt + 1 >= OCR_RETRY) {
  1437. cookie = '';
  1438. }
  1439. }
  1440. cnt += 1
  1441. }
  1442. return cookie
  1443. }
  1444. /**
  1445. * 存在数据库配置表里, key字段对应值value,没有就新增,有就更新,调用此方法会清除key对应的内存缓存
  1446. * @param k 键
  1447. * @param v 值
  1448. */
  1449. function setItem(k, v) {
  1450. local.set(RKEY, k, v);
  1451. console.log(`规则${RKEY}设置${k} => ${v}`)
  1452. }
  1453. /**
  1454. * 获取数据库配置表对应的key字段的value,没有这个key就返回value默认传参.需要有缓存,第一次获取后会存在内存里
  1455. * @param k 键
  1456. * @param v 值
  1457. * @returns {*}
  1458. */
  1459. function getItem(k, v) {
  1460. return local.get(RKEY, k) || v;
  1461. }
  1462. /**
  1463. * 删除数据库key对应的一条数据,并清除此key对应的内存缓存
  1464. * @param k
  1465. */
  1466. function clearItem(k) {
  1467. local.delete(RKEY, k);
  1468. }
  1469. /*** js自封装的方法 ***/
  1470. /**
  1471. * 获取链接的host(带http协议的完整链接)
  1472. * @param url 任意一个正常完整的Url,自动提取根
  1473. * @returns {string}
  1474. */
  1475. function getHome(url) {
  1476. if (!url) {
  1477. return ''
  1478. }
  1479. let tmp = url.split('//');
  1480. url = tmp[0] + '//' + tmp[1].split('/')[0];
  1481. try {
  1482. url = decodeURIComponent(url);
  1483. } catch (e) {
  1484. }
  1485. return url
  1486. }
  1487. /**
  1488. * get参数编译链接,类似python params字典自动拼接
  1489. * @param url 访问链接
  1490. * @param obj 参数字典
  1491. * @returns {*}
  1492. */
  1493. function buildUrl(url, obj) {
  1494. obj = obj || {};
  1495. if (url.indexOf('?') < 0) {
  1496. url += '?'
  1497. }
  1498. let param_list = [];
  1499. let keys = Object.keys(obj);
  1500. keys.forEach(it => {
  1501. param_list.push(it + '=' + obj[it])
  1502. });
  1503. let prs = param_list.join('&');
  1504. if (keys.length > 0 && !url.endsWith('?')) {
  1505. url += '&'
  1506. }
  1507. url += prs;
  1508. return url
  1509. }
  1510. /**
  1511. * 远程依赖执行函数
  1512. * @param url 远程js地址
  1513. */
  1514. function $require(url) {
  1515. eval(request(url));
  1516. }
  1517. /**
  1518. * 将obj所有key变小写
  1519. * @param obj
  1520. */
  1521. function keysToLowerCase(obj) {
  1522. return Object.keys(obj).reduce((result, key) => {
  1523. const newKey = key.toLowerCase();
  1524. result[newKey] = obj[key]; // 如果值也是对象,可以递归调用本函数
  1525. return result;
  1526. }, {});
  1527. }
  1528. /**
  1529. * 海阔网页请求函数完整封装
  1530. * @param url 请求链接
  1531. * @param obj 请求对象 {headers:{},method:'',timeout:5000,body:'',withHeaders:false}
  1532. * @param ocr_flag 标识此flag是用于请求ocr识别的,自动过滤content-type指定编码
  1533. * @returns {string|string|DocumentFragment|*}
  1534. */
  1535. function request(url, obj, ocr_flag) {
  1536. ocr_flag = ocr_flag || false;
  1537. if (typeof (obj) === 'undefined' || !obj || obj === {}) {
  1538. if (!fetch_params || !fetch_params.headers) {
  1539. let headers = {
  1540. 'User-Agent': MOBILE_UA,
  1541. };
  1542. if (rule.headers) {
  1543. Object.assign(headers, rule.headers);
  1544. }
  1545. if (!fetch_params) {
  1546. fetch_params = {};
  1547. }
  1548. fetch_params.headers = headers;
  1549. }
  1550. if (!fetch_params.headers.Referer) {
  1551. fetch_params.headers.Referer = getHome(url)
  1552. }
  1553. obj = fetch_params;
  1554. } else {
  1555. let headers = obj.headers || {};
  1556. let keys = Object.keys(headers).map(it => it.toLowerCase());
  1557. if (!keys.includes('user-agent')) {
  1558. headers['User-Agent'] = MOBILE_UA;
  1559. // fetch_params 里存在ua则优先,否则才默认手机UA
  1560. if (typeof (fetch_params) === 'object' && fetch_params && fetch_params.headers) {
  1561. let fetch_headers = keysToLowerCase(fetch_params.headers);
  1562. if (fetch_headers['user-agent']) {
  1563. headers['User-Agent'] = fetch_headers['user-agent'];
  1564. }
  1565. }
  1566. }
  1567. if (!keys.includes('referer')) {
  1568. headers['Referer'] = getHome(url);
  1569. }
  1570. obj.headers = headers;
  1571. }
  1572. if (rule.encoding && rule.encoding !== 'utf-8' && !ocr_flag) {
  1573. if (!obj.headers.hasOwnProperty('Content-Type') && !obj.headers.hasOwnProperty('content-type')) { // 手动指定了就不管
  1574. obj.headers["Content-Type"] = 'text/html; charset=' + rule.encoding;
  1575. }
  1576. }
  1577. if (typeof (obj.body) != 'undefined' && obj.body && typeof (obj.body) === 'string') {
  1578. // let data = {};
  1579. // obj.body.split('&').forEach(it=>{
  1580. // data[it.split('=')[0]] = it.split('=')[1]
  1581. // });
  1582. // obj.data = data;
  1583. // delete obj.body
  1584. // 传body加 "Content-Type":"application/x-www-form-urlencoded;" 即可post form
  1585. if (!obj.headers.hasOwnProperty('Content-Type') && !obj.headers.hasOwnProperty('content-type')) { // 手动指定了就不管
  1586. obj.headers["Content-Type"] = 'application/x-www-form-urlencoded; charset=' + rule.encoding;
  1587. }
  1588. } else if (typeof (obj.body) != 'undefined' && obj.body && typeof (obj.body) === 'object') {
  1589. obj.data = obj.body;
  1590. delete obj.body
  1591. }
  1592. if (!url) {
  1593. return obj.withHeaders ? '{}' : ''
  1594. }
  1595. if (obj.toBase64) { // 返回base64,用于请求图片
  1596. obj.buffer = 2;
  1597. delete obj.toBase64
  1598. }
  1599. if (obj.redirect === false) {
  1600. obj.redirect = 0;
  1601. }
  1602. console.log(JSON.stringify(obj.headers));
  1603. // console.log('request:'+url+' obj:'+JSON.stringify(obj));
  1604. console.log('request:' + url + `|method:${obj.method || 'GET'}|body:${obj.body || ''}`);
  1605. let res = req(url, obj);
  1606. let html = res.content || '';
  1607. // console.log(html);
  1608. if (obj.withHeaders) {
  1609. let htmlWithHeaders = res.headers;
  1610. htmlWithHeaders.body = html;
  1611. return JSON.stringify(htmlWithHeaders);
  1612. } else {
  1613. return html
  1614. }
  1615. }
  1616. /**
  1617. * 快捷post请求
  1618. * @param url 地址
  1619. * @param obj 对象
  1620. * @returns {string|DocumentFragment|*}
  1621. */
  1622. function post(url, obj) {
  1623. obj = obj || {};
  1624. obj.method = 'POST';
  1625. return request(url, obj);
  1626. }
  1627. /**
  1628. * 快捷获取特殊地址cookie|一般用作搜索过验证
  1629. * 用法 let {cookie,html} = reqCookie(url);
  1630. * @param url 能返回cookie的地址
  1631. * @param obj 常规请求参数
  1632. * @param all_cookie 返回全部cookie.默认false只返回第一个,一般是PhpSessionId
  1633. * @returns {{cookie: string, html: (*|string|DocumentFragment)}}
  1634. */
  1635. function reqCookie(url, obj, all_cookie) {
  1636. obj = obj || {};
  1637. obj.withHeaders = true;
  1638. all_cookie = all_cookie || false;
  1639. let html = request(url, obj);
  1640. let json = JSON.parse(html);
  1641. let setCk = Object.keys(json).find(it => it.toLowerCase() === 'set-cookie');
  1642. let cookie = setCk ? json[setCk] : '';
  1643. if (Array.isArray(cookie)) {
  1644. cookie = cookie.join(';')
  1645. }
  1646. if (!all_cookie) {
  1647. cookie = cookie.split(';')[0];
  1648. }
  1649. html = json.body;
  1650. return {
  1651. cookie,
  1652. html
  1653. }
  1654. }
  1655. fetch = request;
  1656. print = function (data) {
  1657. data = data || '';
  1658. if (typeof (data) == 'object' && Object.keys(data).length > 0) {
  1659. try {
  1660. data = JSON.stringify(data);
  1661. console.log(data);
  1662. } catch (e) {
  1663. // console.log('print:'+e.message);
  1664. console.log(typeof (data) + ':' + data.length);
  1665. return
  1666. }
  1667. } else if (typeof (data) == 'object' && Object.keys(data).length < 1) {
  1668. console.log('null object');
  1669. } else {
  1670. console.log(data);
  1671. }
  1672. }
  1673. log = print;
  1674. /**
  1675. * 检查宝塔验证并自动跳过获取正确源码
  1676. * @param html 之前获取的html
  1677. * @param url 之前的来源url
  1678. * @param obj 来源obj
  1679. * @returns {string|DocumentFragment|*}
  1680. */
  1681. function checkHtml(html, url, obj) {
  1682. if (/\?btwaf=/.test(html)) {
  1683. let btwaf = html.match(/btwaf(.*?)"/)[1];
  1684. url = url.split('#')[0] + '?btwaf' + btwaf;
  1685. print('宝塔验证访问链接:' + url);
  1686. html = request(url, obj);
  1687. }
  1688. return html
  1689. }
  1690. /**
  1691. * 带一次宝塔验证的源码获取
  1692. * @param url 请求链接
  1693. * @param obj 请求参数
  1694. * @returns {string|DocumentFragment}
  1695. */
  1696. function getCode(url, obj) {
  1697. let html = request(url, obj);
  1698. html = checkHtml(html, url, obj);
  1699. return html
  1700. }
  1701. /**
  1702. * 源rule专用的请求方法,自动注入cookie
  1703. * @param url 请求链接
  1704. * @returns {string|DocumentFragment}
  1705. */
  1706. function getHtml(url) {
  1707. let obj = {};
  1708. if (rule.headers) {
  1709. obj.headers = rule.headers;
  1710. }
  1711. let cookie = getItem(RULE_CK, '');
  1712. if (cookie) {
  1713. // log('有cookie:'+cookie);
  1714. if (obj.headers && !Object.keys(obj.headers).map(it => it.toLowerCase()).includes('cookie')) {
  1715. log('历史无cookie,新增过验证后的cookie');
  1716. obj.headers['Cookie'] = cookie;
  1717. } else if (obj.headers && obj.headers.cookie && obj.headers.cookie !== cookie) {
  1718. obj.headers['Cookie'] = cookie;
  1719. log('历史有小写过期的cookie,更新过验证后的cookie');
  1720. } else if (obj.headers && obj.headers.Cookie && obj.headers.Cookie !== cookie) {
  1721. obj.headers['Cookie'] = cookie;
  1722. log('历史有大写过期的cookie,更新过验证后的cookie');
  1723. } else if (!obj.headers) {
  1724. obj.headers = {Cookie: cookie};
  1725. log('历史无headers,更新过验证后的含cookie的headers');
  1726. }
  1727. }
  1728. let html = getCode(url, obj);
  1729. return html
  1730. }
  1731. /**
  1732. * 首页分类解析,筛选暂未实现
  1733. * @param homeObj 首页传参对象
  1734. * @returns {string}
  1735. */
  1736. function homeParse(homeObj) {
  1737. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  1738. let classes = [];
  1739. if (homeObj.class_name && homeObj.class_url) {
  1740. let names = homeObj.class_name.split('&');
  1741. let urls = homeObj.class_url.split('&');
  1742. let cnt = Math.min(names.length, urls.length);
  1743. for (let i = 0; i < cnt; i++) {
  1744. classes.push({
  1745. 'type_id': urls[i],
  1746. 'type_name': names[i]
  1747. });
  1748. }
  1749. }
  1750. if (homeObj.class_parse) {
  1751. if (homeObj.class_parse.startsWith('js:')) {
  1752. var input = homeObj.MY_URL;
  1753. try {
  1754. eval(homeObj.class_parse.replace('js:', ''));
  1755. if (Array.isArray(input)) {
  1756. classes = input;
  1757. }
  1758. } catch (e) {
  1759. log(`通过js动态获取分类发生了错误:${e.message}`);
  1760. }
  1761. } else {
  1762. let p = homeObj.class_parse.split(';');
  1763. let p0 = p[0];
  1764. let _ps = parseTags.getParse(p0);
  1765. let is_json = p0.startsWith('json:');
  1766. _pdfa = _ps.pdfa;
  1767. _pdfh = _ps.pdfh;
  1768. _pd = _ps.pd;
  1769. MY_URL = rule.url;
  1770. if (is_json) {
  1771. try {
  1772. let cms_cate_url = homeObj.MY_URL.replace('ac=detail', 'ac=list');
  1773. let html = homeObj.home_html || getHtml(cms_cate_url);
  1774. if (html) {
  1775. if (cms_cate_url === homeObj.MY_URL) {
  1776. homeHtmlCache = html;
  1777. }
  1778. let list = _pdfa(html, p0.replace('json:', ''));
  1779. if (list && list.length > 0) {
  1780. classes = list;
  1781. }
  1782. }
  1783. } catch (e) {
  1784. console.log(e.message);
  1785. }
  1786. } else if (p.length >= 3 && !is_json) { // 可以不写正则
  1787. try {
  1788. let html = homeObj.home_html || getHtml(homeObj.MY_URL);
  1789. if (html) {
  1790. homeHtmlCache = html;
  1791. let list = _pdfa(html, p0);
  1792. if (list && list.length > 0) {
  1793. list.forEach((it, idex) => {
  1794. try {
  1795. let name = _pdfh(it, p[1]);
  1796. if (homeObj.cate_exclude && (new RegExp(homeObj.cate_exclude).test(name))) {
  1797. return;
  1798. }
  1799. // let url = pdfh(it, p[2]);
  1800. let url = _pd(it, p[2]);
  1801. if (p.length > 3 && p[3] && !homeObj.home_html) {
  1802. let exp = new RegExp(p[3]);
  1803. url = url.match(exp)[1];
  1804. }
  1805. classes.push({
  1806. 'type_id': url.trim(),
  1807. 'type_name': name.trim()
  1808. });
  1809. } catch (e) {
  1810. console.log(`分类列表定位第${idex}个元素正常报错:${e.message}`);
  1811. }
  1812. });
  1813. }
  1814. }
  1815. } catch (e) {
  1816. console.log(e.message);
  1817. }
  1818. }
  1819. }
  1820. }
  1821. // 排除分类
  1822. classes = classes.filter(it => !homeObj.cate_exclude || !(new RegExp(homeObj.cate_exclude).test(it.type_name)));
  1823. let resp = {
  1824. 'class': classes
  1825. };
  1826. if (homeObj.filter) {
  1827. resp.filters = homeObj.filter;
  1828. }
  1829. console.log(JSON.stringify(resp));
  1830. return JSON.stringify(resp);
  1831. }
  1832. /**
  1833. * 推荐和搜索单字段继承一级
  1834. * @param p 推荐或搜索的解析分割;列表
  1835. * @param pn 自身列表序号
  1836. * @param pp 一级解析分割;列表
  1837. * @param ppn 继承一级序号
  1838. * @returns {*}
  1839. */
  1840. function getPP(p, pn, pp, ppn) {
  1841. try {
  1842. let ps = p[pn] === '*' && pp.length > ppn ? pp[ppn] : p[pn]
  1843. return ps
  1844. } catch (e) {
  1845. return ''
  1846. }
  1847. }
  1848. /**
  1849. * 首页推荐列表解析
  1850. * @param homeVodObj
  1851. * @returns {string}
  1852. */
  1853. function homeVodParse(homeVodObj) {
  1854. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  1855. let d = [];
  1856. MY_URL = homeVodObj.homeUrl;
  1857. // setItem('MY_URL',MY_URL);
  1858. console.log(MY_URL);
  1859. let t1 = (new Date()).getTime();
  1860. let p = homeVodObj.推荐;
  1861. print('p:' + p);
  1862. if (p === '*' && rule.一级) {
  1863. p = rule.一级;
  1864. homeVodObj.double = false;
  1865. }
  1866. if (!p || typeof (p) !== 'string') {
  1867. return '{}'
  1868. }
  1869. p = p.trim();
  1870. let pp = rule.一级 ? rule.一级.split(';') : [];
  1871. if (p.startsWith('js:')) {
  1872. const TYPE = 'home';
  1873. var input = MY_URL;
  1874. HOST = rule.host;
  1875. eval(p.replace('js:', ''));
  1876. d = VODS;
  1877. } else {
  1878. p = p.split(';');
  1879. if (!homeVodObj.double && p.length < 5) {
  1880. return '{}'
  1881. } else if (homeVodObj.double && p.length < 6) {
  1882. return '{}'
  1883. }
  1884. let p0 = getPP(p, 0, pp, 0)
  1885. let _ps = parseTags.getParse(p0);
  1886. _pdfa = _ps.pdfa;
  1887. _pdfh = _ps.pdfh;
  1888. _pd = _ps.pd;
  1889. let is_json = p0.startsWith('json:');
  1890. p0 = p0.replace(/^(jsp:|json:|jq:)/, '');
  1891. // print(p[0]);
  1892. let html = homeHtmlCache || getHtml(MY_URL);
  1893. homeHtmlCache = undefined;
  1894. if (is_json) {
  1895. // print('是json,开始处理');
  1896. html = dealJson(html);
  1897. }
  1898. try {
  1899. console.log('double:' + homeVodObj.double);
  1900. if (homeVodObj.double) {
  1901. let items = _pdfa(html, p0);
  1902. // console.log(items.length);
  1903. let p1 = getPP(p, 1, pp, 0);
  1904. let p2 = getPP(p, 2, pp, 1);
  1905. let p3 = getPP(p, 3, pp, 2);
  1906. let p4 = getPP(p, 4, pp, 3);
  1907. let p5 = getPP(p, 5, pp, 4);
  1908. let p6 = getPP(p, 6, pp, 5);
  1909. for (let item of items) {
  1910. // console.log(p[1]);
  1911. let items2 = _pdfa(item, p1);
  1912. // console.log(items2.length);
  1913. for (let item2 of items2) {
  1914. try {
  1915. let title = _pdfh(item2, p2);
  1916. let img = '';
  1917. try {
  1918. img = _pd(item2, p3);
  1919. } catch (e) {
  1920. }
  1921. let desc = '';
  1922. try {
  1923. desc = _pdfh(item2, p4);
  1924. } catch (e) {
  1925. }
  1926. let links = [];
  1927. for (let _p5 of p5.split('+')) {
  1928. let link = !homeVodObj.detailUrl ? _pd(item2, _p5, MY_URL) : _pdfh(item2, _p5);
  1929. links.push(link);
  1930. }
  1931. let content;
  1932. if (p.length > 6 && p[6]) {
  1933. content = _pdfh(item2, p6);
  1934. } else {
  1935. content = '';
  1936. }
  1937. let vid = links.join('$');
  1938. if (rule.二级 === '*') {
  1939. vid = vid + '@@' + title + '@@' + img;
  1940. }
  1941. let vod = {
  1942. vod_name: title,
  1943. vod_pic: img,
  1944. vod_remarks: desc,
  1945. vod_content: content,
  1946. vod_id: vid
  1947. };
  1948. // print(vod);
  1949. d.push(vod);
  1950. } catch (e) {
  1951. console.log(`首页列表双层定位处理发生错误:${e.message}`);
  1952. }
  1953. }
  1954. }
  1955. } else {
  1956. let items = _pdfa(html, p0);
  1957. let p1 = getPP(p, 1, pp, 1);
  1958. let p2 = getPP(p, 2, pp, 2);
  1959. let p3 = getPP(p, 3, pp, 3);
  1960. let p4 = getPP(p, 4, pp, 4);
  1961. let p5 = getPP(p, 5, pp, 5);
  1962. for (let item of items) {
  1963. try {
  1964. let title = _pdfh(item, p1);
  1965. let img = '';
  1966. try {
  1967. img = _pd(item, p2, MY_URL);
  1968. } catch (e) {
  1969. }
  1970. let desc = '';
  1971. try {
  1972. desc = _pdfh(item, p3);
  1973. } catch (e) {
  1974. }
  1975. let links = [];
  1976. for (let _p5 of p4.split('+')) {
  1977. let link = !homeVodObj.detailUrl ? _pd(item, _p5, MY_URL) : _pdfh(item, _p5);
  1978. links.push(link);
  1979. }
  1980. let content;
  1981. if (p.length > 5 && p[5]) {
  1982. content = _pdfh(item, p5);
  1983. } else {
  1984. content = ''
  1985. }
  1986. let vid = links.join('$');
  1987. if (rule.二级 === '*') {
  1988. vid = vid + '@@' + title + '@@' + img;
  1989. }
  1990. let vod = {
  1991. vod_name: title,
  1992. vod_pic: img,
  1993. vod_remarks: desc,
  1994. vod_content: content,
  1995. vod_id: vid
  1996. };
  1997. d.push(vod);
  1998. } catch (e) {
  1999. console.log(`首页列表单层定位处理发生错误:${e.message}`);
  2000. }
  2001. }
  2002. }
  2003. } catch (e) {
  2004. }
  2005. }
  2006. let t2 = (new Date()).getTime();
  2007. console.log('加载首页推荐耗时:' + (t2 - t1) + '毫秒');
  2008. // console.log(JSON.stringify(d));
  2009. if (rule.图片替换) {
  2010. if (rule.图片替换.startsWith('js:')) {
  2011. d.forEach(it => {
  2012. try {
  2013. var input = it.vod_pic;
  2014. eval(rule.图片替换.trim().replace('js:', ''));
  2015. it.vod_pic = input;
  2016. } catch (e) {
  2017. log(`图片:${it.vod_pic}替换错误:${e.message}`);
  2018. }
  2019. });
  2020. } else if (rule.图片替换.includes('=>')) {
  2021. let replace_from = rule.图片替换.split('=>')[0];
  2022. let replace_to = rule.图片替换.split('=>')[1];
  2023. d.forEach(it => {
  2024. if (it.vod_pic && it.vod_pic.startsWith('http')) {
  2025. it.vod_pic = it.vod_pic.replace(replace_from, replace_to);
  2026. }
  2027. });
  2028. }
  2029. }
  2030. if (rule.图片来源) {
  2031. d.forEach(it => {
  2032. if (it.vod_pic && it.vod_pic.startsWith('http')) {
  2033. it.vod_pic = it.vod_pic + rule.图片来源;
  2034. }
  2035. });
  2036. }
  2037. if (d.length > 0) {
  2038. print(d.slice(0, 2));
  2039. }
  2040. return JSON.stringify({
  2041. list: d
  2042. })
  2043. }
  2044. /**
  2045. * 一级分类页数据解析
  2046. * @param cateObj
  2047. * @returns {string}
  2048. */
  2049. function categoryParse(cateObj) {
  2050. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  2051. let p = cateObj.一级;
  2052. if (!p || typeof (p) !== 'string') {
  2053. return '{}'
  2054. }
  2055. let d = [];
  2056. // let url = cateObj.url.replaceAll('fyclass', cateObj.tid).replaceAll('fypage', cateObj.pg);
  2057. let url = cateObj.url.replaceAll('fyclass', cateObj.tid);
  2058. if (cateObj.pg === 1 && url.includes('[') && url.includes(']')) {
  2059. url = url.split('[')[1].split(']')[0];
  2060. } else if (cateObj.pg > 1 && url.includes('[') && url.includes(']')) {
  2061. url = url.split('[')[0];
  2062. }
  2063. if (rule.filter_url) {
  2064. if (!/fyfilter/.test(url)) {
  2065. if (!url.endsWith('&') && !rule.filter_url.startsWith('&')) {
  2066. url += '&'
  2067. }
  2068. url += rule.filter_url;
  2069. } else {
  2070. url = url.replace('fyfilter', rule.filter_url);
  2071. }
  2072. // filter_url支持fyclass
  2073. url = url.replaceAll('fyclass', cateObj.tid);
  2074. // console.log('filter:'+cateObj.filter);
  2075. let fl = cateObj.filter ? cateObj.extend : {};
  2076. // 自动合并 不同分类对应的默认筛选
  2077. if (rule.filter_def && typeof (rule.filter_def) === 'object') {
  2078. try {
  2079. if (Object.keys(rule.filter_def).length > 0 && rule.filter_def.hasOwnProperty(cateObj.tid)) {
  2080. let self_fl_def = rule.filter_def[cateObj.tid];
  2081. if (self_fl_def && typeof (self_fl_def) === 'object') {
  2082. // 引用传递转值传递,避免污染self变量
  2083. let fl_def = JSON.parse(JSON.stringify(self_fl_def));
  2084. fl = Object.assign(fl_def, fl);
  2085. }
  2086. }
  2087. } catch (e) {
  2088. print(`合并不同分类对应的默认筛选出错:${e.message}`);
  2089. }
  2090. }
  2091. let new_url;
  2092. new_url = cheerio.jinja2(url, {fl: fl, fyclass: cateObj.tid});
  2093. // console.log('jinjia2执行后的new_url类型为:'+typeof(new_url));
  2094. url = new_url;
  2095. }
  2096. if (/fypage/.test(url)) {
  2097. if (url.includes('(') && url.includes(')')) {
  2098. let url_rep = url.match(/.*?\((.*)\)/)[1];
  2099. // console.log(url_rep);
  2100. let cnt_page = url_rep.replaceAll('fypage', cateObj.pg);
  2101. // console.log(cnt_page);
  2102. let cnt_pg = eval(cnt_page);
  2103. // console.log(cnt_pg);
  2104. url = url.replaceAll(url_rep, cnt_pg).replaceAll('(', '').replaceAll(')', '');
  2105. } else {
  2106. url = url.replaceAll('fypage', cateObj.pg);
  2107. }
  2108. }
  2109. MY_URL = url;
  2110. // setItem('MY_URL',MY_URL);
  2111. console.log(MY_URL);
  2112. p = p.trim();
  2113. const MY_CATE = cateObj.tid;
  2114. if (p.startsWith('js:')) {
  2115. var MY_FL = cateObj.extend;
  2116. const TYPE = 'cate';
  2117. var input = MY_URL;
  2118. const MY_PAGE = cateObj.pg;
  2119. var desc = '';
  2120. eval(p.trim().replace('js:', ''));
  2121. d = VODS;
  2122. } else {
  2123. p = p.split(';');
  2124. if (p.length < 5) {
  2125. return '{}'
  2126. }
  2127. let _ps = parseTags.getParse(p[0]);
  2128. _pdfa = _ps.pdfa;
  2129. _pdfh = _ps.pdfh;
  2130. _pd = _ps.pd;
  2131. let is_json = p[0].startsWith('json:');
  2132. p[0] = p[0].replace(/^(jsp:|json:|jq:)/, '');
  2133. try {
  2134. let html = getHtml(MY_URL);
  2135. if (html) {
  2136. if (is_json) {
  2137. html = dealJson(html);
  2138. }
  2139. let list = _pdfa(html, p[0]);
  2140. list.forEach(it => {
  2141. let links = p[4].split('+').map(p4 => {
  2142. return !rule.detailUrl ? _pd(it, p4, MY_URL) : _pdfh(it, p4);
  2143. });
  2144. let link = links.join('$');
  2145. let vod_id = rule.detailUrl ? MY_CATE + '$' + link : link;
  2146. let vod_name = _pdfh(it, p[1]).replace(/\n|\t/g, '').trim();
  2147. let vod_pic = _pd(it, p[2], MY_URL);
  2148. if (rule.二级 === '*') {
  2149. vod_id = vod_id + '@@' + vod_name + '@@' + vod_pic;
  2150. }
  2151. d.push({
  2152. 'vod_id': vod_id,
  2153. 'vod_name': vod_name,
  2154. 'vod_pic': vod_pic,
  2155. 'vod_remarks': _pdfh(it, p[3]).replace(/\n|\t/g, '').trim(),
  2156. });
  2157. });
  2158. }
  2159. } catch (e) {
  2160. console.log(e.message);
  2161. }
  2162. }
  2163. if (rule.图片替换) {
  2164. if (rule.图片替换.startsWith('js:')) {
  2165. d.forEach(it => {
  2166. try {
  2167. var input = it.vod_pic;
  2168. eval(rule.图片替换.trim().replace('js:', ''));
  2169. it.vod_pic = input;
  2170. } catch (e) {
  2171. log(`图片:${it.vod_pic}替换错误:${e.message}`);
  2172. }
  2173. });
  2174. } else if (rule.图片替换.includes('=>')) {
  2175. let replace_from = rule.图片替换.split('=>')[0];
  2176. let replace_to = rule.图片替换.split('=>')[1];
  2177. d.forEach(it => {
  2178. if (it.vod_pic && it.vod_pic.startsWith('http')) {
  2179. it.vod_pic = it.vod_pic.replace(replace_from, replace_to);
  2180. }
  2181. });
  2182. }
  2183. }
  2184. if (rule.图片来源) {
  2185. d.forEach(it => {
  2186. if (it.vod_pic && it.vod_pic.startsWith('http')) {
  2187. it.vod_pic = it.vod_pic + rule.图片来源;
  2188. }
  2189. });
  2190. }
  2191. // print(d);
  2192. if (d.length > 0) {
  2193. print(d.slice(0, 2));
  2194. }
  2195. let pagecount = 0;
  2196. if (rule.pagecount && typeof (rule.pagecount) === 'object' && rule.pagecount.hasOwnProperty(MY_CATE)) {
  2197. print(`MY_CATE:${MY_CATE},pagecount:${JSON.stringify(rule.pagecount)}`);
  2198. pagecount = parseInt(rule.pagecount[MY_CATE]);
  2199. }
  2200. let nodata = {
  2201. list: [{
  2202. vod_name: '无数据,防无限请求',
  2203. vod_id: 'no_data',
  2204. vod_remarks: '不要点,会崩的',
  2205. vod_pic: 'https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/404.jpg'
  2206. }],
  2207. total: 1, pagecount: 1, page: 1, limit: 1
  2208. };
  2209. let vod = d.length < 1 ? JSON.stringify(nodata) : JSON.stringify({
  2210. 'page': parseInt(cateObj.pg),
  2211. 'pagecount': pagecount || 999,
  2212. 'limit': 20,
  2213. 'total': 999,
  2214. 'list': d,
  2215. });
  2216. // print(vod);
  2217. return vod
  2218. }
  2219. /**
  2220. * 搜索列表数据解析
  2221. * @param searchObj
  2222. * @returns {string}
  2223. */
  2224. function searchParse(searchObj) {
  2225. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  2226. let d = [];
  2227. if (!searchObj.searchUrl) {
  2228. return '{}'
  2229. }
  2230. let p = searchObj.搜索 === '*' && rule.一级 ? rule.一级 : searchObj.搜索;
  2231. if (!p || typeof (p) !== 'string') {
  2232. return '{}'
  2233. }
  2234. p = p.trim();
  2235. let pp = rule.一级 ? rule.一级.split(';') : [];
  2236. let url = searchObj.searchUrl.replaceAll('**', searchObj.wd);
  2237. if (searchObj.pg === 1 && url.includes('[') && url.includes(']') && !url.includes('#')) {
  2238. url = url.split('[')[1].split(']')[0];
  2239. } else if (searchObj.pg > 1 && url.includes('[') && url.includes(']') && !url.includes('#')) {
  2240. url = url.split('[')[0];
  2241. }
  2242. if (/fypage/.test(url)) {
  2243. if (url.includes('(') && url.includes(')')) {
  2244. let url_rep = url.match(/.*?\((.*)\)/)[1];
  2245. // console.log(url_rep);
  2246. let cnt_page = url_rep.replaceAll('fypage', searchObj.pg);
  2247. // console.log(cnt_page);
  2248. let cnt_pg = eval(cnt_page);
  2249. // console.log(cnt_pg);
  2250. url = url.replaceAll(url_rep, cnt_pg).replaceAll('(', '').replaceAll(')', '');
  2251. } else {
  2252. url = url.replaceAll('fypage', searchObj.pg);
  2253. }
  2254. }
  2255. MY_URL = url;
  2256. console.log(MY_URL);
  2257. // log(searchObj.搜索);
  2258. // setItem('MY_URL',MY_URL);
  2259. if (p.startsWith('js:')) {
  2260. const TYPE = 'search';
  2261. const MY_PAGE = searchObj.pg;
  2262. const KEY = searchObj.wd;
  2263. var input = MY_URL;
  2264. var detailUrl = rule.detailUrl || '';
  2265. eval(p.trim().replace('js:', ''));
  2266. d = VODS;
  2267. } else {
  2268. p = p.split(';');
  2269. if (p.length < 5) {
  2270. return '{}'
  2271. }
  2272. let p0 = getPP(p, 0, pp, 0);
  2273. let _ps = parseTags.getParse(p0);
  2274. _pdfa = _ps.pdfa;
  2275. _pdfh = _ps.pdfh;
  2276. _pd = _ps.pd;
  2277. let is_json = p0.startsWith('json:');
  2278. p0 = p0.replace(/^(jsp:|json:|jq:)/, '');
  2279. // print('1381 p0:'+p0);
  2280. try {
  2281. let req_method = MY_URL.split(';').length > 1 ? MY_URL.split(';')[1].toLowerCase() : 'get';
  2282. let html;
  2283. if (req_method === 'post') {
  2284. let rurls = MY_URL.split(';')[0].split('#')
  2285. let rurl = rurls[0]
  2286. let params = rurls.length > 1 ? rurls[1] : '';
  2287. print(`post=》rurl:${rurl},params:${params}`);
  2288. // let new_dict = {};
  2289. // let new_tmp = params.split('&');
  2290. // new_tmp.forEach(i=>{
  2291. // new_dict[i.split('=')[0]] = i.split('=')[1];
  2292. // });
  2293. // html = post(rurl,{body:new_dict});
  2294. let _fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  2295. let postData = {body: params};
  2296. Object.assign(_fetch_params, postData);
  2297. html = post(rurl, _fetch_params);
  2298. } else if (req_method === 'postjson') {
  2299. let rurls = MY_URL.split(';')[0].split('#')
  2300. let rurl = rurls[0]
  2301. let params = rurls.length > 1 ? rurls[1] : '';
  2302. print(`postjson-》rurl:${rurl},params:${params}`);
  2303. try {
  2304. params = JSON.parse(params);
  2305. } catch (e) {
  2306. params = '{}'
  2307. }
  2308. let _fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  2309. let postData = {body: params};
  2310. Object.assign(_fetch_params, postData);
  2311. html = post(rurl, _fetch_params);
  2312. } else {
  2313. html = getHtml(MY_URL);
  2314. }
  2315. if (html) {
  2316. if (/系统安全验证|输入验证码/.test(html)) {
  2317. let cookie = verifyCode(MY_URL);
  2318. if (cookie) {
  2319. console.log(`本次成功过验证,cookie:${cookie}`);
  2320. setItem(RULE_CK, cookie);
  2321. } else {
  2322. console.log(`本次自动过搜索验证失败,cookie:${cookie}`);
  2323. }
  2324. // obj.headers['Cookie'] = cookie;
  2325. html = getHtml(MY_URL);
  2326. }
  2327. if (!html.includes(searchObj.wd)) {
  2328. console.log('搜索结果源码未包含关键字,疑似搜索失败,正为您打印结果源码');
  2329. console.log(html);
  2330. }
  2331. if (is_json) {
  2332. // console.log(html);
  2333. html = dealJson(html);
  2334. // console.log(JSON.stringify(html));
  2335. }
  2336. // console.log(html);
  2337. let list = _pdfa(html, p0);
  2338. // print(list.length);
  2339. // print(list);
  2340. let p1 = getPP(p, 1, pp, 1);
  2341. let p2 = getPP(p, 2, pp, 2);
  2342. let p3 = getPP(p, 3, pp, 3);
  2343. let p4 = getPP(p, 4, pp, 4);
  2344. let p5 = getPP(p, 5, pp, 5);
  2345. list.forEach(it => {
  2346. let links = p4.split('+').map(_p4 => {
  2347. return !rule.detailUrl ? _pd(it, _p4, MY_URL) : _pdfh(it, _p4)
  2348. });
  2349. let link = links.join('$');
  2350. let content;
  2351. if (p.length > 5 && p[5]) {
  2352. content = _pdfh(it, p5);
  2353. } else {
  2354. content = '';
  2355. }
  2356. let vod_id = link;
  2357. let vod_name = _pdfh(it, p1).replace(/\n|\t/g, '').trim();
  2358. let vod_pic = _pd(it, p2, MY_URL);
  2359. if (rule.二级 === '*') {
  2360. vod_id = vod_id + '@@' + vod_name + '@@' + vod_pic;
  2361. }
  2362. let ob = {
  2363. 'vod_id': vod_id,
  2364. 'vod_name': vod_name,
  2365. 'vod_pic': vod_pic,
  2366. 'vod_remarks': _pdfh(it, p3).replace(/\n|\t/g, '').trim(),
  2367. 'vod_content': content.replace(/\n|\t/g, '').trim(),
  2368. };
  2369. d.push(ob);
  2370. });
  2371. }
  2372. } catch (e) {
  2373. print(`搜索发生错误:${e.message}`);
  2374. return '{}'
  2375. }
  2376. }
  2377. if (rule.图片替换) {
  2378. if (rule.图片替换.startsWith('js:')) {
  2379. d.forEach(it => {
  2380. try {
  2381. var input = it.vod_pic;
  2382. eval(rule.图片替换.trim().replace('js:', ''));
  2383. it.vod_pic = input;
  2384. } catch (e) {
  2385. log(`图片:${it.vod_pic}替换错误:${e.message}`);
  2386. }
  2387. });
  2388. } else if (rule.图片替换.includes('=>')) {
  2389. let replace_from = rule.图片替换.split('=>')[0];
  2390. let replace_to = rule.图片替换.split('=>')[1];
  2391. d.forEach(it => {
  2392. if (it.vod_pic && it.vod_pic.startsWith('http')) {
  2393. it.vod_pic = it.vod_pic.replace(replace_from, replace_to);
  2394. }
  2395. });
  2396. }
  2397. }
  2398. if (rule.图片来源) {
  2399. d.forEach(it => {
  2400. if (it.vod_pic && it.vod_pic.startsWith('http')) {
  2401. it.vod_pic = it.vod_pic + rule.图片来源;
  2402. }
  2403. });
  2404. }
  2405. // print(d);
  2406. return JSON.stringify({
  2407. 'page': parseInt(searchObj.pg),
  2408. 'pagecount': 10,
  2409. 'limit': 20,
  2410. 'total': 100,
  2411. 'list': d,
  2412. });
  2413. }
  2414. /**
  2415. * 二级详情页数据解析
  2416. * @param detailObj
  2417. * @returns {string}
  2418. */
  2419. function detailParse(detailObj) {
  2420. let t1 = (new Date()).getTime();
  2421. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  2422. let orId = detailObj.orId;
  2423. let vod_name = '片名';
  2424. let vod_pic = '';
  2425. let vod_id = orId;
  2426. if (rule.二级 === '*') {
  2427. // vod_id = orId.split('@@')[0]; // 千万不能分割
  2428. let extra = orId.split('@@');
  2429. vod_name = extra.length > 1 ? extra[1] : vod_name;
  2430. vod_pic = extra.length > 2 ? extra[2] : vod_pic;
  2431. }
  2432. // print(vod_pic);
  2433. let vod = {
  2434. vod_id: vod_id, //"id",
  2435. vod_name: vod_name,
  2436. vod_pic: vod_pic,
  2437. type_name: "类型",
  2438. vod_year: "年份",
  2439. vod_area: "地区",
  2440. vod_remarks: "更新信息",
  2441. vod_actor: "主演",
  2442. vod_director: "导演",
  2443. vod_content: "简介"
  2444. };
  2445. let p = detailObj.二级;
  2446. let url = detailObj.url;
  2447. let detailUrl = detailObj.detailUrl;
  2448. let fyclass = detailObj.fyclass;
  2449. let tab_exclude = detailObj.tab_exclude;
  2450. let html = detailObj.html || '';
  2451. MY_URL = url;
  2452. if (detailObj.二级访问前) {
  2453. try {
  2454. print(`尝试在二级访问前执行代码:${detailObj.二级访问前}`);
  2455. eval(detailObj.二级访问前.trim().replace('js:', ''));
  2456. } catch (e) {
  2457. print(`二级访问前执行代码出现错误:${e.message}`)
  2458. }
  2459. }
  2460. // console.log(MY_URL);
  2461. // setItem('MY_URL',MY_URL);
  2462. if (p === '*') {
  2463. vod.vod_play_from = '道长在线';
  2464. vod.vod_remarks = detailUrl;
  2465. vod.vod_actor = '没有二级,只有一级链接直接嗅探播放';
  2466. vod.vod_content = MY_URL;
  2467. vod.vod_play_url = '嗅探播放$' + MY_URL.split('@@')[0];
  2468. } else if (typeof (p) === 'string' && p.trim().startsWith('js:')) {
  2469. const TYPE = 'detail';
  2470. var input = MY_URL;
  2471. var play_url = '';
  2472. eval(p.trim().replace('js:', ''));
  2473. vod = VOD;
  2474. console.log(JSON.stringify(vod));
  2475. } else if (p && typeof (p) === 'object') {
  2476. let tt1 = (new Date()).getTime();
  2477. if (!html) {
  2478. html = getHtml(MY_URL);
  2479. }
  2480. print(`二级${MY_URL}仅获取源码耗时:${(new Date()).getTime() - tt1}毫秒`);
  2481. let _ps;
  2482. if (p.is_json) {
  2483. print('二级是json');
  2484. _ps = parseTags.json;
  2485. html = dealJson(html);
  2486. } else if (p.is_jsp) {
  2487. print('二级是jsp');
  2488. _ps = parseTags.jsp;
  2489. } else if (p.is_jq) {
  2490. print('二级是jq');
  2491. _ps = parseTags.jq;
  2492. } else {
  2493. print('二级默认jq');
  2494. _ps = parseTags.jq;
  2495. // print('二级默认jsp');
  2496. // _ps = parseTags.jsp;
  2497. }
  2498. let tt2 = (new Date()).getTime();
  2499. print(`二级${MY_URL}获取并装载源码耗时:${tt2 - tt1}毫秒`);
  2500. _pdfa = _ps.pdfa;
  2501. _pdfh = _ps.pdfh;
  2502. _pd = _ps.pd;
  2503. if (p.title) {
  2504. let p1 = p.title.split(';');
  2505. vod.vod_name = _pdfh(html, p1[0]).replace(/\n|\t/g, '').trim();
  2506. let type_name = p1.length > 1 ? _pdfh(html, p1[1]).replace(/\n|\t/g, '').replace(/ /g, '').trim() : '';
  2507. vod.type_name = type_name || vod.type_name;
  2508. }
  2509. if (p.desc) {
  2510. try {
  2511. let p1 = p.desc.split(';');
  2512. vod.vod_remarks = _pdfh(html, p1[0]).replace(/\n|\t/g, '').trim();
  2513. vod.vod_year = p1.length > 1 ? _pdfh(html, p1[1]).replace(/\n|\t/g, '').trim() : '';
  2514. vod.vod_area = p1.length > 2 ? _pdfh(html, p1[2]).replace(/\n|\t/g, '').trim() : '';
  2515. // vod.vod_actor = p1.length > 3 ? _pdfh(html, p1[3]).replaceAll('\n', ' ').trim():'';
  2516. vod.vod_actor = p1.length > 3 ? _pdfh(html, p1[3]).replace(/\n|\t/g, '').trim() : '';
  2517. vod.vod_director = p1.length > 4 ? _pdfh(html, p1[4]).replace(/\n|\t/g, '').trim() : '';
  2518. } catch (e) {
  2519. }
  2520. }
  2521. if (p.content) {
  2522. try {
  2523. let p1 = p.content.split(';');
  2524. vod.vod_content = _pdfh(html, p1[0]).replace(/\n|\t/g, '').trim();
  2525. } catch (e) {
  2526. }
  2527. }
  2528. if (p.img) {
  2529. try {
  2530. let p1 = p.img.split(';');
  2531. vod.vod_pic = _pd(html, p1[0], MY_URL);
  2532. } catch (e) {
  2533. }
  2534. }
  2535. let vod_play_from = '$$$';
  2536. let playFrom = [];
  2537. if (p.重定向 && p.重定向.startsWith('js:')) {
  2538. print('开始执行重定向代码:' + p.重定向);
  2539. html = eval(p.重定向.replace('js:', ''));
  2540. }
  2541. // console.log(2);
  2542. if (p.tabs) {
  2543. if (p.tabs.startsWith('js:')) {
  2544. print('开始执行tabs代码:' + p.tabs);
  2545. var input = MY_URL;
  2546. eval(p.tabs.replace('js:', ''));
  2547. playFrom = TABS;
  2548. } else {
  2549. let p_tab = p.tabs.split(';')[0];
  2550. // console.log(p_tab);
  2551. let vHeader = _pdfa(html, p_tab);
  2552. console.log(vHeader.length);
  2553. let tab_text = p.tab_text || 'body&&Text';
  2554. // print('tab_text:'+tab_text);
  2555. let new_map = {};
  2556. for (let v of vHeader) {
  2557. let v_title = _pdfh(v, tab_text).trim();
  2558. if (!v_title) {
  2559. v_title = '线路空'
  2560. }
  2561. console.log(v_title);
  2562. if (tab_exclude && (new RegExp(tab_exclude)).test(v_title)) {
  2563. continue;
  2564. }
  2565. if (!new_map.hasOwnProperty(v_title)) {
  2566. new_map[v_title] = 1;
  2567. } else {
  2568. new_map[v_title] += 1;
  2569. }
  2570. if (new_map[v_title] > 1) {
  2571. v_title += Number(new_map[v_title] - 1);
  2572. }
  2573. playFrom.push(v_title);
  2574. }
  2575. }
  2576. console.log(JSON.stringify(playFrom));
  2577. } else {
  2578. playFrom = ['道长在线']
  2579. }
  2580. vod.vod_play_from = playFrom.join(vod_play_from);
  2581. // console.log(3);
  2582. let vod_play_url = '$$$';
  2583. let vod_tab_list = [];
  2584. if (p.lists) {
  2585. if (p.lists.startsWith('js:')) {
  2586. print('开始执行lists代码:' + p.lists);
  2587. try {
  2588. var input = MY_URL;
  2589. var play_url = '';
  2590. eval(p.lists.replace('js:', ''));
  2591. for (let i in LISTS) {
  2592. if (LISTS.hasOwnProperty(i)) {
  2593. // print(i);
  2594. try {
  2595. LISTS[i] = LISTS[i].map(it => it.split('$').slice(0, 2).join('$'));
  2596. } catch (e) {
  2597. print(`格式化LISTS发生错误:${e.message}`);
  2598. }
  2599. }
  2600. }
  2601. vod_play_url = LISTS.map(it => it.join('#')).join(vod_play_url);
  2602. } catch (e) {
  2603. print(`js执行lists: 发生错误:${e.message}`);
  2604. }
  2605. } else {
  2606. let list_text = p.list_text || 'body&&Text';
  2607. let list_url = p.list_url || 'a&&href';
  2608. let list_url_prefix = p.list_url_prefix || '';
  2609. // print('list_text:'+list_text);
  2610. // print('list_url:'+list_url);
  2611. // print('list_parse:'+p.lists);
  2612. let is_tab_js = p.tabs.trim().startsWith('js:');
  2613. for (let i = 0; i < playFrom.length; i++) {
  2614. let tab_name = playFrom[i];
  2615. let tab_ext = p.tabs.split(';').length > 1 && !is_tab_js ? p.tabs.split(';')[1] : '';
  2616. let p1 = p.lists.replaceAll('#idv', tab_name).replaceAll('#id', i);
  2617. tab_ext = tab_ext.replaceAll('#idv', tab_name).replaceAll('#id', i);
  2618. let tabName = tab_ext ? _pdfh(html, tab_ext) : tab_name;
  2619. console.log(tabName);
  2620. // print('tab_ext:'+tab_ext);
  2621. let new_vod_list = [];
  2622. let tt1 = (new Date()).getTime();
  2623. // print('pdfl:'+typeof (pdfl));
  2624. if (typeof (pdfl) === 'function') {
  2625. new_vod_list = pdfl(html, p1, list_text, list_url, MY_URL);
  2626. if (list_url_prefix) {
  2627. new_vod_list = new_vod_list.map(it => it.split('$')[0] + '$' + list_url_prefix + it.split('$').slice(1).join('$'));
  2628. }
  2629. } else {
  2630. let vodList = [];
  2631. try {
  2632. vodList = _pdfa(html, p1);
  2633. console.log('len(vodList):' + vodList.length);
  2634. } catch (e) {
  2635. // console.log(e.message);
  2636. }
  2637. for (let i = 0; i < vodList.length; i++) {
  2638. let it = vodList[i];
  2639. new_vod_list.push(_pdfh(it, list_text).trim() + '$' + list_url_prefix + _pd(it, list_url, MY_URL));
  2640. }
  2641. }
  2642. if (new_vod_list.length > 0) {
  2643. new_vod_list = forceOrder(new_vod_list, '', x => x.split('$')[0]);
  2644. console.log(`drpy影响性能代码共计列表数循环次数:${new_vod_list.length},耗时:${(new Date()).getTime() - tt1}毫秒`);
  2645. }
  2646. // print(new_vod_list);
  2647. let vlist = new_vod_list.join('#');
  2648. vod_tab_list.push(vlist);
  2649. }
  2650. vod_play_url = vod_tab_list.join(vod_play_url);
  2651. }
  2652. }
  2653. vod.vod_play_url = vod_play_url;
  2654. }
  2655. if (rule.图片替换 && rule.图片替换.includes('=>')) {
  2656. let replace_from = rule.图片替换.split('=>')[0];
  2657. let replace_to = rule.图片替换.split('=>')[1];
  2658. vod.vod_pic = vod.vod_pic.replace(replace_from, replace_to);
  2659. }
  2660. if (rule.图片来源 && vod.vod_pic && vod.vod_pic.startsWith('http')) {
  2661. vod.vod_pic = vod.vod_pic + rule.图片来源;
  2662. }
  2663. if (!vod.vod_id || (vod_id.includes('$') && vod.vod_id !== vod_id)) {
  2664. vod.vod_id = vod_id;
  2665. }
  2666. let t2 = (new Date()).getTime();
  2667. console.log(`加载二级界面${MY_URL}耗时:${t2 - t1}毫秒`);
  2668. // print(vod);
  2669. try {
  2670. vod = vodDeal(vod);
  2671. } catch (e) {
  2672. console.log(`vodDeal发生错误:${e.message}`);
  2673. }
  2674. // print(vod);
  2675. return JSON.stringify({
  2676. list: [vod]
  2677. })
  2678. }
  2679. /**
  2680. * 获取二级待返回的播放线路没处理时的索引关系
  2681. * @param vod
  2682. * @returns {{}}
  2683. */
  2684. function get_tab_index(vod) {
  2685. let obj = {};
  2686. vod.vod_play_from.split('$$$').forEach((it, index) => {
  2687. obj[it] = index;
  2688. });
  2689. return obj
  2690. }
  2691. /**
  2692. * 处理待返回的vod数据|线路去除,排序,重命名
  2693. * @param vod
  2694. * @returns {*}
  2695. */
  2696. function vodDeal(vod) {
  2697. let vod_play_from = vod.vod_play_from.split('$$$');
  2698. let vod_play_url = vod.vod_play_url.split('$$$');
  2699. // 移除指定线路后的列表
  2700. let tab_removed_list = vod_play_from;
  2701. // 排序后的线路列表
  2702. let tab_ordered_list = vod_play_from;
  2703. // 线路重命名后的列表
  2704. let tab_renamed_list = vod_play_from;
  2705. // 定义实际要返回线路
  2706. let tab_list = vod_play_from;
  2707. // 选集列表根据线路排序
  2708. let play_ordered_list = vod_play_url;
  2709. // 判断有移除线路或者线路排序
  2710. if ((rule.tab_remove && rule.tab_remove.length > 0) || (rule.tab_order && rule.tab_order.length > 0)) {
  2711. // 获取原来线路的索引下标
  2712. let tab_index_dict = get_tab_index(vod);
  2713. if (rule.tab_remove && rule.tab_remove.length > 0) {
  2714. tab_removed_list = vod_play_from.filter(it => !rule.tab_remove.includes(it));
  2715. tab_list = tab_removed_list;
  2716. }
  2717. if (rule.tab_order && rule.tab_order.length > 0) {
  2718. let tab_order = rule.tab_order;
  2719. tab_ordered_list = tab_removed_list.sort((a, b) => {
  2720. return (tab_order.indexOf(a) === -1 ? 9999 : tab_order.indexOf(a)) - (tab_order.indexOf(b) === -1 ? 9999 : tab_order.indexOf(b))
  2721. });
  2722. tab_list = tab_ordered_list;
  2723. }
  2724. play_ordered_list = tab_list.map(it => vod_play_url[tab_index_dict[it]]);
  2725. }
  2726. if (rule.tab_rename && typeof (rule.tab_rename) === 'object' & Object.keys(rule.tab_rename).length > 0) {
  2727. tab_renamed_list = tab_list.map(it => rule.tab_rename[it] || it);
  2728. tab_list = tab_renamed_list;
  2729. }
  2730. vod.vod_play_from = tab_list.join('$$$');
  2731. vod.vod_play_url = play_ordered_list.join('$$$');
  2732. return vod
  2733. }
  2734. /**
  2735. * 判断是否需要解析
  2736. * @param url
  2737. * @returns {number|number}
  2738. */
  2739. function tellIsJx(url) {
  2740. try {
  2741. let is_vip = !/\.(m3u8|mp4|m4a)$/.test(url.split('?')[0]) && 是否正版(url);
  2742. return is_vip ? 1 : 0
  2743. } catch (e) {
  2744. return 1
  2745. }
  2746. }
  2747. /**
  2748. * 选集播放点击事件解析
  2749. * @param playObj
  2750. * @returns {string}
  2751. */
  2752. function playParse(playObj) {
  2753. fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
  2754. MY_URL = playObj.url;
  2755. var MY_FLAG = playObj.flag;
  2756. if (!/http/.test(MY_URL)) {
  2757. try {
  2758. MY_URL = base64Decode(MY_URL);
  2759. } catch (e) {
  2760. }
  2761. }
  2762. MY_URL = decodeURIComponent(MY_URL);
  2763. var input = MY_URL;//注入给免嗅js
  2764. var flag = MY_FLAG;//注入播放线路名称给免嗅js
  2765. let common_play = {
  2766. parse: SPECIAL_URL.test(input) || /^(push:)/.test(input) ? 0 : 1,
  2767. url: input,
  2768. flag: flag,
  2769. // url:urlencode(input),
  2770. jx: tellIsJx(input)
  2771. };
  2772. let lazy_play;
  2773. if (!rule.play_parse || !rule.lazy) {
  2774. lazy_play = common_play;
  2775. } else if (rule.play_parse && rule.lazy && typeof (rule.lazy) === 'string') {
  2776. try {
  2777. let lazy_code = rule.lazy.trim();
  2778. if (lazy_code.startsWith('js:')) {
  2779. lazy_code = lazy_code.replace('js:', '').trim();
  2780. }
  2781. print('开始执行js免嗅=>' + lazy_code);
  2782. eval(lazy_code);
  2783. lazy_play = typeof (input) === 'object' ? input : {
  2784. parse: SPECIAL_URL.test(input) || /^(push:)/.test(input) ? 0 : 1,
  2785. jx: tellIsJx(input),
  2786. url: input
  2787. };
  2788. } catch (e) {
  2789. print(`js免嗅错误:${e.message}`);
  2790. lazy_play = common_play;
  2791. }
  2792. } else {
  2793. lazy_play = common_play;
  2794. }
  2795. // print('play_json:'+typeof(rule.play_json));
  2796. // console.log(Array.isArray(rule.play_json));
  2797. if (Array.isArray(rule.play_json) && rule.play_json.length > 0) { // 数组情况判断长度大于0
  2798. let web_url = lazy_play.url;
  2799. for (let pjson of rule.play_json) {
  2800. if (pjson.re && (pjson.re === '*' || web_url.match(new RegExp(pjson.re)))) {
  2801. if (pjson.json && typeof (pjson.json) === 'object') {
  2802. let base_json = pjson.json;
  2803. // print('开始合并:');
  2804. // print(base_json);
  2805. lazy_play = Object.assign(lazy_play, base_json);
  2806. break;
  2807. }
  2808. }
  2809. }
  2810. } else if (rule.play_json && !Array.isArray(rule.play_json)) { // 其他情况 非[] 判断true/false
  2811. let base_json = {
  2812. jx: 1,
  2813. parse: 1,
  2814. };
  2815. lazy_play = Object.assign(lazy_play, base_json);
  2816. } else if (!rule.play_json) { // 不解析传0
  2817. let base_json = {
  2818. jx: 0,
  2819. parse: 1,
  2820. };
  2821. lazy_play = Object.assign(lazy_play, base_json);
  2822. }
  2823. console.log(JSON.stringify(lazy_play));
  2824. return JSON.stringify(lazy_play);
  2825. }
  2826. /**
  2827. * 本地代理解析规则
  2828. * @param params
  2829. */
  2830. function proxyParse(proxyObj) {
  2831. var input = proxyObj.params;
  2832. if (proxyObj.proxy_rule) {
  2833. log('准备执行本地代理规则:\n' + proxyObj.proxy_rule);
  2834. try {
  2835. eval(proxyObj.proxy_rule);
  2836. if (input && input !== proxyObj.params && Array.isArray(input) && input.length >= 3) {
  2837. return input
  2838. } else {
  2839. return [404, 'text/plain', 'Not Found']
  2840. }
  2841. } catch (e) {
  2842. return [500, 'text/plain', '代理规则错误:' + e.message]
  2843. }
  2844. } else {
  2845. return [404, 'text/plain', 'Not Found']
  2846. }
  2847. }
  2848. /**
  2849. * 辅助嗅探解析规则
  2850. * @param isVideoObj
  2851. * @returns {boolean}
  2852. */
  2853. function isVideoParse(isVideoObj) {
  2854. var input = isVideoObj.url;
  2855. if (!isVideoObj.t) { // t为假代表默认传的正则字符串
  2856. let re_matcher = new RegExp(isVideoObj.isVideo, 'i'); // /g匹配多个,/i不区分大小写,/m匹配多行
  2857. return re_matcher.test(input);
  2858. } else {
  2859. // 执行js
  2860. try {
  2861. eval(isVideoObj.isVideo);
  2862. if (typeof (input) === 'boolean') {
  2863. return input
  2864. } else {
  2865. return false
  2866. }
  2867. } catch (e) {
  2868. log(`执行嗅探规则发生错误:${e.message}`);
  2869. return false
  2870. }
  2871. }
  2872. }
  2873. /**
  2874. * 获取加密前的原始的js源文本
  2875. * @param js_code
  2876. */
  2877. function getOriginalJs(js_code) {
  2878. let current_match = /var rule|[\u4E00-\u9FA5]+|function|let |var |const |\(|\)|"|'/;
  2879. if (current_match.test(js_code)) {
  2880. return js_code
  2881. }
  2882. let rsa_private_key = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCqin/jUpqM6+fgYP/oMqj9zcdHMM0mEZXLeTyixIJWP53lzJV2N2E3OP6BBpUmq2O1a9aLnTIbADBaTulTNiOnVGoNG58umBnupnbmmF8iARbDp2mTzdMMeEgLdrfXS6Y3VvazKYALP8EhEQykQVarexR78vRq7ltY3quXx7cgI0ROfZz5Sw3UOLQJ+VoWmwIxu9AMEZLVzFDQN93hzuzs3tNyHK6xspBGB7zGbwCg+TKi0JeqPDrXxYUpAz1cQ/MO+Da0WgvkXnvrry8NQROHejdLVOAslgr6vYthH9bKbsGyNY3H+P12kcxo9RAcVveONnZbcMyxjtF5dWblaernAgMBAAECggEAGdEHlSEPFmAr5PKqKrtoi6tYDHXdyHKHC5tZy4YV+Pp+a6gxxAiUJejx1hRqBcWSPYeKne35BM9dgn5JofgjI5SKzVsuGL6bxl3ayAOu+xXRHWM9f0t8NHoM5fdd0zC3g88dX3fb01geY2QSVtcxSJpEOpNH3twgZe6naT2pgiq1S4okpkpldJPo5GYWGKMCHSLnKGyhwS76gF8bTPLoay9Jxk70uv6BDUMlA4ICENjmsYtd3oirWwLwYMEJbSFMlyJvB7hjOjR/4RpT4FPnlSsIpuRtkCYXD4jdhxGlvpXREw97UF2wwnEUnfgiZJ2FT/MWmvGGoaV/CfboLsLZuQKBgQDTNZdJrs8dbijynHZuuRwvXvwC03GDpEJO6c1tbZ1s9wjRyOZjBbQFRjDgFeWs9/T1aNBLUrgsQL9c9nzgUziXjr1Nmu52I0Mwxi13Km/q3mT+aQfdgNdu6ojsI5apQQHnN/9yMhF6sNHg63YOpH+b+1bGRCtr1XubuLlumKKscwKBgQDOtQ2lQjMtwsqJmyiyRLiUOChtvQ5XI7B2mhKCGi8kZ+WEAbNQcmThPesVzW+puER6D4Ar4hgsh9gCeuTaOzbRfZ+RLn3Aksu2WJEzfs6UrGvm6DU1INn0z/tPYRAwPX7sxoZZGxqML/z+/yQdf2DREoPdClcDa2Lmf1KpHdB+vQKBgBXFCVHz7a8n4pqXG/HvrIMJdEpKRwH9lUQS/zSPPtGzaLpOzchZFyQQBwuh1imM6Te+VPHeldMh3VeUpGxux39/m+160adlnRBS7O7CdgSsZZZ/dusS06HAFNraFDZf1/VgJTk9BeYygX+AZYu+0tReBKSs9BjKSVJUqPBIVUQXAoGBAJcZ7J6oVMcXxHxwqoAeEhtvLcaCU9BJK36XQ/5M67ceJ72mjJC6/plUbNukMAMNyyi62gO6I9exearecRpB/OGIhjNXm99Ar59dAM9228X8gGfryLFMkWcO/fNZzb6lxXmJ6b2LPY3KqpMwqRLTAU/zy+ax30eFoWdDHYa4X6e1AoGAfa8asVGOJ8GL9dlWufEeFkDEDKO9ww5GdnpN+wqLwePWqeJhWCHad7bge6SnlylJp5aZXl1+YaBTtOskC4Whq9TP2J+dNIgxsaF5EFZQJr8Xv+lY9lu0CruYOh9nTNF9x3nubxJgaSid/7yRPfAGnsJRiknB5bsrCvgsFQFjJVs=';
  2883. let decode_content = '';
  2884. function aes_decrypt(data) {
  2885. let key = CryptoJS.enc.Hex.parse("686A64686E780A0A0A0A0A0A0A0A0A0A");
  2886. let iv = CryptoJS.enc.Hex.parse("647A797964730A0A0A0A0A0A0A0A0A0A");
  2887. let encrypted = CryptoJS.AES.decrypt({
  2888. ciphertext: CryptoJS.enc.Base64.parse(data)
  2889. }, key, {
  2890. iv: iv,
  2891. mode: CryptoJS.mode.CBC,
  2892. padding: CryptoJS.pad.Pkcs7
  2893. }).toString(CryptoJS.enc.Utf8);
  2894. return encrypted;
  2895. }
  2896. let error_log = false;
  2897. function logger(text) {
  2898. if (error_log) {
  2899. log(text);
  2900. }
  2901. }
  2902. let decode_funcs = [
  2903. (text) => {
  2904. try {
  2905. return ungzip(text)
  2906. } catch (e) {
  2907. logger('非gzip加密');
  2908. return ''
  2909. }
  2910. },
  2911. (text) => {
  2912. try {
  2913. return base64Decode(text)
  2914. } catch (e) {
  2915. logger('非b64加密');
  2916. return ''
  2917. }
  2918. },
  2919. (text) => {
  2920. try {
  2921. return aes_decrypt(text)
  2922. } catch (e) {
  2923. logger('非aes加密');
  2924. return ''
  2925. }
  2926. },
  2927. (text) => {
  2928. try {
  2929. return RSA.decode(text, rsa_private_key, null)
  2930. } catch (e) {
  2931. logger('非rsa加密');
  2932. return ''
  2933. }
  2934. },
  2935. // (text)=>{try {return NODERSA.decryptRSAWithPrivateKey(text, RSA.getPrivateKey(rsa_private_key).replace(/RSA /g,''), {options: {environment: "browser", encryptionScheme: 'pkcs1',b:'1024'}});} catch (e) {log(e.message);return ''}},
  2936. ]
  2937. let func_index = 0
  2938. while (!current_match.test(decode_content)) {
  2939. decode_content = decode_funcs[func_index](js_code);
  2940. func_index++;
  2941. if (func_index >= decode_funcs.length) {
  2942. break;
  2943. }
  2944. }
  2945. return decode_content
  2946. }
  2947. /**
  2948. * 执行main函数
  2949. * 示例 function main(text){return gzip(text)}
  2950. * @param main_func_code
  2951. * @param arg
  2952. */
  2953. function runMain(main_func_code, arg) {
  2954. let mainFunc = function () {
  2955. return ''
  2956. };
  2957. try {
  2958. eval(main_func_code + '\nmainFunc=main;');
  2959. return mainFunc(arg);
  2960. } catch (e) {
  2961. log(`执行main_funct发生了错误:${e.message}`);
  2962. return ''
  2963. }
  2964. }
  2965. /**
  2966. * js源预处理特定返回对象中的函数
  2967. * @param ext
  2968. */
  2969. function init(ext) {
  2970. console.log('init');
  2971. // init前重置rule和fetch_params
  2972. rule = {};
  2973. rule_fetch_params = {};
  2974. fetch_params = null;
  2975. try {
  2976. // make shared jsContext happy muban不能import,不然会造成换源继承后变量被篡改
  2977. // if (typeof (globalThis.mubanJs) === 'undefined') {
  2978. // let mubanJs = request('https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/js/模板.js', { 'User-Agent': MOBILE_UA });
  2979. // mubanJs = mubanJs.replace('export default', '(function() {return muban;}()) // export default');
  2980. // // console.log(mubanJs);
  2981. // globalThis.mubanJs = mubanJs;
  2982. // }
  2983. // let muban = eval(globalThis.mubanJs);
  2984. let muban = 模板.getMubans();
  2985. // print(typeof (muban));
  2986. // print(muban);
  2987. if (typeof ext == 'object') {
  2988. rule = ext;
  2989. } else if (typeof ext == 'string') {
  2990. if (ext.startsWith('http') || ext.startsWith('file://')) {
  2991. let query = getQuery(ext); // 获取链接传参
  2992. let js = request(ext, {'method': 'GET'});
  2993. if (js) {
  2994. js = getOriginalJs(js);
  2995. // eval(js.replace('var rule', 'rule'));
  2996. // eval("(function(){'use strict';"+js.replace('var rule', 'rule')+"})()");
  2997. eval("(function(){" + js.replace('var rule', 'rule') + "})()");
  2998. }
  2999. if (query.type === 'url' && query.params) { // 指定type是链接并且传了params支持简写如 ./xx.json
  3000. rule.params = urljoin(ext, query.params);
  3001. } else if (query.params) { // 没指定type直接视为字符串
  3002. rule.params = query.params;
  3003. }
  3004. } else {
  3005. ext = getOriginalJs(ext);
  3006. // eval(ext.replace('var rule', 'rule'));
  3007. // eval("(function(){'use strict';"+ext.replace('var rule', 'rule')+"})()");
  3008. eval("(function(){" + ext.replace('var rule', 'rule') + "})()");
  3009. }
  3010. } else {
  3011. console.log(`规则加载失败,不支持的规则类型:${typeof ext}`);
  3012. return
  3013. }
  3014. rule.host = (rule.host || '').rstrip('/');
  3015. HOST = rule.host;
  3016. if (rule.hostJs) {
  3017. console.log(`检测到hostJs,准备执行...`);
  3018. try {
  3019. eval(rule.hostJs);
  3020. rule.host = HOST.rstrip('/');
  3021. } catch (e) {
  3022. console.log(`执行${rule.hostJs}获取host发生错误:${e.message}`);
  3023. }
  3024. }
  3025. if (rule['模板'] === '自动') {
  3026. try {
  3027. let host_headers = rule['headers'] || {};
  3028. let host_html = getCode(HOST, {headers: host_headers});
  3029. let match_muban = '';
  3030. let muban_keys = Object.keys(muban).filter(it => !/默认|短视2|采集1/.test(it));
  3031. for (let muban_key of muban_keys) {
  3032. try {
  3033. let host_data = JSON.parse(home({}, host_html, muban[muban_key].class_parse));
  3034. if (host_data.class && host_data.class.length > 0) {
  3035. match_muban = muban_key;
  3036. console.log(`自动匹配模板:【${muban_key}】`);
  3037. break;
  3038. }
  3039. } catch (e) {
  3040. // @ts-ignore
  3041. console.log(`自动匹配模板:【${muban_key}】错误:${e.message}`);
  3042. }
  3043. }
  3044. if (match_muban) {
  3045. muban['自动'] = muban[match_muban];
  3046. if (rule['模板修改'] && rule['模板修改'].startsWith('js:')) {
  3047. // 模板修改:$js.toString(()=>{ muban.自动.class_parse = ''});
  3048. eval(rule['模板修改'].replace('js:', '').trim());
  3049. }
  3050. } else {
  3051. delete rule['模板']
  3052. }
  3053. } catch (e) {
  3054. delete rule['模板']
  3055. }
  3056. }
  3057. if (rule.模板 && muban.hasOwnProperty(rule.模板)) {
  3058. print('继承模板:' + rule.模板);
  3059. rule = Object.assign(muban[rule.模板], rule);
  3060. }
  3061. /** 处理一下 rule规则关键字段没传递的情况 **/
  3062. let rule_cate_excludes = (rule.cate_exclude || '').split('|').filter(it => it.trim());
  3063. let rule_tab_excludes = (rule.tab_exclude || '').split('|').filter(it => it.trim());
  3064. rule_cate_excludes = rule_cate_excludes.concat(CATE_EXCLUDE.split('|').filter(it => it.trim()));
  3065. rule_tab_excludes = rule_tab_excludes.concat(TAB_EXCLUDE.split('|').filter(it => it.trim()));
  3066. rule.cate_exclude = rule_cate_excludes.join('|');
  3067. rule.tab_exclude = rule_tab_excludes.join('|');
  3068. rule.类型 = rule.类型 || '影视'; // 影视|听书|漫画|小说
  3069. rule.url = rule.url || '';
  3070. rule.double = rule.double || false;
  3071. rule.homeUrl = rule.homeUrl || '';
  3072. rule.detailUrl = rule.detailUrl || '';
  3073. rule.searchUrl = rule.searchUrl || '';
  3074. rule.homeUrl = rule.host && rule.homeUrl ? urljoin(rule.host, rule.homeUrl) : (rule.homeUrl || rule.host);
  3075. rule.homeUrl = cheerio.jinja2(rule.homeUrl, {rule: rule});
  3076. rule.detailUrl = rule.host && rule.detailUrl ? urljoin(rule.host, rule.detailUrl) : rule.detailUrl;
  3077. rule.二级访问前 = rule.二级访问前 || '';
  3078. if (rule.url.includes('[') && rule.url.includes(']')) {
  3079. let u1 = rule.url.split('[')[0]
  3080. let u2 = rule.url.split('[')[1].split(']')[0]
  3081. rule.url = rule.host && rule.url ? urljoin(rule.host, u1) + '[' + urljoin(rule.host, u2) + ']' : rule.url;
  3082. } else {
  3083. rule.url = rule.host && rule.url ? urljoin(rule.host, rule.url) : rule.url;
  3084. }
  3085. if (rule.searchUrl.includes('[') && rule.searchUrl.includes(']') && !rule.searchUrl.includes('#')) {
  3086. let u1 = rule.searchUrl.split('[')[0]
  3087. let u2 = rule.searchUrl.split('[')[1].split(']')[0]
  3088. rule.searchUrl = rule.host && rule.searchUrl ? urljoin(rule.host, u1) + '[' + urljoin(rule.host, u2) + ']' : rule.searchUrl;
  3089. } else {
  3090. rule.searchUrl = rule.host && rule.searchUrl ? urljoin(rule.host, rule.searchUrl) : rule.searchUrl;
  3091. }
  3092. rule.timeout = rule.timeout || 5000;
  3093. rule.encoding = rule.编码 || rule.encoding || 'utf-8';
  3094. rule.search_encoding = rule.搜索编码 || rule.search_encoding || '';
  3095. rule.图片来源 = rule.图片来源 || '';
  3096. rule.图片替换 = rule.图片替换 || '';
  3097. rule.play_json = rule.hasOwnProperty('play_json') ? rule.play_json : [];
  3098. rule.pagecount = rule.hasOwnProperty('pagecount') ? rule.pagecount : {};
  3099. rule.proxy_rule = rule.hasOwnProperty('proxy_rule') ? rule.proxy_rule : '';
  3100. if (!rule.hasOwnProperty('sniffer')) { // 默认关闭辅助嗅探
  3101. rule.sniffer = false;
  3102. }
  3103. rule.sniffer = rule.hasOwnProperty('sniffer') ? rule.sniffer : '';
  3104. rule.sniffer = !!(rule.sniffer && rule.sniffer !== '0' && rule.sniffer !== 'false');
  3105. rule.isVideo = rule.hasOwnProperty('isVideo') ? rule.isVideo : '';
  3106. if (rule.sniffer && !rule.isVideo) { // 默认辅助嗅探自动增强嗅探规则
  3107. rule.isVideo = 'http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|http((?!http).){12,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)|http((?!http).)*?video/tos*|http((?!http).)*?obj/tos*';
  3108. }
  3109. rule.tab_remove = rule.hasOwnProperty('tab_remove') ? rule.tab_remove : [];
  3110. rule.tab_order = rule.hasOwnProperty('tab_order') ? rule.tab_order : [];
  3111. rule.tab_rename = rule.hasOwnProperty('tab_rename') ? rule.tab_rename : {};
  3112. if (rule.headers && typeof (rule.headers) === 'object') {
  3113. try {
  3114. let header_keys = Object.keys(rule.headers);
  3115. for (let k of header_keys) {
  3116. if (k.toLowerCase() === 'user-agent') {
  3117. let v = rule.headers[k];
  3118. console.log(v);
  3119. if (['MOBILE_UA', 'PC_UA', 'UC_UA', 'IOS_UA', 'UA'].includes(v)) {
  3120. rule.headers[k] = eval(v);
  3121. }
  3122. } else if (k.toLowerCase() === 'cookie') {
  3123. let v = rule.headers[k];
  3124. if (v && v.startsWith('http')) {
  3125. console.log(v);
  3126. try {
  3127. v = fetch(v);
  3128. console.log(v);
  3129. rule.headers[k] = v;
  3130. } catch (e) {
  3131. console.log(`从${v}获取cookie发生错误:${e.message}`);
  3132. }
  3133. }
  3134. }
  3135. }
  3136. } catch (e) {
  3137. console.log(`处理headers发生错误:${e.message}`);
  3138. }
  3139. }
  3140. // print(rule.headers);
  3141. rule_fetch_params = {'headers': rule.headers || false, 'timeout': rule.timeout, 'encoding': rule.encoding};
  3142. oheaders = rule.headers || {};
  3143. RKEY = typeof (key) !== 'undefined' && key ? key : 'drpy_' + (rule.title || rule.host);
  3144. pre(); // 预处理
  3145. init_test();
  3146. } catch (e) {
  3147. console.log(`init_test发生错误:${e.message}`);
  3148. }
  3149. }
  3150. let homeHtmlCache = undefined;
  3151. /**
  3152. * js源获取首页分类和筛选特定返回对象中的函数
  3153. * @param filter 筛选条件字典对象
  3154. * @param home_html 指定了源码。无需内部再请求
  3155. * @param class_parse 自动匹配传入的模板的动态分类
  3156. * @returns {string}
  3157. */
  3158. function home(filter, home_html, class_parse) {
  3159. console.log("home");
  3160. home_html = home_html || '';
  3161. class_parse = class_parse || '';
  3162. if (typeof (rule.filter) === 'string' && rule.filter.trim().length > 0) {
  3163. try {
  3164. let filter_json = ungzip(rule.filter.trim());
  3165. rule.filter = JSON.parse(filter_json);
  3166. } catch (e) {
  3167. rule.filter = {};
  3168. }
  3169. }
  3170. let homeObj = {
  3171. filter: rule.filter || false,
  3172. MY_URL: rule.homeUrl,
  3173. class_name: rule.class_name || '',
  3174. class_url: rule.class_url || '',
  3175. class_parse: class_parse || rule.class_parse || '',
  3176. cate_exclude: rule.cate_exclude,
  3177. home_html: home_html,
  3178. };
  3179. return homeParse(homeObj);
  3180. }
  3181. /**
  3182. * js源获取首页推荐数据列表特定返回对象中的函数
  3183. * @param params
  3184. * @returns {string}
  3185. */
  3186. function homeVod(params) {
  3187. console.log("homeVod");
  3188. let homeVodObj = {
  3189. 推荐: rule.推荐,
  3190. double: rule.double,
  3191. homeUrl: rule.homeUrl,
  3192. detailUrl: rule.detailUrl
  3193. };
  3194. return homeVodParse(homeVodObj)
  3195. // return "{}";
  3196. }
  3197. /**
  3198. * js源获取分类页一级数据列表特定返回对象中的函数
  3199. * @param tid 分类id
  3200. * @param pg 页数
  3201. * @param filter 当前选中的筛选条件
  3202. * @param extend 扩展
  3203. * @returns {string}
  3204. */
  3205. function category(tid, pg, filter, extend) {
  3206. let cateObj = {
  3207. url: rule.url,
  3208. 一级: rule.一级,
  3209. tid: tid,
  3210. pg: parseInt(pg),
  3211. filter: filter,
  3212. extend: extend
  3213. };
  3214. // console.log(JSON.stringify(extend));
  3215. return categoryParse(cateObj)
  3216. }
  3217. /**
  3218. * js源获取二级详情页数据特定返回对象中的函数
  3219. * @param vod_url 一级列表中的vod_id或者是带分类的自拼接 vod_id 如 fyclass$vod_id
  3220. * @returns {string}
  3221. */
  3222. function detail(vod_url) {
  3223. let orId = vod_url;
  3224. let fyclass = '';
  3225. log('orId:' + orId);
  3226. if (vod_url.indexOf('$') > -1) {
  3227. let tmp = vod_url.split('$');
  3228. fyclass = tmp[0];
  3229. vod_url = tmp[1];
  3230. }
  3231. let detailUrl = vod_url.split('@@')[0];
  3232. let url;
  3233. if (!detailUrl.startsWith('http') && !detailUrl.includes('/')) {
  3234. url = rule.detailUrl.replaceAll('fyid', detailUrl).replaceAll('fyclass', fyclass);
  3235. } else if (detailUrl.includes('/')) {
  3236. url = urljoin(rule.homeUrl, detailUrl);
  3237. } else {
  3238. url = detailUrl
  3239. }
  3240. let detailObj = {
  3241. orId: orId,
  3242. url: url,
  3243. 二级: rule.二级,
  3244. 二级访问前: rule.二级访问前,
  3245. detailUrl: detailUrl,
  3246. fyclass: fyclass,
  3247. tab_exclude: rule.tab_exclude,
  3248. }
  3249. return detailParse(detailObj)
  3250. }
  3251. /**
  3252. * js源选集按钮播放点击事件特定返回对象中的函数
  3253. * @param flag 线路名
  3254. * @param id 播放按钮的链接
  3255. * @param flags 全局配置的flags是否需要解析的标识列表
  3256. * @returns {string}
  3257. */
  3258. function play(flag, id, flags) {
  3259. let playObj = {
  3260. url: id,
  3261. flag: flag,
  3262. flags: flags
  3263. }
  3264. return playParse(playObj);
  3265. }
  3266. /**
  3267. * js源搜索返回的数据列表特定返回对象中的函数
  3268. * @param wd 搜索关键字
  3269. * @param quick 是否来自快速搜索
  3270. * @returns {string}
  3271. */
  3272. function search(wd, quick, pg) {
  3273. if (rule.search_encoding) {
  3274. if (rule.search_encoding.toLowerCase() !== 'utf-8') {
  3275. // 按搜索编码进行编码
  3276. wd = encodeStr(wd, rule.search_encoding);
  3277. }
  3278. } else if (rule.encoding && rule.encoding.toLowerCase() !== 'utf-8') {
  3279. // 按全局编码进行编码
  3280. wd = encodeStr(wd, rule.encoding);
  3281. }
  3282. let searchObj = {
  3283. searchUrl: rule.searchUrl,
  3284. 搜索: rule.搜索,
  3285. wd: wd,
  3286. //pg: pg,
  3287. pg: pg || 1,
  3288. quick: quick,
  3289. };
  3290. // console.log(JSON.stringify(searchObj));
  3291. return searchParse(searchObj)
  3292. }
  3293. /**
  3294. * js源本地代理返回的数据列表特定返回对象中的函数
  3295. * @param params 代理链接参数比如 /proxy?do=js&url=https://wwww.baidu.com => params就是 {do:'js','url':'https://wwww.baidu.com'}
  3296. * @returns {*}
  3297. */
  3298. function proxy(params) {
  3299. if (rule.proxy_rule && rule.proxy_rule.trim()) {
  3300. rule.proxy_rule = rule.proxy_rule.trim();
  3301. }
  3302. if (rule.proxy_rule.startsWith('js:')) {
  3303. rule.proxy_rule = rule.proxy_rule.replace('js:', '');
  3304. }
  3305. let proxyObj = {
  3306. params: params,
  3307. proxy_rule: rule.proxy_rule
  3308. };
  3309. return proxyParse(proxyObj)
  3310. }
  3311. /**
  3312. * 是否启用辅助嗅探功能,启用后可以根据isVideo函数进行手动识别为视频的链接地址。默认为false
  3313. * @returns {*|boolean|boolean}
  3314. */
  3315. function sniffer() {
  3316. let enable_sniffer = rule.sniffer || false;
  3317. if (enable_sniffer) {
  3318. // log('准备执行辅助嗅探代理规则:\n'+rule.isVideo);
  3319. log('开始执行辅助嗅探代理规则...');
  3320. }
  3321. return enable_sniffer
  3322. }
  3323. /**
  3324. * 启用辅助嗅探功能后根据次函数返回的值识别地址是否为视频,返回true/false
  3325. * @param url
  3326. */
  3327. function isVideo(url) {
  3328. let t = 0;
  3329. let is_video;
  3330. if (rule.isVideo && rule.isVideo.trim()) {
  3331. is_video = rule.isVideo.trim();
  3332. }
  3333. if (is_video.startsWith('js:')) {
  3334. is_video = is_video.replace('js:', '');
  3335. t = 1;
  3336. }
  3337. let isVideoObj = {
  3338. url: url,
  3339. isVideo: is_video,
  3340. t: t,
  3341. };
  3342. let result = isVideoParse(isVideoObj);
  3343. if (result) {
  3344. log('成功执行辅助嗅探规则并检测到视频地址:\n' + rule.isVideo);
  3345. }
  3346. return result
  3347. }
  3348. /**
  3349. * 获取规则
  3350. * @returns {{}}
  3351. */
  3352. function getRule(key) {
  3353. return key ? rule[key] || '' : rule
  3354. }
  3355. function DRPY() {//导出函数
  3356. return {
  3357. runMain: runMain,
  3358. getRule: getRule,
  3359. init: init,
  3360. home: home,
  3361. homeVod: homeVod,
  3362. category: category,
  3363. detail: detail,
  3364. play: play,
  3365. search: search,
  3366. proxy: proxy,
  3367. sniffer: sniffer,
  3368. isVideo: isVideo,
  3369. fixAdM3u8Ai: fixAdM3u8Ai,
  3370. }
  3371. }
  3372. /**
  3373. * 导出函数无法简写成下面的形式:
  3374. export default {
  3375. ...DRPY,
  3376. DRPY
  3377. }
  3378. */
  3379. // 导出函数对象
  3380. export default {
  3381. runMain,
  3382. getRule,
  3383. init,
  3384. home,
  3385. homeVod,
  3386. category,
  3387. detail,
  3388. play,
  3389. search,
  3390. proxy,
  3391. sniffer,
  3392. isVideo,
  3393. fixAdM3u8Ai,
  3394. DRPY,
  3395. }