Closed heschlie closed 9 months ago
So the linter is unhappy about the List
-> Iterable
but in this scenario the typing should be fine so I asked the linter to ignore it. If preferred I can convert the initial declaration of intervals
to:
intervals = (for x in x [( start, end)])
Which returns a Generator
to match the yields
from the call to calculate_intervals()
Just had another look at it, a bit less tired this time :) The way you've implemented it here, the option doesn't just disable the hour rounding; it disables the generator function in general. However, the generator function is needed to split the downloads into 1-hour segments if more than one hour is being downloaded. Otherwise, you risk the Protect console crashing when asking for more than 1 hour of footage at a time.
The way I'd implement it would be to add two options to the generator itself: one that disables the alignment to absolute hours while keeping the 1-hour segment splitting, and a second one that disables the interval generator entirely and returns start and end unchanged (but comes with a warning that this might cause issues/crashes). This, along with some improvements to the generator algorithm itself, should solve the open issues, including your use-case. I've already started experimenting a bit, making good progress so far, and will continue tomorrow. I'll keep you updated. Thanks again for your patience, suggestions and support!
(edit to add) Progress can be seen on this branch: https://github.com/danielfernau/unifi-protect-video-downloader/compare/master...fix-interval-generator
Hi @heschlie!
I've just added the requested feature flags (--disable-alignment
, --disable-splitting
) and also fixed some inconsistencies in the calculations. I'll publish a new version of the tool soon; for now you can use the ':edge' tag of the Docker image to have access to the new features.
Thanks again for your contribution, feel free to suggest additional improvements any time 👍
Adds
--skip-round-to-hour
This leaves the default functionality in place but adds a new flag to skip rounding the clips to the hour(ish)
fixes: #34 #57
I know that the UI can download a time range but for me if that clip is more than ~1m it crashes, it also frequently crashes when scanning over footage, so this is easier/more reliable.