XZZ/worker/wait.py

24 lines
1,002 B
Python
Raw Normal View History

2021-01-26 23:58:00 +08:00
from zzcore import StdAns
import re
import requests
class Ans(StdAns):
def GETMSG(self):
try:
url = self.raw_msg['message'][1]['data']['url']
resp = requests.get(
f"https://trace.moe/api/search?url={url}").json()['docs'][0]
except:
return "There something wrong."
video_url = f"https://media.trace.moe/video/{resp['anilist_id']}/{resp['filename']}?t={resp['at']}&token={resp['tokenthumb']}"
2021-01-27 11:33:32 +08:00
video_url = video_url.replace("&","&").replace("[","[").replace("]","]").replace(",",",")
2021-01-26 23:58:00 +08:00
m, s = divmod(float(resp['at']), 60)
h, m = divmod(m, 60)
2021-01-27 11:33:32 +08:00
# print("%02d:%02d:%02d" % (h, m, s))
2021-01-27 12:12:20 +08:00
text = f"[CQ:reply,id={self.raw_msg['message_id']}]{resp['title_native']}\n{resp['title_chinese']}\nEP#{resp['episode']} {h:02.0f}:{m:02.0f}:{s:02.0f}\n{int(resp['similarity']*100)}% similarity"
2021-01-26 23:58:00 +08:00
2021-01-27 11:57:06 +08:00
msg = f"[CQ:video,file={video_url}]"
self.sendmsg(text)
2021-01-26 23:58:00 +08:00
return msg