Dahua adapter: support shallow folder layout (MM.SS filenames) #135
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Some Dahua cameras use a shallower folder structure than what the adapter currently handles.
Deep format (currently supported):
Example:
AL096ADPAGE8458/2026-08-12/001/jpg/12/24/33[R][0@0][0].jpgShallow format (new cameras):
Example:
AF007D8PAG5B66F/2026-08-12/001/jpg/12/16.36[M][0@0][0].jpgTwo differences:
MM/subdirectory —.jpgfiles sit directly injpg/{HH}/MM.SS[flags]instead of justSS[flags]The adapter must handle both layouts.
Plan
Root cause: The adapter's
_all_snapshots_in_channel()iteratesjpg_root → hh_dir → mm_dir → *.jpg. The new camera has nomm_dir— its.jpgfiles live directly inhh_dir. Similarly,_parse_snapshot_time()assumes the filename stem isSS[flags], but the new camera producesMM.SS[flags].Changes (all in
src/cang/adapters/dahua.py):_parse_snapshot_time()— accept a new parameter or detect the format. If the filename stem contains a., parse it asMM.SSwith minutes from the filename and the hour still from the parent directory. Otherwise fall back to the existingSS-only parse with minutes from the grandparent directory._snapshots_in_minute_dir()— when called for the shallow format, the jpg's parent is the HH directory (not an MM directory), so we need the filename to supply the minutes._all_snapshots_in_channel()— after iterating MM directories (deep format), also check for.jpgfiles directly in eachhh_dir(shallow format). Pass an indicator so the parse function knows which format to use.Approach: The cleanest path is to modify
_parse_snapshot_time()to accept an optionalmm_from_dirparameter. In the shallow format the filename carries minutes, so we don't read the parent dir for minutes. In_all_snapshots_in_channel(), add a fallback that checks for.jpgfiles in thehh_diritself when nomm_dirsubdirectories are found.Branch:
fix/issue-135-shallow-dahua-layoutCommits:
PR:
fj pr createtargetingmain