itsb/feedgen.sh

15 lines
617 B
Bash
Executable File

#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
echo Building to $DIR/feeds
mkdir -p $DIR/feeds
if ! command -v json2xml >/dev/null 2>&1; then
PATH="$DIR/bin:$PATH"
fi
echo Building ATSB feed to $DIR/feeds/atsb.xml
curl -s 'https://www.atsb.gov.au/publications/safety-investigation-reports/?s=1&sort=OccurrenceReleaseDate&sortAscending=descending&investigationStatus=Completed,Discontinued&printAll=true' \
| pup 'table.selectable_grid tr:not(.header) json{}' \
| jq -f $DIR/jq/atsb.jq \
| json2xml > $DIR/feeds/atsb.xml.new && mv $DIR/feeds/atsb.xml.new $DIR/feeds/atsb.xml