From c80a0894bc46f159e43b4fa8d75e912a3e6c5671 Mon Sep 17 00:00:00 2001 From: Colin Powell Date: Fri, 29 Aug 2025 11:07:41 -0400 Subject: [PATCH] [bin] Update cocktail of webcam scripts --- bin/.bin/checkworkmail.py | 11 ++- bin/.bin/webcam-build-timelapses | 126 +++++++++++++++++++++++++++++++ bin/.bin/webcam-capture | 58 +++++++------- bin/.bin/webcam-capture-all | 10 ++- 4 files changed, 170 insertions(+), 35 deletions(-) create mode 100755 bin/.bin/webcam-build-timelapses diff --git a/bin/.bin/checkworkmail.py b/bin/.bin/checkworkmail.py index dd13cdd..f57108a 100755 --- a/bin/.bin/checkworkmail.py +++ b/bin/.bin/checkworkmail.py @@ -30,6 +30,7 @@ SLACK_SENDER = "notification@slack.com" GITHUB_SENDER = "notifications@github.com" JIRA_BASE_URL = os.getenv("JIRA_BASE_URL", "https://yourcompany.atlassian.net/browse") +GH_STATE_AND_TITLE_TO_SKIP = ["New Relic Exporter", "cancelled", "skipped", "succeeded"] # ---------------------- # HELPERS # ---------------------- @@ -179,8 +180,14 @@ def check_notifications(): continue message = format_message(source, subject, body, link) - print(f"Sending {source} notification: {subject}") - send_ntfy_notification(subject, message) + send_notice = True + for exclusion in GH_STATE_AND_TITLE_TO_SKIP: + if exclusion in subject: + print(f"Skipping notification: {subject}") + send_notice = False + if send_notice: + print(f"Sending {source} notification: {subject}") + send_ntfy_notification(subject, message) archive_message(mail, num) mail.expunge() diff --git a/bin/.bin/webcam-build-timelapses b/bin/.bin/webcam-build-timelapses new file mode 100755 index 0000000..66de1e1 --- /dev/null +++ b/bin/.bin/webcam-build-timelapses @@ -0,0 +1,126 @@ +#!/usr/bin/env bash +# run_all_timelapses.sh +# +# Run timelapse creation for a fixed set of webcams, +# collect public URLs, update HTML index, and send one combined ntfy notification. +# +# Requirements: make_timelapse.sh in same folder or PATH + +set -euo pipefail + +# --- Settings --- +BASE_DIR="/media/photos/misc/webcams" +INDEX_FILE="$BASE_DIR/timelapses.html" +WEBCAMS=( + "frontyard" + "basement_table" + "mailbox" + "basement_extension" + "backyard_low" + "backyard_north" + "basement_cape" + "basement_tv" + "backyard" + "bulkhead" + "barn" + "garage" + "birds" + "porch" + "garden" + "diningroom" +) +TIMELAPSE_SCRIPT="/usr/local/bin/make_timelapse" + +NTFY_URL="https://ntfy.unbl.ink/timelapse" +WEB_PREFIX="https://files.lab.unbl.ink" +# ---------------- + +# Yesterday's date +if date -d "yesterday" +%Y >/dev/null 2>&1; then + # GNU date (Linux) + YESTERDAY=$(date -d "yesterday" +"%Y/%m/%d") +else + # BSD date (macOS) + YESTERDAY=$(date -v-1d +"%Y/%m/%d") +fi + +LINKS=() + +for cam in "${WEBCAMS[@]}"; do + TARGET_DIR="$BASE_DIR/$cam/$YESTERDAY" + + if [[ -d "$TARGET_DIR" ]]; then + echo "📷 Processing $cam ($TARGET_DIR)" + OUTPUT=$("$TIMELAPSE_SCRIPT" "$TARGET_DIR") + echo "$OUTPUT" + + LINK="$WEB_PREFIX/$cam/$YESTERDAY/timelapse.mp4" + if [[ -f "$TARGET_DIR/timelapse.mp4" ]]; then + LINKS+=("[$cam] $LINK") + fi + else + echo "⚠️ Skipping $cam (no folder for $YESTERDAY)" + fi +done + +# --- Update HTML index --- +mkdir -p "$BASE_DIR" +if [[ ! -f "$INDEX_FILE" ]]; then + cat >"$INDEX_FILE" < + + + + Webcam Timelapses + + + +

Webcam Timelapses

+ + +EOF +fi + +# Insert new section for yesterday at the top +TMP=$(mktemp) +{ + echo "

$YESTERDAY

" + echo "" + echo "
" +} >"$TMP" + +# Place new block after

line +awk -v block="$(cat "$TMP")" ' + /

