Merge remote-tracking branch 'origin/main'

# Conflicts:
#	package.json
This commit is contained in:
jxxghp
2024-04-29 20:22:09 +08:00
5 changed files with 131 additions and 44 deletions

View File

@@ -51,11 +51,12 @@
"name": "豆瓣想看",
"description": "同步豆瓣想看数据,自动添加订阅。",
"labels": "订阅",
"version": "1.7",
"version": "1.8",
"icon": "douban.png",
"author": "jxxghp",
"level": 2,
"history": {
"v1.8": "不同步在看条目",
"v1.7": "增强API安全性",
"v1.6": "同步历史记录支持手动删除需要主程序升级至v1.8.4+版本",
"v1.5": "豆瓣信息识别后直接添加订阅,不进行搜索下载"
@@ -230,12 +231,13 @@
"name": "IYUU自动辅种",
"description": "基于IYUU官方Api实现自动辅种。",
"labels": "做种,IYUU",
"version": "1.6",
"version": "1.7",
"icon": "IYUU.png",
"author": "jxxghp",
"level": 2,
"history": {
"v1.6": "适配馒头最新变化需要升级至v1.8.5+版本且维护好Authorization",
"v1.7": "适配馒头最新变化需要升级至v1.8.5+版本且维护好Authorization",
"v1.6": "增加不辅种小体积种子功能",
"v1.5": "支持馒头新架构辅种"
}
},
@@ -350,11 +352,12 @@
"name": "MoviePilot更新推送",
"description": "MoviePilot推送release更新通知、自动重启。",
"labels": "消息通知,自动更新",
"version": "1.3",
"version": "1.4",
"icon": "Moviepilot_A.png",
"author": "thsrite",
"level": 1,
"history": {
"v1.4": "兼容更新内容带版本号的情况",
"v1.3": "增加前端版本更新检查需要主程序升级至v1.8.4+版本"
}
},
@@ -464,11 +467,12 @@
"name": "清理硬链接",
"description": "监控目录内文件被删除时,同步删除监控目录内所有和它硬链接的文件",
"labels": "文件整理",
"version": "1.9",
"version": "2.0",
"icon": "Ombi_A.png",
"author": "DzAvril",
"level": 1,
"history": {
"v2.0": "联动删除种子,需安装插件[下载器助手]并打开监听源文件事件",
"v1.9": "增加清理刮削文件功能beta",
"v1.8": "增加清理空目录功能beta",
"v1.7": "修复因未监测重命名事件导致的清理硬链接失败的问题",

View File

@@ -34,7 +34,7 @@ class DoubanSync(_PluginBase):
# 插件图标
plugin_icon = "douban.png"
# 插件版本
plugin_version = "1.7"
plugin_version = "1.8"
# 插件作者
plugin_author = "jxxghp"
# 作者主页
@@ -520,8 +520,8 @@ class DoubanSync(_PluginBase):
try:
dtype = result.get("title", "")[:2]
title = result.get("title", "")[2:]
if dtype not in ["想看", "在看"]:
logger.info(f'标题:{title},非想看/在看数据,跳过')
if dtype not in ["想看"]:
logger.info(f'标题:{title},非想看数据,跳过')
continue
if not result.get("link"):
logger.warn(f'标题:{title},未获取到链接,跳过')

View File

@@ -64,6 +64,7 @@ class IYUUAutoSeed(_PluginBase):
_notify = False
_nolabels = None
_nopaths = None
_size = None
_clearcache = False
# 退出事件
_event = Event()
@@ -107,6 +108,7 @@ class IYUUAutoSeed(_PluginBase):
self._notify = config.get("notify")
self._nolabels = config.get("nolabels")
self._nopaths = config.get("nopaths")
self._size = float(config.get("size")) if config.get("size") else 0
self._clearcache = config.get("clearcache")
self._permanent_error_caches = [] if self._clearcache else config.get("permanent_error_caches") or []
self._error_caches = [] if self._clearcache else config.get("error_caches") or []
@@ -329,7 +331,23 @@ class IYUUAutoSeed(_PluginBase):
{
'component': 'VCol',
'props': {
'cols': 12
'cols': 6
},
'content': [
{
'component': 'VTextField',
'props': {
'model': 'size',
'label': '辅种体积大于(GB)',
'placeholder': '只有大于该值的才辅种'
}
}
]
},
{
'component': 'VCol',
'props': {
'cols': 6
},
'content': [
{
@@ -410,7 +428,8 @@ class IYUUAutoSeed(_PluginBase):
"downloaders": [],
"sites": [],
"nopaths": "",
"nolabels": ""
"nolabels": "",
"size": ""
}
def get_page(self) -> List[dict]:
@@ -428,6 +447,7 @@ class IYUUAutoSeed(_PluginBase):
"notify": self._notify,
"nolabels": self._nolabels,
"nopaths": self._nopaths,
"size": self._size,
"success_caches": self._success_caches,
"error_caches": self._error_caches,
"permanent_error_caches": self._permanent_error_caches
@@ -504,6 +524,13 @@ class IYUUAutoSeed(_PluginBase):
break
if is_skip:
continue
# 体积排除辅种
torrent_size = self.__get_torrent_size(torrent, downloader) / 1024 / 1024 / 1024
if self._size and torrent_size < self._size:
logger.info(f"种子 {hash_str} 大小:{torrent_size:.2f}GB小于设定 {self._size}GB跳过 ...")
continue
hash_strs.append({
"hash": hash_str,
"save_path": save_path
@@ -887,6 +914,17 @@ class IYUUAutoSeed(_PluginBase):
print(str(e))
return ""
@staticmethod
def __get_torrent_size(torrent: Any, dl_type: str):
"""
获取种子大小 int bytes
"""
try:
return torrent.get("total_size") if dl_type == "qbittorrent" else torrent.total_size
except Exception as e:
print(str(e))
return ""
def __get_download_url(self, seed: dict, site: CommentedMap, base_url: str):
"""
拼装种子下载链接
@@ -971,7 +1009,8 @@ class IYUUAutoSeed(_PluginBase):
flags=re.IGNORECASE)
return f"{site.get('url')}{download_url}"
except Exception as e:
logger.warn(f"{site.get('name')} Url转换失败{str(e)}site_url={site.get('url')}base_url={base_url}, seed={seed}")
logger.warn(
f"{site.get('name')} Url转换失败{str(e)}site_url={site.get('url')}base_url={base_url}, seed={seed}")
return self.__get_torrent_url_from_page(seed=seed, site=site)
def __get_torrent_url_from_page(self, seed: dict, site: dict):

View File

@@ -22,7 +22,7 @@ class MoviePilotUpdateNotify(_PluginBase):
# 插件图标
plugin_icon = "Moviepilot_A.png"
# 插件版本
plugin_version = "1.3"
plugin_version = "1.4"
# 插件作者
plugin_author = "thsrite"
# 作者主页
@@ -89,22 +89,10 @@ class MoviePilotUpdateNotify(_PluginBase):
logger.info(f"发现MoviePilot后端更新{release_version} {description} {update_time}")
# 推送更新消息
if self._notify:
# 将时间字符串转为datetime对象
dt = datetime.datetime.strptime(update_time, "%Y-%m-%dT%H:%M:%SZ")
# 设置时区
timezone = pytz.timezone(settings.TZ)
dt = dt.replace(tzinfo=timezone)
# 将datetime对象转换为带时区的字符串
update_time = dt.strftime("%Y-%m-%d %H:%M:%S")
self.post_message(
mtype=NotificationType.SiteMessage,
title="【MoviePilot后端更新通知】",
text=f"{release_version} \n"
f"\n"
f"{description} \n"
f"\n"
f"{update_time}")
self.__notify_update(update_time=update_time,
release_version=release_version,
description=description,
mtype="后端")
return True
@@ -125,6 +113,18 @@ class MoviePilotUpdateNotify(_PluginBase):
logger.info(f"发现MoviePilot前端更新{release_version} {description} {update_time}")
# 推送更新消息
self.__notify_update(update_time=update_time,
release_version=release_version,
description=description,
mtype="前端")
return True
def __notify_update(self, update_time, release_version, description, mtype):
"""
推送更新消息
"""
# 推送更新消息
if self._notify:
# 将时间字符串转为datetime对象
@@ -134,16 +134,12 @@ class MoviePilotUpdateNotify(_PluginBase):
dt = dt.replace(tzinfo=timezone)
# 将datetime对象转换为带时区的字符串
update_time = dt.strftime("%Y-%m-%d %H:%M:%S")
if not description.startswith(release_version):
description = f"{release_version}\n\n{description}"
self.post_message(
mtype=NotificationType.SiteMessage,
title="【MoviePilot前端更新通知】",
text=f"{release_version} \n"
f"\n"
f"{description} \n"
f"\n"
f"{update_time}")
return True
title=f"【MoviePilot{mtype}更新通知】",
text=f"{description}\n\n{update_time}")
@staticmethod
def __get_release_version():

View File

@@ -11,6 +11,8 @@ from watchdog.observers import Observer
from app.log import logger
from app.plugins import _PluginBase
from app.schemas import NotificationType
from app.core.event import eventmanager
from app.schemas.types import EventType
state_lock = threading.Lock()
@@ -106,7 +108,7 @@ class RemoveLink(_PluginBase):
# 插件图标
plugin_icon = "Ombi_A.png"
# 插件版本
plugin_version = "1.9"
plugin_version = "2.0"
# 插件作者
plugin_author = "DzAvril"
# 作者主页
@@ -125,6 +127,7 @@ class RemoveLink(_PluginBase):
_enabled = False
_notify = False
_delete_scrap_infos = False
_delete_torrents = False
_observer = []
# 监控目录的文件列表
state_set: Dict[str, int] = {}
@@ -138,6 +141,7 @@ class RemoveLink(_PluginBase):
self.exclude_dirs = config.get("exclude_dirs") or ""
self.exclude_keywords = config.get("exclude_keywords") or ""
self._delete_scrap_infos = config.get("delete_scrap_infos")
self._delete_torrents = config.get("delete_torrents")
# 停止现有任务
self.stop_service()
@@ -202,7 +206,7 @@ class RemoveLink(_PluginBase):
"content": [
{
"component": "VCol",
"props": {"cols": 12, "md": 4},
"props": {"cols": 12, "md": 6},
"content": [
{
"component": "VSwitch",
@@ -215,7 +219,7 @@ class RemoveLink(_PluginBase):
},
{
"component": "VCol",
"props": {"cols": 12, "md": 4},
"props": {"cols": 12, "md": 6},
"content": [
{
"component": "VSwitch",
@@ -226,9 +230,14 @@ class RemoveLink(_PluginBase):
}
],
},
],
},
{
"component": "VRow",
"content": [
{
"component": "VCol",
"props": {"cols": 12, "md": 4},
"props": {"cols": 12, "md": 6},
"content": [
{
"component": "VSwitch",
@@ -239,6 +248,19 @@ class RemoveLink(_PluginBase):
}
],
},
{
"component": "VCol",
"props": {"cols": 12, "md": 6},
"content": [
{
"component": "VSwitch",
"props": {
"model": "delete_torrents",
"label": "联动删除种子",
},
}
],
},
],
},
{
@@ -317,7 +339,7 @@ class RemoveLink(_PluginBase):
"props": {
"type": "info",
"variant": "tonal",
"text": "监控目录如有多个需换行,源目录和硬链接目录都需要添加到监控目录中;如需实现删除硬链接时不删除源文件,可把源文件目录配置到不删除目录中。",
"text": "联动删除种子需安装插件[下载器助手]并打开监听源文件事件",
},
}
],
@@ -338,6 +360,22 @@ class RemoveLink(_PluginBase):
}
],
},
{
"component": "VCol",
"props": {
"cols": 12,
},
"content": [
{
"component": "VAlert",
"props": {
"type": "info",
"variant": "tonal",
"text": "监控目录如有多个需换行,源目录和硬链接目录都需要添加到监控目录中;如需实现删除硬链接时不删除源文件,可把源文件目录配置到不删除目录中。",
},
}
],
},
],
},
],
@@ -413,7 +451,7 @@ class RemoveLink(_PluginBase):
for file in path.parent.iterdir():
if file.name.startswith(name_prefix):
file.unlink()
logger.info(f'删除刮削文件:{file}')
logger.info(f"删除刮削文件:{file}")
# 清理空目录
self.delete_empty_folders(path)
@@ -438,7 +476,7 @@ class RemoveLink(_PluginBase):
# 清除目录下所有文件
for file in parent_path.iterdir():
file.unlink()
logger.info(f'删除刮削文件:{file}')
logger.info(f"删除刮削文件:{file}")
if not os.listdir(parent_path):
os.rmdir(parent_path)
@@ -462,6 +500,11 @@ class RemoveLink(_PluginBase):
with state_lock:
# 清理刮削文件
self.delete_scrap_infos(file_path)
if self._delete_torrents:
# 发送事件
eventmanager.send_event(
EventType.DownloadFileDeleted, {"src": str(file_path)}
)
# 删除的文件inode
deleted_inode = self.state_set.get(str(file_path))
if not deleted_inode:
@@ -482,12 +525,17 @@ class RemoveLink(_PluginBase):
file.unlink()
# 清理刮削文件
self.delete_scrap_infos(file_path)
if self._delete_torrents:
# 发送事件
eventmanager.send_event(
EventType.DownloadFileDeleted, {"src": str(file_path)}
)
if self._notify:
self.post_message(
mtype=NotificationType.SiteMessage,
title=f"【清理硬链接】",
text=f"监控到删除源文件:[{file_path}]\n"
f"同步删除硬链接文件:[{path}]",
f"同步删除硬链接文件:[{path}]",
)
except Exception as e:
logger.error(