Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid duplicate download of recordings (happens when last recording is downloaded) #93

Open
peterstamps opened this issue Dec 4, 2023 · 0 comments

Comments

@peterstamps
Copy link

peterstamps commented Dec 4, 2023

When downloading in a continues process, at the latest Tapo recording, the module session.py reports something like: "Received response with no or invalid session information. can't deliver" and then a retry is started and the file is downloaded. However I get two downloaded files with the same start time of the recording but with different end times (some seconds more).

I adapted the downloader.py as follows (skipping the retry and save the file. When I inspect the file the whole recording is there. The segment length was probably smaller then anticipated, but the whole file (recording) was delivered.
This work around solves that issue. I do not miss any seconds of the original recording!

                if downloading:
                    # Peter commented this retry block as it was creating non-stop duplicates. 
                    # A shorter and a longer version, both had the same start time but different end times of recording)
                    # Handle case where camera randomly stopped responding
                    #if not downloadedFull and not retry:
                    #    currentAction = "Retrying"
                    #    yield {
                    #        "currentAction": currentAction,
                    #        "fileName": fileName,
                    #        "progress": 0,
                    #        "total": 0,
                    #    }
                    #    retry = True
                    #else:
                    if not downloadedFull:
                        detectedLength = convert.getLength()
                        if (
                            detectedLength >= segmentLength - 5
                        ):  # workaround for weird cases where the recording is a bit shorter than reported
                            downloadedFull = True
                            currentAction = "Converting [shorter]"
                            yield {
                                "currentAction": currentAction,
                                "fileName": fileName,
                                "progress": 0,
                                "total": 0,
                            }
                            convert.save(fileName, segmentLength, method)
                            yield {
                                "currentAction": "Ready Converting [shorter]",
                                "fileName": fileName,
                                "progress": 0,
                                "total": segmentLength,
                            }                                  
                        else:
                            currentAction = "Giving up"
                            yield {
                                "currentAction": currentAction,
                                "fileName": fileName,
                                "progress": 0,
                                "total": 0,
                            }
                        downloading = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant