diff --git a/package.json b/package.json index 7b345d8..ef11b85 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/plugins/mediasyncdel/__init__.py b/plugins/mediasyncdel/__init__.py index 43bed4f..1a9d651 100644 --- a/plugins/mediasyncdel/__init__.py +++ b/plugins/mediasyncdel/__init__.py @@ -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 }) # 保存历史