Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
mine929
dr_py
提交
e16b6518
dr_py
项目概览
mine929
/
dr_py
与 Fork 源项目一致
Fork自
晚风拂柳颜 / dr_py
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
dr_py
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e16b6518
编写于
9月 08, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加了自定义配置并升级版本
上级
72a2acd3
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
71 addition
and
5 deletion
+71
-5
base/custom.conf
base/custom.conf
+18
-0
controllers/home.py
controllers/home.py
+18
-2
js/version.txt
js/version.txt
+1
-1
readme.md
readme.md
+2
-0
utils/encode.py
utils/encode.py
+6
-1
utils/files.py
utils/files.py
+26
-1
未找到文件。
base/custom.conf
0 → 100644
浏览文件 @
e16b6518
# 这是一个自定义的额外用户爬虫配置
# 自动附加到config/mode 对应的在线源里
# 可以使用Python的 # 单行注释
{
"sites"
:[
{
"key"
:
"t4"
,
"name"
:
"T4"
,
"type"
:
4
,
"api"
:
"https://t4.secan.icu/vod?sites=all&ali_token=xxxxxxxxx&timeout=10"
,
# "api":"http://[ip]:[port]/vod?sites=all&ali_token=3xx9cfxxxx509bxx&timeout=5",
"searchable"
:
1
,
"quickSearch"
:
1
,
"filterable"
:
0
}
]
}
\ No newline at end of file
controllers/home.py
浏览文件 @
e16b6518
...
...
@@ -10,7 +10,7 @@ from flask import Blueprint,abort,render_template,url_for,redirect,make_response
from
controllers.service
import
storage_service
from
controllers.classes
import
getClasses
,
getClassInfo
from
utils.web
import
getParmas
from
utils.files
import
getPics
from
utils.files
import
getPics
,
custom_merge
from
js.rules
import
getRules
from
base.R
import
R
from
utils.system
import
cfg
,
getHost
,
is_linux
...
...
@@ -18,6 +18,7 @@ from utils import parser
from
utils.log
import
logger
from
utils.files
import
getAlist
,
get_live_url
from
utils.update
import
getLocalVer
from
utils.encode
import
parseText
from
js.rules
import
getJxs
import
random
...
...
@@ -125,6 +126,17 @@ def get_liveslib():
@
home
.
route
(
'/config/<int:mode>'
)
def
config_render
(
mode
):
# print(dict(app.config))
customFile
=
'base/custom.conf'
if
not
os
.
path
.
exists
(
customFile
):
with
open
(
customFile
,
'w+'
,
encoding
=
'utf-8'
)
as
f
:
f
.
write
(
'{}'
)
customConfig
=
False
try
:
with
open
(
customFile
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
customConfig
=
parseText
(
f
.
read
())
except
Exception
as
e
:
logger
.
info
(
f
'用户自定义配置加载失败:
{
e
}
'
)
if
mode
==
1
:
jyw_ip
=
getHost
(
mode
)
logger
.
info
(
jyw_ip
)
...
...
@@ -136,7 +148,11 @@ def config_render(mode):
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
,
alists
=
alists
,
alists_str
=
alists_str
,
live_url
=
live_url
,
config
=
new_conf
)
response
=
make_response
(
html
)
merged_config
=
custom_merge
(
parseText
(
html
),
customConfig
)
# print(merged_config)
# response = make_response(html)
response
=
make_response
(
json
.
dumps
(
merged_config
,
ensure_ascii
=
False
,
indent
=
1
))
# response = make_response(str(merged_config))
response
.
headers
[
'Content-Type'
]
=
'application/json; charset=utf-8'
return
response
...
...
js/version.txt
浏览文件 @
e16b6518
3.2.8
\ No newline at end of file
3.2.9
\ No newline at end of file
readme.md
浏览文件 @
e16b6518
...
...
@@ -46,6 +46,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
)
###### 2022/09/08
-
[X] 1.升级到3.2.9,支持自动合并自定义用户配置(内置t4测试源)
###### 2022/09/07
-
[X] 1.优化后台管理登录界面,升级更新脚本
-
[X] 2.增加了镜像合并脚本(三合一直接拉 hjdhnx/drpy 即可)
...
...
utils/encode.py
浏览文件 @
e16b6518
...
...
@@ -17,6 +17,7 @@ import requests.utils
from
time
import
sleep
import
os
from
utils.web
import
UC_UA
,
PC_UA
from
ast
import
literal_eval
def
getPreJs
():
base_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
# 上级目
...
...
@@ -222,4 +223,8 @@ def buildUrl(url,obj=None):
url
+=
'&'
url
=
(
url
+
prs
).
replace
(
'"'
,
''
).
replace
(
"'"
,
''
)
# print(url)
return
url
\ No newline at end of file
return
url
def
parseText
(
text
:
str
):
text
=
text
.
replace
(
'false'
,
'False'
).
replace
(
'true'
,
'True'
).
replace
(
'null'
,
'None'
)
return
literal_eval
(
text
)
\ No newline at end of file
utils/files.py
浏览文件 @
e16b6518
...
...
@@ -51,4 +51,29 @@ def getAlist():
})
alists
.
append
(
obj
)
print
(
f
'共计
{
len
(
alists
)
}
条alist记录'
)
return
alists
\ No newline at end of file
return
alists
def
custom_merge
(
original
:
dict
,
custom
:
dict
):
"""
合并用户配置
:param original: 原始配置
:param custom: 自定义配置
:return:
"""
if
not
custom
or
len
(
custom
.
keys
())
<
1
:
return
original
new_keys
=
custom
.
keys
()
updateObj
=
{}
extend_obj
=
{}
for
key
in
[
'wallpaper'
,
'spider'
,
'homepage'
]:
if
key
in
new_keys
:
updateObj
[
key
]
=
custom
[
key
]
for
key
in
[
'drives'
,
'sites'
,
'flags'
,
'lives'
,
'ads'
]:
if
key
in
new_keys
:
extend_obj
[
key
]
=
custom
[
key
]
original
.
update
(
updateObj
)
for
key
in
extend_obj
.
keys
():
original
[
key
].
extend
(
extend_obj
[
key
])
return
original
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录