/ { print; getline; print; print block; next } + { print } +' "$INDEX_FILE" >"$INDEX_FILE.new" + +mv "$INDEX_FILE.new" "$INDEX_FILE" +rm "$TMP" + +echo "📄 Updated HTML index: $INDEX_FILE" + +# --- Send combined notification --- +if [[ -n "$NTFY_URL" ]] && [[ ${#LINKS[@]} -gt 0 ]]; then + MSG="Timelapses for $YESTERDAY:\n$(printf '%s\n' "${LINKS[@]}")" + curl -s -H "Title: Timelapses complete" \ + -H "Priority: high" \ + -d "$MSG" \ + "$NTFY_URL" >/dev/null || true + echo "📢 Combined notification sent to ntfy." +fi + diff --git a/bin/.bin/webcam-capture b/bin/.bin/webcam-capture index 604fed7..85dbd58 100755 --- a/bin/.bin/webcam-capture +++ b/bin/.bin/webcam-capture @@ -11,55 +11,39 @@ if [ "$1" = "frontyard" ]; then host="loge.local" port=8082 fi -if [ "$1" = "house" ]; then - port=8083 - host="kiviuq.local" +if [ "$1" = "basement_tv" ]; then + port=8081 + host="polydeuces.local" fi if [ "$1" = "basement_cape" ]; then port=8081 host="kiviuq.local" fi -if [ "$1" = "basement_cape_2" ]; then - port=8081 - host="bebhionn.local" -fi if [ "$1" = "bulkhead" ]; then port=8082 host="kiviuq.local" fi if [ "$1" = "backyard" ]; then - port=8084 - host="paaliaq.local" + port=8082 + host="mundilfari.local" fi if [ "$1" = "backyard_low" ]; then - port=8081 - host="paaliaq.local" + port=8083 + host="mundilfari.local" fi if [ "$1" = "backyard_north" ]; then - port=8082 - host="paaliaq.local" + port=8084 + host="mundilfari.local" fi if [ "$1" = "basement_extension" ]; then - port=8083 - host="paaliaq.local" -fi -if [ "$1" = "diningroom" ]; then - port=8082 - host="kari.local" -fi -if [ "$1" = "livingroom" ]; then port=8081 - host="mimas.local" -fi -if [ "$1" = "christmas_tree" ]; then - port=8083 - host="mimas.local" + host="mundilfari.local" fi if [ "$1" = "orchard" ]; then port=8081 host="mobian.local" fi -if [ "$1" = "chicks" ]; then +if [ "$1" = "barn" ]; then port=8083 host="iapetus.local" fi @@ -67,9 +51,25 @@ if [ "$1" = "garage" ]; then port=8082 host="iapetus.local" fi -if [ "$1" = "barn" ]; then +if [ "$1" = "chicks" ]; then port=8081 - host="pan.local" + host="iapetus.local" +fi +if [ "$1" = "porch" ]; then + port=8081 + host="siarnaq.local" +fi +if [ "$1" = "birds" ]; then + port=8082 + host="siarnaq.local" +fi +if [ "$1" = "garden" ]; then + port=8083 + host="siarnaq.local" +fi +if [ "$1" = "diningroom" ]; then + port=8081 + host="kari.local" fi ROOT="/var/photos/misc/webcams" diff --git a/bin/.bin/webcam-capture-all b/bin/.bin/webcam-capture-all index e9c4d58..1c8d08c 100755 --- a/bin/.bin/webcam-capture-all +++ b/bin/.bin/webcam-capture-all @@ -1,16 +1,18 @@ #!/bin/bash /home/powellc/.bin/webcam-capture frontyard -/home/powellc/.bin/webcam-capture basement_table /home/powellc/.bin/webcam-capture mailbox +/home/powellc/.bin/webcam-capture basement_table +/home/powellc/.bin/webcam-capture basement_tv /home/powellc/.bin/webcam-capture basement_extension /home/powellc/.bin/webcam-capture backyard_low /home/powellc/.bin/webcam-capture backyard_north /home/powellc/.bin/webcam-capture basement_cape -/home/powellc/.bin/webcam-capture house /home/powellc/.bin/webcam-capture backyard /home/powellc/.bin/webcam-capture bulkhead -/home/powellc/.bin/webcam-capture orchard -/home/powellc/.bin/webcam-capture chicks /home/powellc/.bin/webcam-capture barn /home/powellc/.bin/webcam-capture garage +/home/powellc/.bin/webcam-capture birds +/home/powellc/.bin/webcam-capture porch +/home/powellc/.bin/webcam-capture garden +/home/powellc/.bin/webcam-capture diningroom