-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbili_video.py
30 lines (27 loc) · 1.2 KB
/
bili_video.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
from math import log
def scoring(info: dict):
like = info["like"]
view = info["view"]
dm = info["danmaku"]
coin = info["coin"]
fav = info["favorite"]
share = info["share"]
if view == 0: return 0
else:
scale = lambda x: log(x) * 25
return scale(like * (1 + 0.1 * (fav / 5 + dm + share / 5 + coin / 2)) / (view**0.5))
def formatVideoInfo(info: dict):
return '\n'.join([
"__{}__ ({} / av{})".format(info["title"], info["bvid"], info["aid"]),
":link: **Nexus**: https://www.bilibili.com/video/{}".format(
info["bvid"]),
":pencil: **Auctor**: {}".format(info["owner"]["name"]),
":arrow_forward: **Visa**: {}".format(info["stat"]["view"]),
":satellite: **Danmaku**: {}".format(info["stat"]["danmaku"]),
":speech_balloon: **Responsa**: {}".format(info["stat"]["reply"]),
":+1: **Approbata**: {}".format(info["stat"]["like"]),
":coin: **Nummi**: {}".format(info["stat"]["coin"]),
":star: **Collecta**: {}".format(info["stat"]["favorite"]),
":loudspeaker: **Consociata**: {}".format(info["stat"]["share"]),
":triangular_ruler: **Ratio**: {:.2f}".format(scoring(info["stat"]))
])