Merge pull request #28 from thsrite/main
This commit is contained in:
commit
ec62be7783
@ -75,7 +75,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
self._enabled = config.get("enabled")
|
self._enabled = config.get("enabled")
|
||||||
self._cron = config.get("cron")
|
self._cron = config.get("cron")
|
||||||
self._notify = config.get("notify")
|
self._notify = config.get("notify")
|
||||||
self._queue_cnt = config.get("queue_cnt")
|
self._queue_cnt = config.get("queue_cnt") or 5
|
||||||
self._sign_sites = config.get("sign_sites")
|
self._sign_sites = config.get("sign_sites")
|
||||||
|
|
||||||
# 加载模块
|
# 加载模块
|
||||||
@ -385,7 +385,7 @@ class AutoSignIn(_PluginBase):
|
|||||||
|
|
||||||
# 执行签到
|
# 执行签到
|
||||||
logger.info("开始执行签到任务 ...")
|
logger.info("开始执行签到任务 ...")
|
||||||
with ThreadPool(min(len(sign_sites), self._queue_cnt)) as p:
|
with ThreadPool(min(len(sign_sites), int(self._queue_cnt))) as p:
|
||||||
status = p.map(self.signin_site, sign_sites)
|
status = p.map(self.signin_site, sign_sites)
|
||||||
|
|
||||||
if status:
|
if status:
|
||||||
|
@ -88,43 +88,44 @@ class DirMonitor(_PluginBase):
|
|||||||
# 停止现有任务
|
# 停止现有任务
|
||||||
self.stop_service()
|
self.stop_service()
|
||||||
|
|
||||||
# 启动任务
|
if self._enabled:
|
||||||
monitor_dirs = self._monitor_dirs.split("\n")
|
# 启动任务
|
||||||
if not monitor_dirs:
|
monitor_dirs = self._monitor_dirs.split("\n")
|
||||||
return
|
if not monitor_dirs:
|
||||||
for mon_path in monitor_dirs:
|
return
|
||||||
if not mon_path:
|
for mon_path in monitor_dirs:
|
||||||
continue
|
if not mon_path:
|
||||||
# 检查目录是不是媒体库目录的子目录
|
continue
|
||||||
if Path(mon_path).is_relative_to(settings.LIBRARY_PATH):
|
# 检查目录是不是媒体库目录的子目录
|
||||||
logger.warn(f"{mon_path} 是媒体库目录的子目录,无法监控")
|
if Path(mon_path).is_relative_to(settings.LIBRARY_PATH):
|
||||||
self.systemmessage.put(f"{mon_path} 是媒体库目录的子目录,无法监控")
|
logger.warn(f"{mon_path} 是媒体库目录的子目录,无法监控")
|
||||||
continue
|
self.systemmessage.put(f"{mon_path} 是媒体库目录的子目录,无法监控")
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if self._mode == "compatibility":
|
if self._mode == "compatibility":
|
||||||
# 兼容模式,目录同步性能降低且NAS不能休眠,但可以兼容挂载的远程共享目录如SMB
|
# 兼容模式,目录同步性能降低且NAS不能休眠,但可以兼容挂载的远程共享目录如SMB
|
||||||
observer = PollingObserver(timeout=10)
|
observer = PollingObserver(timeout=10)
|
||||||
else:
|
else:
|
||||||
# 内部处理系统操作类型选择最优解
|
# 内部处理系统操作类型选择最优解
|
||||||
observer = Observer(timeout=10)
|
observer = Observer(timeout=10)
|
||||||
self._observer.append(observer)
|
self._observer.append(observer)
|
||||||
observer.schedule(FileMonitorHandler(mon_path, self), path=mon_path, recursive=True)
|
observer.schedule(FileMonitorHandler(mon_path, self), path=mon_path, recursive=True)
|
||||||
observer.daemon = True
|
observer.daemon = True
|
||||||
observer.start()
|
observer.start()
|
||||||
logger.info(f"{mon_path} 的目录监控服务启动")
|
logger.info(f"{mon_path} 的目录监控服务启动")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
err_msg = str(e)
|
err_msg = str(e)
|
||||||
if "inotify" in err_msg and "reached" in err_msg:
|
if "inotify" in err_msg and "reached" in err_msg:
|
||||||
logger.warn(f"目录监控服务启动出现异常:{err_msg},请在宿主机上(不是docker容器内)执行以下命令并重启:"
|
logger.warn(f"目录监控服务启动出现异常:{err_msg},请在宿主机上(不是docker容器内)执行以下命令并重启:"
|
||||||
+ """
|
+ """
|
||||||
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
|
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
|
||||||
echo fs.inotify.max_user_instances=524288 | sudo tee -a /etc/sysctl.conf
|
echo fs.inotify.max_user_instances=524288 | sudo tee -a /etc/sysctl.conf
|
||||||
sudo sysctl -p
|
sudo sysctl -p
|
||||||
""")
|
""")
|
||||||
else:
|
else:
|
||||||
logger.error(f"{mon_path} 启动目录监控失败:{err_msg}")
|
logger.error(f"{mon_path} 启动目录监控失败:{err_msg}")
|
||||||
self.systemmessage.put(f"{mon_path} 启动目录监控失败:{err_msg}")
|
self.systemmessage.put(f"{mon_path} 启动目录监控失败:{err_msg}")
|
||||||
|
|
||||||
def file_change_handler(self, event, text: str, event_path: str):
|
def file_change_handler(self, event, text: str, event_path: str):
|
||||||
"""
|
"""
|
||||||
|
@ -500,7 +500,6 @@ class MediaSyncDel(_PluginBase):
|
|||||||
mtype = match[1]
|
mtype = match[1]
|
||||||
name = match[2]
|
name = match[2]
|
||||||
path = match[3]
|
path = match[3]
|
||||||
mid = match[4]
|
|
||||||
|
|
||||||
year = None
|
year = None
|
||||||
year_pattern = r'\(\d+\)'
|
year_pattern = r'\(\d+\)'
|
||||||
@ -542,7 +541,6 @@ class MediaSyncDel(_PluginBase):
|
|||||||
"name": name,
|
"name": name,
|
||||||
"year": year,
|
"year": year,
|
||||||
"path": path,
|
"path": path,
|
||||||
"id": mid,
|
|
||||||
"season": season,
|
"season": season,
|
||||||
"episode": episode,
|
"episode": episode,
|
||||||
}
|
}
|
||||||
@ -571,7 +569,7 @@ class MediaSyncDel(_PluginBase):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
# 正则解析删除的媒体信息
|
# 正则解析删除的媒体信息
|
||||||
pattern = r'(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{3}) Info App: Removing item from database, Type: (\w+), Name: (.*), Path: (.*), Id: (\d+)'
|
pattern = r'\[(.*?)\].*?Removing item, Type: "(.*?)", Name: "(.*?)", Path: "(.*?)"'
|
||||||
matches = re.findall(pattern, log_res.text)
|
matches = re.findall(pattern, log_res.text)
|
||||||
|
|
||||||
del_medias = []
|
del_medias = []
|
||||||
@ -585,7 +583,6 @@ class MediaSyncDel(_PluginBase):
|
|||||||
mtype = match[1]
|
mtype = match[1]
|
||||||
name = match[2]
|
name = match[2]
|
||||||
path = match[3]
|
path = match[3]
|
||||||
mid = match[4]
|
|
||||||
|
|
||||||
year = None
|
year = None
|
||||||
year_pattern = r'\(\d+\)'
|
year_pattern = r'\(\d+\)'
|
||||||
@ -627,7 +624,6 @@ class MediaSyncDel(_PluginBase):
|
|||||||
"name": name,
|
"name": name,
|
||||||
"year": year,
|
"year": year,
|
||||||
"path": path,
|
"path": path,
|
||||||
"id": mid,
|
|
||||||
"season": season,
|
"season": season,
|
||||||
"episode": episode,
|
"episode": episode,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user