diff --git a/controllers/cms.py b/controllers/cms.py index 3cec614c5899d74cb40afac775c401ba72a5f382..cec65c9a2515dc66732fba3ff081de5821417663 100644 --- a/controllers/cms.py +++ b/controllers/cms.py @@ -17,7 +17,7 @@ from utils.encode import verifyCode,setDetail,join,urljoin2,parseText from utils.safePython import safePython from utils.parser import runPy,runJScode,JsObjectWrapper from utils.htmlParser import jsoup -from urllib.parse import urljoin +from urllib.parse import urljoin,quote,unquote from concurrent.futures import ThreadPoolExecutor # 引入线程池 from flask import url_for,redirect,render_template_string from easydict import EasyDict as edict @@ -35,6 +35,11 @@ def clearItem(key): lsg = storage_service() return lsg.clearItem(key) +def encodeUrl(url): + # return base64Encode(quote(url)) + # return base64Encode(url) + return quote(url) + py_ctx = { 'requests':requests,'print':print,'base64Encode':base64Encode,'baseDecode':baseDecode, 'log':logger.info,'fetch':fetch,'post':post,'request':request,'getCryptoJS':getCryptoJS, @@ -917,8 +922,8 @@ class CMS: # print(vodList) # vodList = [pq(i).text()+'$'+pd(i,'a&&href') for i in vodList] # 拼接成 名称$链接 if self.play_parse: # 自动base64编码 - vodList = [(pdfh(html,tab_ext) if tab_ext else tab_name)+'$'+self.play_url+base64Encode(i) for i in vodList] if is_json else\ - [pq(i).text()+'$'+self.play_url+base64Encode(pd(i,'a&&href')) for i in vodList] # 拼接成 名称$链接 + vodList = [(pdfh(html,tab_ext) if tab_ext else tab_name)+'$'+self.play_url+encodeUrl(i) for i in vodList] if is_json else\ + [pq(i).text()+'$'+self.play_url+encodeUrl(pd(i,'a&&href')) for i in vodList] # 拼接成 名称$链接 else: vodList = [(pdfh(html, tab_ext) if tab_ext else tab_name) + '$' + self.play_url + i for i in vodList] if is_json else \ @@ -1084,12 +1089,15 @@ class CMS: # 注意:全局flags里的视频没法执行免嗅代码,因为会自动拦截去调用解析: url=yoursite:5705/vod?play_url=xxxx if not jxs: jxs = [] + # print(play_url) if play_url.find('http') == -1: # 字符串看起来被编码的 try: play_url = baseDecode(play_url) # 自动base64解码 except: pass + # print(unquote(play_url)) + play_url = unquote(play_url) if self.lazy: print(f'{play_url}->开始执行免嗅代码{type(self.lazy)}->{self.lazy}') t1 = time() diff --git a/js/version.txt b/js/version.txt index c3f6bdc3de94183519ca377cd54ce03419cba388..b55f10804fd3f270d8780e2ca9ba09217e3b89c5 100644 --- a/js/version.txt +++ b/js/version.txt @@ -1 +1 @@ -3.6.4 \ No newline at end of file +3.6.5 \ No newline at end of file diff --git "a/js/\350\217\234\347\213\227.js" "b/js/\350\217\234\347\213\227.js" index 5e099b9d67c213d30a54881cfbae011794672cd0..34582ab7e62f025cfb2293adf3f2857769d4e688 100644 --- "a/js/\350\217\234\347\213\227.js" +++ "b/js/\350\217\234\347\213\227.js" @@ -19,11 +19,12 @@ var rule = { limit:20, play_parse:true, // 手动调用解析请求json的url,此lazy不方便 - lazy:'js:fetch_params.headers["user-agent"]=MOBILE_UA;let html=request(input);let rurl=html.match(/window\\.open\\(\'(.*?)\',/)[1];rurl=urlDeal(rurl);input={parse:1,url:rurl};', + lazy:'js:print(input);fetch_params.headers["user-agent"]=MOBILE_UA;let html=request(input);let rurl=html.match(/window\\.open\\(\'(.*?)\',/)[1];rurl=urlDeal(rurl);input={parse:1,url:rurl};', // 推荐:'.list_item;img&&alt;img&&src;a&&Text;a&&data-float', 一级:'js:let d=[];let html=request(input);html=JSON.parse(html);let list=html.listData.results;list.forEach(function(it){let desc1=it.ipad_play_for_list.finish_episode?it.ipad_play_for_list.episode===it.ipad_play_for_list.finish_episode?"全集"+it.ipad_play_for_list.finish_episode:"连载"+it.ipad_play_for_list.episode+"/"+it.ipad_play_for_list.finish_episode:"";let desc2=it.score?"评分:"+it.score:"";let desc3=it.date?"更至:"+it.date:"";d.push({title:it.name,img:it.v_picurl,url:"https://v.sogou.com"+it.url.replace("teleplay","series").replace("cartoon","series"),desc:desc1||desc2||desc3})});setResult(d);', 二级:'', - 二级:'js:var vod={vod_id:input};let html=request(input);function adhead(url){let hd="https://v.sogou.com";if(!url.startsWith(hd)){url=hd+url}return url}try{let json=JSON.parse(html.match(/INITIAL_STATE.*?({.*});/)[1]).detail.itemData;let key=json.dockey;let name=json.name;let zone=json.zone;let score=json.score?json.score:"暂无";let style=json.style;let emcee=json.emcee?"主持:"+json.emcee:json.name;let director=json.director?"导演:"+json.director:name;director=director.replace(/;/g,"\\t");let starring=json.starring?"演员:"+json.starring:"声优:"+json.shengyou;starring=starring.replace(/.*undefined/,"").replace(/;/g,"\\t");let update=json.update_wordstr?json.update_wordstr:"";let tv_station=json.tv_station?json.tv_station:zone;let introduction=json.introduction;let shengyou=json.shengyou;let shows=json.play_from_open_index;let plays=json.play.item_list;if(shows){vod.vod_name=name;vod.vod_area=emcee+","+tv_station;vod.vod_director=director;vod.vod_actor=starring;vod.vod_pic=jsp.pd(html,"#thumb_img&&img&&src");vod.vod_remarks=style+" 评分:"+score+","+update;vod.vod_content=introduction}else{vod.vod_name=name;vod.vod_director=director;vod.vod_actor=starring;vod.vod_pic=jsp.pd(html,"#thumb_img&&img&&src");vod.vod_content=introduction}let tp="&type=json";try{let tabs=[];let lists=[];plays.forEach(function(it){lists.push(it.info);let tbn=it.sitename[0]||it.site.replace(".com","");tbn=tbn.split("").join(" ");tabs.push(tbn)});vod.vod_play_from=tabs.join("$$$");vod_lists=[];play_url=play_url.replace("&play_url=","&type=json&play_url=");lists.forEach(function(item,idex){if(item||shows){if(item&&Array.isArray(item)&&item.length>1){let tmp=item.slice(1).map(function(its){return its.index+"$"+play_url+base64Encode(adhead(its.url))});vod_lists.push(tmp.join("#"))}if(shows){let arr=[];let tmp=[];let zy=shows.item_list[idex];zy.date.forEach(function(date){let day=date.day;for(let j=0;j=10?day[j][0]:"0"+day[j][0];let Tdate=date.year+date.month+dayy;arr.push(Tdate)}});for(let k=0;k0?img[0]:""}}catch(e){}', + 二级:'js:var vod={vod_id:input};let html=request(input);function adhead(url){let hd="https://v.sogou.com";if(!url.startsWith(hd)){url=hd+url}return urlencode(url)}try{let json=JSON.parse(html.match(/INITIAL_STATE.*?({.*});/)[1]).detail.itemData;let key=json.dockey;let name=json.name;let zone=json.zone;let score=json.score?json.score:"暂无";let style=json.style;let emcee=json.emcee?"主持:"+json.emcee:json.name;let director=json.director?"导演:"+json.director:name;director=director.replace(/;/g,"\\t");let starring=json.starring?"演员:"+json.starring:"声优:"+json.shengyou;starring=starring.replace(/.*undefined/,"").replace(/;/g,"\\t");let update=json.update_wordstr?json.update_wordstr:"";let tv_station=json.tv_station?json.tv_station:zone;let introduction=json.introduction;let shengyou=json.shengyou;let shows=json.play_from_open_index;let plays=json.play.item_list;if(shows){vod.vod_name=name;vod.vod_area=emcee+","+tv_station;vod.vod_director=director;vod.vod_actor=starring;vod.vod_pic=jsp.pd(html,"#thumb_img&&img&&src");vod.vod_remarks=style+" 评分:"+score+","+update;vod.vod_content=introduction}else{vod.vod_name=name;vod.vod_director=director;vod.vod_actor=starring;vod.vod_pic=jsp.pd(html,"#thumb_img&&img&&src");vod.vod_content=introduction}let tp="&type=json";try{let tabs=[];let lists=[];plays.forEach(function(it){lists.push(it.info);let tbn=it.sitename[0]||it.site.replace(".com","");tbn=tbn.split("").join(" ");tabs.push(tbn)});vod.vod_play_from=tabs.join("$$$");vod_lists=[];play_url=play_url.replace("&play_url=","&type=json&play_url=");lists.forEach(function(item,idex){if(item||shows){if(item&&Array.isArray(item)&&item.length>1){let tmp=item.slice(1).map(function(its){return its.index+"$"+play_url+base64Encode(adhead(its.url))});vod_lists.push(tmp.join("#"))}if(shows){let arr=[];let tmp=[];let zy=shows.item_list[idex];zy.date.forEach(function(date){let day=date.day;for(let j=0;j=10?day[j][0]:"0"+day[j][0];let Tdate=date.year+date.month+dayy;arr.push(Tdate)}});for(let k=0;k0?img[0]:""}}catch(e){}', + // 二级:'js:var vod={vod_id:input};let html=request(input);function adhead(url){let hd="https://v.sogou.com";if(!url.startsWith(hd)){url=hd+url}return url}try{let json=JSON.parse(html.match(/INITIAL_STATE.*?({.*});/)[1]).detail.itemData;let key=json.dockey;let name=json.name;let zone=json.zone;let score=json.score?json.score:"暂无";let style=json.style;let emcee=json.emcee?"主持:"+json.emcee:json.name;let director=json.director?"导演:"+json.director:name;director=director.replace(/;/g,"\\t");let starring=json.starring?"演员:"+json.starring:"声优:"+json.shengyou;starring=starring.replace(/.*undefined/,"").replace(/;/g,"\\t");let update=json.update_wordstr?json.update_wordstr:"";let tv_station=json.tv_station?json.tv_station:zone;let introduction=json.introduction;let shengyou=json.shengyou;let shows=json.play_from_open_index;let plays=json.play.item_list;if(shows){vod.vod_name=name;vod.vod_area=emcee+","+tv_station;vod.vod_director=director;vod.vod_actor=starring;vod.vod_pic=jsp.pd(html,"#thumb_img&&img&&src");vod.vod_remarks=style+" 评分:"+score+","+update;vod.vod_content=introduction}else{vod.vod_name=name;vod.vod_director=director;vod.vod_actor=starring;vod.vod_pic=jsp.pd(html,"#thumb_img&&img&&src");vod.vod_content=introduction}let tp="&type=json";try{let tabs=[];let lists=[];plays.forEach(function(it){lists.push(it.info);let tbn=it.sitename[0]||it.site.replace(".com","");tbn=tbn.split("").join(" ");tabs.push(tbn)});vod.vod_play_from=tabs.join("$$$");vod_lists=[];play_url=play_url.replace("&play_url=","&type=json&play_url=");lists.forEach(function(item,idex){if(item||shows){if(item&&Array.isArray(item)&&item.length>1){let tmp=item.slice(1).map(function(its){return its.index+"$"+play_url+base64Encode(adhead(its.url))});vod_lists.push(tmp.join("#"))}if(shows){let arr=[];let tmp=[];let zy=shows.item_list[idex];zy.date.forEach(function(date){let day=date.day;for(let j=0;j=10?day[j][0]:"0"+day[j][0];let Tdate=date.year+date.month+dayy;arr.push(Tdate)}});for(let k=0;k0?img[0]:""}}catch(e){}', 搜索:'', 搜索:'js:let d=[];let html=request(input);let jsonA=JSON.parse(html.match(/INITIAL_STATE.*?({.*});/)[1]).result.longVideo.results;jsonA.forEach(function(it){let name=it.name;let introduction=it.introduction;let pic=it.v_picurl;let url=it.tiny_url;let zone=it.zone;let score=it.score||"暂无";let style=it.style;if(it.play.item_list){let r={};r.title=name.replace(//,"").replace(//,"");r.url="https://v.sogou.com"+url;r.desc=it.list_category.join(",");r.content=introduction;r.pic_url=pic;d.push(r)}});setResult(d);', } \ No newline at end of file diff --git a/libs/pre.js b/libs/pre.js index e3dcbb9e8537eefb677ad65ef8f5070975f1e816..497a119716460e6f1cce360938234dfc7fc93590 100644 --- a/libs/pre.js +++ b/libs/pre.js @@ -216,4 +216,11 @@ function request(url,obj){ return html } return '' -} \ No newline at end of file +} + +function urlencode (str) { + str = (str + '').toString(); + + return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28'). + replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+'); +} diff --git "a/py/\346\220\234\347\213\227\344\272\214\347\272\247.js" "b/py/\346\220\234\347\213\227\344\272\214\347\272\247.js" index c4ca2faa7517e27b87034bf652628a3f9cd2ea50..95c3b7412ecc8b31bfac46edceb6382df4764b12 100644 --- "a/py/\346\220\234\347\213\227\344\272\214\347\272\247.js" +++ "b/py/\346\220\234\347\213\227\344\272\214\347\272\247.js" @@ -8,7 +8,7 @@ function adhead(url){ if(!url.startsWith(hd)){ url = hd+url } - return url + return urlencode(url) } try { let json = JSON.parse(html.match(/INITIAL_STATE.*?({.*});/)[1]).detail.itemData; diff --git a/readme.md b/readme.md index faefa57c61f2f84164793388d8a61db6bd9de5ba..daf64c779114b68971e995397242c91f85ffcd77 100644 --- a/readme.md +++ b/readme.md @@ -48,6 +48,7 @@ [获取本地设备信息](https://m.jb51.net/article/140716.htm) ###### 2022/09/14 - [X] 1.升级至3.6.2,增加了一些解析 +- [X] 2.升级至3.6.5,修复菜狗部分源解析失败问题(url参数有+号被自动变空格导致的) ###### 2022/09/13 - [X] 1.升级至3.5.8 - [X] 2.迁移alist.conf文件,修改默认模板,增加模板url参数支持fyfilter变量从此支持更多筛选场景