fix(fam-edge): WatchProcessor 递归扫描子目录(GDrive 录像按 YYYYMMDDAM/PM 子目录组织)
This commit is contained in:
@@ -35,19 +35,21 @@ class WatchProcessor:
|
||||
self._thread = None
|
||||
|
||||
def _scan_files(self) -> List[str]:
|
||||
"""递归扫描监听目录,返回所有视频文件的完整路径"""
|
||||
if not os.path.isdir(self.local_dir):
|
||||
logger.warning(f"监听目录不存在: {self.local_dir}")
|
||||
return []
|
||||
out = []
|
||||
for fn in sorted(os.listdir(self.local_dir)):
|
||||
if fn.lower().endswith(VIDEO_EXTS):
|
||||
out.append(fn)
|
||||
for root, _dirs, files in os.walk(self.local_dir):
|
||||
for fn in sorted(files):
|
||||
if fn.lower().endswith(VIDEO_EXTS):
|
||||
out.append(os.path.join(root, fn))
|
||||
return out
|
||||
|
||||
def _register_new(self, files: List[str]):
|
||||
for fn in files:
|
||||
for path in files:
|
||||
fn = os.path.basename(path)
|
||||
if self.db.get_video_by_filename(fn) is None:
|
||||
path = os.path.join(self.local_dir, fn)
|
||||
self.db.ensure_video(fn, path, camera_name=self.camera_name)
|
||||
logger.info(f"登记新视频: {fn}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user