-
Notifications
You must be signed in to change notification settings - Fork 0
/
Timelapse.py
27 lines (24 loc) · 854 Bytes
/
Timelapse.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
import urllib.request
import requests
from datetime import datetime as DateTime
import time
import os
path = os.getcwd() + "/cameras/wz"
print(path)
monat = (time.strftime("%m"))
jahr = (time.strftime("%Y"))
tag = (time.strftime("%d"))
path = path + '/' + jahr + '/' + monat + '/' + tag
if not os.path.exists(path):
print('gibts nicht')
os.makedirs(path)
while True:
url_WZ = 'http://10.0.1.241/api.cgi?cmd=GetMdState&user=admin&password=polier2003'
resp_WZ = requests.get(url_WZ)
data_WZ = resp_WZ.json()
motion_wz = data_WZ[0]['value']['state']
if motion_wz == 1:
Zeit = DateTime.now().strftime('%H_%M_%S')
url = 'http://10.0.1.241/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=polier2003'
urllib.request.urlretrieve(url, path + '/Bild'+Zeit+'.jpg')
time.sleep(2)