Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxaah
dr_py
提交
0e3dee15
dr_py
项目概览
sxaah
/
dr_py
与 Fork 源项目一致
Fork自
晚风拂柳颜 / dr_py
通知
1
Star
1
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,发现更多精彩内容 >>
提交
0e3dee15
编写于
9月 25, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
实现了js自建解析
上级
6d4929c3
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
197 addition
and
18 deletion
+197
-18
app.py
app.py
+1
-0
controllers/__init__.py
controllers/__init__.py
+2
-1
controllers/home.py
controllers/home.py
+13
-8
controllers/parse.py
controllers/parse.py
+76
-0
jiexi/无名.js
jiexi/无名.js
+13
-0
js/rules.py
js/rules.py
+10
-5
js/version.txt
js/version.txt
+1
-1
js/解析.conf
js/解析.conf
+2
-1
readme.md
readme.md
+3
-0
utils/pyctx.py
utils/pyctx.py
+74
-0
utils/update.py
utils/update.py
+2
-2
未找到文件。
app.py
浏览文件 @
0e3dee15
...
...
@@ -22,6 +22,7 @@ def create_flask_app():
app
.
register_blueprint
(
vod
.
vod
,
url_prefix
=
''
)
app
.
register_blueprint
(
cls
.
cls
,
url_prefix
=
'/cls'
)
app
.
register_blueprint
(
layui
.
layui
,
url_prefix
=
'/layui'
)
app
.
register_blueprint
(
parse
.
parse
,
url_prefix
=
'/parse'
)
app
.
logger
.
name
=
"drLogger"
# lsg = service.storage_service()
logger
.
info
(
f
"默认解析地址:
{
app
.
config
.
get
(
'PLAY_URL'
)
}
"
)
...
...
controllers/__init__.py
浏览文件 @
0e3dee15
...
...
@@ -11,4 +11,5 @@ from . import vod
from
.
import
cms
from
.
import
cls
from
.
import
classes
from
.
import
layui
\ No newline at end of file
from
.
import
layui
from
.
import
parse
\ No newline at end of file
controllers/home.py
浏览文件 @
0e3dee15
...
...
@@ -210,7 +210,7 @@ def config_render(mode):
# print(ali_token)
customConfig
=
getCustonDict
(
host
,
ali_token
)
# print(customConfig)
jxs
=
getJxs
()
jxs
=
getJxs
(
host
=
host
)
lsg
=
storage_service
()
use_py
=
lsg
.
getItem
(
'USE_PY'
)
pys
=
getPys
()
if
use_py
else
[]
...
...
@@ -242,7 +242,6 @@ def config_gen():
store_conf_dict
=
lsg
.
getStoreConfDict
()
new_conf
.
update
(
store_conf_dict
)
try
:
jxs
=
getJxs
()
lsg
=
storage_service
()
use_py
=
lsg
.
getItem
(
'USE_PY'
)
pys
=
getPys
()
if
use_py
else
False
...
...
@@ -250,26 +249,32 @@ def config_gen():
alists_str
=
json
.
dumps
(
alists
,
ensure_ascii
=
False
)
rules
=
getRules
(
'js'
)
rules
=
get_multi_rules
(
rules
)
set_local
=
render_template
(
'config.txt'
,
pys
=
pys
,
rules
=
rules
,
alists
=
alists
,
alists_str
=
alists_str
,
live_url
=
get_live_url
(
new_conf
,
0
),
mode
=
0
,
host
=
getHost
(
0
),
jxs
=
jxs
)
host0
=
getHost
(
0
)
jxs
=
getJxs
(
host
=
host0
)
set_local
=
render_template
(
'config.txt'
,
pys
=
pys
,
rules
=
rules
,
alists
=
alists
,
alists_str
=
alists_str
,
live_url
=
get_live_url
(
new_conf
,
0
),
mode
=
0
,
host
=
host0
,
jxs
=
jxs
)
# print(set_local)
set_area
=
render_template
(
'config.txt'
,
pys
=
pys
,
rules
=
rules
,
alists
=
alists
,
alists_str
=
alists_str
,
live_url
=
get_live_url
(
new_conf
,
1
),
mode
=
1
,
host
=
getHost
(
1
),
jxs
=
jxs
)
set_online
=
render_template
(
'config.txt'
,
pys
=
pys
,
rules
=
rules
,
alists
=
alists
,
alists_str
=
alists_str
,
live_url
=
get_live_url
(
new_conf
,
2
),
mode
=
1
,
host
=
getHost
(
2
),
jxs
=
jxs
)
host1
=
getHost
(
1
)
jxs
=
getJxs
(
host
=
host1
)
set_area
=
render_template
(
'config.txt'
,
pys
=
pys
,
rules
=
rules
,
alists
=
alists
,
alists_str
=
alists_str
,
live_url
=
get_live_url
(
new_conf
,
1
),
mode
=
1
,
host
=
host1
,
jxs
=
jxs
)
host2
=
getHost
(
2
)
jxs
=
getJxs
(
host
=
host2
)
set_online
=
render_template
(
'config.txt'
,
pys
=
pys
,
rules
=
rules
,
alists
=
alists
,
alists_str
=
alists_str
,
live_url
=
get_live_url
(
new_conf
,
2
),
mode
=
1
,
host
=
host2
,
jxs
=
jxs
)
ali_token
=
new_conf
.
ALI_TOKEN
with
open
(
'txt/pycms0.json'
,
'w+'
,
encoding
=
'utf-8'
)
as
f
:
customConfig
=
getCustonDict
(
getHost
(
0
)
,
ali_token
)
customConfig
=
getCustonDict
(
host0
,
ali_token
)
set_dict
=
custom_merge
(
parseText
(
set_local
),
customConfig
)
merged_hide
(
set_dict
)
# set_dict = json.loads(set_local)
f
.
write
(
json
.
dumps
(
set_dict
,
ensure_ascii
=
False
,
indent
=
4
))
with
open
(
'txt/pycms1.json'
,
'w+'
,
encoding
=
'utf-8'
)
as
f
:
customConfig
=
getCustonDict
(
getHost
(
1
)
,
ali_token
)
customConfig
=
getCustonDict
(
host1
,
ali_token
)
set_dict
=
custom_merge
(
parseText
(
set_area
),
customConfig
)
merged_hide
(
set_dict
)
# set_dict = json.loads(set_area)
f
.
write
(
json
.
dumps
(
set_dict
,
ensure_ascii
=
False
,
indent
=
4
))
with
open
(
'txt/pycms2.json'
,
'w+'
,
encoding
=
'utf-8'
)
as
f
:
customConfig
=
getCustonDict
(
getHost
(
2
)
,
ali_token
)
customConfig
=
getCustonDict
(
host2
,
ali_token
)
set_dict
=
custom_merge
(
parseText
(
set_online
),
customConfig
)
merged_hide
(
set_dict
)
# set_dict = json.loads(set_online)
...
...
controllers/parse.py
0 → 100644
浏览文件 @
0e3dee15
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : parse.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/24
from
flask
import
Blueprint
,
jsonify
from
utils.web
import
getParmas
,
get_interval
import
os
from
utils.log
import
logger
from
utils.pyctx
import
py_ctx
,
getPreJs
,
runJScode
,
JsObjectWrapper
,
PyJsString
,
parseText
,
jsoup
,
time
parse
=
Blueprint
(
"parse"
,
__name__
)
class
R
(
object
):
@
classmethod
def
ok
(
self
,
msg
=
'操作成功'
,
url
=
None
,
extra
=
None
):
if
extra
is
None
:
extra
=
{}
result
=
{
"code"
:
200
,
"msg"
:
msg
,
"url"
:
url
}
result
.
update
(
extra
)
return
jsonify
(
result
)
@
classmethod
def
error
(
self
,
msg
=
"系统异常"
,
code
=
404
,
extra
=
None
):
if
extra
is
None
:
extra
=
{}
result
=
{
"code"
:
code
,
"msg"
:
msg
}
result
.
update
(
extra
)
return
jsonify
(
result
)
@
classmethod
def
success
(
self
,
msg
=
'操作成功'
,
url
=
None
,
extra
=
None
):
return
self
.
ok
(
msg
,
url
,
extra
)
@
classmethod
def
failed
(
self
,
msg
=
"系统异常"
,
code
=
404
,
extra
=
None
):
return
self
.
error
(
msg
,
code
,
extra
)
@
parse
.
route
(
'/api/<path:filename>'
)
def
parse_home
(
filename
):
url
=
getParmas
(
'url'
)
# http://localhost:5705/parse/api/%E6%97%A0%E5%90%8D.js?url=https://www.iqiyi.com/v_ik3832z0go.html
if
not
url
or
not
url
.
startswith
(
'http'
):
return
R
.
failed
(
f
'url必填!
{
url
}
,且必须是http开头'
)
base_path
=
'jiexi'
os
.
makedirs
(
base_path
,
exist_ok
=
True
)
file_path
=
os
.
path
.
join
(
base_path
,
filename
)
if
not
os
.
path
.
exists
(
file_path
):
return
R
.
failed
(
f
'
{
file_path
}
文件不存在'
)
logger
.
info
(
f
'开始尝试通过
{
filename
}
解析:
{
url
}
'
)
jsp
=
jsoup
(
url
)
py_ctx
.
update
({
'vipUrl'
:
url
,
'fetch_params'
:
{
'headers'
:
{
'Referer'
:
url
},
'timeout'
:
10
,
'encoding'
:
'utf-8'
},
'jsp'
:
jsp
})
ctx
=
py_ctx
with
open
(
file_path
,
encoding
=
'utf-8'
)
as
f
:
code
=
f
.
read
()
jscode
=
getPreJs
()
+
code
.
strip
().
replace
(
'js:'
,
''
,
1
)
# print(jscode)
t1
=
time
()
try
:
loader
,
_
=
runJScode
(
jscode
,
ctx
=
ctx
)
realUrl
=
loader
.
eval
(
'realUrl'
)
if
not
realUrl
:
return
R
.
failed
(
f
'解析失败:
{
realUrl
}
'
)
if
isinstance
(
realUrl
,
PyJsString
):
realUrl
=
parseText
(
str
(
realUrl
))
return
R
.
success
(
f
'
{
filename
}
解析成功'
,
realUrl
,{
'time'
:
f
'
{
get_interval
(
t1
)
}
毫秒'
})
except
Exception
as
e
:
msg
=
f
'
{
filename
}
解析出错:
{
e
}
'
logger
.
info
(
msg
)
return
R
.
failed
(
msg
,
extra
=
{
'time'
:
f
'
{
get_interval
(
t1
)
}
毫秒'
})
\ No newline at end of file
jiexi/无名.js
0 → 100644
浏览文件 @
0e3dee15
let
jxUrl
=
'
http://api.ckflv.cn/?url=
'
;
fetch_params
.
headers
.
Referer
=
jxUrl
;
try
{
// realUrl = null;
let
html
=
request
(
jxUrl
+
vipUrl
);
log
(
html
);
realUrl
=
jsp
.
pjfh
(
html
,
'
$..url
'
);
log
(
'
解析到真实播放地址:
'
+
realUrl
);
}
catch
(
e
)
{
log
(
'
解析发生错误:
'
+
e
.
message
);
realUrl
=
vipUrl
;
}
\ No newline at end of file
js/rules.py
浏览文件 @
0e3dee15
...
...
@@ -10,6 +10,7 @@ import js2py
from
utils.log
import
logger
# from utils.web import get_interval,UA
from
utils.ua
import
UA
,
get_interval
from
flask
import
render_template_string
def
getRuleLists
():
base_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
# 当前文件所在目录
...
...
@@ -86,8 +87,12 @@ def getRules(path='cache'):
logger
.
info
(
f
'自动配置装载耗时:
{
get_interval
(
t1
)
}
毫秒'
)
return
rules
def
jxTxt2Json
(
text
:
str
):
data
=
text
.
strip
().
split
(
'
\n
'
)
def
jxTxt2Json
(
text
:
str
,
host
:
str
):
try
:
data
=
render_template_string
(
text
,
host
=
host
).
strip
().
split
(
'
\n
'
)
except
Exception
as
e
:
logger
.
info
(
f
'jxTxt2Json发生错误:
{
e
}
'
)
data
=
[]
jxs
=
[]
for
i
in
data
:
i
=
i
.
strip
()
...
...
@@ -104,7 +109,7 @@ def jxTxt2Json(text:str):
logger
.
info
(
f
'解析行有错误:
{
e
}
'
)
return
jxs
def
getJxs
(
path
=
'js'
):
def
getJxs
(
path
=
'js'
,
host
=
None
):
custom_jx
=
'base/解析.conf'
if
not
os
.
path
.
exists
(
custom_jx
):
with
open
(
custom_jx
,
'w+'
,
encoding
=
'utf-8'
)
as
f1
:
...
...
@@ -118,10 +123,10 @@ def getJxs(path='js'):
with
open
(
f
'
{
path
}
/解析.conf'
,
encoding
=
'utf-8'
)
as
f
:
text
=
f
.
read
()
jxs
=
jxTxt2Json
(
text
)
jxs
=
jxTxt2Json
(
text
,
host
)
with
open
(
custom_jx
,
encoding
=
'utf-8'
)
as
f2
:
text
=
f2
.
read
()
jxs2
=
jxTxt2Json
(
text
)
jxs2
=
jxTxt2Json
(
text
,
host
)
jxs
.
extend
(
jxs2
)
print
(
f
'共计
{
len
(
jxs
)
}
条解析'
)
return
jxs
...
...
js/version.txt
浏览文件 @
0e3dee15
3.7.9
\ No newline at end of file
3.7.10
\ No newline at end of file
js/解析.conf
浏览文件 @
0e3dee15
...
...
@@ -8,7 +8,8 @@
# 快看,http://api.8a5.cn/parse/kuaikan/de.php?url=,1
# 钢铁侠,https://json.freejx.in/?url=,1
# 绿叶,https://hc.izny.cn/json.php?url=,1
无名
1
,
http
://
api
.
ckflv
.
cn
/?
url
=,
1
# 无名1,http://api.ckflv.cn/?url=,1
无名
1
,{{
host
}}/
parse
/
api
/无名.
js
?
url
=,
1
BT5V
,
https
://
rx
.
bt5v
.
com
/
json
/
jsonindex
.
php
/?
url
=,
1
# 查询,https://chaxun.truechat365.com/?url= # 这个解析真的牛逼,只能电脑看
# llq,https://hc.izny.cn/json.php?url=,1
...
...
readme.md
浏览文件 @
0e3dee15
...
...
@@ -46,6 +46,9 @@
[
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/25
-
[X] 1.v3.7.10 增加了自定义解析功能,解析.conf支持变量{{host}}
-
[X] 2.新增了 jiexi/无名.js作为示例,接受vipUrl返回realUrl
###### 2022/09/23
-
[X] 1.v3.7.5 优化了首图2模板的搜索定位以及几个相关的源
-
[X] 2.二级渲染功能拆分,js单独调用
...
...
utils/pyctx.py
0 → 100644
浏览文件 @
0e3dee15
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File : pyctx.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/9/24
import
json
import
requests
from
utils.web
import
*
from
utils.log
import
logger
from
utils.encode
import
base64Encode
,
baseDecode
,
fetch
,
post
,
request
,
getCryptoJS
,
getPreJs
,
buildUrl
,
getHome
,
parseText
from
utils.encode
import
setDetail
,
join
,
urljoin2
,
parseText
,
requireCache
from
utils.encode
import
md5
as
mmd5
from
utils.parser
import
runPy
,
runJScode
,
JsObjectWrapper
,
PyJsObject
,
PyJsString
from
urllib.parse
import
quote
from
utils.htmlParser
import
jsoup
from
controllers.service
import
storage_service
def
setItem
(
key
,
value
):
lsg
=
storage_service
()
if
isinstance
(
key
,
PyJsString
):
key
=
parseText
(
str
(
key
))
if
isinstance
(
value
,
PyJsString
):
value
=
parseText
(
str
(
value
))
return
lsg
.
setItem
(
key
,
value
)
def
getItem
(
key
,
value
=
''
):
lsg
=
storage_service
()
if
isinstance
(
key
,
PyJsString
):
key
=
parseText
(
str
(
key
))
if
isinstance
(
value
,
PyJsString
):
value
=
parseText
(
str
(
value
))
return
lsg
.
getItem
(
key
,
value
)
def
clearItem
(
key
):
lsg
=
storage_service
()
if
isinstance
(
key
,
PyJsString
):
key
=
parseText
(
str
(
key
))
return
lsg
.
clearItem
(
key
)
def
encodeUrl
(
url
):
# return base64Encode(quote(url))
# return base64Encode(url)
# print(type(url))
if
isinstance
(
url
,
PyJsString
):
# obj = obj.to_dict()
url
=
parseText
(
str
(
url
))
return
quote
(
url
)
def
stringify
(
obj
):
if
isinstance
(
obj
,
PyJsObject
):
# obj = obj.to_dict()
obj
=
parseText
(
str
(
obj
))
return
json
.
dumps
(
obj
,
separators
=
(
','
,
':'
),
ensure_ascii
=
False
)
def
requireObj
(
url
):
if
isinstance
(
url
,
PyJsString
):
url
=
parseText
(
str
(
url
))
return
requireCache
(
url
)
def
md5
(
text
):
if
isinstance
(
text
,
PyJsString
):
text
=
parseText
(
str
(
text
))
return
mmd5
(
text
)
py_ctx
=
{
'requests'
:
requests
,
'print'
:
print
,
'base64Encode'
:
base64Encode
,
'baseDecode'
:
baseDecode
,
'log'
:
logger
.
info
,
'fetch'
:
fetch
,
'post'
:
post
,
'request'
:
request
,
'getCryptoJS'
:
getCryptoJS
,
'buildUrl'
:
buildUrl
,
'getHome'
:
getHome
,
'setDetail'
:
setDetail
,
'join'
:
join
,
'urljoin2'
:
urljoin2
,
'PC_UA'
:
PC_UA
,
'MOBILE_UA'
:
MOBILE_UA
,
'UC_UA'
:
UC_UA
,
'IOS_UA'
:
IOS_UA
,
'setItem'
:
setItem
,
'getItem'
:
getItem
,
'clearItem'
:
clearItem
,
'stringify'
:
stringify
,
'encodeUrl'
:
encodeUrl
,
'requireObj'
:
requireObj
,
'md5'
:
md5
}
\ No newline at end of file
utils/update.py
浏览文件 @
0e3dee15
...
...
@@ -127,8 +127,8 @@ def copy_to_update():
logger
.
info
(
f
'升级失败,找不到目录
{
dr_path
}
'
)
return
False
# 千万不能覆盖super,base
paths
=
[
'js'
,
'models'
,
'controllers'
,
'libs'
,
'static'
,
'templates'
,
'utils'
,
'txt'
]
exclude_files
=
[
'txt/pycms0.json'
,
'txt/pycms1.json'
,
'txt/pycms2.json'
]
paths
=
[
'js'
,
'models'
,
'controllers'
,
'libs'
,
'static'
,
'templates'
,
'utils'
,
'txt'
,
'jiexi'
]
exclude_files
=
[
'txt/pycms0.json'
,
'txt/pycms1.json'
,
'txt/pycms2.json'
,
'base/rules.db'
]
for
path
in
paths
:
force_copy_files
(
os
.
path
.
join
(
dr_path
,
path
),
os
.
path
.
join
(
base_path
,
path
),
exclude_files
)
try
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录