forked from DrRyanHuang/bilibiliTool
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathyingbi.py
86 lines (51 loc) · 2.08 KB
/
yingbi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import json
import requests as r
def getVideoInfoFromAid(aid, headers=None):
'''
@Brife:
通过 `aid` 获得视频的数据
aid、bvid、view(视频播放数)、danmaku(总弹幕数)、reply(评论数)
share(分享数)、like(点赞数)、favorite(收藏)、coin(投币数)
@Param:
aid : B站视频的 `aid`
headers : 请求头字典
@Return:
video_info : 返回B站视频的点赞收藏量字典
@Notice:
以下参数暂时未知:
"now_rank": 0,
"his_rank": 0,
"no_reprint": 1,
"copyright": 1,
"argue_msg": "",
"evaluation": ""
'''
data_url = 'https://api.bilibili.com/x/web-interface/archive/stat?aid={}'.format(aid)
if headers is None:
headers = {
'User-Agent':'Mozilla/5.0',
}
repon = r.get(data_url, headers=headers)
repon.encoding = repon.apparent_encoding
repon_str = json.loads(repon.text)
'''
注:
>>> repon_str.keys()
dict_keys(['code', 'message', 'ttl', 'data'])
>>> # 此处的键: 'code', 'message', 'ttl', 暂时未知, 但应该对本代码不影响
'''
video_info = repon_str['data']
return video_info
# 视频链接
# https://lv6rur2.yfcalc.com:48129/upos-dash-mirrorks3u.bilivideo.com/bilibilidash_9bcf6f6d51fa976772f26e7148b34dcff9d6736f/197909629_nb2-1-30080.m4s?timeout=1595922942&check=2576959748&yfdspt=1595318142783&sttype=90&scuid=I7VmBFeAx22t6dB1niZx&yfpri=150&yfopt=17&yfskip=1&yfreqid=CMpPliFRgDxaffsAAF&yftt=100&yfhost=0nmr0o1.yfcache.com&yfpm=1
# 主页视频信息
# https://api.bilibili.com/x/space/arc/search?mid=10119428&ps=30&pn=2
uid = '10119428'
space_url = 'https://space.bilibili.com/10119428'
def _(uid=None, space_uid=None):
'''
@brife:
uid : 用户 `id` 号
space_uid : 用户的 `space` 的url
'''
space_url = 'https://space.bilibili.com/{}'.format(uid)