news/update.sh

28 lines
482 B
Bash
Raw Permalink Normal View History

#!/bin/bash
curl 'https://api.ngn.tf/v1/news/en' --silent -o feed.atom
if [ $? -ne 0 ]; then
echo "failed to get the feed"
exit 1
fi
for p in posts/*; do
post_title="$(jq -r .title.en "${p}")"
if grep "<title>${post_title}</title>" feed.atom &> /dev/null; then
echo "${p} is already posted, skipping"
continue
fi
echo "posting ${p}"
admin_script add_news "${p}"
if [ $? -ne 0 ]; then
echo "failed to post ${p}"
break
fi
done
rm -f feed.atom