-
Notifications
You must be signed in to change notification settings - Fork 59
/
DownloadRecordings.py
56 lines (49 loc) · 1.82 KB
/
DownloadRecordings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
from pytapo import Tapo
from pytapo.media_stream.downloader import Downloader
import asyncio
import os
# mandatory
outputDir = os.environ.get("OUTPUT") # directory path where videos will be saved
date = os.environ.get("DATE") # date to download recordings for in format YYYYMMDD
host = os.environ.get("HOST") # change to camera IP
password_cloud = os.environ.get("PASSWORD_CLOUD") # set to your cloud password
# optional
window_size = os.environ.get(
"WINDOW_SIZE"
) # set to prefferred window size, affects download speed and stability, recommended: 50
print("Connecting to camera...")
tapo = Tapo(host, "admin", 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"], 2))
+ " / "
+ str(status["total"])
)
else:
statusString += "..."
print(
statusString + (" " * 10) + "\r",
end="",
)
print("")
loop = asyncio.get_event_loop()
loop.run_until_complete(download_async())