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

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

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