Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_43434433
dr_py
提交
90c6470a
dr_py
项目概览
qq_43434433
/
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,发现更多精彩内容 >>
提交
90c6470a
编写于
11月 23, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新了Py源
上级
be96628d
变更
6
展开全部
隐藏空白更改
内联
并排
Showing
6 changed file
with
1623 addition
and
195 deletion
+1623
-195
js/version.txt
js/version.txt
+1
-1
txt/py/py_alist.py
txt/py/py_alist.py
+1
-0
txt/py/py_bilibili.py
txt/py/py_bilibili.py
+864
-169
txt/py/py_bilimy.py
txt/py/py_bilimy.py
+215
-0
txt/py/py_biliys.py
txt/py/py_biliys.py
+536
-0
txt/py/py_bilizb.py
txt/py/py_bilizb.py
+6
-25
未找到文件。
js/version.txt
浏览文件 @
90c6470a
3.9.23beta6
\ No newline at end of file
3.9.23beta7
\ No newline at end of file
txt/py/py_alist.py
浏览文件 @
90c6470a
...
...
@@ -25,6 +25,7 @@ class Spider(Spider): # 元类 默认的元类 type
def
homeContent
(
self
,
filter
):
result
=
{}
cateManual
=
{
"丫仙女"
:
"http://alist.xiaoya.pro/"
,
"七米蓝"
:
"https://al.chirmyram.com/"
,
"梅花盘"
:
"https://pan.142856.xyz/OneDrive"
,
"触光云盘"
:
"https://pan.ichuguang.com"
,
...
...
txt/py/py_bilibili.py
浏览文件 @
90c6470a
此差异已折叠。
点击以展开。
txt/py/py_bilimy.py
0 → 100644
浏览文件 @
90c6470a
# coding=utf-8
# !/usr/bin/python
import
sys
sys
.
path
.
append
(
'..'
)
from
base.spider
import
Spider
import
json
from
requests
import
session
,
utils
import
os
import
time
import
base64
class
Spider
(
Spider
):
box_video_type
=
''
def
getDependence
(
self
):
return
[
'py_bilibili'
]
def
getName
(
self
):
return
"我的哔哩"
def
init
(
self
,
extend
=
""
):
self
.
bilibili
=
extend
[
0
]
print
(
"============{0}============"
.
format
(
extend
))
pass
def
isVideoFormat
(
self
,
url
):
pass
def
manualVideoCheck
(
self
):
pass
def
homeContent
(
self
,
filter
):
result
=
{}
cateManual
=
{
# ————————以下可自定义关键词,结果以搜索方式展示————————
"宅舞"
:
"宅舞"
,
"cosplay"
:
"cosplay"
,
"周杰伦"
:
"周杰伦"
,
"狗狗"
:
"汪星人"
,
"猫咪"
:
"喵星人"
,
"请自定义关键词"
:
"美女"
,
# ————————以下可自定义UP主,冒号后须填写UID————————
"虫哥说电影"
:
"29296192"
,
}
classes
=
[]
for
k
in
cateManual
:
classes
.
append
({
'type_name'
:
k
,
'type_id'
:
cateManual
[
k
]
})
result
[
'class'
]
=
classes
if
(
filter
):
filters
=
{}
for
lk
in
cateManual
:
if
not
cateManual
[
lk
].
isdigit
():
link
=
cateManual
[
lk
]
filters
.
update
({
link
:
[{
"key"
:
"order"
,
"name"
:
"排序"
,
"value"
:
[{
"n"
:
"综合排序"
,
"v"
:
"totalrank"
},
{
"n"
:
"最新发布"
,
"v"
:
"pubdate"
},
{
"n"
:
"最多点击"
,
"v"
:
"click"
},
{
"n"
:
"最多收藏"
,
"v"
:
"stow"
},
{
"n"
:
"最多弹幕"
,
"v"
:
"dm"
},
]},
{
"key"
:
"duration"
,
"name"
:
"时长"
,
"value"
:
[{
"n"
:
"全部"
,
"v"
:
"0"
},
{
"n"
:
"60分钟以上"
,
"v"
:
"4"
},
{
"n"
:
"30~60分钟"
,
"v"
:
"3"
},
{
"n"
:
"5~30分钟"
,
"v"
:
"2"
},
{
"n"
:
"5分钟以下"
,
"v"
:
"1"
}]}]
})
result
[
'filters'
]
=
filters
return
result
# 用户cookies,请在py_bilibili里填写,此处不用改
cookies
=
''
def
getCookie
(
self
):
self
.
cookies
=
self
.
bilibili
.
getCookie
()
return
self
.
cookies
def
homeVideoContent
(
self
):
result
=
{}
return
result
def
get_up_videos
(
self
,
tid
,
pg
):
result
=
{}
url
=
'https://api.bilibili.com/x/space/arc/search?mid={0}&pn={1}&ps=20'
.
format
(
tid
,
pg
)
rsp
=
self
.
fetch
(
url
,
cookies
=
self
.
cookies
)
content
=
rsp
.
text
jo
=
json
.
loads
(
content
)
if
jo
[
'code'
]
==
0
:
videos
=
[]
vodList
=
jo
[
'data'
][
'list'
][
'vlist'
]
for
vod
in
vodList
:
aid
=
str
(
vod
[
'aid'
]).
strip
()
title
=
vod
[
'title'
].
strip
().
replace
(
"<em class=
\"
keyword
\"
>"
,
""
).
replace
(
"</em>"
,
""
)
img
=
vod
[
'pic'
].
strip
()
remark
=
str
(
vod
[
'length'
]).
strip
()
videos
.
append
({
"vod_id"
:
aid
,
"vod_name"
:
title
,
"vod_pic"
:
img
,
"vod_remarks"
:
remark
})
result
[
'list'
]
=
videos
result
[
'page'
]
=
pg
result
[
'pagecount'
]
=
9999
result
[
'limit'
]
=
90
result
[
'total'
]
=
999999
return
result
def
categoryContent
(
self
,
tid
,
pg
,
filter
,
extend
):
self
.
box_video_type
=
"分区"
if
tid
.
isdigit
():
return
self
.
get_up_videos
(
tid
,
pg
)
else
:
result
=
self
.
bilibili
.
categoryContent
(
tid
,
pg
,
filter
,
extend
)
return
result
def
cleanSpace
(
self
,
str
):
return
str
.
replace
(
'
\n
'
,
''
).
replace
(
'
\t
'
,
''
).
replace
(
'
\r
'
,
''
).
replace
(
' '
,
''
)
def
detailContent
(
self
,
array
):
if
self
.
box_video_type
==
"搜索"
:
mid
=
array
[
0
]
# 获取UP主视频列表,ps后面为视频数量,默认为20,加快加载速度
url
=
'https://api.bilibili.com/x/space/arc/search?mid={0}&pn=1&ps=20'
.
format
(
mid
)
rsp
=
self
.
fetch
(
url
,
headers
=
self
.
header
)
content
=
rsp
.
text
jRoot
=
json
.
loads
(
content
)
jo
=
jRoot
[
'data'
][
'list'
][
'vlist'
]
url2
=
"https://api.bilibili.com/x/web-interface/card?mid={0}"
.
format
(
mid
)
rsp2
=
self
.
fetch
(
url2
,
headers
=
self
.
header
)
jRoot2
=
json
.
loads
(
rsp2
.
text
)
jo2
=
jRoot2
[
'data'
][
'card'
]
name
=
jo2
[
'name'
].
replace
(
"<em class=
\"
keyword
\"
>"
,
""
).
replace
(
"</em>"
,
""
)
pic
=
jo2
[
'face'
]
desc
=
jo2
[
'Official'
][
'desc'
]
+
" "
+
jo2
[
'Official'
][
'title'
]
vod
=
{
"vod_id"
:
mid
,
"vod_name"
:
name
+
" "
+
"个人主页"
,
"vod_pic"
:
pic
,
"type_name"
:
"最近投稿"
,
"vod_year"
:
""
,
"vod_area"
:
"bilidanmu"
,
"vod_remarks"
:
""
,
# 不会显示
'vod_tags'
:
'mv'
,
# 不会显示
"vod_actor"
:
"粉丝数:"
+
self
.
bilibili
.
zh
(
jo2
[
'fans'
]),
"vod_director"
:
name
,
"vod_content"
:
desc
}
playUrl
=
''
for
tmpJo
in
jo
:
eid
=
tmpJo
[
'aid'
]
url3
=
"https://api.bilibili.com/x/web-interface/view?aid=%s"
%
str
(
eid
)
rsp3
=
self
.
fetch
(
url3
)
jRoot3
=
json
.
loads
(
rsp3
.
text
)
cid
=
jRoot3
[
'data'
][
'cid'
]
part
=
tmpJo
[
'title'
].
replace
(
"#"
,
"-"
)
playUrl
=
playUrl
+
'{0}${1}_{2}#'
.
format
(
part
,
eid
,
cid
)
vod
[
'vod_play_from'
]
=
'B站'
vod
[
'vod_play_url'
]
=
playUrl
result
=
{
'list'
:
[
vod
]
}
return
result
else
:
return
self
.
bilibili
.
detailContent
(
array
)
def
searchContent
(
self
,
key
,
quick
):
self
.
box_video_type
=
"搜索"
if
len
(
self
.
cookies
)
<=
0
:
self
.
getCookie
()
url
=
'https://api.bilibili.com/x/web-interface/search/type?search_type=bili_user&keyword={0}'
.
format
(
key
)
rsp
=
self
.
fetch
(
url
,
cookies
=
self
.
cookies
)
content
=
rsp
.
text
jo
=
json
.
loads
(
content
)
videos
=
[]
vodList
=
jo
[
'data'
][
'result'
]
for
vod
in
vodList
:
aid
=
str
(
vod
[
'mid'
])
# str(vod["res"][0]["aid"])
title
=
"UP主:"
+
vod
[
'uname'
].
strip
()
+
" ☜"
+
key
img
=
'https:'
+
vod
[
'upic'
].
strip
()
remark
=
"粉丝数"
+
self
.
bilibili
.
zh
(
vod
[
'fans'
])
videos
.
append
({
"vod_id"
:
aid
,
"vod_name"
:
title
,
"vod_pic"
:
img
,
"vod_remarks"
:
remark
})
result
=
{
'list'
:
videos
}
return
result
def
playerContent
(
self
,
flag
,
id
,
vipFlags
):
return
self
.
bilibili
.
playerContent
(
flag
,
id
,
vipFlags
)
config
=
{
"player"
:
{},
"filter"
:
{
}
}
header
=
{
"Referer"
:
"https://www.bilibili.com"
,
"User-Agent"
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}
def
localProxy
(
self
,
param
):
return
[
200
,
"video/MP2T"
,
action
,
""
]
txt/py/py_biliys.py
0 → 100644
浏览文件 @
90c6470a
# coding=utf-8
# !/usr/bin/python
import
sys
sys
.
path
.
append
(
'..'
)
from
base.spider
import
Spider
import
json
from
requests
import
session
,
utils
import
os
import
time
import
base64
class
Spider
(
Spider
):
def
getDependence
(
self
):
return
[
'py_bilibili'
]
def
getName
(
self
):
return
"哔哩影视"
def
init
(
self
,
extend
=
""
):
self
.
bilibili
=
extend
[
0
]
print
(
"============{0}============"
.
format
(
extend
))
pass
def
isVideoFormat
(
self
,
url
):
pass
def
manualVideoCheck
(
self
):
pass
def
homeContent
(
self
,
filter
):
result
=
{}
cateManual
=
{
"番剧"
:
"1"
,
"国创"
:
"4"
,
"电影"
:
"2"
,
"电视剧"
:
"5"
,
"纪录片"
:
"3"
,
"综艺"
:
"7"
,
"全部"
:
"全部"
,
"追番"
:
"追番"
,
"追剧"
:
"追剧"
,
"时间表"
:
"时间表"
,
}
classes
=
[]
for
k
in
cateManual
:
classes
.
append
({
'type_name'
:
k
,
'type_id'
:
cateManual
[
k
]
})
result
[
'class'
]
=
classes
if
(
filter
):
result
[
'filters'
]
=
self
.
config
[
'filter'
]
return
result
# 用户cookies
cookies
=
''
userid
=
''
def
getCookie
(
self
):
self
.
cookies
=
self
.
bilibili
.
getCookie
()
self
.
userid
=
self
.
bilibili
.
userid
return
self
.
cookies
# 将超过10000的数字换成成以万和亿为单位
def
zh
(
self
,
num
):
if
int
(
num
)
>=
100000000
:
p
=
round
(
float
(
num
)
/
float
(
100000000
),
1
)
p
=
str
(
p
)
+
'亿'
else
:
if
int
(
num
)
>=
10000
:
p
=
round
(
float
(
num
)
/
float
(
10000
),
1
)
p
=
str
(
p
)
+
'万'
else
:
p
=
str
(
num
)
return
p
def
homeVideoContent
(
self
):
result
=
{}
videos
=
self
.
get_rank
(
1
)[
'list'
][
0
:
5
]
for
i
in
[
4
,
2
,
5
,
3
,
7
]:
videos
+=
self
.
get_rank2
(
i
)[
'list'
][
0
:
5
]
result
[
'list'
]
=
videos
return
result
def
get_rank
(
self
,
tid
):
result
=
{}
url
=
'https://api.bilibili.com/pgc/web/rank/list?season_type={0}&day=3'
.
format
(
tid
)
rsp
=
self
.
fetch
(
url
,
cookies
=
self
.
cookies
)
content
=
rsp
.
text
jo
=
json
.
loads
(
content
)
if
jo
[
'code'
]
==
0
:
videos
=
[]
vodList
=
jo
[
'result'
][
'list'
]
for
vod
in
vodList
:
aid
=
str
(
vod
[
'season_id'
]).
strip
()
title
=
vod
[
'title'
].
strip
()
img
=
vod
[
'cover'
].
strip
()
remark
=
vod
[
'new_ep'
][
'index_show'
]
videos
.
append
({
"vod_id"
:
aid
,
"vod_name"
:
title
,
"vod_pic"
:
img
,
"vod_remarks"
:
remark
})
result
[
'list'
]
=
videos
result
[
'page'
]
=
1
result
[
'pagecount'
]
=
1
result
[
'limit'
]
=
90
result
[
'total'
]
=
999999
return
result
def
get_rank2
(
self
,
tid
):
result
=
{}
url
=
'https://api.bilibili.com/pgc/season/rank/web/list?season_type={0}&day=3'
.
format
(
tid
)
rsp
=
self
.
fetch
(
url
,
cookies
=
self
.
cookies
)
content
=
rsp
.
text
jo
=
json
.
loads
(
content
)
if
jo
[
'code'
]
==
0
:
videos
=
[]
vodList
=
jo
[
'data'
][
'list'
]
for
vod
in
vodList
:
aid
=
str
(
vod
[
'season_id'
]).
strip
()
title
=
vod
[
'title'
].
strip
()
img
=
vod
[
'cover'
].
strip
()
remark
=
vod
[
'new_ep'
][
'index_show'
]
videos
.
append
({
"vod_id"
:
aid
,
"vod_name"
:
title
,
"vod_pic"
:
img
,
"vod_remarks"
:
remark
})
result
[
'list'
]
=
videos
result
[
'page'
]
=
1
result
[
'pagecount'
]
=
1
result
[
'limit'
]
=
90
result
[
'total'
]
=
999999
return
result
def
get_zhui
(
self
,
pg
,
mode
):
result
=
{}
if
len
(
self
.
cookies
)
<=
0
:
self
.
getCookie
()
url
=
'https://api.bilibili.com/x/space/bangumi/follow/list?type={2}&follow_status=0&pn={1}&ps=10&vmid={0}'
.
format
(
self
.
userid
,
pg
,
mode
)
rsp
=
self
.
fetch
(
url
,
cookies
=
self
.
cookies
)
content
=
rsp
.
text
jo
=
json
.
loads
(
content
)
videos
=
[]
vodList
=
jo
[
'data'
][
'list'
]
for
vod
in
vodList
:
aid
=
str
(
vod
[
'season_id'
]).
strip
()
title
=
vod
[
'title'
]
img
=
vod
[
'cover'
].
strip
()
remark
=
vod
[
'new_ep'
][
'index_show'
].
strip
()
videos
.
append
({
"vod_id"
:
aid
,
"vod_name"
:
title
,
"vod_pic"
:
img
,
"vod_remarks"
:
remark
})
result
[
'list'
]
=
videos
result
[
'page'
]
=
pg
result
[
'pagecount'
]
=
9999
result
[
'limit'
]
=
90
result
[
'total'
]
=
999999
return
result
def
get_all
(
self
,
tid
,
pg
,
order
,
season_status
,
extend
):
result
=
{}
if
len
(
self
.
cookies
)
<=
0
:
self
.
getCookie
()
url
=
'https://api.bilibili.com/pgc/season/index/result?order={2}&pagesize=20&type=1&season_type={0}&page={1}&season_status={3}'
.
format
(
tid
,
pg
,
order
,
season_status
)
rsp
=
self
.
fetch
(
url
,
cookies
=
self
.
cookies
)
content
=
rsp
.
text
jo
=
json
.
loads
(
content
)
videos
=
[]
vodList
=
jo
[
'data'
][
'list'
]
for
vod
in
vodList
:
aid
=
str
(
vod
[
'season_id'
]).
strip
()
title
=
vod
[
'title'
]
img
=
vod
[
'cover'
].
strip
()
remark
=
vod
[
'index_show'
].
strip
()
videos
.
append
({
"vod_id"
:
aid
,
"vod_name"
:
title
,
"vod_pic"
:
img
,
"vod_remarks"
:
remark
})
result
[
'list'
]
=
videos
result
[
'page'
]
=
pg
result
[
'pagecount'
]
=
9999
result
[
'limit'
]
=
90
result
[
'total'
]
=
999999
return
result
def
get_timeline
(
self
,
tid
,
pg
):
result
=
{}
url
=
'https://api.bilibili.com/pgc/web/timeline/v2?season_type={0}&day_before=2&day_after=4'
.
format
(
tid
)
rsp
=
self
.
fetch
(
url
,
cookies
=
self
.
cookies
)
content
=
rsp
.
text
jo
=
json
.
loads
(
content
)
if
jo
[
'code'
]
==
0
:
videos1
=
[]
vodList
=
jo
[
'result'
][
'latest'
]
for
vod
in
vodList
:
aid
=
str
(
vod
[
'season_id'
]).
strip
()
title
=
vod
[
'title'
].
strip
()
img
=
vod
[
'cover'
].
strip
()
remark
=
vod
[
'pub_index'
]
+
' '
+
vod
[
'follows'
].
replace
(
'系列'
,
''
)
videos1
.
append
({
"vod_id"
:
aid
,
"vod_name"
:
title
,
"vod_pic"
:
img
,
"vod_remarks"
:
remark
})
videos2
=
[]
for
i
in
range
(
0
,
7
):
vodList
=
jo
[
'result'
][
'timeline'
][
i
][
'episodes'
]
for
vod
in
vodList
:
if
str
(
vod
[
'published'
])
==
"0"
:
aid
=
str
(
vod
[
'season_id'
]).
strip
()
title
=
str
(
vod
[
'title'
]).
strip
()
img
=
str
(
vod
[
'cover'
]).
strip
()
date
=
str
(
time
.
strftime
(
"%m-%d %H:%M"
,
time
.
localtime
(
vod
[
'pub_ts'
])))
remark
=
date
+
" "
+
vod
[
'pub_index'
]
videos2
.
append
({
"vod_id"
:
aid
,
"vod_name"
:
title
,
"vod_pic"
:
img
,
"vod_remarks"
:
remark
})
result
[
'list'
]
=
videos2
+
videos1
result
[
'page'
]
=
1
result
[
'pagecount'
]
=
1
result
[
'limit'
]
=
90
result
[
'total'
]
=
999999
return
result
def
categoryContent
(
self
,
tid
,
pg
,
filter
,
extend
):
result
=
{}
if
len
(
self
.
cookies
)
<=
0
:
self
.
getCookie
()
if
tid
==
"1"
:
return
self
.
get_rank
(
tid
=
tid
)
elif
tid
in
{
"2"
,
"3"
,
"4"
,
"5"
,
"7"
}:
return
self
.
get_rank2
(
tid
=
tid
)
elif
tid
==
"全部"
:
tid
=
'1'
order
=
'2'
season_status
=
'-1'
if
'tid'
in
extend
:
tid
=
extend
[
'tid'
]
if
'order'
in
extend
:
order
=
extend
[
'order'
]
if
'season_status'
in
extend
:
season_status
=
extend
[
'season_status'
]
return
self
.
get_all
(
tid
,
pg
,
order
,
season_status
,
extend
)
elif
tid
==
"追番"
:
return
self
.
get_zhui
(
pg
,
1
)
elif
tid
==
"追剧"
:
return
self
.
get_zhui
(
pg
,
2
)
elif
tid
==
"时间表"
:
tid
=
1
if
'tid'
in
extend
:
tid
=
extend
[
'tid'
]
return
self
.
get_timeline
(
tid
,
pg
)
else
:
result
=
self
.
searchContent
(
key
=
tid
,
quick
=
"false"
)
return
result
def
cleanSpace
(
self
,
str
):
return
str
.
replace
(
'
\n
'
,
''
).
replace
(
'
\t
'
,
''
).
replace
(
'
\r
'
,
''
).
replace
(
' '
,
''
)
def
detailContent
(
self
,
array
):
aid
=
array
[
0
]
url
=
"https://api.bilibili.com/pgc/view/web/season?season_id={0}"
.
format
(
aid
)
rsp
=
self
.
fetch
(
url
,
headers
=
self
.
header
)
jRoot
=
json
.
loads
(
rsp
.
text
)
jo
=
jRoot
[
'result'
]
id
=
jo
[
'season_id'
]
title
=
jo
[
'title'
]
pic
=
jo
[
'cover'
]
# areas = jo['areas']['name'] 改bilidanmu显示弹幕
typeName
=
jo
[
'share_sub_title'
]
date
=
jo
[
'publish'
][
'pub_time'
][
0
:
4
]
dec
=
jo
[
'evaluate'
]
remark
=
jo
[
'new_ep'
][
'desc'
]
stat
=
jo
[
'stat'
]
# 演员和导演框展示视频状态,包括以下内容:
status
=
"弹幕: "
+
self
.
zh
(
stat
[
'danmakus'
])
+
" 点赞: "
+
self
.
zh
(
stat
[
'likes'
])
+
" 投币: "
+
self
.
zh
(
stat
[
'coins'
])
+
" 追番追剧: "
+
self
.
zh
(
stat
[
'favorites'
])
if
'rating'
in
jo
:
score
=
"评分: "
+
str
(
jo
[
'rating'
][
'score'
])
+
' '
+
jo
[
'subtitle'
]
else
:
score
=
"暂无评分"
+
' '
+
jo
[
'subtitle'
]
vod
=
{
"vod_id"
:
id
,
"vod_name"
:
title
,
"vod_pic"
:
pic
,
"type_name"
:
typeName
,
"vod_year"
:
date
,
"vod_area"
:
"bilidanmu"
,
"vod_remarks"
:
remark
,
"vod_actor"
:
status
,
"vod_director"
:
score
,
"vod_content"
:
dec
}
ja
=
jo
[
'episodes'
]
playUrl
=
''
for
tmpJo
in
ja
:
eid
=
tmpJo
[
'id'
]
cid
=
tmpJo
[
'cid'
]
part
=
tmpJo
[
'title'
].
replace
(
"#"
,
"-"
)
playUrl
=
playUrl
+
'{0}${1}_{2}#'
.
format
(
part
,
eid
,
cid
)
vod
[
'vod_play_from'
]
=
'B站'
vod
[
'vod_play_url'
]
=
playUrl
result
=
{
'list'
:
[
vod
]
}
return
result
def
searchContent
(
self
,
key
,
quick
):
if
len
(
self
.
cookies
)
<=
0
:
self
.
getCookie
()
url1
=
'https://api.bilibili.com/x/web-interface/search/type?search_type=media_bangumi&keyword={0}'
.
format
(
key
)
# 番剧搜索
rsp1
=
self
.
fetch
(
url1
,
cookies
=
self
.
cookies
)
content1
=
rsp1
.
text
jo1
=
json
.
loads
(
content1
)
rs1
=
jo1
[
'data'
]
url2
=
'https://api.bilibili.com/x/web-interface/search/type?search_type=media_ft&keyword={0}'
.
format
(
key
)
# 影视搜索
rsp2
=
self
.
fetch
(
url2
,
cookies
=
self
.
cookies
)
content2
=
rsp2
.
text
jo2
=
json
.
loads
(
content2
)
rs2
=
jo2
[
'data'
]
videos
=
[]
if
rs1
[
'numResults'
]
==
0
:
vodList
=
jo2
[
'data'
][
'result'
]
elif
rs2
[
'numResults'
]
==
0
:
vodList
=
jo1
[
'data'
][
'result'
]
else
:
vodList
=
jo1
[
'data'
][
'result'
]
+
jo2
[
'data'
][
'result'
]
for
vod
in
vodList
:
aid
=
str
(
vod
[
'season_id'
]).
strip
()
title
=
key
+
'➢'
+
vod
[
'title'
].
strip
().
replace
(
"<em class=
\"
keyword
\"
>"
,
""
).
replace
(
"</em>"
,
""
)
img
=
vod
[
'cover'
].
strip
()
# vod['eps'][0]['cover'].strip()原来的错误写法
remark
=
vod
[
'index_show'
]
videos
.
append
({
"vod_id"
:
aid
,
"vod_name"
:
title
,
"vod_pic"
:
img
,
"vod_remarks"
:
remark
})
result
=
{
'list'
:
videos
}
return
result
def
playerContent
(
self
,
flag
,
id
,
vipFlags
):
result
=
{}
ids
=
id
.
split
(
"_"
)
header
=
{
"Referer"
:
"https://www.bilibili.com"
,
"User-Agent"
:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
}
url
=
'https://api.bilibili.com/pgc/player/web/playurl?qn=116&ep_id={0}&cid={1}'
.
format
(
ids
[
0
],
ids
[
1
])
if
len
(
self
.
cookies
)
<=
0
:
self
.
getCookie
()
rsp
=
self
.
fetch
(
url
,
cookies
=
self
.
cookies
,
headers
=
header
)
jRoot
=
json
.
loads
(
rsp
.
text
)
if
jRoot
[
'message'
]
!=
'success'
:
print
(
"需要大会员权限才能观看"
)
return
{}
jo
=
jRoot
[
'result'
]
ja
=
jo
[
'durl'
]
maxSize
=
-
1
position
=
-
1
for
i
in
range
(
len
(
ja
)):
tmpJo
=
ja
[
i
]
if
maxSize
<
int
(
tmpJo
[
'size'
]):
maxSize
=
int
(
tmpJo
[
'size'
])
position
=
i
url
=
''
if
len
(
ja
)
>
0
:
if
position
==
-
1
:
position
=
0
url
=
ja
[
position
][
'url'
]
result
[
"parse"
]
=
0
result
[
"playUrl"
]
=
''
result
[
"url"
]
=
url
result
[
"header"
]
=
{
"Referer"
:
"https://www.bilibili.com"
,
"User-Agent"
:
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36"
}
result
[
"contentType"
]
=
'video/x-flv'
return
result
config
=
{
"player"
:
{},
"filter"
:
{
"全部"
:
[
{
"key"
:
"tid"
,
"name"
:
"分类"
,
"value"
:
[{
"n"
:
"番剧"
,
"v"
:
"1"
},
{
"n"
:
"国创"
,
"v"
:
"4"
},
{
"n"
:
"电影"
,
"v"
:
"2"
},
{
"n"
:
"电视剧"
,
"v"
:
"5"
},
{
"n"
:
"记录片"
,
"v"
:
"3"
},
{
"n"
:
"综艺"
,
"v"
:
"7"
}
]
},
{
"key"
:
"order"
,
"name"
:
"排序"
,
"value"
:
[
{
"n"
:
"播放数量"
,
"v"
:
"2"
},
{
"n"
:
"更新时间"
,
"v"
:
"0"
},
{
"n"
:
"最高评分"
,
"v"
:
"4"
},
{
"n"
:
"弹幕数量"
,
"v"
:
"1"
},
{
"n"
:
"追看人数"
,
"v"
:
"3"
},
{
"n"
:
"开播时间"
,
"v"
:
"5"
},
{
"n"
:
"上映时间"
,
"v"
:
"6"
},
]
},
{
"key"
:
"season_status"
,
"name"
:
"付费"
,
"value"
:
[
{
"n"
:
"全部"
,
"v"
:
"-1"
},
{
"n"
:
"免费"
,
"v"
:
"1"
},
{
"n"
:
"付费"
,
"v"
:
"2%2C6"
},
{
"n"
:
"大会员"
,
"v"
:
"4%2C6"
},
]
},
],
"时间表"
:
[{
"key"
:
"tid"
,
"name"
:
"分类"
,
"value"
:
[
{
"n"
:
"番剧"
,
"v"
:
"1"
},
{
"n"
:
"国创"
,
"v"
:
"4"
},
]
},
],
}
}
header
=
{
"Referer"
:
"https://www.bilibili.com"
,
"User-Agent"
:
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36'
}
def
localProxy
(
self
,
param
):
return
[
200
,
"video/MP2T"
,
action
,
""
]
txt/py/py_bilizb.py
浏览文件 @
90c6470a
...
...
@@ -11,7 +11,9 @@ import time
import
base64
class
Spider
(
Spider
):
# 元类 默认的元类 type
class
Spider
(
Spider
):
def
getDependence
(
self
):
return
[
'py_bilibili'
]
def
getName
(
self
):
return
"哔哩直播"
...
...
@@ -49,31 +51,11 @@ class Spider(Spider): # 元类 默认的元类 type
userid
=
''
def
getCookie
(
self
):
# --------↓↓↓↓↓↓↓------在下方cookies_str后的双引号内填写-------↓↓↓↓↓↓↓--------
cookies_str
=
""
if
cookies_str
:
cookies
=
dict
([
co
.
strip
().
split
(
'='
,
1
)
for
co
in
cookies_str
.
split
(
';'
)])
bili_jct
=
cookies
[
'bili_jct'
]
SESSDATA
=
cookies
[
'SESSDATA'
]
DedeUserID
=
cookies
[
'DedeUserID'
]
cookies_jar
=
{
"bili_jct"
:
bili_jct
,
'SESSDATA'
:
SESSDATA
,
'DedeUserID'
:
DedeUserID
}
rsp
=
session
()
rsp
.
cookies
=
cookies_jar
content
=
self
.
fetch
(
"https://api.bilibili.com/x/web-interface/nav"
,
cookies
=
rsp
.
cookies
)
res
=
json
.
loads
(
content
.
text
)
if
res
[
"code"
]
==
0
:
self
.
cookies
=
rsp
.
cookies
self
.
userid
=
res
[
"data"
].
get
(
'mid'
)
return
rsp
.
cookies
rsp
=
self
.
fetch
(
"https://www.bilibili.com/"
)
self
.
cookies
=
rsp
.
cookies
return
rsp
.
cookies
self
.
cookies
=
self
.
bilibili
.
getCookie
()
return
self
.
cookies
def
init
(
self
,
extend
=
""
):
self
.
bilibili
=
extend
[
0
]
print
(
"============{0}============"
.
format
(
extend
))
pass
...
...
@@ -96,7 +78,6 @@ class Spider(Spider): # 元类 默认的元类 type
p
=
str
(
num
)
return
p
# 获取主播用户名
uname
=
''
def
get_live_userInfo
(
self
,
uid
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录