fix 媒体删除插件支持手动删除订阅历史记录

This commit is contained in:
thsrite
2024-05-15 09:22:29 +08:00
parent 1dd6f770ef
commit 0efa418250
2 changed files with 47 additions and 5 deletions

View File

@@ -125,10 +125,13 @@
"name": "媒体文件同步删除",
"description": "同步删除历史记录、源文件和下载任务。",
"labels": "文件整理",
"version": "1.4",
"version": "1.5",
"icon": "mediasyncdel.png",
"author": "thsrite",
"level": 1
"level": 1,
"history": {
"v1.5": "支持手动删除订阅历史记录(本次更新之后的历史)"
}
},
"CustomHosts": {
"name": "自定义Hosts",

View File

@@ -31,7 +31,7 @@ class MediaSyncDel(_PluginBase):
# 插件图标
plugin_icon = "mediasyncdel.png"
# 插件版本
plugin_version = "1.4"
plugin_version = "1.5"
# 插件作者
plugin_author = "thsrite"
# 作者主页
@@ -105,7 +105,29 @@ class MediaSyncDel(_PluginBase):
pass
def get_api(self) -> List[Dict[str, Any]]:
pass
return [
{
"path": "/delete_history",
"endpoint": self.delete_history,
"methods": ["GET"],
"summary": "删除历史记录"
}
]
def delete_history(self, key: str, apikey: str):
"""
删除历史记录
"""
if apikey != settings.API_TOKEN:
return schemas.Response(success=False, message="API密钥错误")
# 历史记录
historys = self.get_data('history')
if not historys:
return schemas.Response(success=False, message="未找到历史记录")
# 删除指定记录
historys = [h for h in historys if f"{h.get("title")}:{h.get("tmdb_id")}" != key]
self.save_data('history', historys)
return schemas.Response(success=True, message="删除成功")
def get_service(self) -> List[Dict[str, Any]]:
"""
@@ -535,6 +557,22 @@ class MediaSyncDel(_PluginBase):
{
'component': 'VCard',
'content': [
{
"component": "VDialogCloseBtn",
"props": {
'innerClass': 'absolute top-0 right-0',
},
'events': {
'click': {
'api': 'plugin/MediaSyncDel/delete_history',
'method': 'get',
'params': {
'key': f"{title}:{tmdbid}",
'apikey': settings.API_TOKEN
}
}
},
},
{
'component': 'div',
'props': {
@@ -833,7 +871,8 @@ class MediaSyncDel(_PluginBase):
"season": season_num if season_num and str(season_num).isdigit() else None,
"episode": episode_num if episode_num and str(episode_num).isdigit() else None,
"image": poster_image,
"del_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))
"del_time": time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time())),
"tmdb_id": tmdb_id
})
# 保存历史