Fall back to FILE_FIND when cmd 272 VOD search returns 405 - #185
Open
florian-bailly wants to merge 1 commit into
Open
Fall back to FILE_FIND when cmd 272 VOD search returns 405#185florian-bailly wants to merge 1 commit into
florian-bailly wants to merge 1 commit into
Conversation
Some firmwares (Reolink E1 Pro, Argus battery cameras) do not implement the cmd 272 VOD search and answer it with HTTP 405. Fall back to the Baichuan FILE_FIND protocol (cmd 14 open / 15 list / 16 close) to enumerate the SD-card recordings on those devices. Closes starkillerOG#150. The firmware searches a single calendar day per FILE_FIND open (a multi-day window returns only the start day), so the search iterates day-by-day and merges the results, de-duplicating clips by name across days. The recordType/alarmType -> VOD_trigger classification is factored into a shared VOD_TRIGGER_TOKENS table and _classify_vod_triggers helper, used by both the cmd 272 and FILE_FIND paths so they classify identically (this also gives FILE_FIND the full trigger set, incl. cry/crossline/intrusion/...). Live-verified on an Argus PT Ultra (fw v3.0.0.3911): a 12-day window now returns 123 clips across 11 days. Tests cover the 405 fallback, per-day iteration, multi-page paging, cross-day de-dup, days without recordings, the full trigger table, malformed entries, 64-bit sizes, and close-failure tolerance.
florian-bailly
force-pushed
the
fix-search-vod-type-405-filefind
branch
from
July 26, 2026 14:49
4e9c367 to
baddcb4
Compare
Author
|
hello @starkillerOG This is a small PR to fix the listing cmd not supported on (some?) camera batteries. It's targeted on the 405 return for the cmd 272, so regressions are quite unlikely on other models. It ran successfully on my Argus PT Ultra. This issue was also reported by #150 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
search_vod_typeuses the Baichuan cmd 272 VOD search, which the Reolink E1 Pro and Argus battery cameras do not implement — they reject it with status 405, so the call raisesApiErrorand no recordings can be listed (#150).This catches the 405 on the first request and falls back to the generic FILE_FIND search (cmd 14 open / 15 list / 16 close), which returns the same SD-card recordings. The public API and return type of
search_vod_typeare unchanged, so existing callers keep working and now also succeed on these models.How it works
ApiError(rspCode=405)on the first request switches to FILE_FIND; any otherApiErrorstill propagates.[start.date(), end.date()](_filefind_day) and merges the results, de-duplicating clips by name across days (a clip straddling midnight is returned by both days' searches).<recordType>/alarmType →VOD_triggermapping already existed inline in the cmd 272 path. Both paths now share a singleVOD_TRIGGER_TOKENStable +_classify_vod_triggershelper, so they classify identically and FILE_FIND gets the full trigger set (motion / io / person / face / vehicle / animal / doorbell / package / crying / crossline / intrusion / linger / forgotten- & taken-item).The commented-out FILE_FIND sketch previously left in
search_vod_typeis replaced by this working implementation.Warning
Known smell — paging termination is coupled to de-dup. In
_filefind_day, a singlenew_filesflag decides both "did this page add clips?" and "should paging continue?". A page that is entirely already-seenclips, or entirely malformed, breaks the loop early even if later pages still hold new clips.With a sequential per-day handle this should not happen in practice, which is why it is shipped as-is — but it is a real coupling. If preferred, I can split termination from de-dup (break only on a genuinely empty
<FileInfo>set). Say the word and I'll adjust.Test plan
tests/test_baichuan_filefind_fallback.py(10 tests / 16 subtests):ApiErrorstill propagates (no accidental swallowing);recordTypetoken maps to itsVOD_trigger;sizeL + (sizeH << 32);Verified on real hardware — Argus PT Ultra (fw
v3.0.0.3911): a 12-day window returned 123 clips across 11 days (MOTION/PERSON/ANIMAL) instead of raising.black --check,isort,pylint(10.00/10) andmypypass on the changed module.Closes #150.
🤖 Generated with Claude Code