From 79ece2bdd42d974e28fecc6c3aad93c4df0784dc Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Sun, 30 Aug 2020 20:56:12 +0800 Subject: [PATCH] =?UTF-8?q?NeteaseMusic=E9=87=8D=E5=A4=A7=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=EF=BC=9A=E4=B8=8A=E4=BC=A0=E9=80=9F=E5=BA=A6=E5=8A=A0?= =?UTF-8?q?=E5=BF=AB=EF=BC=8C=E4=BF=AE=E5=A4=8D=E5=B0=81=E9=9D=A2=E9=94=99?= =?UTF-8?q?=E4=B9=B1=E9=97=AE=E9=A2=98=EF=BC=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 4 ++-- neteasemusic.py | 27 +++++++++++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/list.json b/list.json index 8fd2c32..cdb5fbf 100644 --- a/list.json +++ b/list.json @@ -282,10 +282,10 @@ }, { "name": "neteasemusic", - "version": "3.0", + "version": "3.1", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "25.3 kb", + "size": "26.3 kb", "supported": true, "des-short": "网易云点歌", "des": "可以在线搜索并且快速点歌,歌曲信息齐全,支持直接回复点歌。命令:nem。" diff --git a/neteasemusic.py b/neteasemusic.py index 8339ab1..c3d7728 100644 --- a/neteasemusic.py +++ b/neteasemusic.py @@ -1,3 +1,4 @@ +# -*- coding: utf-8 -*- import json import requests import re @@ -9,7 +10,7 @@ from time import sleep from pagermaid.listener import listener from pagermaid import bot from pagermaid.utils import obtain_message -from os import remove, path +from os import remove, path, mkdir from os.path import exists from collections import defaultdict from telethon.tl.types import DocumentAttributeAudio @@ -389,13 +390,10 @@ async def nem(context): await bot.send_message(context.chat_id, f"【{info['title']}】\n" + "歌曲获取失败,资源获取可能受限,你可以再次尝试。\n" + res, parse_mode='html', link_preview=True) return duration = 0 + imagedata = requests.get( + info['albumpic'], headers=headers).content if imported is True: await context.edit(f"{title}信息导入中 . . .") - try: - imagedata = requests.get( - info['albumpic'], headers=headers).content - except: - await bot.send_message(context.chat_id, '唔 封面好像获取失败了呢,不要在意不要在意 ~ ') tag = eyed3.load(name) duration = int(tag.info.time_secs) tag.initTag() @@ -417,12 +415,29 @@ async def nem(context): alias = "\n\n__" + info['alias'][0] + "__" cap += "\n#NeteaseMusic " + br + alias await context.edit(f"{title}上传中 . . .") + if not exists("plugins/NeteaseMusicExtra/FastTelethon.py"): + if not exists("plugins/NeteaseMusicExtra"): + mkdir("plugins/NeteaseMusicExtra") + faster = requests.request( + "GET", "https://gist.githubusercontent.com/TNTcraftHIM/ca2e6066ed5892f67947eb2289dd6439/raw/86244b02c7824a3ca32ce01b2649f5d9badd2e49/FastTelethon.py") + for ____ in range(6): # 最多尝试6次 + if faster.status_code == 200: + with open("plugins/NeteaseMusicExtra/FastTelethon.py", "wb") as f: + f.write(faster.content) + break + try: + from NeteaseMusicExtra.FastTelethon import upload_file + name = await upload_file(context.client, open(name, 'rb'), name) + except: + await bot.send_message(context.chat_id, '(`FastTelethon`支持文件导入失败,上传速度可能受到影响)') + await context.client.send_file( context.chat_id, name, caption=cap, link_preview=False, force_document=False, + thumb=imagedata, attributes=(DocumentAttributeAudio( duration, False, info['title'], info['artist']),) )