NeteaseMusic重大更新:解锁灰色歌曲!

This commit is contained in:
TNTcraftHIM 2020-08-29 02:09:54 +08:00
parent 25ee089593
commit e95f086158
2 changed files with 39 additions and 16 deletions

View File

@ -282,10 +282,10 @@
}, },
{ {
"name": "neteasemusic", "name": "neteasemusic",
"version": "2.4", "version": "2.5",
"section": "daily", "section": "daily",
"maintainer": "TNTcraftHIM", "maintainer": "TNTcraftHIM",
"size": "23.0 kb", "size": "24.2 kb",
"supported": true, "supported": true,
"des-short": "网易云点歌", "des-short": "网易云点歌",
"des": "可以在线搜索并且快速点歌歌曲信息齐全支持直接回复点歌。命令nem。" "des": "可以在线搜索并且快速点歌歌曲信息齐全支持直接回复点歌。命令nem。"

View File

@ -23,15 +23,23 @@ async def nem(context):
proxynum = 0 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', 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"} "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://64.64.250.246:8848', 'https': 'http://64.64.250.246:8848'},{'http': 'http://192.210.137.108:8848', 'https': 'http://192.210.137.108:8848'},{'http': 'http://music.lolico.me:39000', 'https': 'http://music.lolico.me:39000'},{'http': 'http://xbmmw.xyz:1001', 'https': 'http://xbmmw.xyz:1001'},{'http': 'http://aimer.one:2333', 'https': 'http://aimer.one:2333'}] 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://64.64.250.246:8080', 'https': 'http://64.64.250.246:8080'}]
if len(context.parameter) < 2: if len(context.parameter) < 2:
await context.edit("使用方法:`-nem` `<指令>` `<关键词>`\n(指令s为搜索指令p为播放\n关键词可填歌曲ID或直接回复搜索结果消息 `-nem` `p` `<歌曲数字序号>`)") await context.edit("使用方法:`-nem` `<指令>` `<关键词>`\n\n指令s为搜索p为点歌id为歌曲ID点歌\n搜索灰色歌曲请给出歌手\n可回复搜索结果消息`-nem` `p` `<歌曲数字序号>`点歌")
return return
else: else:
keyword = '' keyword = ''
for i in range(1, len(context.parameter)): for i in range(1, len(context.parameter)):
keyword += context.parameter[i] + " " keyword += context.parameter[i] + " "
keyword = keyword[:-1] keyword = keyword[:-1]
idplay = False
if context.parameter[0] == "id": # ID点歌功能
if len(context.parameter) > 2:
await context.edit("使用方法:`-nem` `<指令>` `<关键词>`\n\n指令s为搜索p为点歌id为歌曲ID点歌\n搜索灰色歌曲请给出歌手\n可回复搜索结果消息`-nem` `p` `<歌曲数字序号>`点歌")
return
idplay = keyword
context.parameter[0] = "p"
if context.parameter[0] == "s": # 搜索功能 if context.parameter[0] == "s": # 搜索功能
await context.edit(f"{keyword}】搜索中 . . .") await context.edit(f"{keyword}】搜索中 . . .")
url = "http://music.163.com/api/search/pc?&s=" + \ url = "http://music.163.com/api/search/pc?&s=" + \
@ -85,7 +93,7 @@ async def nem(context):
sleep(3) sleep(3)
await context.delete() await context.delete()
return return
elif context.parameter[0] == "p": # 播放功能 elif context.parameter[0] == "p": # 点歌功能
try: try:
reply = await context.get_reply_message() reply = await context.get_reply_message()
except ValueError: except ValueError:
@ -133,6 +141,15 @@ async def nem(context):
proxynum = 0 proxynum = 0
proxies = proxy[proxynum] proxies = proxy[proxynum]
proxynum += 1 proxynum += 1
if idplay: # 指定ID播放
idurl = 'https://music.163.com/song?id=' + idplay
text = requests.get(url=idurl, headers=headers).text
pattern = re.compile(r'歌曲名《(.*?)》.*?由 (.*?) 演唱.*?')
keyword = pattern.findall(
text)[0][0] + " " + pattern.findall(text)[0][1]
url = "http://music.163.com/api/search/pc?&s=" + \
keyword + "&offset=0&limit=1&type=1"
# 普通搜索+播放
req = requests.request("GET", url, headers=headers) req = requests.request("GET", url, headers=headers)
if req.status_code == 200: if req.status_code == 200:
req = json.loads(req.content) req = json.loads(req.content)
@ -158,6 +175,7 @@ async def nem(context):
else: else:
title = f"{info['title']}" title = f"{info['title']}"
await context.edit(f"{title}下载中 . . .") await context.edit(f"{title}下载中 . . .")
try: try:
from Crypto.Cipher import AES from Crypto.Cipher import AES
AES.new("0CoJUm6Qyw8W8jud".encode('utf-8'), AES.new("0CoJUm6Qyw8W8jud".encode('utf-8'),
@ -169,6 +187,7 @@ async def nem(context):
name = info['title'].replace('/', " ") + ".mp3" name = info['title'].replace('/', " ") + ".mp3"
if ccimported: # 尝试使用高清音质下载 if ccimported: # 尝试使用高清音质下载
songid = str(info['id']) songid = str(info['id'])
class WangyiyunDownload(object): class WangyiyunDownload(object):
def __init__(self): def __init__(self):
self.key = '0CoJUm6Qyw8W8jud' self.key = '0CoJUm6Qyw8W8jud'
@ -368,10 +387,13 @@ async def nem(context):
tag.album = info['album'] tag.album = info['album']
tag.images.remove('') tag.images.remove('')
tag.images.set(3, imagedata, "image/jpeg", u"Cover") tag.images.set(3, imagedata, "image/jpeg", u"Cover")
tag.save(version=eyed3.id3.ID3_DEFAULT_VERSION, encoding='utf-8') tag.save(version=eyed3.id3.ID3_DEFAULT_VERSION,
encoding='utf-8')
br = "" br = ""
if imported is True: if imported is True:
br = "#" + str(eyed3.mp3.Mp3AudioFile(name).info.bit_rate[1]) + "kbps " br = "#" + \
str(eyed3.mp3.Mp3AudioFile(
name).info.bit_rate[1]) + "kbps "
alias = "" alias = ""
if info['alias']: if info['alias']:
alias = "\n\n__" + info['alias'][0] + "__" alias = "\n\n__" + info['alias'][0] + "__"
@ -383,7 +405,8 @@ async def nem(context):
caption=cap, caption=cap,
link_preview=False, link_preview=False,
force_document=False, force_document=False,
attributes=(DocumentAttributeAudio(0, False, info['title'], info['artist']),) attributes=(DocumentAttributeAudio(
0, False, info['title'], info['artist']),)
) )
try: try:
if reply.sender.is_self: if reply.sender.is_self:
@ -411,5 +434,5 @@ async def nem(context):
sleep(3) sleep(3)
await context.delete() await context.delete()
else: # 错误输入 else: # 错误输入
await context.edit("使用方法:`-nem` `<指令>` `<关键词>`\n(指令s为搜索指令p为播放\n关键词可填歌曲ID或直接回复搜索结果消息 `-nem` `p` `<歌曲数字序号>`)") await context.edit("使用方法:`-nem` `<指令>` `<关键词>`\n\n指令s为搜索p为点歌id为歌曲ID点歌\n搜索灰色歌曲请给出歌手\n可回复搜索结果消息`-nem` `p` `<歌曲数字序号>`点歌")
return return