mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 12:15:37 +00:00
neteasedown 支持显示登录信息,自动清理缓存
This commit is contained in:
parent
bcbb12683c
commit
2c3523283e
@ -292,13 +292,13 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "neteasedown",
|
"name": "neteasedown",
|
||||||
"version": "1.202",
|
"version": "1.21",
|
||||||
"section": "daily",
|
"section": "daily",
|
||||||
"maintainer": "xtaodada",
|
"maintainer": "xtaodada",
|
||||||
"size": "6.7 kb",
|
"size": "9.2 kb",
|
||||||
"supported": true,
|
"supported": true,
|
||||||
"des-short": "网易云搜歌/点歌",
|
"des-short": "网易云搜歌/点歌",
|
||||||
"des": "可以在线搜索并且快速点歌(可回复信息点歌),支持解锁VIP歌曲。命令:ned。"
|
"des": "可以在线搜索并且快速点歌,支持解锁VIP歌曲。命令:ned。"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "killallmembers",
|
"name": "killallmembers",
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
from asyncio import sleep
|
||||||
from os import sep, remove, listdir
|
from os import sep, remove, listdir
|
||||||
from os.path import isfile
|
from os.path import isfile
|
||||||
from sys import executable
|
from sys import executable
|
||||||
|
from time import strftime, localtime
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from mutagen.id3 import ID3, APIC, TIT2, TPE1
|
from mutagen.id3 import ID3, APIC, TIT2, TPE1
|
||||||
@ -12,7 +13,8 @@ try:
|
|||||||
|
|
||||||
cc_imported = True
|
cc_imported = True
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print(f'[!] Please install {executable} -m pip install requests mutagen pycryptodome tqdm git+https://github.com/Xtao-Labs/pyncm.git')
|
print(f'[!] Please run {executable} -m pip install requests pycryptodome tqdm mutagen and '
|
||||||
|
f'{executable} -m pip installgit+https://github.com/Xtao-Labs/pyncm.git')
|
||||||
cc_imported = False
|
cc_imported = False
|
||||||
|
|
||||||
|
|
||||||
@ -38,6 +40,13 @@ def gen_author(song_info: dict) -> str:
|
|||||||
return " ".join(data)
|
return " ".join(data)
|
||||||
|
|
||||||
|
|
||||||
|
def get_duration(song_info: dict, track_info: dict) -> int:
|
||||||
|
if track_info["data"][0]["freeTrialInfo"]:
|
||||||
|
return track_info["data"][0]["freeTrialInfo"]["end"] - track_info["data"][0]["freeTrialInfo"]["start"]
|
||||||
|
else:
|
||||||
|
return int(song_info["songs"][0]["dt"] / 1000)
|
||||||
|
|
||||||
|
|
||||||
async def netease_down(track_info: dict, song_info: dict) -> str:
|
async def netease_down(track_info: dict, song_info: dict) -> str:
|
||||||
if not isfile(f'data{sep}{song_info["songs"][0]["name"]}.{track_info["data"][0]["type"]}'):
|
if not isfile(f'data{sep}{song_info["songs"][0]["name"]}.{track_info["data"][0]["type"]}'):
|
||||||
# Downloding source audio
|
# Downloding source audio
|
||||||
@ -73,17 +82,30 @@ async def netease_down(track_info: dict, song_info: dict) -> str:
|
|||||||
return f'data{sep}{song_info["songs"][0]["name"]}.{track_info["data"][0]["type"]}'
|
return f'data{sep}{song_info["songs"][0]["name"]}.{track_info["data"][0]["type"]}'
|
||||||
|
|
||||||
|
|
||||||
|
ned_help_msg = f"""
|
||||||
|
网易云搜/点歌。
|
||||||
|
|
||||||
|
i.e.
|
||||||
|
`-{alias_command('ned')} 失眠飞行 兔籽鲸 / 雨客Yoker` # 通过歌曲名称+歌手(可选)点歌
|
||||||
|
`-{alias_command('ned')} 1430702717` # 通过歌曲 ID 点歌
|
||||||
|
`-{alias_command('ned')} login` # 显示登录信息
|
||||||
|
`-{alias_command('ned')} login 手机号码 密码` # 登录账号
|
||||||
|
`-{alias_command('ned')} clear` # 手动清除缓存
|
||||||
|
"""
|
||||||
|
|
||||||
|
|
||||||
@listener(is_plugin=True, outgoing=True, command=alias_command("ned"),
|
@listener(is_plugin=True, outgoing=True, command=alias_command("ned"),
|
||||||
description="网易云搜/点歌。",
|
description=ned_help_msg,
|
||||||
parameters="{关键词/id}/{login <账号> <密码>}/{clear}")
|
parameters="{关键词/id}/{login <账号> <密码>}/{clear}")
|
||||||
async def ned(context):
|
async def ned(context):
|
||||||
if not cc_imported:
|
if not cc_imported:
|
||||||
await context.edit(f"[!] Please run `-sh {executable} -m pip install requests pycryptodome tqdm "
|
await context.edit(f"[!] Please run `-sh {executable} -m pip install requests pycryptodome tqdm mutagen` "
|
||||||
f"mutagen git+https://github.com/Xtao-Labs/pyncm.git` and then restart pagermaid.")
|
f"and run `-sh {executable} -m pip install git+https://github.com/Xtao-Labs/pyncm.git` "
|
||||||
|
f"and then restart pagermaid.")
|
||||||
return
|
return
|
||||||
if len(context.parameter) < 1:
|
if len(context.parameter) < 1:
|
||||||
# 使用方法
|
# 使用方法
|
||||||
await context.edit(f"**使用方法:** `-{alias_command('ned')}" + " {关键词/id}/{login <账号> <密码>}`")
|
await context.edit(ned_help_msg)
|
||||||
return
|
return
|
||||||
# 加载登录信息
|
# 加载登录信息
|
||||||
if isfile(f"data{sep}session.ncm"):
|
if isfile(f"data{sep}session.ncm"):
|
||||||
@ -95,11 +117,21 @@ async def ned(context):
|
|||||||
if len(context.parameter) == 1:
|
if len(context.parameter) == 1:
|
||||||
login_info = GetCurrentSession().login_info
|
login_info = GetCurrentSession().login_info
|
||||||
if login_info["success"]:
|
if login_info["success"]:
|
||||||
await context.edit(f"已登录账号:**{login_info['content']['profile']['nickname']}**")
|
# 获取VIP类型
|
||||||
return
|
if login_info['content']['account']['vipType'] != 0:
|
||||||
|
vip_type = "**VIP**"
|
||||||
|
else:
|
||||||
|
vip_type = "**普通**"
|
||||||
|
# 获取账号创建时间
|
||||||
|
time = strftime("%Y-%m-%d %H:%M:%S", localtime(login_info['content']['account']['createTime'] / 1000))
|
||||||
|
if context.is_group:
|
||||||
|
await context.edit(f"[ned] 已登录{vip_type}账号,账号创建时间:`{time}`")
|
||||||
|
else:
|
||||||
|
await context.edit(f"[ned] 已登录{vip_type}账号:`{login_info['content']['profile']['nickname']}`,"
|
||||||
|
f"账号创建时间:`{time}`")
|
||||||
else:
|
else:
|
||||||
await context.edit(f"**未登录/登录失败**,错误信息:`{login_info['content']}`")
|
await context.edit(f"[ned] **未登录/登录失败**,额外信息:`{login_info['content']}`")
|
||||||
return
|
return
|
||||||
# 过滤空参数
|
# 过滤空参数
|
||||||
if len(context.parameter) == 2:
|
if len(context.parameter) == 2:
|
||||||
# 登录命令格式错误
|
# 登录命令格式错误
|
||||||
@ -113,7 +145,18 @@ async def ned(context):
|
|||||||
return
|
return
|
||||||
# 获取登录信息
|
# 获取登录信息
|
||||||
login_info = GetCurrentSession().login_info
|
login_info = GetCurrentSession().login_info
|
||||||
await context.edit(f"**登录成功**,已登录账号:**{login_info['content']['profile']['nickname']}**")
|
# 获取VIP类型
|
||||||
|
if login_info['content']['account']['vipType'] != 0:
|
||||||
|
vip_type = "**VIP**"
|
||||||
|
else:
|
||||||
|
vip_type = "**普通**"
|
||||||
|
# 获取账号创建时间
|
||||||
|
time = strftime("%Y-%m-%d %H:%M:%S", localtime(login_info['content']['account']['createTime']/1000))
|
||||||
|
if context.is_group:
|
||||||
|
await context.edit(f"[ned] **登录成功**,已登录{vip_type}账号,账号创建时间:`{time}`")
|
||||||
|
else:
|
||||||
|
await context.edit(f"[ned] **登录成功**,已登录{vip_type}账号:`{login_info['content']['profile']['nickname']}`,"
|
||||||
|
f"账号创建时间:`{time}`")
|
||||||
# 保存登录信息
|
# 保存登录信息
|
||||||
with open(f"data{sep}session.ncm", 'w+') as f:
|
with open(f"data{sep}session.ncm", 'w+') as f:
|
||||||
f.write(DumpSessionAsString(GetCurrentSession()))
|
f.write(DumpSessionAsString(GetCurrentSession()))
|
||||||
@ -149,11 +192,15 @@ async def ned(context):
|
|||||||
path = await netease_down(track_info, song_info)
|
path = await netease_down(track_info, song_info)
|
||||||
await context.edit("正在上传歌曲。。。")
|
await context.edit("正在上传歌曲。。。")
|
||||||
# 上传歌曲
|
# 上传歌曲
|
||||||
|
cap_ = ""
|
||||||
|
# 提醒登录VIP账号
|
||||||
|
if track_info["data"][0]["freeTrialInfo"]:
|
||||||
|
cap_ = f"**非VIP,正在试听 {track_info['data'][0]['freeTrialInfo']['start']}s ~ " \
|
||||||
|
f"{track_info['data'][0]['freeTrialInfo']['end']}s**\n"
|
||||||
cap = f"「**{song_info['songs'][0]['name']}**」\n" \
|
cap = f"「**{song_info['songs'][0]['name']}**」\n" \
|
||||||
f"{gen_author(song_info)}\n" \
|
f"{gen_author(song_info)}\n" \
|
||||||
f"\n" \
|
f"\n{cap_}" \
|
||||||
f"#netease #{int(track_info['data'][0]['br'] / 1000)}kbps #{track_info['data'][0]['type']}"
|
f"#netease #{int(track_info['data'][0]['br'] / 1000)}kbps #{track_info['data'][0]['type']}"
|
||||||
duration = int(song_info['songs'][0]['dt'] / 1000)
|
|
||||||
await context.client.send_file(
|
await context.client.send_file(
|
||||||
context.chat_id,
|
context.chat_id,
|
||||||
path,
|
path,
|
||||||
@ -162,6 +209,14 @@ async def ned(context):
|
|||||||
force_document=False,
|
force_document=False,
|
||||||
thumb=path[:-3] + 'jpg',
|
thumb=path[:-3] + 'jpg',
|
||||||
attributes=(DocumentAttributeAudio(
|
attributes=(DocumentAttributeAudio(
|
||||||
duration, False, song_info['songs'][0]['name'], gen_author(song_info)),)
|
get_duration(song_info, track_info), False, song_info['songs'][0]['name'], gen_author(song_info)),)
|
||||||
)
|
)
|
||||||
await context.delete()
|
await context.delete()
|
||||||
|
# 过多文件自动清理
|
||||||
|
if len(listdir("data")) > 100:
|
||||||
|
for i in listdir("data"):
|
||||||
|
if i.find(".mp3") != -1 or i.find(".jpg") != -1:
|
||||||
|
remove(f"data{sep}{i}")
|
||||||
|
msg = await context.respond("**已清除缓存**")
|
||||||
|
await sleep(3)
|
||||||
|
await msg.delete()
|
||||||
|
Loading…
Reference in New Issue
Block a user