photos: Add bambulab timelapse fetcher
This commit is contained in:
parent
fedc15a1d7
commit
7911bc0d7d
5 changed files with 84 additions and 0 deletions
26
roles/photos/templates/bambulab-fetch.sh
Normal file
26
roles/photos/templates/bambulab-fetch.sh
Normal file
|
@ -0,0 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
# {{ ansible_managed }}
|
||||
|
||||
set -eu
|
||||
|
||||
host={{ bambulab_host }}
|
||||
pass={{ bambulab_key }}
|
||||
dir={{ photos_path }}
|
||||
|
||||
files=$(curl -ksl "ftps://bblp:$pass@$host:990/timelapse/" | grep ^video_)
|
||||
|
||||
for file in $files; do
|
||||
# $file is formatted like 'video_2024-06-27_22-50-12.mp4'
|
||||
echo $file
|
||||
|
||||
day=$(echo $file | sed -nr 's/^video_([0-9]+)-([0-9]+)-([0-9]+)_.*/\1\2\3/p')
|
||||
time=$(echo $file | sed -nr 's/^video_[^_]+_([^\.]+)\.mp4/\1/p')
|
||||
ofile="$dir/$day/bambu_timelapse_$time.mp4"
|
||||
echo $ofile
|
||||
|
||||
if [ ! -e "$ofile" ]; then
|
||||
mkdir -p "$(dirname $ofile)"
|
||||
curl -ks "ftps://bblp:$pass@$host:990/timelapse/$file" -o "$ofile"
|
||||
fi
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue