summaryrefslogtreecommitdiff
path: root/ATRI/plugins/rich/data_source.py
diff options
context:
space:
mode:
🔥🚚✨
- 移除:laugh.txt,需要时再拉取 - 移动控制台文件至plugins/console目录下 - 新增: - 和管理贴贴w - 正式的可视化前端单页
Diffstat (limited to 'ATRI/plugins/rich/data_source.py')
1 files changed, 11 insertions, 8 deletions
diff --git a/ATRI/plugins/rich/data_source.py b/ATRI/plugins/rich/data_source.py
index 9e59bf5..a59c922 100644
--- a/ATRI/plugins/rich/data_source.py
+++ b/ATRI/plugins/rich/data_source.py
@@ -8,6 +8,7 @@ from ATRI.exceptions import RequestError
URL = f"https://api.kyomotoi.moe/api/bilibili/v2/?aid="
+
table = "fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF"
tr = dict()
for i in range(58):
@@ -24,9 +25,10 @@ __doc__ = """
class Rich(Service):
+
def __init__(self):
Service.__init__(self, "小程序处理", __doc__, rule=is_in_service("小程序处理"))
-
+
@staticmethod
def _bv_dec(x) -> str:
r = 0
@@ -34,7 +36,7 @@ class Rich(Service):
r += tr[x[s[i]]] * 58 ** i
result = "av" + str((r - add) ^ xor)
return result
-
+
@staticmethod
def _bv_enc(x) -> str:
x = (x ^ xor) + add
@@ -42,7 +44,7 @@ class Rich(Service):
for i in range(6):
r[s[i]] = table[x // 58 ** i % 58]
return "".join(r)
-
+
@classmethod
async def fk_bili(cls, text: str) -> tuple:
"""
@@ -51,7 +53,7 @@ class Rich(Service):
"""
msg = text.replace("\\", "")
bv = False
-
+
if "qqdocurl" not in msg:
if "av" in msg:
av = re.findall(r"(av\d+)", msg)
@@ -69,7 +71,7 @@ class Rich(Service):
if not bv_url:
return "Get value (bv url) failed!", False
bv_url = bv_url[3]
-
+
try:
res = await request.get(bv_url)
except RequestError:
@@ -78,7 +80,7 @@ class Rich(Service):
if not bv:
return "Get value (bv) failed!", False
av = cls._bv_dec(bv[0])
-
+
if not bv:
if "av" in msg:
av = re.findall(r"(av\d+)", msg)
@@ -87,7 +89,7 @@ class Rich(Service):
av = av[0].replace("av", "")
else:
return "Not found av", False
-
+
url = URL + av
try:
res = await request.get(url)
@@ -95,10 +97,11 @@ class Rich(Service):
return "Request failed!", False
res_data = await res.json()
data = res_data["data"]
-
+
result = (
f"{data['bvid']} INFO:\n"
f"Title: {data['title']}\n"
f"Link: {data['short_link']}"
)
return result, True
+ \ No newline at end of file