Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
夏至溪檐
dr_py
提交
54a77836
dr_py
项目概览
夏至溪檐
/
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,发现更多精彩内容 >>
提交
54a77836
编写于
8月 29, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加随机图片
上级
4c911e0f
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
67 addition
and
16 deletion
+67
-16
app.py
app.py
+24
-0
classes/cms.py
classes/cms.py
+3
-3
config.py
config.py
+2
-1
images/1.jpg
images/1.jpg
+0
-0
js/干饭影视.js
js/干饭影视.js
+1
-1
models/rules.db
models/rules.db
+0
-0
py/干饭.js
py/干饭.js
+1
-1
readme.md
readme.md
+1
-0
templates/config.txt
templates/config.txt
+1
-1
utils/encode.py
utils/encode.py
+34
-9
未找到文件。
app.py
浏览文件 @
54a77836
...
...
@@ -3,6 +3,7 @@
# File : app.py
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/8/25
import
random
from
flask_sqlalchemy
import
SQLAlchemy
import
config
...
...
@@ -155,6 +156,17 @@ def getRules(path='cache'):
rules
=
{
'list'
:
rule_list
,
'count'
:
len
(
rule_list
)}
return
rules
def
getPics
(
path
=
'images'
):
base_path
=
path
+
'/'
# 当前文件所在目录
os
.
makedirs
(
base_path
,
exist_ok
=
True
)
file_name
=
os
.
listdir
(
base_path
)
# file_name = list(filter(lambda x: str(x).endswith('.js') and str(x).find('模板') < 0, file_name))
# print(file_name)
pic_list
=
[
base_path
+
file
for
file
in
file_name
]
# pic_list = file_name
# print(type(pic_list))
return
pic_list
def
getJxs
(
path
=
'js'
):
with
open
(
f
'
{
path
}
/解析.txt'
,
encoding
=
'utf-8'
)
as
f
:
data
=
f
.
read
().
strip
()
...
...
@@ -216,6 +228,18 @@ def rules():
def
rules_raw
():
return
render_template
(
'raw.html'
,
rules
=
getRules
(),
classes
=
getClasses
())
@
app
.
route
(
'/pics'
)
def
random_pics
():
pics
=
getPics
()
if
len
(
pics
)
>
0
:
pic
=
random
.
choice
(
pics
)
file
=
open
(
pic
,
"rb"
).
read
()
response
=
make_response
(
file
)
response
.
headers
[
'Content-Type'
]
=
'image/jpeg'
return
response
else
:
return
redirect
(
config
.
WALL_PAPER
)
@
app
.
route
(
'/config/<int:mode>'
)
def
config_render
(
mode
):
# print(dict(app.config))
...
...
classes/cms.py
浏览文件 @
54a77836
...
...
@@ -11,7 +11,7 @@ from utils.web import *
from
models
import
*
from
utils.config
import
config
from
utils.log
import
logger
from
utils.encode
import
base64Encode
,
baseDecode
,
fetch
,
post
from
utils.encode
import
base64Encode
,
baseDecode
,
fetch
,
post
,
request
from
utils.safePython
import
safePython
from
utils.parser
import
runPy
,
runJScode
from
utils.htmlParser
import
jsoup
...
...
@@ -22,7 +22,7 @@ from easydict import EasyDict as edict
py_ctx
=
{
'requests'
:
requests
,
'print'
:
print
,
'base64Encode'
:
base64Encode
,
'baseDecode'
:
baseDecode
,
'log'
:
logger
.
info
,
'fetch'
:
fetch
,
'post'
:
post
'log'
:
logger
.
info
,
'fetch'
:
fetch
,
'post'
:
post
,
'request'
:
request
}
class
CMS
:
...
...
@@ -648,7 +648,7 @@ class CMS:
loader
,
_
=
runJScode
(
jscode
,
ctx
=
ctx
)
# print(loader.toString())
play_url
=
loader
.
eval
(
'input'
)
logger
.
info
(
'免嗅播放地址:'
,
play_url
)
logger
.
info
(
f
'免嗅播放地址:
{
play_url
}
'
)
return
play_url
...
...
config.py
浏览文件 @
54a77836
...
...
@@ -20,4 +20,5 @@ JSON_AS_ASCII = False # jsonify返回的中文正常显示
# PLAY_URL = 'http://localhost:5705' # 匹配远程解析服务器链接
# PLAY_URL = PLAY_URL.rstrip('/')
PLAY_DISABLE
=
False
# 全局禁用播放解析
WALL_PAPER
=
"https://picsum.photos/1280/720/?blur=10"
# 自定义壁纸,可注释
\ No newline at end of file
WALL_PAPER
=
"https://picsum.photos/1280/720/?blur=10"
# 自定义壁纸,可注释
# {% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %}
\ No newline at end of file
images/1.jpg
0 → 100644
浏览文件 @
54a77836
21.0 KB
js/干饭影视.js
浏览文件 @
54a77836
...
...
@@ -14,7 +14,7 @@ var rule = {
// lazy:'干饭',
// lazy:'@js:cacheUrl = d.getParse(input);print(cacheUrl);input=cacheUrl',
// lazy:'js:cacheUrl = d.getParse(input);print(cacheUrl);input=cacheUrl',
lazy
:
'
js:cacheUrl=d.getParse(input);if(cacheUrl){input=cacheUrl}else{try{let html=fetch(input,{headers:d.headers,timeout:d.timeout,encoding:d.encoding});let ret=html.match(/var player_(.*?)=(.*?)</)[2];let url=JSON.parse(ret).url;if(url.length>10){real_url="https://player.buyaotou.xyz/?url="+url;
log("免嗅地址:"+real_url);
d.saveParse(input,real_url);input=real_url}}catch(e){print("网络请求发生错误:"+e.message)}}
'
,
lazy
:
'
js:cacheUrl=d.getParse(input);if(cacheUrl){input=cacheUrl}else{try{let html=fetch(input,{headers:d.headers,timeout:d.timeout,encoding:d.encoding});let ret=html.match(/var player_(.*?)=(.*?)</)[2];let url=JSON.parse(ret).url;if(url.length>10){real_url="https://player.buyaotou.xyz/?url="+url;d.saveParse(input,real_url);input=real_url}}catch(e){print("网络请求发生错误:"+e.message)}}
'
,
limit
:
5
,
推荐
:
'
ul.stui-vodlist.clearfix;li;a&&title;.lazyload&&data-original;;a&&href
'
,
double
:
true
,
// 推荐内容是否双层定位
...
...
models/rules.db
浏览文件 @
54a77836
无法预览此类型文件
py/干饭.js
浏览文件 @
54a77836
...
...
@@ -13,7 +13,7 @@ if(cacheUrl){
let
url
=
JSON
.
parse
(
ret
).
url
;
if
(
url
.
length
>
10
){
real_url
=
'
https://player.buyaotou.xyz/?url=
'
+
url
;
log
(
'
免嗅地址:
'
+
real_url
);
//
log('免嗅地址:'+real_url);
d
.
saveParse
(
input
,
real_url
);
input
=
real_url
;
}
...
...
readme.md
浏览文件 @
54a77836
...
...
@@ -4,6 +4,7 @@
-
[X] 1.更换js引擎,速度更快性能更好
-
[X] 2.新版js支持与python互动,后期可能支持js免嗅(lazy:'@js:xxx')
-
[X] 3.支持了js免嗅和常用的fetch,post方法
-
[X] 4.配置uglifyjs可以把js代码压缩到一行(es5不支持多行js)
###### 2022/08/28
-
[X] 1.增加linux进程启动,命令 supervisord -c manager.conf
-
[X] 2.转移文本文件到txt目录
...
...
templates/config.txt
浏览文件 @
54a77836
{
{% if config.WALL_PAPER %}"wallpaper":"{{ config.WALL_PAPER }}",{% endif %}
"wallpaper":"http://{{ host }}/pics",
"dr_count": {{rules.list|length}},
"mode": {{ mode }},
"sites": [{% for rule in rules.list %}{% if mode == 0 %}
...
...
utils/encode.py
浏览文件 @
54a77836
...
...
@@ -6,6 +6,7 @@
import
base64
import
requests
from
utils.web
import
UC_UA
def
base64Encode
(
text
):
return
base64
.
b64encode
(
text
.
encode
(
"utf8"
)).
decode
(
"utf-8"
)
#base64编码
...
...
@@ -13,8 +14,7 @@ def base64Encode(text):
def
baseDecode
(
text
):
return
base64
.
b64decode
(
text
).
decode
(
"utf-8"
)
#base64解码
def
base_request
(
url
,
obj
,
method
=
'get'
):
url
=
str
(
url
).
replace
(
"'"
,
""
)
def
dealObj
(
obj
):
encoding
=
obj
.
get
(
'encoding'
)
or
'utf-8'
encoding
=
str
(
encoding
).
replace
(
"'"
,
""
)
# print(type(url),url)
...
...
@@ -33,25 +33,50 @@ def base_request(url,obj,method='get'):
new_body
=
{}
for
i
in
body
:
new_body
[
str
(
i
).
replace
(
"'"
,
""
)]
=
str
(
body
[
i
]).
replace
(
"'"
,
""
)
# print(type(new_body), new_body)
return
{
'encoding'
:
encoding
,
'headers'
:
new_headers
,
'timeout'
:
timeout
,
'body'
:
new_body
,
}
def
base_request
(
url
,
obj
,
method
=
None
):
url
=
str
(
url
).
replace
(
"'"
,
""
)
if
not
method
:
method
=
'get'
# print(obj)
try
:
# r = requests.get(url, headers=headers, params=body, timeout=timeout)
if
method
.
lower
()
==
'get'
:
r
=
requests
.
get
(
url
,
headers
=
new_headers
,
params
=
new_body
,
timeout
=
timeout
)
r
=
requests
.
get
(
url
,
headers
=
obj
[
'headers'
],
params
=
obj
[
'body'
],
timeout
=
obj
[
'timeout'
]
)
else
:
r
=
requests
.
post
(
url
,
headers
=
new_headers
,
data
=
new_body
,
timeout
=
timeout
)
r
=
requests
.
post
(
url
,
headers
=
obj
[
'headers'
],
data
=
obj
[
'body'
],
timeout
=
obj
[
'timeout'
]
)
# r = requests.get(url, timeout=timeout)
# r = requests.get(url)
# print(encoding)
r
.
encoding
=
encoding
r
.
encoding
=
obj
[
'encoding'
]
# print(f'源码:{r.text}')
return
r
.
text
except
Exception
as
e
:
print
(
f
'
{
method
}
请求发生错误:
{
e
}
'
)
return
''
def
fetch
(
url
,
obj
):
return
base_request
(
url
,
obj
)
def
fetch
(
url
,
obj
,
method
=
None
):
if
not
method
:
method
=
'get'
obj
=
dealObj
(
obj
)
print
(
method
)
return
base_request
(
url
,
obj
,
method
)
def
post
(
url
,
obj
):
return
base_request
(
url
,
obj
,
'post'
)
\ No newline at end of file
obj
=
dealObj
(
obj
)
return
base_request
(
url
,
obj
,
'post'
)
def
request
(
url
,
obj
,
method
=
None
):
if
not
method
:
method
=
'get'
obj
=
dealObj
(
obj
)
if
not
obj
.
get
(
'headers'
)
or
not
obj
[
'headers'
].
get
(
'User-Agent'
):
obj
[
'headers'
][
'User-Agent'
]
=
UC_UA
return
base_request
(
url
,
obj
,
method
)
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录