render planespotter thumbs from planespotter

This commit is contained in:
kx1t
2025-03-17 01:53:07 +01:00
parent d0a5258129
commit 3fb048e1f1
2 changed files with 32 additions and 27 deletions

View File

@@ -90,6 +90,7 @@ GET_PS_PHOTO () {
curl -ssL --fail --clobber "$thumb" -o "/usr/share/planefence/persist/planepix/cache/$1.jpg"
echo "$link" > "/usr/share/planefence/persist/planepix/cache/$1.link"
echo "$thumb" > "/usr/share/planefence/persist/planepix/cache/$1.thumb.link"
touch -d "+$((HISTTIME+1)) days" "/usr/share/planefence/persist/planepix/cache/$1.link" "/usr/share/planefence/persist/planepix/cache/$1.thumb.link"
echo "$link"
echo "pfn - $(date) - $(( $(date +%s) - starttime )) secs - $1 - picture retrieved from planespotters.net" >> /tmp/getpi.log
else
@@ -721,6 +722,7 @@ do
# get an image if it exists and if SHOWIMAGES==true
if $SHOWIMAGES; then
# make sure we have an image to show
if [[ ! -f "/usr/share/planefence/persist/planepix/cache/${pa_record[0]}.thumb.link" ]]; then
readarray -t images <<< "$(find /usr/share/planefence/persist/planepix -iname "${pa_record[0]}*.jpg" -print)"
if [[ -z "${images[*]}" ]]; then
# try to get at least 1 image. At this time, we need only 1 image for display only. This saves disk space
@@ -742,7 +744,7 @@ do
fi
if [[ -f "/usr/share/planefence/persist/planepix/cache/${pa_record[0]}.link" ]]; then
IMG="<a href=\"$(<"/usr/share/planefence/persist/planepix/cache/${pa_record[0]}.link")\" target=\"_blank\"><img src=\"imgcache/${pa_record[0]}.jpg\" style=\"width: auto; height: 75px;\"></a>" >&3 # column: image
IMG="<a href=\"$(<"/usr/share/planefence/persist/planepix/cache/${pa_record[0]}.link")\" target=\"_blank\"><img src=\"$(<"/usr/share/planefence/persist/planepix/cache/${pa_record[0]}.thumb.link")\" style=\"width: auto; height: 75px;\"></a>" >&3 # column: image
else
file="$(find /usr/share/planefence/persist/planepix -iname "${pa_record[0]}*.jpg" -print -quit 2>/dev/null || true)"
file="${file##*/}"
@@ -750,6 +752,9 @@ do
IMG="<img src=\"imgcache/${file}\" style=\"width: auto; height: 75px;\">" >&3 # column: image
fi
fi
else
IMG="<a href=\"$(<"/usr/share/planefence/persist/planepix/cache/${pa_record[0]}.link")\" target=\"_blank\"><img src=\"$(<"/usr/share/planefence/persist/planepix/cache/${pa_record[0]}.thumb.link")\" style=\"width: auto; height: 75px;\"></a>" >&3 # column: image
fi
fi
# print aircraft silhouette if it exists

View File

@@ -456,7 +456,7 @@ EOF
fi
if ! chk_disabled "${SHOW_IMAGES}"; then photo="$(GET_PS_PHOTO "${NEWVALUES[0]}")"; else photo=""; fi # get the photo from PlaneSpotters.net. If a notification was sent, it should already be in the cache so this should be quick
if [[ -n "$photo" ]]; then
printf " <td><a href=\"%s\" target=_blank><img src=\"%s\" alt=\"%s\" style=\"width: auto; height: 75px;\"></a></td>\n" "$photo" "imgcache/${NEWVALUES[0]}.jpg" "${NEWVALUES[0]}" >&3
printf " <td><a href=\"%s\" target=_blank><img src=\"%s\" alt=\"%s\" style=\"width: auto; height: 75px;\"></a></td>\n" "$photo" "$(<"/usr/share/planefence/persist/planepix/cache/${NEWVALUES[0]}.thumb.link")" "${NEWVALUES[0]}" >&3
elif ! chk_disabled "${SHOW_IMAGES}"; then
printf " <td></td>\n" >&3
fi