summaryrefslogtreecommitdiff
path: root/ATRI/plugins/cloudmusic.py
diff options
context:
space:
mode:
authorKyomotoi <[email protected]>2020-08-02 23:49:04 +0800
committerKyomotoi <[email protected]>2020-08-02 23:49:04 +0800
commit0a9e22b3681efb24b93be9d3b374a233d86b4f0f (patch)
tree13480920f774c04ae00dba8cac7c2a25831ebcf9 /ATRI/plugins/cloudmusic.py
parent0e0a021f50d46f4be11ecab3c1e5ba463e3ac27e (diff)
downloadATRI-0a9e22b3681efb24b93be9d3b374a233d86b4f0f.tar.gz
ATRI-0a9e22b3681efb24b93be9d3b374a233d86b4f0f.tar.bz2
ATRI-0a9e22b3681efb24b93be9d3b374a233d86b4f0f.zip
[Update] new function
Diffstat (limited to 'ATRI/plugins/cloudmusic.py')
-rw-r--r--ATRI/plugins/cloudmusic.py81
1 files changed, 0 insertions, 81 deletions
diff --git a/ATRI/plugins/cloudmusic.py b/ATRI/plugins/cloudmusic.py
deleted file mode 100644
index ad85cad..0000000
--- a/ATRI/plugins/cloudmusic.py
+++ /dev/null
@@ -1,81 +0,0 @@
-import json
-import nonebot
-from orjson import loads
-from html import unescape
-
-from ATRI.modules import response
-
-REPORT_FORMAT = """Status: {status}
-Song id: {id}
-Br: {br}
-Download: {url}
-MD5: {md5}"""
-
-
[email protected]_natural_language(only_to_me = False)
-async def fk_tx_app_cloudmusic(session: nonebot.NLPSession):
- rich_message = [x for x in session.ctx['message'] if x.get('type') == 'rich']
-
- if not rich_message:
- return
-
- rich_message = rich_message[0]['data']['content']
-
- if '网易云音乐' not in str(rich_message):
- return
-
- if 'music' not in str(rich_message):
- return
-
- data = loads(unescape(rich_message))
-
- URL = data['music']['jumpUrl']
- rep = URL.split('/')
- wid = rep[4]
-
- url = f'https://api.imjad.cn/cloudmusic/?type=song&id={wid}&br=320000'
- print(url)
-
- dc = json.loads(response.request_api(url))
-
- await session.send(
- REPORT_FORMAT.format(
- status = dc["code"],
- id = dc["data"][0]["id"],
- br = dc["data"][0]["br"],
- url = dc["data"][0]["url"],
- md5 = dc["data"][0]["md5"],
- )
- )
-
-
[email protected]_natural_language(only_to_me = False)
-async def cloudmusic_link(session: nonebot.NLPSession):
- share_message = [x for x in session.ctx['message'] if x.get('type') == 'share']
-
- if not share_message:
- return
-
- share_message = share_message[0]['data']['url']
-
- if 'music.163.com' not in str(share_message):
- return
-
- rep = share_message.replace('=', '/')
- rep = rep.replace('&', '/')
- wid = rep[4]
-
- url = f'https://api.imjad.cn/cloudmusic/?type=song&id={wid}&br=320000'
- print(url)
-
- dc = json.loads(response.request_api(url))
-
- await session.send(
- REPORT_FORMAT.format(
- status = dc["code"],
- id = dc["data"][0]["id"],
- br = dc["data"][0]["br"],
- url = dc["data"][0]["url"],
- md5 = dc["data"][0]["md5"],
- )
- ) \ No newline at end of file