first commit

This commit is contained in:
Xarus
2024-05-11 23:30:09 -07:00
commit c0e2bfb6a7
2 changed files with 54 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
download

53
download.sh Executable file
View File

@@ -0,0 +1,53 @@
#!/usr/bin/env bash
DATE_START="2024-05-11 04:00"
URL="https://services.swpc.noaa.gov/images/animations/ovation/north"
mkdir -p ./download
pushd ./download
start_stamp=$[$(date -d "${DATE_START}" +%s --utc)]
now=$[$(date +%s --utc)]
j_1=$[$(date +%s --utc) - 24 * 60 * 60]
istamp=${start_stamp}
istamp=$[${j_1} - ${j_1} % (5 * 60)]
function downloadIfPossible(){
if [ ${2} -lt ${j_1} ]
then
echo "Download Fail: file to old."
else
echo "Download ${1}."
wget "${URL}/${1}" -O "${1}" > /dev/null 2>&1
fi
}
while [ ${istamp} -lt ${now} ]
do
filename=$(date -d@${istamp} "+aurora_N_%Y-%m-%d_%H%M.jpg" --utc)
if [ ! -f "${filename}" ]
then
echo "Downloading: ${filename}."
downloadIfPossible "${filename}" ${istamp}
else
if [ $(stat -c %s "${filename}") -eq 0 ]
then
rm "${filename}"
echo "Downloading (empty file): ${filename}."
downloadIfPossible "${filename}" ${istamp}
else
if ! jpeginfo -c "${filename}" > /dev/null
then
rm "${filename}"
echo "Downloading (corrupted file): ${filename}."
downloadIfPossible "${filename}" ${istamp}
fi
fi
fi
istamp=$[${istamp} + 5 * 60]
done
popd