Files
sky-cam/sunrise.py
T
Claude ae40b898f6 Fix executable bits and add camera name to 4-seasons notifications
- chmod +x all *.sh and *.py in install.sh so permissions survive git checkouts
- Fix daily_sunrise_video.sh and Python scripts missing executable bit
- Add [CAM_NAME] prefix to all 4-seasons.sh notify.sh calls so multi-camera
  setups show which camera each daily clip came from
- Include camera name in output filename: YYYY-MM-DD_<cam>_MvtN-DayXofY-final.mp4

https://claude.ai/code/session_01C4jbd3waXG3eKZYbGUjLUQ
2026-04-22 12:56:37 +00:00

35 lines
983 B
Python
Executable File

from datetime import datetime
import pathlib
import pytz
from suntime import Sun
# Locate sky-cam.conf next to this script (works regardless of cwd).
_here = pathlib.Path(__file__).resolve().parent
def _read_conf(path):
conf = {}
with open(path) as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
k, v = line.split('=', 1)
conf[k.strip()] = v.strip()
return conf
conf = _read_conf(_here / 'sky-cam.conf')
for _key in ('LATITUDE', 'LONGITUDE', 'TIMEZONE'):
if _key not in conf:
raise SystemExit(f"sunrise.py: {_key} not set in sky-cam.conf")
latitude = float(conf['LATITUDE'])
longitude = float(conf['LONGITUDE'])
tz = pytz.timezone(conf['TIMEZONE'])
sun = Sun(latitude, longitude)
now = datetime.now(tz)
sunrise_utc = sun.get_sunrise_time(now)
sunrise_time = sunrise_utc.astimezone(tz)
print(sunrise_time.strftime('%Y-%m-%d %H:%M:%S'))