提交 94543b8d 编写于 作者: H hjdhnx

接口优化,推荐的double也支持第二位写*

上级 0b8a6032
无法预览此类型文件
......@@ -572,8 +572,11 @@ class CMS:
jsp = jsoup(self.homeUrl)
pp = self.一级.split(';')
def getPP(p,pn,pp,ppn):
ps = pp[ppn] if p[pn] == '*' and len(pp) > ppn else p[pn]
return ps
try:
ps = pp[ppn] if p[pn] == '*' and len(pp) > ppn else p[pn]
return ps
except Exception as e:
return ''
p0 = getPP(p,0,pp,0)
is_json = str(p0).startswith('json:')
if is_json:
......@@ -582,8 +585,6 @@ class CMS:
pdfa = jsp.pjfa if is_json else jsp.pdfa
pd = jsp.pj if is_json else jsp.pd
# print(html)
try:
if self.double:
......@@ -591,29 +592,30 @@ class CMS:
# print(p[0])
# print(items)
# print(len(items))
p1 = getPP(p, 1, pp, 0)
p2 = getPP(p, 2, pp, 1)
p3 = getPP(p, 3, pp, 2)
p4 = getPP(p, 4, pp, 3)
p5 = getPP(p, 5, pp, 4)
p6 = getPP(p, 6, pp, 5)
for item in items:
items2 = pdfa(item,p[1])
items2 = pdfa(item,p1)
# print(len(items2))
for item2 in items2:
try:
p2 = getPP(p,2,pp,1)
title = pdfh(item2, p2)
# print(title)
try:
p3 = getPP(p,3,pp,2)
img = pd(item2, p3)
except:
img = ''
try:
p4 = getPP(p,4,pp,3)
desc = pdfh(item2, p4)
except:
desc = ''
p5 = getPP(p,5,pp,4)
links = [pd(item2, _p5) if not self.detailUrl else pdfh(item2, _p5) for _p5 in p5.split('+')]
vid = '$'.join(links)
if len(p) > 6 and p[6]:
p6 = getPP(p,6,pp,5)
content = pdfh(item2, p6)
else:
content = ''
......@@ -635,26 +637,27 @@ class CMS:
else:
items = pdfa(html, p0.replace('json:',''))
# print(items)
p1 = getPP(p, 1, pp, 1)
p2 = getPP(p, 2, pp, 2)
p3 = getPP(p, 3, pp, 3)
p4 = getPP(p, 4, pp, 4)
p5 = getPP(p, 5, pp, 5)
for item in items:
try:
p1 = getPP(p,1,pp,1)
title = pdfh(item, p1)
try:
p2 = getPP(p,2,pp,2)
img = pd(item, p2)
except:
img = ''
try:
p3 = getPP(p,3,pp,3)
desc = pdfh(item, p3)
except:
desc = ''
p4 = getPP(p,4,pp,4)
# link = pd(item, p[4])
links = [pd(item, _p5) if not self.detailUrl else pdfh(item, _p5) for _p5 in p4.split('+')]
vid = '$'.join(links)
if len(p) > 5 and p[5]:
p5 = getPP(p,5,pp,5)
content = pdfh(item, p5)
else:
content = ''
......
......@@ -14,10 +14,10 @@ var rule = {
play_parse:true,
lazy:'',
limit:5,
推荐:'ul.tbox_m2;li;*;*;*;*',
推荐:'.tbox2;*;*;*;*;*',
double:true, // 推荐内容是否双层定位
一级:'ul.tbox_m2 li;a&&title;a&&data-original;span&&Text;a&&href',
二级:{"title":".data h4&&Text","img":".item-lazy&&data-original","desc":".cr3.starLink&&Text","content":".tbox_js&&Text","tabs":"js:pdfa=jsp.pdfa;TABS=pdfa(html,'.tbox_t h3').map(function(it,idex){return '线路'+(idex+1)})","lists":"ul.list_block:eq(#id) li"},
二级:{"title":".data h4--i&&Text;.yac&&Text","img":".item-lazy&&data-original","desc":";;;.act&&Text;.dir&&Text","content":".tbox_js&&Text","tabs":"js:pdfa=jsp.pdfa;TABS=pdfa(html,'.tbox_t h3').map(function(it,idex){return '线路'+(idex+1)})","lists":"ul.list_block:eq(#id) li"},
搜索:'ul.tbox_m li;*;*;*;*',
}
var rule = {
title:'酷客影院',
host:'http://www.2kuke.com',
// homeUrl:'/',
url:'/list/fyclass_fypage.html',
//searchUrl:'/vodsearch/**----------fypage---.html',
searchable:0,//是否启用全局搜索,
quickSearch:0,//是否启用快速搜索,
filterable:0,//是否启用分类筛选,
headers:{//网站的请求头,完整支持所有的,常带ua和cookies
'User-Agent':'MOBILE_UA',
// "Cookie": "searchneed=ok"
},
//class_parse:'.stui-header__menu li.hidden-xs;a&&Text;a&&href;/(\\d+)/',
class_name:'电影&剧集&综艺&动漫&伦理',
class_url:'1&2&4&3&6',
play_parse:true,
lazy:'',
limit:8,
推荐:'.stui-vodlist.clearfix;.stui-vodlist__box;a&&title;a&&data-original;.pic-text&&Text;a&&href',
double:true, // 推荐内容是否双层定位
一级:'.stui-vodlist.clearfix li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
二级:{"title":"h1.line1&&Text;.stui-content__detail p:eq(0)&&Text","img":".lazyload&&data-original","desc":";;;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text","content":".stui-content__detail p:eq(-1)&&Text","tabs":".nav.nav-tabs.pull-right&&li","lists":".stui-content__playlist:eq(#id) li"},
}
......@@ -1134,8 +1134,12 @@ function homeParse(homeObj) {
* @returns {*}
*/
function getPP(p, pn, pp, ppn){
let ps = p[pn] === '*' && pp.length > ppn ?pp[ppn]:p[pn]
return ps
try {
let ps = p[pn] === '*' && pp.length > ppn ?pp[ppn]:p[pn]
return ps
}catch (e) {
return ''
}
}
/**
......@@ -1193,25 +1197,27 @@ function homeVodParse(homeVodObj){
if (homeVodObj.double) {
let items = _pdfa(html, p0);
// console.log(items.length);
let p1 = getPP(p,1,pp,0);
let p2 = getPP(p,2,pp,1);
let p3 = getPP(p,3,pp,2);
let p4 = getPP(p,4,pp,3);
let p5 = getPP(p,5,pp,4);
let p6 = getPP(p,6,pp,5);
for (let item of items) {
// console.log(p[1]);
let items2 = _pdfa(item, p[1]);
let items2 = _pdfa(item, p1);
// console.log(items2.length);
for (let item2 of items2) {
try {
let p2 = getPP(p,2,pp,1);
let title = _pdfh(item2, p2);
let img = '';
try {
let p3 = getPP(p,3,pp,2);
img = _pd(item2, p3);
} catch (e) {}
let desc = '';
try {
let p4 = getPP(p,4,pp,3);
desc = _pdfh(item2, p4);
}catch (e) {}
let p5 = getPP(p,5,pp,4);
let links = [];
for (let _p5 of p5.split('+')) {
let link = !homeVodObj.detailUrl ? _pd(item2, _p5, MY_URL) : _pdfh(item2, _p5);
......@@ -1219,7 +1225,6 @@ function homeVodParse(homeVodObj){
}
let content;
if(p.length > 6 && p[6]){
let p6 = getPP(p,6,pp,5);
content = _pdfh(item2, p6);
} else{
content = '';
......@@ -1249,21 +1254,22 @@ function homeVodParse(homeVodObj){
} else {
let items = _pdfa(html, p0);
let p1 = getPP(p,1,pp,1);
let p2 = getPP(p,2,pp,2);
let p3 = getPP(p,3,pp,3);
let p4 = getPP(p,4,pp,4);
let p5 = getPP(p,5,pp,5);
for (let item of items) {
try {
let p1 = getPP(p,1,pp,1);
let title = _pdfh(item, p1);
let img = '';
try {
let p2 = getPP(p,2,pp,2);
img = _pd(item, p2, MY_URL);
} catch (e) {}
let desc = '';
try {
let p3 = getPP(p,3,pp,3);
desc = _pdfh(item, p3);
}catch (e) {}
let p4 = getPP(p,4,pp,4);
let links = [];
for (let _p5 of p4.split('+')) {
let link = !homeVodObj.detailUrl ? _pd(item, _p5, MY_URL) : _pdfh(item, _p5);
......@@ -1271,7 +1277,6 @@ function homeVodParse(homeVodObj){
}
let content;
if(p.length > 5 && p[5]){
let p5 = getPP(p,5,pp,5);
content = _pdfh(item, p5);
}else{
content = ''
......
此差异已折叠。
......@@ -1027,8 +1027,12 @@ function homeParse(homeObj) {
* @returns {*}
*/
function getPP(p, pn, pp, ppn){
let ps = p[pn] === '*' && pp.length > ppn ?pp[ppn]:p[pn]
return ps
try {
let ps = p[pn] === '*' && pp.length > ppn ?pp[ppn]:p[pn]
return ps
}catch (e) {
return ''
}
}
/**
......@@ -1086,25 +1090,27 @@ function homeVodParse(homeVodObj){
if (homeVodObj.double) {
let items = _pdfa(html, p0);
// console.log(items.length);
let p1 = getPP(p,1,pp,0);
let p2 = getPP(p,2,pp,1);
let p3 = getPP(p,3,pp,2);
let p4 = getPP(p,4,pp,3);
let p5 = getPP(p,5,pp,4);
let p6 = getPP(p,6,pp,5);
for (let item of items) {
// console.log(p[1]);
let items2 = _pdfa(item, p[1]);
let items2 = _pdfa(item, p1);
// console.log(items2.length);
for (let item2 of items2) {
try {
let p2 = getPP(p,2,pp,1);
let title = _pdfh(item2, p2);
let img = '';
try {
let p3 = getPP(p,3,pp,2);
img = _pd(item2, p3);
} catch (e) {}
let desc = '';
try {
let p4 = getPP(p,4,pp,3);
desc = _pdfh(item2, p4);
}catch (e) {}
let p5 = getPP(p,5,pp,4);
let links = [];
for (let _p5 of p5.split('+')) {
let link = !homeVodObj.detailUrl ? _pd(item2, _p5, MY_URL) : _pdfh(item2, _p5);
......@@ -1112,7 +1118,6 @@ function homeVodParse(homeVodObj){
}
let content;
if(p.length > 6 && p[6]){
let p6 = getPP(p,6,pp,5);
content = _pdfh(item2, p6);
} else{
content = '';
......@@ -1142,21 +1147,23 @@ function homeVodParse(homeVodObj){
} else {
let items = _pdfa(html, p0);
let p1 = getPP(p,1,pp,1);
let p2 = getPP(p,2,pp,2);
let p3 = getPP(p,3,pp,3);
let p4 = getPP(p,4,pp,4);
let p5 = getPP(p,5,pp,5);
for (let item of items) {
try {
let p1 = getPP(p,1,pp,1);
let title = _pdfh(item, p1);
let img = '';
try {
let p2 = getPP(p,2,pp,2);
img = _pd(item, p2, MY_URL);
} catch (e) {}
let desc = '';
try {
let p3 = getPP(p,3,pp,3);
desc = _pdfh(item, p3);
}catch (e) {}
let p4 = getPP(p,4,pp,4);
let links = [];
for (let _p5 of p4.split('+')) {
let link = !homeVodObj.detailUrl ? _pd(item, _p5, MY_URL) : _pdfh(item, _p5);
......@@ -1164,7 +1171,6 @@ function homeVodParse(homeVodObj){
}
let content;
if(p.length > 5 && p[5]){
let p5 = getPP(p,5,pp,5);
content = _pdfh(item, p5);
}else{
content = ''
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册