From 9466bff17ce5d184c0b6c0f2777e149b00468037 Mon Sep 17 00:00:00 2001 From: xmengnet <51263043+xmengnet@users.noreply.github.com> Date: Wed, 14 Apr 2021 20:41:56 +0800 Subject: [PATCH] Add files via upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 下载网易云音乐和舔狗日记 --- worker/song.py | 29 +++++++++++++++++++++++++++++ worker/tiangou.py | 20 ++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 worker/song.py create mode 100644 worker/tiangou.py diff --git a/worker/song.py b/worker/song.py new file mode 100644 index 0000000..02e4368 --- /dev/null +++ b/worker/song.py @@ -0,0 +1,29 @@ +from zzcore import StdAns +import requests +import urllib3 +urllib3.disable_warnings() + +class Ans(StdAns): + def GETMSG(self): + # self.parms[] + if len(self.parms) < 2: + return '不加参数是坏文明!' + url = 'https://music.xmengnet.cn/api' + + try: + # print(self.parms[1]) + getid = requests.get(url + '/search?keywords=' + self.raw_msg['raw_message'][5:], verify=False).json() + id = getid['result']['songs'][0]['id'] + # print(id) + downurl = requests.get(url + '/song/url?id=' + str(id), verify=False).json() + # print(downurl) + down = downurl['data'][0]['url'] + song = getid['result']['songs'][0]['name'] + '-' \ + + getid['result']['songs'][0]['artists'][0]['name'] + msg = f"[CQ:reply,id={self.raw_msg['message_id']}]" + return msg+song+'的下载地址为:'+down + # msg = f'[CQ:music,type=163,id={id}]' + except Exception as e: + print(e) + msg = '什么东西坏掉了,大概是网易云吧...不可能是咱!' + return msg diff --git a/worker/tiangou.py b/worker/tiangou.py new file mode 100644 index 0000000..06e2193 --- /dev/null +++ b/worker/tiangou.py @@ -0,0 +1,20 @@ +from zzcore import StdAns, mysakuya +import requests + +class Ans(StdAns): + #AllowGroup = [874769998,596678277] + def GETMSG(self): + msg = f"[CQ:reply,id={self.raw_msg['message_id']}]" + try: + msg += tiangou() + except: + msg += '可能是api坏掉了,可不是咱!' + return msg + +def tiangou(): + r = requests.get(url='https://api.muxiaoguo.cn/api/tiangourj').json() + # print(r) + msg = None + if r['msg'] == 'success': + msg = r['data']['comment'] + return msg