Skip to content

Improve list/download robustness (pagination, retries, per-camera summary)#16

Open
JorisLimousin wants to merge 5 commits intodimme:mainfrom
JorisLimousin:improve-robustness
Open

Improve list/download robustness (pagination, retries, per-camera summary)#16
JorisLimousin wants to merge 5 commits intodimme:mainfrom
JorisLimousin:improve-robustness

Conversation

@JorisLimousin
Copy link

Improve list-videos and download-videos reliability (pagination, retries, per-camera summary)

Summary

This PR improves the reliability and usability of the list-videos and download-videos commands, especially when downloading a large number of videos (e.g., last 30 days) where the Tapo API may intermittently fail.

Changes

  • Pagination for /v2/videos/list

    • Reduces pageSize from 3000 → 1000 to avoid intermittent HTTP 500 errors from the Tapo cloud API
    • Iterates pages until no more results are returned, ensuring all videos are processed
  • Resilient downloads with retry logic

    • Retries failed downloads up to 3 times on ChunkedEncodingError / ConnectionError
    • Continues to the next file on repeated failure instead of aborting the whole script
  • Per-camera result summary

    • Shows, for each camera:

      • Number of successfully downloaded videos
      • Number of videos skipped because they already exist (--overwrite 0)
      • Number of downloads that failed after retrying
    • Helps users quickly validate the outcome and rerun if needed

  • Fixed UTC deprecation warning

    • Replaces datetime.datetime.utcfromtimestamp() with datetime.datetime.fromtimestamp(..., datetime.timezone.utc)
    • Uses timezone-aware datetimes to prevent warnings in Python 3.12+

Impact

These updates significantly improve the stability of large download operations from the Tapo Cloud, especially over slower or inconsistent network connections. The CLI now:

  • Can survive transient network failures
  • Downloads all available recordings correctly
  • Provides clear feedback to the user

Compatibility

  • No breaking changes to existing command usage
  • Fully backwards-compatible with current Tapo CLI workflows

@dimme
Copy link
Owner

dimme commented Nov 16, 2025

This smells like AI

@JorisLimousin
Copy link
Author

The description is and I used it to help me fix these issues but I've been debugging manually and it took me over 2 days to download all videos (I have 2 cameras) with about 7000 each for a month. I actually went to great length to get this PR in because I had no environment setup on that machine, but thought it might help people to get these fixes in so took the time to make the PR. If you have over 3000 videos the default page length simply doesn't work, you get a 500 internal error from Tapo's API.

@JorisLimousin
Copy link
Author

Also got some weird issues with the S3 signed URLs, not exactly sure why they happen but adding retries helps sort it out. Could be related to my own home internet speed though, either way I thought it was still useful to incorporate.

@olivievranska
Copy link

This smells like AI

Honestly, once AI will carry out videos download (instead of me), this piece of code may smell till end of the world (far away)...

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

Successfully merging this pull request may close these issues.

3 participants