提交 58fd0194 编写于 作者: H hjdhnx

内部聚搜优化

上级 e7dcd71e
......@@ -48,6 +48,7 @@ CATE_EXCLUDE = '首页|留言|APP|下载|资讯|新闻|动态|明星|专题|最
TAB_EXCLUDE = '猜你|喜欢|APP|下载|剧情|简介|排序' # 动态线路名过滤
# {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %}
SEARCH_TIMEOUT = 5000 # 聚搜超时毫秒
SEARCH_LIMIT = 24 # 聚搜限制条数
MULTI_MODE = 0 # 多源模式
XR_MODE = 1 # 仙人模式
JS_PROXY = 'http://localhost:5705/admin/view/=>https://gitcode.net/qq_32394351/dr_py/-/raw/master/js/' # 源代理
......
......@@ -22,7 +22,7 @@ class storage_service(object):
def __init__(self):
conf_list = ['LIVE_URL', 'USE_PY', 'JS_MODE','JS0_DISABLE','JS0_PASSWORD','PLAY_URL', 'PLAY_DISABLE', 'LAZYPARSE_MODE', 'WALL_PAPER_ENABLE',
'WALL_PAPER', 'UNAME', 'PWD', 'LIVE_MODE', 'CATE_EXCLUDE', 'TAB_EXCLUDE','SEARCH_TIMEOUT','MULTI_MODE','XR_MODE','JS_PROXY','ENV','ALI_TOKEN']
'WALL_PAPER', 'UNAME', 'PWD', 'LIVE_MODE', 'CATE_EXCLUDE', 'TAB_EXCLUDE','SEARCH_TIMEOUT','SEARCH_LIMIT','MULTI_MODE','XR_MODE','JS_PROXY','ENV','ALI_TOKEN']
for conf in conf_list:
if not self.hasItem(conf):
print(f'开始初始化{conf}')
......@@ -32,9 +32,9 @@ class storage_service(object):
def getStoreConf(self):
# MAX_CONTENT_LENGTH 最大上传和端口ip一样是顶级配置,无法外部修改的
conf_list = ['LIVE_URL', 'LIVE_MODE','PLAY_URL', 'PID_URL','USE_PY','JS_MODE', 'JS0_DISABLE','JS0_PASSWORD','PLAY_DISABLE', 'LAZYPARSE_MODE', 'WALL_PAPER_ENABLE',
'WALL_PAPER', 'UNAME', 'PWD', 'CATE_EXCLUDE', 'TAB_EXCLUDE','SEARCH_TIMEOUT','MULTI_MODE','XR_MODE','JS_PROXY','ENV','ALI_TOKEN']
'WALL_PAPER', 'UNAME', 'PWD', 'CATE_EXCLUDE', 'TAB_EXCLUDE','SEARCH_TIMEOUT','SEARCH_LIMIT','MULTI_MODE','XR_MODE','JS_PROXY','ENV','ALI_TOKEN']
conf_name_list = ['直播地址', '直播模式','远程地址', '进程管理链接','启用py源', 'js模式','禁用js0','js0密码','禁用免嗅', '免嗅模式', '启用壁纸', '壁纸链接', '管理账号',
'管理密码', '分类排除', '线路排除','聚搜超时','多源模式','仙人模式','源代理','环境变量','阿里tk']
'管理密码', '分类排除', '线路排除','聚搜超时','搜索条数','多源模式','仙人模式','源代理','环境变量','阿里tk']
conf_lists = []
for i in range(len(conf_list)):
conf = conf_list[i]
......
......@@ -3,6 +3,7 @@
# File : vod.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/6
import functools
import json
from flask import Blueprint,abort,request,render_template,render_template_string,jsonify,make_response,redirect,current_app
......@@ -25,7 +26,6 @@ from quickjs import Function,Context
import ujson
vod = Blueprint("vod", __name__)
def search_one_py(rule, wd, before: str = ''):
t1 = time()
if not before:
......@@ -153,6 +153,53 @@ def disable_exit_for_threadpool_executor():
import concurrent.futures
atexit.unregister(concurrent.futures.thread._python_exit)
def sort_lsg_rules(sites:list):
"""
查询结果按order和write_date 联合排序
:param sites:
:return:
"""
def comp(x, y):
if x['order'] > y['order']:
return 1
elif x['order'] < y['order']:
return - 1
else:
if x['write_date'] < y['write_date']:
return 1
elif x['write_date'] > y['write_date']:
return -1
else:
return 0
sites.sort(key=functools.cmp_to_key(comp), reverse=False)
return sites
def sort_lsg_rules2(sites:list,lsg_rule_names:list):
"""
查询结果按order和write_date 联合排序
:param sites:
:return:
"""
def comp(x, y):
try:
x1 = lsg_rule_names.index(x)
except:
x1 = 999
try:
y1 = lsg_rule_names.index(y)
except:
y1 = 999
if x1 >= y1:
return 1
elif x1 < y1:
return - 1
sites.sort(key=functools.cmp_to_key(comp), reverse=False)
return sites
def multi_search(wd):
lsg = storage_service()
env = get_env()
......@@ -173,7 +220,31 @@ def multi_search(wd):
logger.info(f'开始聚搜{wd},共计{len(search_sites)}个规则,聚搜超时{timeout}秒')
logger.info(f'不支持聚搜的规则,共计{len(nosearch_sites)}个规则:{",".join(nosearch_sites)}')
search_sites = merged_hide(search_sites)
# print(len(search_sites))
# search_sites = []
lsg_rules = rules_service()
lsg_rule_list = lsg_rules.query_all()
# print(len(lsg_rule_list))
# rule_names = list(map(lambda x: x['name'], rule_list))
lsg_rule_list = list(filter(lambda x:x['name'] in search_sites,lsg_rule_list))
lsg_rule_names = list(map(lambda x: x['name'], lsg_rule_list))
search_sites = sort_lsg_rules2(search_sites,lsg_rule_names)
# print(len(lsg_rule_list))
# lsg_rule_list = sort_lsg_rules(lsg_rule_list)
# print(len(lsg_rule_list))
# print(search_sites)
SEARCH_LIMIT = lsg.getItem('SEARCH_LIMIT', 24)
try:
SEARCH_LIMIT = int(SEARCH_LIMIT)
except:
SEARCH_LIMIT = 0
if SEARCH_LIMIT < 1:
SEARCH_LIMIT = 0
search_sites = search_sites[:SEARCH_LIMIT]
msearch_msg = f'搜索限制条数:{SEARCH_LIMIT}/{len(search_sites)} {search_sites}'
logger.info(msearch_msg)
print(msearch_msg)
# search_sites = []
res = []
if len(search_sites) > 0:
......
3.9.33beta14
\ No newline at end of file
3.9.34beta1
\ No newline at end of file
......@@ -49,6 +49,8 @@
[dockerfile教程](https://blog.csdn.net/qq_46158060/article/details/125718218)
[获取本地设备信息](https://blog.csdn.net/cui_yonghua/article/details/125508991)
[获取本地设备信息](https://m.jb51.net/article/140716.htm)
###### 2023/01/03
- [X] 3.9.34 聚搜功能优化,设置中心增加搜索条数设置,默认24条。关联未来功能里的排序顺序进行搜索取数
###### 2022/12/26
- [X] 3.9.33beta4 修复腾云驾雾搜索
- [X] 3.9.33beta5 修复腾云驾雾综艺,电影的二级
......
......@@ -21,8 +21,9 @@ body{
height: 40px;
}
.mz{
text-align: left;
text-align: center;
display: inline-block;
width: 40%;
}
.mz a{
border-radius: 50px;
......@@ -38,7 +39,7 @@ body{
.sj{
text-align: center;
width: 48%;
width: 18%;
display: inline-block;
}
.sj a{
......@@ -52,10 +53,28 @@ body{
background-color: #17af30;
}
.ss{
width: 18%;
text-align: center;
display: inline-block;
}
.ss a{
border-radius: 50px;
border-style: solid;
color: #FFFFFF;
text-align: center;
padding: 1px 3px 1px 3px;
border-style: solid;
border-color: #1379cb;
text-decoration: none;
background-color: #1379cb;
}
.sc{
text-align: right;
width: 15%;
padding-right: 5%;
text-align: center;
width: 18%;
/*padding-right: 5%;*/
display: inline-block;
}
.sc a{
......
......@@ -26,6 +26,11 @@
location.href = '/vod?{% if js0_password %}pwd={{js0_password}}&{% endif %}rule='+rule;
});
$(".view_search").click(function(){
let rule = this.getAttribute('value').trim();
location.href = '/vod?{% if js0_password %}pwd={{js0_password}}&{% endif %}rule='+rule+'&wd=斗罗大陆';
});
$("#checkUpdate").click(function(){
console.log('开始检查升级...');
$.get("/admin/get_ver",function(data,status){
......@@ -239,7 +244,8 @@ function getFileSize(fileObj) {
{% for rule in rules.list %}
<div class="red">
<div class="mz"><a class="view" href="javascript:void(0);">{{ rule.name }}</a></div>
<div class="sj"><a class="view_home" href="javascript:void(0);" value="{{ rule.name }}">主页数据预览</a></div>
<div class="sj"><a class="view_home" href="javascript:void(0);" value="{{ rule.name }}">主页</a></div>
<div class="ss"><a class="view_search" href="javascript:void(0);" value="{{ rule.name }}">搜索</a></div>
<div class="sc"><a class="clear" href="javascript:void(0);" value="{{ rule.name }}">删除</a></div>
</div>
{% endfor %}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册