提交 fea19c75 编写于 作者: H hjdhnx

增加了对源是否启用搜索的独立配置

上级 8e47c7b3
......@@ -5,6 +5,7 @@
# Date : 2022/8/25
import random
import js2py
from flask_sqlalchemy import SQLAlchemy
import config
# import settings
......@@ -34,7 +35,7 @@ db = SQLAlchemy(app)
rule_list = getRuleLists()
logger.info(rule_list)
logger.info(f'http://{getHost(1, 5705)}/index\nhttp://localhost:5705/index')
logger.info(f'局域网: {getHost(1, 5705)}/index\n本地: {getHost(0, 5705)}/index')
from models import *
from gevent.pywsgi import WSGIServer
......@@ -69,9 +70,13 @@ def forbidden(): # put application's code here
@app.route('/index')
def index(): # put application's code here
# logger.info("进入了首页")
manager = getHost(1).split(':')[0] + ':9001'
manager2 = getHost(0).split(':')[0] + ':9001'
return render_template('index.html',getHost=getHost,manager=manager,manager2=manager2,is_linux=is_linux())
sup_port = app.config.get('SUP_PORT',9001)
manager0 = ':'.join(getHost(0).split(':')[0:2]) + f':{sup_port}'
manager1 = ':'.join(getHost(1).split(':')[0:2]) + f':{sup_port}'
manager2 = ':'.join(getHost(2).split(':')[0:2]) + f':{sup_port}'
# print(manager2)
# print(manager2)
return render_template('index.html',getHost=getHost,manager0=manager0,manager1=manager1,manager2=manager2,is_linux=is_linux())
@app.route('/vod')
def vod():
......@@ -155,6 +160,7 @@ def clear():
return jsonify(error.success('成功删除文件:'+cache_path))
def getRules(path='cache'):
t1 = time()
base_path = path+'/' # 当前文件所在目录
# print(base_path)
os.makedirs(base_path,exist_ok=True)
......@@ -162,7 +168,29 @@ def getRules(path='cache'):
file_name = list(filter(lambda x: str(x).endswith('.js') and str(x).find('模板') < 0, file_name))
# print(file_name)
rule_list = [file.replace('.js', '') for file in file_name]
rules = {'list': rule_list, 'count': len(rule_list)}
js_path = [f'{path}/{rule}.js' for rule in rule_list]
with open('js/模板.js', encoding='utf-8') as f:
before = f.read()
rule_codes = []
for js in js_path:
with open(js,encoding='utf-8') as f:
rule_codes.append(js2py.eval_js(before+f.read()))
# print(rule_codes)
# print(type(rule_codes[0]),rule_codes[0])
# print(rule_codes[0].title)
# print(rule_codes[0].searchable)
# print(rule_codes[0].quickSearch)
new_rule_list = []
for i in range(len(rule_list)):
new_rule_list.append({
'name':rule_list[i],
'searchable':rule_codes[i].searchable or 0,
'quickSearch':rule_codes[i].quickSearch or 0
})
# print(new_rule_list)
rules = {'list': new_rule_list, 'count': len(rule_list)}
logger.info(f'自动配置装载耗时:{get_interval(t1)}毫秒')
return rules
def getPics(path='images'):
......
......@@ -39,7 +39,7 @@ class CMS:
# 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(1))
play_url = new_conf.get('PLAY_URL',getHost(2))
if not play_url.startswith('http'):
play_url = 'http://'+play_url
if self.play_parse:
......
......@@ -17,9 +17,11 @@ SQLALCHEMY_DATABASE_URI = DB_URI
SQLALCHEMY_TRACK_MODIFICATIONS = False
SQLALCHEMY_ECHO = False # 打印sql语句
JSON_AS_ASCII = False # jsonify返回的中文正常显示
# PLAY_URL = 'http://localhost:5705' # 匹配远程解析服务器链接
# PLAY_URL = PLAY_URL.rstrip('/')
PLAY_URL = 'http://cms.nokia.press' # 匹配远程解析服务器链接 远程接口主页地址,后面不能有/
PLAY_URL = PLAY_URL.rstrip('/')
PLAY_DISABLE = False # 全局禁用播放解析
LAZYPARSE_MODE = 1 # 播放解析模式(0 本地 1 局域网 2远程 仅在全局禁用为False的时候生效)
WALL_PAPER_ENABLE = True # 启用自定义壁纸
WALL_PAPER = "https://picsum.photos/1280/720/?blur=10" # 自定义壁纸,可注释
SUP_PORT = 9001 # supervisord 服务端口
# {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %}
\ No newline at end of file
......@@ -4,6 +4,8 @@ var rule = {
// homeUrl:'/',
url:'/vodshow/fyclass--------fypage---.html',
searchUrl:'/vodsearch/**----------fypage---.html',
searchable:1,
quickSearch:1,
headers:{//网站的请求头,完整支持所有的,常带ua和cookies
'User-Agent':'MOBILE_UA',
"Cookie": "searchneed=ok"
......
......@@ -4,6 +4,8 @@ var rule = {
// homeUrl:'/',
url:'/vodshow/fyclass--------fypage---.html',
searchUrl:'/vodsearch/**----------fypage---.html',
searchable:0,
quickSearch:0,
headers:{
'User-Agent':'MOBILE_UA',
"Cookie": "showBtn=true;PHPSESSID=58nhbq5r54jivukrk4o27dn7m6"
......
......@@ -4,6 +4,8 @@ var rule = {
// homeUrl:'/',
url:'/t/fyclass/fypage.html',
searchUrl:'/s/**/fypage.html',
searchable:1,
quickSearch:1,
headers:{
'User-Agent':'UC_UA'
},
......
......@@ -2,6 +2,8 @@ var rule = Object.assign(muban.mxpro,{
title:'夜空',
host:'https://www.yekong.cc',
url:'/pianku-fyclass--------fypage---/',
searchUrl:'/search-**----------fypage---/',
class_parse:'.navbar-items li:gt(1):lt(7);a&&Text;a&&href;.*v/(.*?)/',
searchUrl:'/search-**----------fypage---/',
searchable:0,
quickSearch:0,
class_parse:'.navbar-items li:gt(1):lt(7);a&&Text;a&&href;.*v/(.*?)/',
});
\ No newline at end of file
......@@ -7,6 +7,8 @@ var rule = {
'User-Agent':'MOBILE_UA'
},
searchUrl:'/search/**-fypage.html',
searchable:1,
quickSearch:1,
// 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',
......
......@@ -17,6 +17,8 @@ var muban = {
// homeUrl:'/',
url:'/vodshow/fyclass--------fypage---.html',
searchUrl:'/vodsearch/**----------fypage---.html',
searchable:0,//是否启用全局搜索,
quickSearch:0,//是否启用快速搜索,
headers:{//网站的请求头,完整支持所有的,常带ua和cookies
'User-Agent':'MOBILE_UA',
"Cookie": "searchneed=ok"
......
......@@ -4,6 +4,8 @@ var rule = {
// homeUrl:'/',
url:'/vodshow/fyclass--------fypage---.html',
searchUrl:'/vodsearch/**----------fypage---.html',
searchable:0,
quickSearch:0,
headers:{//网站的请求头,完整支持所有的,常带ua和cookies
'User-Agent':'MOBILE_UA',
"Cookie": "searchneed=ok"
......
......@@ -2,6 +2,8 @@ var rule = Object.assign(muban.mxpro,{
title:'看视界',
host:'https://www.1080kan.cc',
url:'/show/fyclass--------fypage---.html',
searchUrl:'/search/**-------------.html',
class_parse:'.navbar-items li:gt(1):lt(6);a&&Text;a&&href;.*/(.*?).html',
searchUrl:'/search/**-------------.html',
searchable:0,
quickSearch:0,
class_parse:'.navbar-items li:gt(1):lt(6);a&&Text;a&&href;.*/(.*?).html',
});
\ No newline at end of file
......@@ -4,6 +4,8 @@ var rule = {
// homeUrl:'/',
url:'/index.php/vod/show/id/fyclass/page/fypage.html',
searchUrl:'/vodsearch/**----------fypage---.html',
searchable:0,
quickSearch:0,
headers:{//网站的请求头,完整支持所有的,常带ua和cookies
'User-Agent':'MOBILE_UA',
"Cookie": "searchneed=ok"
......
var rule = {
title:'蓝莓影视1',
title:'蓝莓影视',
host:'https://lanmeiguojiang.com',
// homeUrl:'/',
url:'/show/fyclass--------fypage---.html',
......@@ -7,6 +7,8 @@ var rule = {
'User-Agent':'MOBILE_UA'
},
searchUrl:'/search/**-fypage.html',
searchable:1,
quickSearch:1,
// class_name:'电影&网剧&剧集&动漫&综艺&记录',
// class_url:'20&1&2&3&4&23',
class_parse:'.navbar-items li:gt(1):lt(8);a&&Text;a&&href;/(\\d+).html',
......
......@@ -5,6 +5,8 @@ var rule = {
url:'/vodshow/fyclass--------fypage---.html',
detailUrl:'https://yanetflix.com/voddetail/fyid.html',//非必填
searchUrl:'/vodsearch/**----------fypage---.html',
searchable:0,
quickSearch:0,
// class_name:'电影&连续剧&综艺&动漫',
// class_url:'dianying&lianxuju&zongyi&dongman',
class_parse:'.navbar-items li:gt(1):lt(6);a&&Text;a&&href;.*/(.*?).html',
......
......@@ -6,6 +6,9 @@
- [X] 3.增加视界的加密库
- [X] 4.增加蓝莓影视免嗅探
- [X] 5.增加免嗅耗时毫秒数统计
- [X] 6.增加自动装载配置
- [X] 7.增加js里单独设置某个源是否可搜索
- [X] 8.增加外网免嗅(自定义config.py里面改)
###### 2022/08/29
- [X] 1.更换js引擎,速度更快性能更好
- [X] 2.新版js支持与python互动,后期可能支持js免嗅(lazy:'js:xxx')
......@@ -60,6 +63,7 @@
[远程服务配置地址](http://cms.nokia.press/config/2)
### 配置相关
直接复制对应的三种地址就行了,不需要生成本地文件(下面教程不要了)
本地地址 clan://localhost/pycms_local.json
推荐把文件放到 /storage/emulated/0/PlutoPlayer/pycms_local.json
并且pluto要自己切换路径为PlutoPlayer
......@@ -78,6 +82,10 @@ var rule = {
url:'/fyclass/fypage.html[/fyclass/]',//网站的分类页面链接
detailUrl:'https://yanetflix.com/voddetail/fyid.html',//非必填,二级详情拼接链接,感觉没啥卵用
searchUrl:'',//搜索链接 可以是完整路径或者相对路径,用于分类获取和推荐获取 **代表搜索词 fypage代表页数
searchable:0,//是否启用全局搜索,
quickSearch:0,//是否启用快速搜索,
// 注意,由于猫有配置缓存,搜索配置没法热加载,修改了js不需要重启服务器
// 但是需要tv_box进设置里换源使配置重新装载
headers:{//网站的请求头,完整支持所有的,常带ua和cookies
'User-Agent':'MOBILE_UA',
"Cookie": "searchneed=ok"
......
{
{% if config.WALL_PAPER_ENABLE %}"wallpaper":"http://{{ host }}/pics",{% endif %}
{% if config.WALL_PAPER_ENABLE %}"wallpaper":"{{ host }}/pics",{% endif %}
"dr_count": {{rules.list|length}},
"mode": {{ mode }},
"sites": [{% for rule in rules.list %}{% if mode == 0 %}
{
"key":"dr_{{ rule }}",
"name":"{{ rule }}(道长)",
"key":"dr_{{ rule.name }}",
"name":"{{ rule.name }}(道长)",
"type":1,
"api":"http://{{ host }}/vod?rule={{ rule }}",
"searchable": 1,
"quickSearch": 1,
"api":"{{ host }}/vod?rule={{ rule.name }}",
"searchable": {{ rule.searchable }},
"quickSearch": {{ rule.quickSearch }},
"filterable": 1
}{% else %}
{
"key":"dr_{{ rule }}",
"name":"{{ rule }}(道长)",
"key":"dr_{{ rule.name }}",
"name":"{{ rule.name }}(道长)",
"type":1,
"api":"http://{{ host }}/vod?rule={{ rule }}",
"searchable": 1,
"quickSearch": 1,
"api":"{{ host }}/vod?rule={{ rule.name }}",
"searchable": {{ rule.searchable }},
"quickSearch": {{ rule.quickSearch }},
"filterable": 1
}{% endif %}{% if loop.last==False %},{% endif %}{% endfor %}],
"parses": [{
......
......@@ -66,32 +66,36 @@ a {
<a href="/raw">缓存文件列表-查看</a>
</div>
<div class="btn">
<a href="http://{{ getHost(0) }}/config/0">本地配置地址</a>
<a href="{{ getHost(0) }}/config/0">本地配置地址</a>
</div>
{% if is_linux %}
<div class="btn">
<a href="http://{{ manager2 }}" target="_blank">本地在线进程管理[linux]</a>
<a href="{{ manager0 }}" target="_blank">本地在线进程管理[linux]</a>
</div>
{% endif %}
<!--<a href="{{ getHost(1) }}">局域网:{{ getHost(1) }}</a>-->
<a class="jyw" href="https://picsum.photos/1280/720/?blur=10">局域网:{{ getHost(1) }}</a>
{% if '192.168' in getHost(1) %}
<div class="btn">
<a href="http://{{ getHost(1) }}/config/1">局域网配置地址</a>
<a href="{{ getHost(1) }}/config/1">局域网配置地址</a>
</div>
{% if is_linux %}
<div class="btn">
<a href="http://{{ manager }}" target="_blank">局域网在线进程管理[linux]</a>
<a href="{{ manager1 }}" target="_blank">局域网在线进程管理[linux]</a>
</div>
{% endif %}
<div class="btn">
<a href="http://{{ getHost(1) }}/pics" target="_blank">局域网随机图片</a>
<a href="{{ getHost(1) }}/pics" target="_blank">局域网随机图片</a>
</div>
{% endif %}
<div class="btn">
<a href="http://{{ getHost(2) }}/config/2">远程配置地址</a>
<a href="{{ getHost(2) }}/config/2">远程配置地址</a>
</div>
{% if is_linux %}
<div class="btn">
<a href="{{ manager2 }}" target="_blank">远程在线进程管理[linux]</a>
</div>
{% endif %}
<div class="btn">
<a href="javascript:void(0);" id="gen_config">生成配置文件</a>
</div>
......
......@@ -18,6 +18,7 @@ headers = {
'user-agent': UA,
}
from time import time
import config as settings
def get_host_ip2(): # 获取局域网ip
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
......@@ -47,13 +48,13 @@ def getHost(mode=0,port=None):
# print(ip)
# mode 为0是本地,1是局域网 2是线上
if mode == 0:
host = f'localhost:{port}'
host = f'http://localhost:{port}'
elif mode == 1:
REAL_IP = get_host_ip()
ip = REAL_IP
host = f'{ip}:{port}'
host = f'http://{ip}:{port}'
else:
host = 'cms.nokia.press'
host = get_conf(settings).get('PLAY_URL','http://cms.nokia.press')
return host
def get_conf(obj):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册