diff --git a/controllers/cms.py b/controllers/cms.py index 2bf9a287b7e10a56893e81045f25a0daeac47154..8b58a37f76ce65a741fb02f4481e60ca1dded2c8 100644 --- a/controllers/cms.py +++ b/controllers/cms.py @@ -13,7 +13,7 @@ from utils.system import getHost from utils.config import playerConfig from utils.log import logger from utils.encode import base64Encode,baseDecode,fetch,post,request,getCryptoJS,getPreJs,buildUrl,getHome -from utils.encode import verifyCode,setDetail,join,urljoin2 +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 @@ -463,7 +463,10 @@ class CMS: result['class'] = classes if self.filter: - result['filters'] = playerConfig['filter'] + if isinstance(self.filter,dict): + result['filters'] = self.filter + else: + result['filters'] = playerConfig['filter'] result.update(video_result) # print(result) logger.info(f'{self.getName()}获取首页总耗时(包含读取缓存):{get_interval(t1)}毫秒') @@ -611,7 +614,23 @@ class CMS: # url = self.url + '/{0}.html'.format t1 = time() pg = str(fypage) - url = self.url.replace('fyclass',fyclass).replace('fypage',pg) + url = self.url.replace('fyclass',fyclass) + if url.find('fypage') > -1: + if '(' in url and ')' in url: + # url_rep = url[url.find('('):url.find(')')+1] + # cnt_page = url.split('(')[1].split(')')[0].replace('fypage',pg) + # print(url_rep) + url_rep = re.search('.*?\((.*)\)',url,re.M|re.S).groups()[0] + cnt_page = url_rep.replace('fypage', pg) + # print(url_rep) + # print(cnt_page) + cnt_ctx = {} + exec(f'cnt_pg={cnt_page}', cnt_ctx) + cnt_pg = str(cnt_ctx['cnt_pg']) # 计算表达式的结果 + url = url.replace(url_rep,str(cnt_pg)).replace('(','').replace(')','') + print(url) + else: + url = url.replace('fypage',pg) if fypage == 1 and self.test('[\[\]]',url): url = url.split('[')[1].split(']')[0] p = self.一级 @@ -958,9 +977,10 @@ class CMS: loader, _ = runJScode(jscode, ctx=ctx) # print(loader.toString()) vods = loader.eval('VODS') - # print(vods) + # print(len(vods),type(vods)) if isinstance(vods, JsObjectWrapper): videos = vods.to_list() + # print(videos) else: p = p.split(';') if len(p) < 5: diff --git "a/js/\350\217\234\347\213\227.js" "b/js/\350\217\234\347\213\227.js" new file mode 100644 index 0000000000000000000000000000000000000000..ddddba3eac7a8db3fa693b04a6a79332a77f5ce6 --- /dev/null +++ "b/js/\350\217\234\347\213\227.js" @@ -0,0 +1,32 @@ +var rule = { + title:'菜狗', + host:'https://waptv.sogou.com/', + homeUrl:'', + detailUrl:'https://node.video.%71%71.com/x/api/float_vinfo2?cid=fyid', + searchUrl:'https://v.sogou.com/v?query=**&typemask=6&p=&dp=&dr=&_asf=v.sogou.com&enter=1&ie=utf8', + searchable:1, + quickSearch:0, + // 分类链接fypage参数支持1个()表达式 + url:'/napi/video/classlist?abtest=0&iploc=CN1304&spver=&listTab=fyclass&filter=&start=((fypage-1)*15)&len=15&fr=filter', + headers:{ + 'User-Agent':'MOBILE_UA' + }, + timeout:5000, + class_name:'电视剧&电影&动漫&综艺&纪录片', + class_url:'teleplay&film&cartoon&tvshow&documentary', + filterable:1, + filter:{'teleplay': [{'key': 'style', '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': '其他'}]}, {'key': 'zone', 'name': '地区', 'value': [{'n': '全部', 'v': ''}, {'n': '内地', 'v': '内地'}, {'n': '香港', 'v': '香港'}, {'n': '台湾', 'v': '台湾'}, {'n': '韩国', 'v': '韩国'}, {'n': '泰国', 'v': '泰国'}, {'n': '日本', 'v': '日本'}, {'n': '美国', 'v': '美国'}, {'n': '英国', 'v': '英国'}, {'n': '新加坡', 'v': '新加坡'}, {'n': '其他', 'v': '其他'}]}, {'key': 'year', 'name': '年代', 'value': [{'n': '全部', 'v': ''}, {'n': '2022', 'v': '2022'}, {'n': '2021', 'v': '2021'}, {'n': '2020', 'v': '2020'}, {'n': '2019', 'v': '2019'}, {'n': '2018', 'v': '2018'}, {'n': '2017', 'v': '2017'}, {'n': '2016', 'v': '2016'}, {'n': '2015', 'v': '2015'}, {'n': '2014', 'v': '2014'}, {'n': '更早', 'v': '更早'}]}, {'key': 'fee', 'name': '资源', 'value': [{'n': '全部', 'v': ''}, {'n': '正片', 'v': '正片'}, {'n': '免费正片', 'v': '免费正片'}, {'n': '付费正片', 'v': '付费正片'}]}, {'key': 'order', 'name': '排序', 'value': [{'n': '全部', 'v': ''}, {'n': '最新', 'v': '最新'}, {'n': '好评', 'v': '好评'}]}], 'film': [{'key': 'style', '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': '其他'}]}, {'key': 'zone', 'name': '地区', 'value': [{'n': '全部', 'v': ''}, {'n': '内地', 'v': '内地'}, {'n': '香港', 'v': '香港'}, {'n': '台湾', 'v': '台湾'}, {'n': '韩国', 'v': '韩国'}, {'n': '泰国', 'v': '泰国'}, {'n': '日本', 'v': '日本'}, {'n': '美国', 'v': '美国'}, {'n': '英国', 'v': '英国'}, {'n': '新加坡', 'v': '新加坡'}, {'n': '其他', 'v': '其他'}]}, {'key': 'year', 'name': '年代', 'value': [{'n': '全部', 'v': ''}, {'n': '2022', 'v': '2022'}, {'n': '2021', 'v': '2021'}, {'n': '2020', 'v': '2020'}, {'n': '2019', 'v': '2019'}, {'n': '2018', 'v': '2018'}, {'n': '2017', 'v': '2017'}, {'n': '2016', 'v': '2016'}, {'n': '2015', 'v': '2015'}, {'n': '2014', 'v': '2014'}, {'n': '更早', 'v': '更早'}]}, {'key': 'fee', 'name': '资源', 'value': [{'n': '全部', 'v': ''}, {'n': '正片', 'v': '正片'}, {'n': '免费正片', 'v': '免费正片'}, {'n': '付费正片', 'v': '付费正片'}]}, {'key': 'order', 'name': '排序', 'value': [{'n': '全部', 'v': ''}, {'n': '最新', 'v': '最新'}, {'n': '好评', 'v': '好评'}]}], 'cartoon': [{'key': 'style', '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': '其他'}]}, {'key': 'zone', 'name': '地区', 'value': [{'n': '全部', 'v': ''}, {'n': '日本', 'v': '日本'}, {'n': '欧美', 'v': '欧美'}, {'n': '国产', 'v': '国产'}, {'n': '其他', 'v': '其他'}]}, {'key': 'year', 'name': '年代', 'value': [{'n': '全部', 'v': ''}, {'n': '2022', 'v': '2022'}, {'n': '2021', 'v': '2021'}, {'n': '2020', 'v': '2020'}, {'n': '2019', 'v': '2019'}, {'n': '2018', 'v': '2018'}, {'n': '2017', 'v': '2017'}, {'n': '2016', 'v': '2016'}, {'n': '2015', 'v': '2015'}, {'n': '2014', 'v': '2014'}, {'n': '更早', 'v': '更早'}]}, {'key': 'fee', 'name': '资源', 'value': [{'n': '全部', 'v': ''}, {'n': '正片', 'v': '正片'}, {'n': '免费正片', 'v': '免费正片'}, {'n': '付费正片', 'v': '付费正片'}]}, {'key': 'order', 'name': '排序', 'value': [{'n': '全部', 'v': ''}, {'n': '最新', 'v': '最新'}, {'n': '好评', 'v': '好评'}]}], 'tvshow': [{'key': 'style', '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': '其他'}]}, {'key': 'zone', 'name': '地区', 'value': [{'n': '全部', 'v': ''}, {'n': '内地', 'v': '内地'}, {'n': '台湾', 'v': '台湾'}, {'n': '日韩', 'v': '日韩'}, {'n': '欧美', 'v': '欧美'}, {'n': '其他', 'v': '其他'}]}, {'key': 'emcee', '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': '谢娜'}]}, {'key': 'order', 'name': '排序', 'value': [{'n': '全部', 'v': ''}, {'n': '最新', 'v': '最新'}, {'n': '好评', 'v': '好评'}]}], 'documentary': [{'key': 'style', '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': '其他'}]}, {'key': 'zone', 'name': '地区', 'value': [{'n': '全部', 'v': ''}, {'n': '内地', 'v': '内地'}, {'n': '香港', 'v': '香港'}, {'n': '台湾', 'v': '台湾'}, {'n': '韩国', 'v': '韩国'}, {'n': '泰国', 'v': '泰国'}, {'n': '日本', 'v': '日本'}, {'n': '美国', 'v': '美国'}, {'n': '英国', 'v': '英国'}, {'n': '新加坡', 'v': '新加坡'}, {'n': '其他', 'v': '其他'}]}, {'key': 'year', 'name': '年代', 'value': [{'n': '全部', 'v': ''}, {'n': '2022', 'v': '2022'}, {'n': '2021', 'v': '2021'}, {'n': '2020', 'v': '2020'}, {'n': '2019', 'v': '2019'}, {'n': '2018', 'v': '2018'}, {'n': '2017', 'v': '2017'}, {'n': '2016', 'v': '2016'}, {'n': '2015', 'v': '2015'}, {'n': '2014', 'v': '2014'}, {'n': '更早', 'v': '更早'}]}, {'key': 'fee', 'name': '资源', 'value': [{'n': '全部', 'v': ''}, {'n': '正片', 'v': '正片'}, {'n': '免费正片', 'v': '免费正片'}, {'n': '付费正片', 'v': '付费正片'}]}, {'key': 'order', 'name': '排序', 'value': [{'n': '全部', 'v': ''}, {'n': '最新', 'v': '最新'}, {'n': '好评', 'v': '好评'}]}]}, + limit:20, + // play_parse:true, + // 手动调用解析请求json的url,此lazy不方便 + lazy:'js:input="https://cache.json.icu/home/api?type=ys&uid=292796&key=fnoryABDEFJNPQV269&url="+input.split("?")[0];log(input);let html=JSON.parse(request(input));log(html);input=html.url||input', + // 推荐:'.list_item;img&&alt;img&&src;a&&Text;a&&data-float', + // 一级:'json:.listData.results;name;v_picurl;ipad_play_for_list.episode||score||date;url', + 一级:'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);', + // 二级:{is_json:1,"title":"data.title;data.moviecategory[0]+data.moviecategory[1]","img":"data.cdncover","desc":"data.area[0];data.director[0]","content":"data.description","tabs":"data.playlink_sites;data.playlinksdetail.#idv.quality","lists":"data.playlinksdetail.#idv.default_url"}, + // 二级:{is_json:1,"title":"data.title;data.moviecategory[0]+data.moviecategory[1]","img":"data.cdncover","desc":"data.area[0];data.director[0]","content":"data.description","tabs":"data.playlink_sites","lists":"data.playlinksdetail.#idv.default_url"}, + 二级:'', + 二级:'js:var vod={};let d=[];let video_list=[];let video_lists=[];let list=[];let html=fetch(input,fetch_params);let sourceId=/get_playsource/.test(input)?input.match(/id=(\\d*?)&/)[1]:input.split("cid=")[1];let cid=sourceId;let detailUrl="https://v.%71%71.com/detail/m/"+cid+".html";log("详情页:"+detailUrl);var pdfh=jsp.pdfh;var pd=jsp.pd;try{let json=JSON.parse(html);vod={vod_id:json.c.vid,vod_url:input,vod_name:json.c.title,type_name:json.typ.join(","),vod_actor:json.nam.join(","),vod_year:json.c.year,vod_content:json.c.description,vod_remarks:json.rec,vod_pic:urljoin2(input,json.c.pic)}}catch(e){log("解析片名海报等基础信息发生错误:"+e.message)}if(/get_playsource/.test(input)){eval(html);let indexList=QZOutputJson.PlaylistItem.indexList;indexList.forEach(function(it){let dataUrl="https://s.video.qq.com/get_playsource?id="+sourceId+"&plat=2&type=4&data_type=3&range="+it+"&video_type=10&plname=qq&otype=json";eval(fetch(dataUrl,fetch_params));let vdata=QZOutputJson.PlaylistItem.videoPlayList;vdata.forEach(function(item){d.push({title:item.title,pic_url:item.pic,desc:item.episode_number+"\\t\\t\\t播放量:"+item.thirdLine,url:item.playUrl})});video_lists=video_lists.concat(vdata)})}else{let json=JSON.parse(html);video_lists=json.c.video_ids;let url="https://v.qq.com/x/cover/"+sourceId+".html";if(json.c.type===10){let dataUrl="https://s.video.qq.com/get_playsource?id="+json.c.column_id+"&plat=2&type=2&data_type=3&video_type=8&plname=qq&otype=json";let o_html=fetch(dataUrl,fetch_params);eval(o_html);video_lists=[];let indexList=QZOutputJson.PlaylistItem.indexList;indexList.forEach(function(it){let dataUrl="https://s.video.qq.com/get_playsource?id="+json.c.column_id+"&plat=2&type=4&data_type=3&range="+it+"&video_type=10&plname=qq&otype=json";eval(fetch(dataUrl,fetch_params));let vdata=QZOutputJson.PlaylistItem.videoPlayList;vdata.forEach(function(item){d.push({title:item.title,pic_url:item.pic,desc:item.episode_number+"\\t\\t\\t播放量:"+item.thirdLine,url:item.playUrl})});video_lists=video_lists.concat(vdata)})}else if(video_lists.length===1){d.push({title:"在线播放",url:url})}else if(video_lists.length>1){for(let i=0;i': '““””', + url: `#noLoading#@lazyRule=.js:let conf = getVar('shsort');if(conf==' - 逆序'){putVar({key:'shsort', value:' - 正序'});}else{putVar({key:'shsort', value:' - 逆序'})};refreshPage(false);'toast://切换排序成功';'#noHistory#hiker://empty'`, + col_type: 'flex_button' + }) ; + for (var o in tabs) { + var url = "#noLoading#@lazyRule=.js:putVar('" + vari + "', '" + o + "');refreshPage(false);'toast://切换成功!';'#noHistory#hiker://empty'"; + d.push({ + title: getVar(vari, '0') == o ? '‘‘' + tabs[o] + '’’': tabs[o], + url: url, + col_type: 'flex_button' + }) + } + d.push({ + col_type: "line" + }) + } else { + d.push({ + col_type: "blank_block" + }) + } + } + + function setLists(lists, index) { + if (plays[i].info || shows) { + var list = lists[index]; + if (list) { + if (getVar('shsort') == ' - 逆序') { + + for (var j = list.length - 1; j >= 0; j--) { + if (!list[j].index == '0') { + d.push({ + title: list[j].index, + url: 'https://v.sogou.com' + list[j].url + easy, + col_type: "text_4" + }); + } + } + } else { + + for (var j = 0; j < list.length; j++) { + if (!list[j].index == '0') { + d.push({ + title: list[j].index, + url: 'https://v.sogou.com' + list[j].url + easy, + col_type: "text_4" + }); + } + } + } + } + if (shows) { + var arr = []; + zy = shows.item_list[index]; + + for (var ii in zy.date) { + + date = zy.date[ii]; + + day = zy.date[ii].day; + + for (j in day) { + + dayy = day[j][0] >= 10 ? day[j][0] : "0" + day[j][0]; + + Tdate = date.year + date.month + dayy; + + arr.push(Tdate); + if (getVar('shsort') == ' - 逆序') { + arr.sort(function(a, b) { + return b - a + }) + } else { + arr.sort(function(a, b) { + return a - b + }) + } + } + } + for (var k = 0; k < arr.length; k++) { + url = "https://v.sogou.com/vc/eplay?query=" + arr[k] + "&date=" + arr[k] + "&key=" + json.dockey + "&st=5&tvsite=" + plays[index].site; + + d.push({ + title: "第" + arr[k] + "期", + col_type: "text_2", + url: url + easy + }); + } + } + } else if (plays[index].site) { + for (var m in plays) { + if (plays[m].flag_list.indexOf('trailer') == -1) { + d.push({ + title: plays[m].sitename[0], + img: plays[m].picurl || 'http://dlweb.sogoucdn.com/video/wap/static/img/logo/' + plays[m].sitename[1], + url: 'https://v.sogou.com' + plays[m].url + easy, + col_type: !plays[m].picurl ? "icon_2": "movie_2" + }) + } else { + d.push({ + url: "https://v.sogou.com" + plays[m].url + easy, + img: plays[m].picurl || 'http://dlweb.sogoucdn.com/video/wap/static/img/logo/' + plays[m].sitename[1], + title: plays[m].sitename[0] + '—预告', + col_type: !plays[m].picurl ? "icon_2": "movie_2" + }); + } + } + } + } + setTabs(tabs, MY_URL); + setLists(lists, getVar(MY_URL, '0')); + } catch(e) { + var img = json.photo.item_list; + d.push({ + title: '‘‘本片无选集’’', + col_type: "text_center_1" + }); + for (var i in img) { + d.push({ + img: img[i], + col_type: "pic_1_full" + }) + } + } +} catch(e) {} + +res.data = d; +setHomeResult(res); \ No newline at end of file diff --git "a/py/\346\220\234\347\213\227\346\220\234\347\264\242.js" "b/py/\346\220\234\347\213\227\346\220\234\347\264\242.js" new file mode 100644 index 0000000000000000000000000000000000000000..e09c8ab29b5555d91577a70bcb946304e7bb4d3e --- /dev/null +++ "b/py/\346\220\234\347\213\227\346\220\234\347\264\242.js" @@ -0,0 +1,24 @@ +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); + } +}); +// print(d); +setResult(d); \ No newline at end of file diff --git "a/py/\346\220\234\347\213\227\347\255\233\351\200\211.py" "b/py/\346\220\234\347\213\227\347\255\233\351\200\211.py" new file mode 100644 index 0000000000000000000000000000000000000000..9923b254933938512cc5db6c4858dded06aff015 --- /dev/null +++ "b/py/\346\220\234\347\213\227\347\255\233\351\200\211.py" @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# File : 搜狗筛选.py +# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------ +# Date : 2022/9/11 +import requests +from pprint import pprint + +cates = 'teleplay&film&cartoon&tvshow&documentary'.split('&') +urls = [f'https://waptv.sogou.com/napi/video/classlist?abtest=0&iploc=CN1304&spver=&listTab={cate}&filter=&start=0&len=15&fr=filter' for cate in cates] +print(urls) +headers = {'user-agent':'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36'} + +ft_dict = {} +def getOne(url): + r = requests.get(url, headers=headers) + html = r.json() + filters = html['listData']['list']['filter_list'] + cate_id = html['listData']['list']['entity'] + ft_dict[cate_id] = [] + for i in range(len(filters)): + ft = filters[i] + value = [{"n":"全部","v":""}] + vl = [{"n":i,"v":i} for i in ft['option_list']] + value.extend(vl) + ft_dict[cate_id].append({ + 'key':ft['option_name'], + 'name':ft['name'], + 'value':value + }) + return ft_dict +# print(ft_dict) +for url in urls: + # print(getOne(urls[0])) + # print(getOne(url)) + getOne(url) +print(ft_dict) \ No newline at end of file diff --git "a/py/\346\220\234\347\264\242\344\270\200\347\272\247.js" "b/py/\346\220\234\347\264\242\344\270\200\347\272\247.js" new file mode 100644 index 0000000000000000000000000000000000000000..51a633ed0bd68d847dc1a0e3c48dd5d1c3036b5d --- /dev/null +++ "b/py/\346\220\234\347\264\242\344\270\200\347\272\247.js" @@ -0,0 +1,17 @@ +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); \ No newline at end of file diff --git a/readme.md b/readme.md index 9efc98fb9cbc52dc227a94dd05cc8eab622cdcc2..db92016d3bc9581b090a20c2dfca7388846260b1 100644 --- a/readme.md +++ b/readme.md @@ -201,6 +201,7 @@ var rule = { searchable:0,//是否启用全局搜索, quickSearch:0,//是否启用快速搜索, filterable:0,//是否启用筛选, + filter:{},// 筛选条件字典 // 注意,由于猫有配置缓存,搜索配置没法热加载,修改了js不需要重启服务器 // 但是需要tv_box进设置里换源使配置重新装载 headers:{//网站的请求头,完整支持所有的,常带ua和cookies diff --git a/utils/htmlParser.py b/utils/htmlParser.py index 339b8e202d20f4c820e01ddfbd06b361219d066c..f2fadaf306af14e78ab11f16aee571cba458946d 100644 --- a/utils/htmlParser.py +++ b/utils/htmlParser.py @@ -31,6 +31,7 @@ class jsoup: parse = ' '.join([i if self.test(':eq|:lt|:gt|#',i) else f'{i}:eq(0)' for i in parse]) else: parse = parse[0] if self.test(':eq|:lt|:gt|#',parse[0]) else f'{parse[0]}:eq(0)' + # FIXME 暂时不支持jsonpath那样的|| 分割取或属性 if option: # print(f'parse:{parse}=>(option:{option})') ret = doc(parse) @@ -89,13 +90,17 @@ class jsoup: return '' if not parse.startswith('$.'): parse = f'$.{parse}' - ret = jsonpath(html,parse) - if isinstance(ret,list): - ret = str(ret[0]) if ret[0] else '' - else: - ret = str(ret) if ret else '' - if add_url: - ret = urljoin(self.MY_URL, ret) + ret = '' + for ps in parse.split('||'): + ret = jsonpath(html,ps) + if isinstance(ret,list): + ret = str(ret[0]) if ret[0] else '' + else: + ret = str(ret) if ret else '' + if add_url and ret: + ret = urljoin(self.MY_URL, ret) + if ret: + break return ret def pj(self, html, parse:str):