Merge remote-tracking branch 'origin/main'

This commit is contained in:
jxxghp
2024-03-01 13:02:08 +08:00
3 changed files with 43 additions and 6 deletions

View File

@@ -58,7 +58,7 @@
"DoubanRank": {
"name": "豆瓣榜单订阅",
"description": "监控豆瓣热门榜单,自动添加订阅。",
"version": "1.5",
"version": "1.6",
"icon": "movie.jpg",
"author": "jxxghp",
"level": 2
@@ -346,7 +346,7 @@
"RemoveLink": {
"name": "清理硬链接",
"description": "监控目录内文件被删除时,同步删除监控目录内所有和它硬链接的文件",
"version": "1.4",
"version": "1.5",
"icon": "Ombi_A.png",
"author": "DzAvril",
"level": 1

View File

@@ -27,7 +27,7 @@ class DoubanRank(_PluginBase):
# 插件图标
plugin_icon = "movie.jpg"
# 插件版本
plugin_version = "1.5"
plugin_version = "1.6"
# 插件作者
plugin_author = "jxxghp"
# 作者主页
@@ -53,6 +53,7 @@ class DoubanRank(_PluginBase):
'movie-hot-gaia': 'https://rsshub.app/douban/movie/weekly/movie_hot_gaia',
'tv-hot': 'https://rsshub.app/douban/movie/weekly/tv_hot',
'movie-top250': 'https://rsshub.app/douban/movie/weekly/movie_top250',
'movie-top250-full': 'https://rsshub.app/douban/list/movie_top250',
}
_enabled = False
_cron = ""
@@ -274,6 +275,7 @@ class DoubanRank(_PluginBase):
{'title': '热门电影', 'value': 'movie-hot-gaia'},
{'title': '热门电视剧', 'value': 'tv-hot'},
{'title': '电影TOP10', 'value': 'movie-top250'},
{'title': '电影TOP250', 'value': 'movie-top250-full'},
]
}
}

View File

@@ -85,7 +85,7 @@ class RemoveLink(_PluginBase):
# 插件图标
plugin_icon = "Ombi_A.png"
# 插件版本
plugin_version = "1.4"
plugin_version = "1.5"
# 插件作者
plugin_author = "DzAvril"
# 作者主页
@@ -99,6 +99,7 @@ class RemoveLink(_PluginBase):
# preivate property
monitor_dirs = ""
exclude_dirs = ""
exclude_keywords = ".!qB"
_enabled = False
_notify = False
@@ -112,10 +113,12 @@ class RemoveLink(_PluginBase):
self._enabled = config.get("enabled")
self._notify = config.get("notify")
self.monitor_dirs = config.get("monitor_dirs")
self.exclude_dirs = config.get("exclude_dirs") or ""
self.exclude_keywords = config.get("exclude_keywords") or ""
# 停止现有任务
self.stop_service()
if self._enabled:
# 读取目录配置
monitor_dirs = self.monitor_dirs.split("\n")
@@ -215,7 +218,27 @@ class RemoveLink(_PluginBase):
"model": "monitor_dirs",
"label": "监控目录",
"rows": 5,
"placeholder": "每一行一个目录",
"placeholder": "源目录及硬链接目录均需加入监控,每一行一个目录",
},
}
],
}
],
},
{
"component": "VRow",
"content": [
{
"component": "VCol",
"props": {"cols": 12},
"content": [
{
"component": "VTextarea",
"props": {
"model": "exclude_dirs",
"label": "不删除目录",
"rows": 5,
"placeholder": "该目录下的文件不会被动删除,一行一个目录",
},
}
],
@@ -258,7 +281,7 @@ class RemoveLink(_PluginBase):
'props': {
'type': 'info',
'variant': 'tonal',
'text': '监控目录如有多个换行,源目录和硬链接目录都需要添加到监控目录中。'
'text': '监控目录如有多个换行,源目录和硬链接目录都需要添加到监控目录中;如需实现删除硬链接时不删除源文件,可把源文件目录配置到不删除目录中'
}
}
]
@@ -292,6 +315,15 @@ class RemoveLink(_PluginBase):
logger.error(f"停止目录监控失败:{str(e)}")
self._observer = []
def __is_excluded(self, file_path: Path) -> bool:
"""
是否排除目录
"""
for exclude_dir in self.exclude_dirs.split("\n"):
if exclude_dir and exclude_dir in str(file_path):
return True
return False
def handle_deleted(self, file_path: Path):
"""
处理删除事件
@@ -310,6 +342,9 @@ class RemoveLink(_PluginBase):
for path, inode in self.state_set.copy().items():
if inode == deleted_inode:
file = Path(path)
if self.__is_excluded(file):
logger.info(f"文件 {file} 在不删除目录中,不处理")
continue
# 删除硬链接文件
logger.info(f"删除硬链接文件:{path} inode: {inode}")
file.unlink()