mirror of
https://github.com/TeamPGM/PagerMaid_Plugins.git
synced 2024-11-22 07:08:18 +00:00
netease 优化安装依赖包流程,支持登出
This commit is contained in:
parent
2efe4c1d25
commit
5e14035f70
@ -292,10 +292,10 @@
|
||||
},
|
||||
{
|
||||
"name": "neteasedown",
|
||||
"version": "1.21",
|
||||
"version": "1.211",
|
||||
"section": "daily",
|
||||
"maintainer": "xtaodada",
|
||||
"size": "9.2 kb",
|
||||
"size": "9.4 kb",
|
||||
"supported": true,
|
||||
"des-short": "网易云搜歌/点歌",
|
||||
"des": "可以在线搜索并且快速点歌,支持解锁VIP歌曲。命令:ned。"
|
||||
|
@ -10,11 +10,11 @@ try:
|
||||
from pyncm import GetCurrentSession, apis, DumpSessionAsString, SetCurrentSession, LoadSessionFromString
|
||||
from pyncm.apis import LoginFailedException
|
||||
from pyncm.apis.cloudsearch import CloudSearchType
|
||||
from pyncm.apis.login import LoginLogout
|
||||
|
||||
cc_imported = True
|
||||
except ImportError:
|
||||
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')
|
||||
print(f'[!] Please run {executable} -m pip install pyncm')
|
||||
cc_imported = False
|
||||
|
||||
|
||||
@ -99,8 +99,7 @@ i.e.
|
||||
parameters="{关键词/id}/{login <账号> <密码>}/{clear}")
|
||||
async def ned(context):
|
||||
if not cc_imported:
|
||||
await context.edit(f"[!] Please run `-sh {executable} -m pip install requests pycryptodome tqdm mutagen` "
|
||||
f"and run `-sh {executable} -m pip install git+https://github.com/Xtao-Labs/pyncm.git` "
|
||||
await context.edit(f"[!] Please run `-sh {executable} -m pip install pyncm` "
|
||||
f"and then restart pagermaid.")
|
||||
return
|
||||
if len(context.parameter) < 1:
|
||||
@ -111,6 +110,8 @@ async def ned(context):
|
||||
if isfile(f"data{sep}session.ncm"):
|
||||
with open(f"data{sep}session.ncm") as f:
|
||||
SetCurrentSession(LoadSessionFromString(f.read()))
|
||||
# 海外用户
|
||||
GetCurrentSession().headers['X-Real-IP'] = '118.88.88.88'
|
||||
# 处理账号登录
|
||||
if context.parameter[0] == "login":
|
||||
# 显示登录信息
|
||||
@ -161,12 +162,18 @@ async def ned(context):
|
||||
with open(f"data{sep}session.ncm", 'w+') as f:
|
||||
f.write(DumpSessionAsString(GetCurrentSession()))
|
||||
return
|
||||
if context.parameter[0] == "clear":
|
||||
elif context.parameter[0] == "logout":
|
||||
# 登出
|
||||
LoginLogout()
|
||||
if isfile(f"data{sep}session.ncm"):
|
||||
remove(f"data{sep}session.ncm")
|
||||
return await context.edit("[ned] 账号登出成功。")
|
||||
elif context.parameter[0] == "clear":
|
||||
# 清除歌曲缓存
|
||||
for i in listdir("data"):
|
||||
if i.find(".mp3") != -1 or i.find(".jpg") != -1:
|
||||
remove(f"data{sep}{i}")
|
||||
await context.edit("**已清除缓存**")
|
||||
await context.edit("[ned] **已清除缓存**")
|
||||
return
|
||||
# 搜索歌曲
|
||||
song_id = context.arguments
|
||||
@ -217,6 +224,6 @@ async def ned(context):
|
||||
for i in listdir("data"):
|
||||
if i.find(".mp3") != -1 or i.find(".jpg") != -1:
|
||||
remove(f"data{sep}{i}")
|
||||
msg = await context.respond("**已清除缓存**")
|
||||
msg = await context.respond("[ned] **已自动清除缓存**")
|
||||
await sleep(3)
|
||||
await msg.delete()
|
||||
|
Loading…
Reference in New Issue
Block a user