import requests
from datetime import datetime
import time
CAMERAS = {
"cam1": "http://user:[email protected]/cgi-bin/snapshot.cgi",
"cam2": "http://user:[email protected]/cgi-bin/snapshot.cgi",
"cam3": "http://user:[email protected]/cgi-bin/snapshot.cgi",
"cam4": "http://user:[email protected]/cgi-bin/snapshot.cgi",
}
def capture_snapshot(name, url):
try:
response = requests.get(url, timeout=5)
if response.status_code == 200:
filename = f"{name}_{datetime.now().strftime('%Y%m%d_%H%M%S')}.jpg"
with open(filename, "wb") as f:
f.write(response.content)
print(f"Saved {filename}")
except Exception as e:
print(f"Error capturing from {name}: {e}")
while True:
for name, url in CAMERAS.items():
capture_snapshot(name, url)
time.sleep(3600) # wait 1 hour
import os
import time
import requests
from datetime import datetime
# Example camera URLs (replace with yours)
CAMERAS = {
"cam1": "http://user:[email protected]/cgi-bin/snapshot.cgi",
"cam2": "http://user:[email protected]/cgi-bin/snapshot.cgi",
"cam3": "http://user:[email protected]/cgi-bin/snapshot.cgi",
"cam4": "http://user:[email protected]/cgi-bin/snapshot.cgi",
}
SAVE_DIR = "snapshots"
os.makedirs(SAVE_DIR, exist_ok=True)
def capture_snapshot(name, url):
try:
now = datetime.now()
timestamp = now.strftime("%Y-%m-%d_%H-%M-%S")
date_folder = os.path.join(SAVE_DIR, now.strftime("%Y-%m-%d"))
os.makedirs(date_folder, exist_ok=True)
filename = os.path.join(date_folder, f"{name}_{timestamp}.jpg")
response = requests.get(url, timeout=10)
if response.status_code == 200:
with open(filename, "wb") as f:
f.write(response.content)
print(f"Saved snapshot: {filename}")
else:
print(f"Failed to get snapshot from {name}")
except Exception as e:
print(f"[{name}] Error: {e}")
while True:
print(f"Capturing snapshots at {datetime.now()}")
for name, url in CAMERAS.items():
capture_snapshot(name, url)
print("Sleeping for 1 hour...")
time. Sleep(3600)
jeez, i copied samplenhold 's Hourly folder. but i created it thru by selecting Aux5 and then have it point to a new folder using default BI steps. Then it wanted to repair regen the DB.