提交 d22cbde4 编写于 作者: H hjdhnx

优化直播源渲染速度

上级 551333f5
...@@ -404,13 +404,25 @@ def random_pics(): ...@@ -404,13 +404,25 @@ def random_pics():
else: else:
return redirect(config.WALL_PAPER) return redirect(config.WALL_PAPER)
def get_live_url(new_conf,mode):
host = getHost(mode)
live_url = host + '/lives' if new_conf.get('LIVE_MODE',
1) == 0 else 'https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/0830zb.txt'
live_url = base64Encode(live_url)
return live_url
@app.route('/config/<int:mode>') @app.route('/config/<int:mode>')
def config_render(mode): def config_render(mode):
# print(dict(app.config)) # print(dict(app.config))
if mode == 1: if mode == 1:
jyw_ip = getHost(mode) jyw_ip = getHost(mode)
logger.info(jyw_ip) logger.info(jyw_ip)
html = render_template('config.txt',rules=getRules('js'),host=getHost(mode),mode=mode,jxs=getJxs(),base64Encode=base64Encode,config=dict(app.config)) new_conf = dict(app.config)
host = getHost(mode)
jxs = getJxs()
live_url = get_live_url(new_conf,mode)
# html = render_template('config.txt',rules=getRules('js'),host=host,mode=mode,jxs=jxs,base64Encode=base64Encode,config=new_conf)
html = render_template('config.txt',rules=getRules('js'),host=host,mode=mode,jxs=jxs,live_url=live_url,config=new_conf)
response = make_response(html) response = make_response(html)
response.headers['Content-Type'] = 'application/json; charset=utf-8' response.headers['Content-Type'] = 'application/json; charset=utf-8'
return response return response
...@@ -432,10 +444,12 @@ def get_lives(): ...@@ -432,10 +444,12 @@ def get_lives():
def config_gen(): def config_gen():
# 生成文件 # 生成文件
os.makedirs('txt',exist_ok=True) os.makedirs('txt',exist_ok=True)
jxs=getJxs() new_conf = dict(app.config)
set_local = render_template('config.txt',rules=getRules('js'),base64Encode=base64Encode,mode=0,host=getHost(0),jxs=jxs) jxs = getJxs()
set_area = render_template('config.txt',rules=getRules('js'),base64Encode=base64Encode,mode=1,host=getHost(1),jxs=jxs) set_local = render_template('config.txt',rules=getRules('js'),live_url=get_live_url(new_conf,0),mode=0,host=getHost(0),jxs=jxs)
set_online = render_template('config.txt',rules=getRules('js'),base64Encode=base64Encode,mode=1,host=getHost(2),jxs=jxs) print(set_local)
set_area = render_template('config.txt',rules=getRules('js'),live_url=get_live_url(new_conf,1),mode=1,host=getHost(1),jxs=jxs)
set_online = render_template('config.txt',rules=getRules('js'),live_url=get_live_url(new_conf,2),mode=1,host=getHost(2),jxs=jxs)
with open('txt/pycms0.json','w+',encoding='utf-8') as f: with open('txt/pycms0.json','w+',encoding='utf-8') as f:
set_dict = json.loads(set_local) set_dict = json.loads(set_local)
f.write(json.dumps(set_dict,ensure_ascii=False,indent=4)) f.write(json.dumps(set_dict,ensure_ascii=False,indent=4))
......
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
}{% if loop.last==False %},{% endif %}{% endfor %} }{% if loop.last==False %},{% endif %}{% endfor %}
], ],
"flags": ["youku", "qq", "iqiyi", "qiyi", "letv", "sohu", "tudou","xigua","cntv","1905", "pptv", "mgtv", "wasu", "bilibili", "renrenmi"], "flags": ["youku", "qq", "iqiyi", "qiyi", "letv", "sohu", "tudou","xigua","cntv","1905", "pptv", "mgtv", "wasu", "bilibili", "renrenmi"],
"lives":[{"group":"redirect","channels":[{"name":"直播","urls":["proxy://do=live&type=txt&ext={% if config.LIVE_MODE==0 %}{{base64Encode(host+'/lives')}}{% else %}{{ base64Encode('https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/0830zb.txt')}}{% endif %}"]}]}], "lives":[{"group":"redirect","channels":[{"name":"直播","urls":["proxy://do=live&type=txt&ext={{live_url}}"]}]}],
"ijk": [{ "ijk": [{
"group": "软解码", "group": "软解码",
"options": [{ "options": [{
......
...@@ -18,5 +18,6 @@ assert subprocess.call( ...@@ -18,5 +18,6 @@ assert subprocess.call(
下面格式原版tv_box才能用? 下面格式原版tv_box才能用?
"live","urls":["proxy://do=live&type=txt&ext=aHR0cHM6Ly9naXRjb2RlLm5ldC9xcV8yNjg5ODIzMS9UVkJveC8tL3Jhdy9tYWluL2xpdmUvMDgzMHpiLnR4dA=="]}]}], "live","urls":["proxy://do=live&type=txt&ext=aHR0cHM6Ly9naXRjb2RlLm5ldC9xcV8yNjg5ODIzMS9UVkJveC8tL3Jhdy9tYWluL2xpdmUvMDgzMHpiLnR4dA=="]}]}],
"lives":[{"group":"redirect","channels":[{"name":"直播","urls":["proxy://do=live&type=txt&ext={{ base64Encode(host+'/lives') }}"]}]}], "lives":[{"group":"redirect","channels":[{"name":"直播","urls":["proxy://do=live&type=txt&ext={{ base64Encode(host+'/lives') }}"]}]}],
"lives":[{"group":"redirect","channels":[{"name":"直播","urls":["proxy://do=live&type=txt&ext={% if config.LIVE_MODE==0 %}{{base64Encode(host+'/lives')}}{% else %}{{ base64Encode('https://gitcode.net/qq_26898231/TVBox/-/raw/main/live/0830zb.txt')}}{% endif %}"]}]}],
...@@ -579,7 +579,7 @@ ...@@ -579,7 +579,7 @@
{ {
"name": "直播", "name": "直播",
"urls": [ "urls": [
"proxy://do=live&type=txt&ext=aHR0cDovL2xvY2FsaG9zdDo1NzA1L2xpdmVz" "proxy://do=live&type=txt&ext=aHR0cHM6Ly9naXRjb2RlLm5ldC9xcV8yNjg5ODIzMS9UVkJveC8tL3Jhdy9tYWluL2xpdmUvMDgzMHpiLnR4dA=="
] ]
} }
] ]
......
...@@ -579,7 +579,7 @@ ...@@ -579,7 +579,7 @@
{ {
"name": "直播", "name": "直播",
"urls": [ "urls": [
"proxy://do=live&type=txt&ext=aHR0cDovLzE5Mi4xNjguMTAuOTk6NTcwNS9saXZlcw==" "proxy://do=live&type=txt&ext=aHR0cHM6Ly9naXRjb2RlLm5ldC9xcV8yNjg5ODIzMS9UVkJveC8tL3Jhdy9tYWluL2xpdmUvMDgzMHpiLnR4dA=="
] ]
} }
] ]
......
...@@ -579,7 +579,7 @@ ...@@ -579,7 +579,7 @@
{ {
"name": "直播", "name": "直播",
"urls": [ "urls": [
"proxy://do=live&type=txt&ext=aHR0cDovL2Ntcy5ub2tpYS5wcmVzcy9saXZlcw==" "proxy://do=live&type=txt&ext=aHR0cHM6Ly9naXRjb2RlLm5ldC9xcV8yNjg5ODIzMS9UVkJveC8tL3Jhdy9tYWluL2xpdmUvMDgzMHpiLnR4dA=="
] ]
} }
] ]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册