Created
February 3, 2024 21:42
-
-
Save im-noob/878e49e0b07f6ea388d6b4915fd75649 to your computer and use it in GitHub Desktop.
Tapo Camera TP Link Recording Download in python
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
from pytapo import Tapo | |
from pytapo.media_stream.downloader import Downloader | |
import asyncio | |
import os | |
#sudo apt install ffmpeg | |
#python3 -m pip install pytapo | |
#https://github.com/JurajNyiri/pytapo | |
# mandatory | |
outputDir = '/home/user/Downloads/' # directory path where videos will be saved | |
date = '20240203' # date to download recordings for in format YYYYMMDD | |
host = "192.168.0.1" # change to camera IP | |
user = 'admin' | |
password_cloud = "CLOUD_PASS" # set to your cloud password | |
tapo = Tapo(host, user, password_cloud) | |
print(tapo.getBasicInfo()) | |
# optional | |
window_size = 50 # set to prefferred window size, affects download speed and stability, recommended: 50 | |
print("Connecting to camera...") | |
tapo = Tapo(host, user, password_cloud, password_cloud) | |
async def download_async(): | |
print("Getting recordings...") | |
recordings = tapo.getRecordings(date) | |
timeCorrection = tapo.getTimeCorrection() | |
for recording in recordings: | |
for key in recording: | |
downloader = Downloader( | |
tapo, | |
recording[key]["startTime"], | |
recording[key]["endTime"], | |
timeCorrection, | |
outputDir, | |
None, | |
False, | |
window_size, | |
) | |
async for status in downloader.download(): | |
statusString = status["currentAction"] + " " + status["fileName"] | |
if status["progress"] > 0: | |
statusString += ( | |
": " | |
+ str(round(status["progress"])) | |
+ " / " | |
+ str(status["total"]) | |
) | |
else: | |
statusString += "..." | |
print( | |
statusString + (" " * 10) + "\r", | |
end="", | |
) | |
print("") | |
# break | |
# break | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(download_async()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment