Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
没毛的刷子
dr_py
提交
55b1ec5a
dr_py
项目概览
没毛的刷子
/
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,发现更多精彩内容 >>
提交
55b1ec5a
编写于
8月 29, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
支持js免嗅
上级
7ae407d7
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
94 addition
and
21 deletion
+94
-21
app.py
app.py
+3
-2
classes/cms.py
classes/cms.py
+29
-13
js/干饭影视.js
js/干饭影视.js
+3
-1
js/模板.js
js/模板.js
+12
-0
js/蓝莓影视.js
js/蓝莓影视.js
+1
-1
py/干饭.js
py/干饭.js
+28
-0
utils/parser.py
utils/parser.py
+18
-4
未找到文件。
app.py
浏览文件 @
55b1ec5a
...
@@ -88,13 +88,14 @@ def vod():
...
@@ -88,13 +88,14 @@ def vod():
return
jsonify
(
error
.
failed
(
'爬虫规则加载失败'
))
return
jsonify
(
error
.
failed
(
'爬虫规则加载失败'
))
# rule = ctx.eval('rule')
# rule = ctx.eval('rule')
rule
=
ctx
.
rule
.
to_dict
()
ruleDict
=
ctx
.
rule
.
to_dict
()
ruleDict
[
'id'
]
=
rule
# 把路由请求的id装到字典里,后面播放嗅探才能用
# print(rule)
# print(rule)
# print(type(rule))
# print(type(rule))
logger
.
info
(
f
'js装载耗时:
{
get_interval
(
t2
)
}
毫秒'
)
logger
.
info
(
f
'js装载耗时:
{
get_interval
(
t2
)
}
毫秒'
)
# print(rule)
# print(rule)
cms
=
CMS
(
rule
,
db
,
RuleClass
,
PlayParse
,
app
.
config
)
cms
=
CMS
(
rule
Dict
,
db
,
RuleClass
,
PlayParse
,
app
.
config
)
wd
=
getParmas
(
'wd'
)
wd
=
getParmas
(
'wd'
)
ac
=
getParmas
(
'ac'
)
ac
=
getParmas
(
'ac'
)
quick
=
getParmas
(
'quick'
)
quick
=
getParmas
(
'quick'
)
...
...
classes/cms.py
浏览文件 @
55b1ec5a
...
@@ -12,7 +12,7 @@ from models import *
...
@@ -12,7 +12,7 @@ from models import *
from
utils.config
import
config
from
utils.config
import
config
from
utils.log
import
logger
from
utils.log
import
logger
from
utils.safePython
import
safePython
from
utils.safePython
import
safePython
from
utils.parser
import
runPy
from
utils.parser
import
runPy
,
runJScode
from
utils.htmlParser
import
jsoup
from
utils.htmlParser
import
jsoup
from
urllib.parse
import
urljoin
from
urllib.parse
import
urljoin
from
concurrent.futures
import
ThreadPoolExecutor
# 引入线程池
from
concurrent.futures
import
ThreadPoolExecutor
# 引入线程池
...
@@ -24,6 +24,7 @@ class CMS:
...
@@ -24,6 +24,7 @@ class CMS:
if
new_conf
is
None
:
if
new_conf
is
None
:
new_conf
=
{}
new_conf
=
{}
self
.
title
=
rule
.
get
(
'title'
,
''
)
self
.
title
=
rule
.
get
(
'title'
,
''
)
self
.
id
=
rule
.
get
(
'id'
,
self
.
title
)
self
.
lazy
=
rule
.
get
(
'lazy'
,
False
)
self
.
lazy
=
rule
.
get
(
'lazy'
,
False
)
self
.
play_disable
=
new_conf
.
get
(
'PLAY_DISABLE'
,
False
)
self
.
play_disable
=
new_conf
.
get
(
'PLAY_DISABLE'
,
False
)
self
.
vod
=
redirect
(
url_for
(
'vod'
)).
headers
[
'Location'
]
self
.
vod
=
redirect
(
url_for
(
'vod'
)).
headers
[
'Location'
]
...
@@ -35,7 +36,7 @@ class CMS:
...
@@ -35,7 +36,7 @@ class CMS:
play_url
=
'http://'
+
play_url
play_url
=
'http://'
+
play_url
if
self
.
play_parse
:
if
self
.
play_parse
:
# self.play_url = play_url + self.vod + '?play_url='
# self.play_url = play_url + self.vod + '?play_url='
self
.
play_url
=
f
'
{
play_url
}{
self
.
vod
}
?rule=
{
self
.
title
}
&play_url='
self
.
play_url
=
f
'
{
play_url
}{
self
.
vod
}
?rule=
{
self
.
id
}
&play_url='
# logger.info(f'cms重定向链接:{self.play_url}')
# logger.info(f'cms重定向链接:{self.play_url}')
else
:
else
:
self
.
play_url
=
''
self
.
play_url
=
''
...
@@ -615,17 +616,32 @@ class CMS:
...
@@ -615,17 +616,32 @@ class CMS:
def
playContent
(
self
,
play_url
):
def
playContent
(
self
,
play_url
):
if
self
.
lazy
:
if
self
.
lazy
:
print
(
f
'
{
play_url
}
->开始执行免嗅代码->
{
self
.
lazy
}
'
)
print
(
f
'
{
play_url
}
->开始执行免嗅代码->
{
self
.
lazy
}
'
)
pycode
=
runPy
(
self
.
lazy
)
if
not
str
(
self
.
lazy
).
startswith
(
'js:'
):
if
pycode
:
pycode
=
runPy
(
self
.
lazy
)
# print(pycode)
if
pycode
:
pos
=
pycode
.
find
(
'def lazyParse'
)
# print(pycode)
if
pos
<
0
:
pos
=
pycode
.
find
(
'def lazyParse'
)
return
play_url
if
pos
<
0
:
pyenv
=
safePython
(
self
.
lazy
,
pycode
[
pos
:])
return
play_url
lazy_url
=
pyenv
.
action_task_exec
(
'lazyParse'
,[
play_url
,
self
.
d
])
pyenv
=
safePython
(
self
.
lazy
,
pycode
[
pos
:])
logger
.
info
(
f
'播放免嗅结果:
{
lazy_url
}
'
)
lazy_url
=
pyenv
.
action_task_exec
(
'lazyParse'
,[
play_url
,
self
.
d
])
if
isinstance
(
lazy_url
,
str
)
and
lazy_url
.
startswith
(
'http'
):
logger
.
info
(
f
'播放免嗅结果:
{
lazy_url
}
'
)
play_url
=
lazy_url
if
isinstance
(
lazy_url
,
str
)
and
lazy_url
.
startswith
(
'http'
):
play_url
=
lazy_url
else
:
jscode
=
str
(
self
.
lazy
).
split
(
'js:'
)[
1
]
# jscode = f'var input={play_url};{jscode}'
# print(jscode)
loader
,
_
=
runJScode
(
jscode
,
ctx
=
{
'input'
:
play_url
,
'requests'
:
requests
,
'print'
:
print
,
'd'
:
self
.
d
,
'log'
:
logger
.
info
,
'pdfh'
:
self
.
d
.
jsp
.
pdfh
,
'pdfa'
:
self
.
d
.
jsp
.
pdfa
,
'pd'
:
self
.
d
.
jsp
.
pd
,
})
# print(loader.toString())
play_url
=
loader
.
eval
(
'input'
)
print
(
'play_url:'
,
play_url
)
return
play_url
return
play_url
else
:
else
:
logger
.
info
(
f
'播放重定向到:
{
play_url
}
'
)
logger
.
info
(
f
'播放重定向到:
{
play_url
}
'
)
...
...
js/干饭影视.js
浏览文件 @
55b1ec5a
...
@@ -11,7 +11,9 @@ var rule = {
...
@@ -11,7 +11,9 @@ var rule = {
// class_url:'20&1&2&3&4&23',
// class_url:'20&1&2&3&4&23',
class_parse
:
'
.stui-header__menu li:gt(0):lt(5);a&&Text;a&&href;/(
\\
d+).html
'
,
class_parse
:
'
.stui-header__menu li:gt(0):lt(5);a&&Text;a&&href;/(
\\
d+).html
'
,
play_parse
:
true
,
play_parse
:
true
,
lazy
:
'
干饭
'
,
// lazy:'干饭',
// lazy:'@js:cacheUrl = d.getParse(input);print(cacheUrl);input=cacheUrl',
lazy
:
'
js:cacheUrl = d.getParse(input);print(cacheUrl);input=cacheUrl
'
,
limit
:
5
,
limit
:
5
,
推荐
:
'
ul.stui-vodlist.clearfix;li;a&&title;.lazyload&&data-original;;a&&href
'
,
推荐
:
'
ul.stui-vodlist.clearfix;li;a&&title;.lazyload&&data-original;;a&&href
'
,
double
:
true
,
// 推荐内容是否双层定位
double
:
true
,
// 推荐内容是否双层定位
...
...
js/模板.js
浏览文件 @
55b1ec5a
Object
.
assign
=
function
()
{
var
target
=
arguments
[
0
];
for
(
var
i
=
1
;
i
<
arguments
.
length
;
i
++
)
{
var
source
=
arguments
[
i
];
for
(
var
key
in
source
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
source
,
key
))
{
target
[
key
]
=
source
[
key
];
}
}
}
return
target
;
};
var
muban
=
{
var
muban
=
{
mxpro
:{
mxpro
:{
title
:
''
,
title
:
''
,
...
...
js/蓝莓影视.js
浏览文件 @
55b1ec5a
...
@@ -10,7 +10,7 @@ var rule = {
...
@@ -10,7 +10,7 @@ var rule = {
// class_name:'电影&网剧&剧集&动漫&综艺&记录',
// class_name:'电影&网剧&剧集&动漫&综艺&记录',
// class_url:'20&1&2&3&4&23',
// class_url:'20&1&2&3&4&23',
class_parse
:
'
.navbar-items li:gt(1):lt(8);a&&Text;a&&href;/(
\\
d+).html
'
,
class_parse
:
'
.navbar-items li:gt(1):lt(8);a&&Text;a&&href;/(
\\
d+).html
'
,
play_parse
:
true
,
play_parse
:
true
,
//一般有免嗅才开,没免嗅还开只能服务器打印日志进行监听并重定向
// lazy:'通用免嗅',
// lazy:'通用免嗅',
limit
:
30
,
limit
:
30
,
推荐
:
'
.tab-list.active;a.module-poster-item.module-item;.module-poster-item-title&&Text;.lazyload&&data-original;.module-item-note&&Text;a&&href
'
,
推荐
:
'
.tab-list.active;a.module-poster-item.module-item;.module-poster-item-title&&Text;.lazyload&&data-original;.module-item-note&&Text;a&&href
'
,
...
...
py/干饭.js
0 → 100644
浏览文件 @
55b1ec5a
js
:
cacheUrl
=
d
.
getParse
(
input
);
print
(
cacheUrl
);
if
(
cacheUrl
){
input
=
cacheUrl
;
}
else
{
try
{
r
=
requests
.
get
(
input
,
headers
=
d
.
headers
,
timeout
=
d
.
timeout
);
r
.
encoding
=
d
.
encoding
;
html
=
r
.
text
;
let
ret
=
html
.
match
(
/var player_
(
.*
?)
=
(
.*
?)
</
)[
2
];
let
url
=
JSON
.
parse
(
ret
).
url
;
if
(
/
\.
m3u8|
\.
mp4/
.
test
(
url
)){
input
=
url
}
else
if
(
!
/http/
.
test
(
url
)
&&!
/
\/
/
.
test
(
url
)){
try
{
url
=
unescape
(
base64Decode
(
url
));
if
(
/http/
.
test
(
url
)){
input
=
url
}
}
catch
(
e
)
{
print
(
'
解码url发生错误:
'
+
e
.
message
);
}
}
}
catch
(
e
)
{
print
(
'
发生错误:
'
+
e
.
message
);
}
}
utils/parser.py
浏览文件 @
55b1ec5a
...
@@ -18,6 +18,14 @@ import js2py
...
@@ -18,6 +18,14 @@ import js2py
# os.environ["EXECJS_RUNTIME"] = "JScript"
# os.environ["EXECJS_RUNTIME"] = "JScript"
# print(execjs.get().name)
# print(execjs.get().name)
def
runJScode
(
jscode
,
loader
=
None
,
ctx
=
None
):
if
loader
is
None
:
if
ctx
is
None
:
ctx
=
{}
loader
=
js2py
.
EvalJs
(
ctx
)
loader
.
execute
(
jscode
)
return
loader
,
jscode
def
runJs
(
jsPath
,
before
=
''
,
after
=
''
,
ctx
=
None
):
def
runJs
(
jsPath
,
before
=
''
,
after
=
''
,
ctx
=
None
):
# base_path = os.path.dirname(os.path.abspath(__file__)) # 当前文件所在目录
# base_path = os.path.dirname(os.path.abspath(__file__)) # 当前文件所在目录
# base_path = os.path.dirname(os.getcwd()) # 当前主程序所在工作目录
# base_path = os.path.dirname(os.getcwd()) # 当前主程序所在工作目录
...
@@ -52,9 +60,11 @@ def runJs(jsPath, before='', after='', ctx=None):
...
@@ -52,9 +60,11 @@ def runJs(jsPath, before='', after='', ctx=None):
if
after
:
if
after
:
jscode_to_run
+=
after
jscode_to_run
+=
after
loader
=
js2py
.
EvalJs
(
ctx
)
loader
=
js2py
.
EvalJs
(
ctx
)
return
runJScode
(
jscode_to_run
,
loader
)
# loader = execjs.compile(jscode_to_run)
# loader = execjs.compile(jscode_to_run)
loader
.
execute
(
jscode_to_run
)
# print(jscode_to_run)
return
loader
,
js_code
# loader.execute(jscode_to_run)
# return loader,js_code
def
toJs
(
jsPath
):
def
toJs
(
jsPath
):
base_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
# 上级目录
base_path
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
os
.
path
.
dirname
(
__file__
)))
# 上级目录
...
@@ -96,7 +106,7 @@ def runPy(pyPath):
...
@@ -96,7 +106,7 @@ def runPy(pyPath):
f
.
write
(
py_code
)
f
.
write
(
py_code
)
except
Exception
as
e
:
except
Exception
as
e
:
print
(
'发生了错误:'
,
e
)
print
(
'发生了错误:'
,
e
)
return
None
,
''
return
None
else
:
else
:
with
open
(
cache_path
,
'r'
,
encoding
=
'UTF-8'
)
as
fp
:
with
open
(
cache_path
,
'r'
,
encoding
=
'UTF-8'
)
as
fp
:
py_code
=
fp
.
read
()
py_code
=
fp
.
read
()
...
@@ -119,6 +129,7 @@ def covert_demo():
...
@@ -119,6 +129,7 @@ def covert_demo():
loader
.
execute
(
'function f(x) {return x*x};var a=py_sum([2,3]);var b=[a,5];var c={"a":a};'
)
loader
.
execute
(
'function f(x) {return x*x};var a=py_sum([2,3]);var b=[a,5];var c={"a":a};'
)
f
=
loader
.
f
f
=
loader
.
f
print
(
f
(
8
))
print
(
f
(
8
))
print
(
f
.
toString
())
print
(
loader
.
eval
(
'py_sum(new Array(1, 2, 3))'
))
print
(
loader
.
eval
(
'py_sum(new Array(1, 2, 3))'
))
print
(
loader
.
eval
(
'py_sum([1, 2])'
))
print
(
loader
.
eval
(
'py_sum([1, 2])'
))
a
=
loader
.
a
a
=
loader
.
a
...
@@ -141,7 +152,10 @@ def covert_demo():
...
@@ -141,7 +152,10 @@ def covert_demo():
print
(
r
[
0
].
a
)
print
(
r
[
0
].
a
)
print
(
loader
.
eval
(
'r = requests.get("https://www.baidu.com/");r.encoding = "utf-8";r.text'
))
print
(
loader
.
eval
(
'r = requests.get("https://www.baidu.com/");r.encoding = "utf-8";r.text'
))
# 下面是错误用法,没有loader环境没法正确eval_js,有loader用eval不需要eval_js
# 下面是错误用法,没有loader环境没法正确eval_js,有loader用eval不需要eval_js
print
(
js2py
.
eval_js
(
'r = requests.get("https://www.baidu.com/");r.encoding = "utf-8";r.text'
))
# print(js2py.eval_js('r = requests.get("https://www.baidu.com/");r.encoding = "utf-8";r.text'))
with
open
(
'../js/夜空.js'
,
encoding
=
'utf-8'
)
as
f
:
yk
=
f
.
read
()
print
(
yk
)
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录