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

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

上级 0b8a6032
无法预览此类型文件
...@@ -572,8 +572,11 @@ class CMS: ...@@ -572,8 +572,11 @@ class CMS:
jsp = jsoup(self.homeUrl) jsp = jsoup(self.homeUrl)
pp = self.一级.split(';') pp = self.一级.split(';')
def getPP(p,pn,pp,ppn): def getPP(p,pn,pp,ppn):
ps = pp[ppn] if p[pn] == '*' and len(pp) > ppn else p[pn] try:
return ps 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) p0 = getPP(p,0,pp,0)
is_json = str(p0).startswith('json:') is_json = str(p0).startswith('json:')
if is_json: if is_json:
...@@ -582,8 +585,6 @@ class CMS: ...@@ -582,8 +585,6 @@ class CMS:
pdfa = jsp.pjfa if is_json else jsp.pdfa pdfa = jsp.pjfa if is_json else jsp.pdfa
pd = jsp.pj if is_json else jsp.pd pd = jsp.pj if is_json else jsp.pd
# print(html) # print(html)
try: try:
if self.double: if self.double:
...@@ -591,29 +592,30 @@ class CMS: ...@@ -591,29 +592,30 @@ class CMS:
# print(p[0]) # print(p[0])
# print(items) # print(items)
# print(len(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: for item in items:
items2 = pdfa(item,p[1]) items2 = pdfa(item,p1)
# print(len(items2)) # print(len(items2))
for item2 in items2: for item2 in items2:
try: try:
p2 = getPP(p,2,pp,1)
title = pdfh(item2, p2) title = pdfh(item2, p2)
# print(title) # print(title)
try: try:
p3 = getPP(p,3,pp,2)
img = pd(item2, p3) img = pd(item2, p3)
except: except:
img = '' img = ''
try: try:
p4 = getPP(p,4,pp,3)
desc = pdfh(item2, p4) desc = pdfh(item2, p4)
except: except:
desc = '' desc = ''
p5 = getPP(p,5,pp,4)
links = [pd(item2, _p5) if not self.detailUrl else pdfh(item2, _p5) for _p5 in p5.split('+')] links = [pd(item2, _p5) if not self.detailUrl else pdfh(item2, _p5) for _p5 in p5.split('+')]
vid = '$'.join(links) vid = '$'.join(links)
if len(p) > 6 and p[6]: if len(p) > 6 and p[6]:
p6 = getPP(p,6,pp,5)
content = pdfh(item2, p6) content = pdfh(item2, p6)
else: else:
content = '' content = ''
...@@ -635,26 +637,27 @@ class CMS: ...@@ -635,26 +637,27 @@ class CMS:
else: else:
items = pdfa(html, p0.replace('json:','')) items = pdfa(html, p0.replace('json:',''))
# print(items) # 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: for item in items:
try: try:
p1 = getPP(p,1,pp,1)
title = pdfh(item, p1) title = pdfh(item, p1)
try: try:
p2 = getPP(p,2,pp,2)
img = pd(item, p2) img = pd(item, p2)
except: except:
img = '' img = ''
try: try:
p3 = getPP(p,3,pp,3)
desc = pdfh(item, p3) desc = pdfh(item, p3)
except: except:
desc = '' desc = ''
p4 = getPP(p,4,pp,4)
# link = pd(item, p[4]) # link = pd(item, p[4])
links = [pd(item, _p5) if not self.detailUrl else pdfh(item, _p5) for _p5 in p4.split('+')] links = [pd(item, _p5) if not self.detailUrl else pdfh(item, _p5) for _p5 in p4.split('+')]
vid = '$'.join(links) vid = '$'.join(links)
if len(p) > 5 and p[5]: if len(p) > 5 and p[5]:
p5 = getPP(p,5,pp,5)
content = pdfh(item, p5) content = pdfh(item, p5)
else: else:
content = '' content = ''
......
...@@ -14,10 +14,10 @@ var rule = { ...@@ -14,10 +14,10 @@ var rule = {
play_parse:true, play_parse:true,
lazy:'', lazy:'',
limit:5, limit:5,
推荐:'ul.tbox_m2;li;*;*;*;*', 推荐:'.tbox2;*;*;*;*;*',
double:true, // 推荐内容是否双层定位 double:true, // 推荐内容是否双层定位
一级:'ul.tbox_m2 li;a&&title;a&&data-original;span&&Text;a&&href', 一级:'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;*;*;*;*', 搜索:'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) { ...@@ -1134,8 +1134,12 @@ function homeParse(homeObj) {
* @returns {*} * @returns {*}
*/ */
function getPP(p, pn, pp, ppn){ function getPP(p, pn, pp, ppn){
let ps = p[pn] === '*' && pp.length > ppn ?pp[ppn]:p[pn] try {
return ps let ps = p[pn] === '*' && pp.length > ppn ?pp[ppn]:p[pn]
return ps
}catch (e) {
return ''
}
} }
/** /**
...@@ -1193,25 +1197,27 @@ function homeVodParse(homeVodObj){ ...@@ -1193,25 +1197,27 @@ function homeVodParse(homeVodObj){
if (homeVodObj.double) { if (homeVodObj.double) {
let items = _pdfa(html, p0); let items = _pdfa(html, p0);
// console.log(items.length); // 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) { for (let item of items) {
// console.log(p[1]); // console.log(p[1]);
let items2 = _pdfa(item, p[1]); let items2 = _pdfa(item, p1);
// console.log(items2.length); // console.log(items2.length);
for (let item2 of items2) { for (let item2 of items2) {
try { try {
let p2 = getPP(p,2,pp,1);
let title = _pdfh(item2, p2); let title = _pdfh(item2, p2);
let img = ''; let img = '';
try { try {
let p3 = getPP(p,3,pp,2);
img = _pd(item2, p3); img = _pd(item2, p3);
} catch (e) {} } catch (e) {}
let desc = ''; let desc = '';
try { try {
let p4 = getPP(p,4,pp,3);
desc = _pdfh(item2, p4); desc = _pdfh(item2, p4);
}catch (e) {} }catch (e) {}
let p5 = getPP(p,5,pp,4);
let links = []; let links = [];
for (let _p5 of p5.split('+')) { for (let _p5 of p5.split('+')) {
let link = !homeVodObj.detailUrl ? _pd(item2, _p5, MY_URL) : _pdfh(item2, _p5); let link = !homeVodObj.detailUrl ? _pd(item2, _p5, MY_URL) : _pdfh(item2, _p5);
...@@ -1219,7 +1225,6 @@ function homeVodParse(homeVodObj){ ...@@ -1219,7 +1225,6 @@ function homeVodParse(homeVodObj){
} }
let content; let content;
if(p.length > 6 && p[6]){ if(p.length > 6 && p[6]){
let p6 = getPP(p,6,pp,5);
content = _pdfh(item2, p6); content = _pdfh(item2, p6);
} else{ } else{
content = ''; content = '';
...@@ -1249,21 +1254,22 @@ function homeVodParse(homeVodObj){ ...@@ -1249,21 +1254,22 @@ function homeVodParse(homeVodObj){
} else { } else {
let items = _pdfa(html, p0); 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) { for (let item of items) {
try { try {
let p1 = getPP(p,1,pp,1);
let title = _pdfh(item, p1); let title = _pdfh(item, p1);
let img = ''; let img = '';
try { try {
let p2 = getPP(p,2,pp,2);
img = _pd(item, p2, MY_URL); img = _pd(item, p2, MY_URL);
} catch (e) {} } catch (e) {}
let desc = ''; let desc = '';
try { try {
let p3 = getPP(p,3,pp,3);
desc = _pdfh(item, p3); desc = _pdfh(item, p3);
}catch (e) {} }catch (e) {}
let p4 = getPP(p,4,pp,4);
let links = []; let links = [];
for (let _p5 of p4.split('+')) { for (let _p5 of p4.split('+')) {
let link = !homeVodObj.detailUrl ? _pd(item, _p5, MY_URL) : _pdfh(item, _p5); let link = !homeVodObj.detailUrl ? _pd(item, _p5, MY_URL) : _pdfh(item, _p5);
...@@ -1271,7 +1277,6 @@ function homeVodParse(homeVodObj){ ...@@ -1271,7 +1277,6 @@ function homeVodParse(homeVodObj){
} }
let content; let content;
if(p.length > 5 && p[5]){ if(p.length > 5 && p[5]){
let p5 = getPP(p,5,pp,5);
content = _pdfh(item, p5); content = _pdfh(item, p5);
}else{ }else{
content = '' content = ''
......
此差异已折叠。
...@@ -1027,8 +1027,12 @@ function homeParse(homeObj) { ...@@ -1027,8 +1027,12 @@ function homeParse(homeObj) {
* @returns {*} * @returns {*}
*/ */
function getPP(p, pn, pp, ppn){ function getPP(p, pn, pp, ppn){
let ps = p[pn] === '*' && pp.length > ppn ?pp[ppn]:p[pn] try {
return ps let ps = p[pn] === '*' && pp.length > ppn ?pp[ppn]:p[pn]
return ps
}catch (e) {
return ''
}
} }
/** /**
...@@ -1086,25 +1090,27 @@ function homeVodParse(homeVodObj){ ...@@ -1086,25 +1090,27 @@ function homeVodParse(homeVodObj){
if (homeVodObj.double) { if (homeVodObj.double) {
let items = _pdfa(html, p0); let items = _pdfa(html, p0);
// console.log(items.length); // 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) { for (let item of items) {
// console.log(p[1]); // console.log(p[1]);
let items2 = _pdfa(item, p[1]); let items2 = _pdfa(item, p1);
// console.log(items2.length); // console.log(items2.length);
for (let item2 of items2) { for (let item2 of items2) {
try { try {
let p2 = getPP(p,2,pp,1);
let title = _pdfh(item2, p2); let title = _pdfh(item2, p2);
let img = ''; let img = '';
try { try {
let p3 = getPP(p,3,pp,2);
img = _pd(item2, p3); img = _pd(item2, p3);
} catch (e) {} } catch (e) {}
let desc = ''; let desc = '';
try { try {
let p4 = getPP(p,4,pp,3);
desc = _pdfh(item2, p4); desc = _pdfh(item2, p4);
}catch (e) {} }catch (e) {}
let p5 = getPP(p,5,pp,4);
let links = []; let links = [];
for (let _p5 of p5.split('+')) { for (let _p5 of p5.split('+')) {
let link = !homeVodObj.detailUrl ? _pd(item2, _p5, MY_URL) : _pdfh(item2, _p5); let link = !homeVodObj.detailUrl ? _pd(item2, _p5, MY_URL) : _pdfh(item2, _p5);
...@@ -1112,7 +1118,6 @@ function homeVodParse(homeVodObj){ ...@@ -1112,7 +1118,6 @@ function homeVodParse(homeVodObj){
} }
let content; let content;
if(p.length > 6 && p[6]){ if(p.length > 6 && p[6]){
let p6 = getPP(p,6,pp,5);
content = _pdfh(item2, p6); content = _pdfh(item2, p6);
} else{ } else{
content = ''; content = '';
...@@ -1142,21 +1147,23 @@ function homeVodParse(homeVodObj){ ...@@ -1142,21 +1147,23 @@ function homeVodParse(homeVodObj){
} else { } else {
let items = _pdfa(html, p0); 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) { for (let item of items) {
try { try {
let p1 = getPP(p,1,pp,1);
let title = _pdfh(item, p1); let title = _pdfh(item, p1);
let img = ''; let img = '';
try { try {
let p2 = getPP(p,2,pp,2);
img = _pd(item, p2, MY_URL); img = _pd(item, p2, MY_URL);
} catch (e) {} } catch (e) {}
let desc = ''; let desc = '';
try { try {
let p3 = getPP(p,3,pp,3);
desc = _pdfh(item, p3); desc = _pdfh(item, p3);
}catch (e) {} }catch (e) {}
let p4 = getPP(p,4,pp,4);
let links = []; let links = [];
for (let _p5 of p4.split('+')) { for (let _p5 of p4.split('+')) {
let link = !homeVodObj.detailUrl ? _pd(item, _p5, MY_URL) : _pdfh(item, _p5); let link = !homeVodObj.detailUrl ? _pd(item, _p5, MY_URL) : _pdfh(item, _p5);
...@@ -1164,7 +1171,6 @@ function homeVodParse(homeVodObj){ ...@@ -1164,7 +1171,6 @@ function homeVodParse(homeVodObj){
} }
let content; let content;
if(p.length > 5 && p[5]){ if(p.length > 5 && p[5]){
let p5 = getPP(p,5,pp,5);
content = _pdfh(item, p5); content = _pdfh(item, p5);
}else{ }else{
content = '' content = ''
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册