Files
dotfiles/bin/.bin/nyt

18 lines
595 B
Bash
Executable File

#!/bin/bash
BASEDIR="/var/photos/misc/nytimes"
DATE=$(date +"%Y-%m-%d")
TMPFILE=/tmp/nyt.pdf
OUTFILE=$BASEDIR/$DATE.jpg
if test -f "$OUTFILE"; then
echo "NYT front page already found. Not downloading."
else
DATEPATH=$(date +"%Y/%m/%d")
curl -o /tmp/nyt.pdf -L https://static01.nyt.com/images/$DATEPATH/nytfrontpage/scan.pdf
convert -density 150 -quality 75 $TMPFILE $OUTFILE
ln -sf $OUTFILE /var/lib/weewx/www/today.jpg
ln -sf $OUTFILE $BASEDIR/today.jpg
curl -H "X-Title: NYT headlines today" -d "https://files.lab.unbl.ink/nytimes/today.jpg" https://ntfy.unbl.ink/news
rm $TMPFILE
fi