XZZ/worker/music.py

27 lines
912 B
Python
Raw Permalink Normal View History

2020-02-29 14:58:14 +08:00
from zzcore import StdAns
import requests
class Ans(StdAns):
def GETMSG(self):
if len(self.parms) < 2:
return '不加参数是坏文明!'
2020-04-07 19:11:32 +08:00
# url = 'https://api.imjad.cn/cloudmusic/'
2020-08-21 10:57:38 +08:00
# url = 'https://music.jeeas.cn/v1/search'
2020-08-03 11:56:59 +08:00
# url = 'http://mc.sakuya.love:3000/search'
2020-08-21 10:57:38 +08:00
url = 'http://inuyasha.love:8001/search'
2020-02-29 14:58:14 +08:00
params = {
'limit': 1,
2021-01-27 11:33:32 +08:00
'keywords':self.raw_msg['raw_message'][6:],
2020-02-29 14:58:14 +08:00
}
try:
resp = requests.get(url=url,params=params).json()
2020-08-03 12:34:53 +08:00
# print(resp)
2020-02-29 14:58:14 +08:00
musicid = resp['result']['songs'][0]['id']
2020-08-25 22:34:51 +08:00
# musicname = resp['result']['songs'][0]['name']
msg = f'[CQ:music,type=163,id={musicid}]'
2020-02-29 14:58:14 +08:00
except Exception as e:
print(e)
msg = '什么东西坏掉了,大概是网易云吧...不可能是咱!'
return msg