From 432ac7db3d71ffd0a57dcf27f4b8191507c74cd9 Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Sat, 29 Aug 2020 17:20:49 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E6=AD=8C?= =?UTF-8?q?=E6=9B=B2TG=E9=A2=84=E8=A7=88=E6=97=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=97=B6=E9=95=BF=E4=B8=BA0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 4 ++-- neteasemusic.py | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/list.json b/list.json index c53545a..662dcaa 100644 --- a/list.json +++ b/list.json @@ -282,10 +282,10 @@ }, { "name": "neteasemusic", - "version": "2.7", + "version": "2.8", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "24.3 kb", + "size": "25.0 kb", "supported": true, "des-short": "网易云点歌", "des": "可以在线搜索并且快速点歌,歌曲信息齐全,支持直接回复点歌。命令:nem。" diff --git a/neteasemusic.py b/neteasemusic.py index 1bf7801..02b5053 100644 --- a/neteasemusic.py +++ b/neteasemusic.py @@ -383,14 +383,16 @@ 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 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, '唔 ~ 封面好像获取失败了呢,不要在意不要在意 ~ ') + await bot.send_message(context.chat_id, '唔 封面好像获取失败了呢,不要在意不要在意 ~ ') tag = eyed3.load(name) + duration = int(tag.info.time_secs) tag.initTag() tag = tag.tag tag.artist = info['artist'] @@ -417,7 +419,7 @@ async def nem(context): link_preview=False, force_document=False, attributes=(DocumentAttributeAudio( - 0, False, info['title'], info['artist']),) + duration, False, info['title'], info['artist']),) ) try: if reply.sender.is_self: From bf40ed0748826be880f2277ceb2b804f60dd2aa8 Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Sat, 29 Aug 2020 18:26:00 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E8=B0=83=E6=95=B4=E8=A7=A3=E5=AF=86?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E6=97=B6=E7=94=B3=E8=AF=B7=E7=9A=84=E9=9F=B3?= =?UTF-8?q?=E8=B4=A8=EF=BC=88=E6=8B=89=E6=BB=A1=E4=BA=86=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- neteasemusic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neteasemusic.py b/neteasemusic.py index 02b5053..76bc600 100644 --- a/neteasemusic.py +++ b/neteasemusic.py @@ -272,7 +272,7 @@ async def nem(context): random_num=random_num) # 调用两次AES加密生成params # 初始化歌曲song_info - song_info = '{"ids":"[%s]","level":"exhigh","encodeType":"mp3","csrf_token":"477c1bd99fddedb3adc074f47fee2d35"}' % song_id + song_info = '{"ids":"[%s]","level":"lossless","encodeType":"mp3","csrf_token":"477c1bd99fddedb3adc074f47fee2d35"}' % song_id # 第一次加密,传入encText, key和iv first_encryption = self.AES_encrypt( msg=song_info, key=self.key, iv=self.iv) From 4e1bea2fec9123698b728f834b2a7134e4d3b541 Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Sat, 29 Aug 2020 18:30:21 +0800 Subject: [PATCH 3/7] =?UTF-8?q?Revert=20"=E8=B0=83=E6=95=B4=E8=A7=A3?= =?UTF-8?q?=E5=AF=86=E7=94=B3=E8=AF=B7=E6=97=B6=E7=94=B3=E8=AF=B7=E7=9A=84?= =?UTF-8?q?=E9=9F=B3=E8=B4=A8=EF=BC=88=E6=8B=89=E6=BB=A1=E4=BA=86=EF=BC=89?= =?UTF-8?q?"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit bf40ed0748826be880f2277ceb2b804f60dd2aa8. --- neteasemusic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/neteasemusic.py b/neteasemusic.py index 76bc600..02b5053 100644 --- a/neteasemusic.py +++ b/neteasemusic.py @@ -272,7 +272,7 @@ async def nem(context): random_num=random_num) # 调用两次AES加密生成params # 初始化歌曲song_info - song_info = '{"ids":"[%s]","level":"lossless","encodeType":"mp3","csrf_token":"477c1bd99fddedb3adc074f47fee2d35"}' % song_id + song_info = '{"ids":"[%s]","level":"exhigh","encodeType":"mp3","csrf_token":"477c1bd99fddedb3adc074f47fee2d35"}' % song_id # 第一次加密,传入encText, key和iv first_encryption = self.AES_encrypt( msg=song_info, key=self.key, iv=self.iv) From 397b959b012a81d746be6288e08e9d2f74f2c897 Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Sat, 29 Aug 2020 19:05:11 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 2 +- neteasemusic.py | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/list.json b/list.json index 662dcaa..61f193f 100644 --- a/list.json +++ b/list.json @@ -285,7 +285,7 @@ "version": "2.8", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "25.0 kb", + "size": "25.3 kb", "supported": true, "des-short": "网易云点歌", "des": "可以在线搜索并且快速点歌,歌曲信息齐全,支持直接回复点歌。命令:nem。" diff --git a/neteasemusic.py b/neteasemusic.py index 02b5053..6e6e09d 100644 --- a/neteasemusic.py +++ b/neteasemusic.py @@ -14,7 +14,8 @@ from os.path import exists from collections import defaultdict from telethon.tl.types import DocumentAttributeAudio -class RetryError(Exception): #重试错误,用于再次重试 + +class RetryError(Exception): # 重试错误,用于再次重试 pass @@ -26,7 +27,8 @@ async def nem(context): proxynum = 0 headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063', "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "X-Real-IP": "223.252.199.66"} - proxy = [{'http': 'http://192.210.137.108:8080', 'https': 'http://192.210.137.108:8080'}, {'http': 'http://music.lolico.me:39000', 'https': 'http://music.lolico.me:39000'}, {'http': 'http://aimer.one:2333', 'https': 'http://aimer.one:2333'}, {'http': 'http://fs2.ilogic.net.cn:5200','https': 'http://fs2.ilogic.net.cn:5200'}, {'http': 'http://64.64.250.246:8080', 'https': 'http://64.64.250.246:8080'}] + proxy = [{'http': 'http://192.210.137.108:8080', 'https': 'http://192.210.137.108:8080'}, {'http': 'http://music.lolico.me:39000', 'https': 'http://music.lolico.me:39000'}, {'http': 'http://aimer.one:2333', + 'https': 'http://aimer.one:2333'}, {'http': 'http://fs2.ilogic.net.cn:5200', 'https': 'http://fs2.ilogic.net.cn:5200'}, {'http': 'http://64.64.250.246:8080', 'https': 'http://64.64.250.246:8080'}] if len(context.parameter) < 2: await context.edit("**使用方法:** `-nem` `<指令>` `<关键词>`\n\n指令s为搜索,p为点歌,id为歌曲ID点歌\n搜索灰色歌曲请给出歌手\n可回复搜索结果消息`-nem` `p` `<歌曲数字序号>`点歌") return @@ -144,7 +146,8 @@ async def nem(context): proxies = proxy[proxynum] proxynum += 1 if idplay: # 指定ID播放 - url = "http://music.163.com/api/song/detail?id="+ idplay +"&ids=[" + idplay + "]" + url = "http://music.163.com/api/song/detail?id=" + \ + idplay + "&ids=[" + idplay + "]" # 搜索后播放 req = requests.request("GET", url, headers=headers) if req.status_code == 200: @@ -189,6 +192,7 @@ async def nem(context): name = info['title'].replace('/', " ") + ".mp3" if ccimported: # 尝试使用高清音质下载 songid = str(info['id']) + class WangyiyunDownload(object): def __init__(self): self.key = '0CoJUm6Qyw8W8jud' @@ -329,7 +333,7 @@ async def nem(context): try: content = requests.get( url=real_url, headers=self.headers).content - with open(file, 'wb') as fp: + with open(file, 'wb', encoding='utf8') as fp: fp.write(content) except: print('服务器连接出错') @@ -368,7 +372,7 @@ async def nem(context): ';', ', ') + " - " + "**" + info['title'] + "**" if ccimported is False: - with open(name, 'wb') as f: + with open(name, 'wb', encoding='utf8') as f: f.write(music.content) if (path.getsize(name) / 1024) < 100: remove(name) @@ -383,7 +387,7 @@ 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 + duration = 0 if imported is True: await context.edit(f"{title}信息导入中 . . .") try: From 1a8406f8d86db18ff061daad04a0faa176cd1f8e Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Sat, 29 Aug 2020 19:41:08 +0800 Subject: [PATCH 5/7] big fix --- list.json | 4 ++-- neteasemusic.py | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/list.json b/list.json index 61f193f..a599688 100644 --- a/list.json +++ b/list.json @@ -282,10 +282,10 @@ }, { "name": "neteasemusic", - "version": "2.8", + "version": "2.9", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "25.3 kb", + "size": "25.4 kb", "supported": true, "des-short": "网易云点歌", "des": "可以在线搜索并且快速点歌,歌曲信息齐全,支持直接回复点歌。命令:nem。" diff --git a/neteasemusic.py b/neteasemusic.py index 6e6e09d..8339ab1 100644 --- a/neteasemusic.py +++ b/neteasemusic.py @@ -190,6 +190,7 @@ async def nem(context): ccimported = False await bot.send_message(context.chat_id, '(`PyCryptodome`支持库未安装,音乐曲库/音质受限\n请使用 `-sh` `pip3` `install` `pycryptodome` 安装,或自行ssh安装)') name = info['title'].replace('/', " ") + ".mp3" + name = name.encode('utf-8').decode('utf-8') if ccimported: # 尝试使用高清音质下载 songid = str(info['id']) @@ -333,7 +334,7 @@ async def nem(context): try: content = requests.get( url=real_url, headers=self.headers).content - with open(file, 'wb', encoding='utf8') as fp: + with open(file, 'wb') as fp: fp.write(content) except: print('服务器连接出错') @@ -372,7 +373,7 @@ async def nem(context): ';', ', ') + " - " + "**" + info['title'] + "**" if ccimported is False: - with open(name, 'wb', encoding='utf8') as f: + with open(name, 'wb') as f: f.write(music.content) if (path.getsize(name) / 1024) < 100: remove(name) From 4fe4b5a4c07c9bcada50d40b707539c7fabf363f Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Sat, 29 Aug 2020 19:48:54 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E6=88=91=E6=98=AF=E6=86=A8=E6=89=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.json | 4 ++-- neteasemusic.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/list.json b/list.json index 04eb228..8fd2c32 100644 --- a/list.json +++ b/list.json @@ -282,10 +282,10 @@ }, { "name": "neteasemusic", - "version": "2.9", + "version": "3.0", "section": "daily", "maintainer": "TNTcraftHIM", - "size": "25.4 kb", + "size": "25.3 kb", "supported": true, "des-short": "网易云点歌", "des": "可以在线搜索并且快速点歌,歌曲信息齐全,支持直接回复点歌。命令:nem。" diff --git a/neteasemusic.py b/neteasemusic.py index 614053d..8339ab1 100644 --- a/neteasemusic.py +++ b/neteasemusic.py @@ -334,7 +334,7 @@ async def nem(context): try: content = requests.get( url=real_url, headers=self.headers).content - with open(file, 'wb', encoding='utf8') as fp: + with open(file, 'wb') as fp: fp.write(content) except: print('服务器连接出错') @@ -373,7 +373,7 @@ async def nem(context): ';', ', ') + " - " + "**" + info['title'] + "**" if ccimported is False: - with open(name, 'wb', encoding='utf8') as f: + with open(name, 'wb') as f: f.write(music.content) if (path.getsize(name) / 1024) < 100: remove(name) From 79ece2bdd42d974e28fecc6c3aad93c4df0784dc Mon Sep 17 00:00:00 2001 From: TNTcraftHIM Date: Sun, 30 Aug 2020 20:56:12 +0800 Subject: [PATCH 7/7] =?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']),) )