提交 3c7e85a6 编写于 作者: H hjdhnx

修复外网免嗅配置模式异常问题

上级 7a5f2fb3
......@@ -186,7 +186,8 @@ def getRules(path='cache'):
new_rule_list.append({
'name':rule_list[i],
'searchable':rule_codes[i].searchable or 0,
'quickSearch':rule_codes[i].quickSearch or 0
'quickSearch':rule_codes[i].quickSearch or 0,
'filterable':rule_codes[i].filterable or 0,
})
# print(new_rule_list)
rules = {'list': new_rule_list, 'count': len(rule_list)}
......
......@@ -35,11 +35,13 @@ class CMS:
self.id = rule.get('id', self.title)
self.lazy = rule.get('lazy', False)
self.play_disable = new_conf.get('PLAY_DISABLE',False)
self.lazy_mode = new_conf.get('LAZYPARSE_MODE')
self.vod = redirect(url_for('vod')).headers['Location']
# if not self.play_disable and self.lazy:
if not self.play_disable:
self.play_parse = rule.get('play_parse', False)
play_url = new_conf.get('PLAY_URL',getHost(2))
play_url = getHost(self.lazy_mode)
# play_url = new_conf.get('PLAY_URL',getHost(2))
if not play_url.startswith('http'):
play_url = 'http://'+play_url
if self.play_parse:
......@@ -356,11 +358,32 @@ class CMS:
for item in items:
items2 = pdfa(item,p[1])
for item2 in items2:
title = pdfh(item2, p[2])
img = pd(item2, p[3])
desc = pdfh(item2, p[4])
link = pd(item2, p[5])
content = '' if len(p) < 7 else pdfh(item2, p[6])
try:
title = pdfh(item2, p[2])
img = pd(item2, p[3])
desc = pdfh(item2, p[4])
link = pd(item2, p[5])
content = '' if len(p) < 7 else pdfh(item2, p[6])
videos.append({
"vod_id": link,
"vod_name": title,
"vod_pic": img,
"vod_remarks": desc,
"vod_content": content,
"type_id": 1,
"type_name": "首页推荐",
})
except:
pass
else:
items = pdfa(html, p[0])
for item in items:
try:
title = pdfh(item, p[1])
img = pd(item, p[2])
desc = pdfh(item, p[3])
link = pd(item, p[4])
content = '' if len(p) < 6 else pdfh(item, p[5])
videos.append({
"vod_id": link,
"vod_name": title,
......@@ -370,23 +393,8 @@ class CMS:
"type_id": 1,
"type_name": "首页推荐",
})
else:
items = pdfa(html, p[0])
for item in items:
title = pdfh(item, p[1])
img = pd(item, p[2])
desc = pdfh(item, p[3])
link = pd(item, p[4])
content = '' if len(p) < 6 else pdfh(item, p[5])
videos.append({
"vod_id": link,
"vod_name": title,
"vod_pic": img,
"vod_remarks": desc,
"vod_content": content,
"type_id": 1,
"type_name": "首页推荐",
})
except:
pass
result['list'] = videos
result['code'] = 1
result['msg'] = '数据列表'
......@@ -421,9 +429,6 @@ class CMS:
url = self.url.replace('fyclass',fyclass).replace('fypage',pg)
if fypage == 1 and self.test('[\[\]]',url):
url = url.split('[')[1].split(']')[0]
r = requests.get(url, headers=self.headers,timeout=self.timeout)
r.encoding = self.encoding
print(r.url)
p = self.一级.split(';') # 解析
if len(p) < 5:
return self.blank()
......@@ -435,23 +440,35 @@ class CMS:
# print(pdfh(r.text,'body a.module-poster-item.module-item:eq(1)&&Text'))
# print(pdfh(r.text,'body a.module-poster-item.module-item:eq(0)'))
# print(pdfh(r.text,'body a.module-poster-item.module-item:first'))
items = pdfa(r.text, p[0])
videos = []
items = []
try:
r = requests.get(url, headers=self.headers, timeout=self.timeout)
r.encoding = self.encoding
print(r.url)
html = r.text
items = pdfa(html, p[0])
except:
pass
for item in items:
# print(item)
title = pdfh(item, p[1])
img = pd(item, p[2])
desc = pdfh(item, p[3])
link = pd(item, p[4])
content = '' if len(p) < 6 else pdfh(item, p[5])
# sid = self.regStr(sid, "/video/(\\S+).html")
videos.append({
"vod_id": link,
"vod_name": title,
"vod_pic": img,
"vod_remarks": desc,
"vod_content": content,
})
try:
title = pdfh(item, p[1])
img = pd(item, p[2])
desc = pdfh(item, p[3])
link = pd(item, p[4])
content = '' if len(p) < 6 else pdfh(item, p[5])
# sid = self.regStr(sid, "/video/(\\S+).html")
videos.append({
"vod_id": link,
"vod_name": title,
"vod_pic": img,
"vod_remarks": desc,
"vod_content": content,
})
except:
pass
result['list'] = videos
result['page'] = fypage
result['pagecount'] = 9999
......@@ -469,10 +486,6 @@ class CMS:
url = detailUrl
# print(url)
try:
r = requests.get(url, headers=self.headers,timeout=self.timeout)
r.encoding = self.encoding
html = r.text
# print(html)
p = self.二级 # 解析
if p == '*':
vod = self.blank_vod()
......@@ -493,6 +506,10 @@ class CMS:
pq = jsp.pq
obj = {}
vod_name = ''
r = requests.get(url, headers=self.headers, timeout=self.timeout)
r.encoding = self.encoding
html = r.text
# print(html)
if p.get('title'):
p1 = p['title'].split(';')
vod_name = pdfh(html,p1[0]).replace('\n',' ')
......@@ -557,7 +574,7 @@ class CMS:
vod['vod_play_url'] = vod_play_url
except Exception as e:
logger.info(f'{self.getName()}获取单个详情页出错{e}')
print(vod)
return vod
def detailContent(self, fypage, array):
......@@ -610,22 +627,27 @@ class CMS:
r.encoding = self.encoding
html = r.text
items = pdfa(html, p[0])
# print(items)
videos = []
for item in items:
# print(item)
title = pdfh(item, p[1])
img = pd(item, p[2])
desc = pdfh(item, p[3])
link = pd(item, p[4])
content = '' if len(p) < 6 else pdfh(item, p[5])
# sid = self.regStr(sid, "/video/(\\S+).html")
videos.append({
"vod_id": link,
"vod_name": title,
"vod_pic": img,
"vod_remarks": desc,
"vod_content": content,
})
try:
title = pdfh(item, p[1])
img = pd(item, p[2])
desc = pdfh(item, p[3])
link = pd(item, p[4])
content = '' if len(p) < 6 else pdfh(item, p[5])
# sid = self.regStr(sid, "/video/(\\S+).html")
videos.append({
"vod_id": link,
"vod_name": title,
"vod_pic": img,
"vod_remarks": desc,
"vod_content": content,
})
except:
pass
# print(videos)
except Exception as e:
logger.info(f'搜索{self.getName()}发生错误:{e}')
result = {
......
......@@ -4,11 +4,12 @@ var rule = {
// homeUrl:'/',
url:'/vodtype/fyclass-fypage.html',
headers:{
'User-Agent':'MOBILE_UA'
'User-Agent':'MOBILE_UA',
"Cookie": "searchneed=ok"
},
searchUrl:'/search/**-fypage.html',
searchable:1,
quickSearch:1,
searchUrl:'/vodsearch/**----------fypage---.html',
searchable:0,
quickSearch:0,
// class_name:'电影&网剧&剧集&动漫&综艺&记录',
// class_url:'20&1&2&3&4&23',
class_parse:'.stui-header__menu li:gt(0):lt(5);a&&Text;a&&href;/(\\d+).html',
......
......@@ -4,8 +4,8 @@ var rule = {
// homeUrl:'/',
url:'/vodshow/fyclass--------fypage---.html',
searchUrl:'/vodsearch/**----------fypage---.html',
searchable:0,
quickSearch:0,
searchable:1,
quickSearch:1,
headers:{//网站的请求头,完整支持所有的,常带ua和cookies
'User-Agent':'MOBILE_UA',
"Cookie": "searchneed=ok"
......
......@@ -84,6 +84,7 @@ var rule = {
searchUrl:'',//搜索链接 可以是完整路径或者相对路径,用于分类获取和推荐获取 **代表搜索词 fypage代表页数
searchable:0,//是否启用全局搜索,
quickSearch:0,//是否启用快速搜索,
filterable:0,//是否启用筛选,
// 注意,由于猫有配置缓存,搜索配置没法热加载,修改了js不需要重启服务器
// 但是需要tv_box进设置里换源使配置重新装载
headers:{//网站的请求头,完整支持所有的,常带ua和cookies
......
......@@ -10,7 +10,7 @@
"api":"{{ host }}/vod?rule={{ rule.name }}",
"searchable": {{ rule.searchable }},
"quickSearch": {{ rule.quickSearch }},
"filterable": 1
"filterable": {{ rule.filterable }}
}{% else %}
{
"key":"dr_{{ rule.name }}",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册