From 5d3d77ed6c2b0eabac1a2027b3e975a238af8ed1 Mon Sep 17 00:00:00 2001 From: Dennis Reimann Date: Tue, 13 Oct 2020 07:47:37 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20Update=20feed=20check?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tasks/check-feed.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tasks/check-feed.sh b/tasks/check-feed.sh index 551b648b1c5..c67faafc383 100755 --- a/tasks/check-feed.sh +++ b/tasks/check-feed.sh @@ -5,13 +5,17 @@ log="$dir/check-feed.log" file="$dir/.check-feed" prev=$(cat $file) feed=$(curl -s https://anchor.fm/s/d8d3c38/podcast/rss) -date=$(echo "$feed" | awk 'BEGIN { FS="<|>"; RS="\n" }; { if ($0 ~ /lastBuildDate/) print $3}') +dates=$(echo "$feed" | awk 'BEGIN { FS="<|>"; RS="\n" }; { if ($0 ~ /pubDate/) print $3}') +count=$(echo "$dates" | wc -l | xargs) +date=$(echo "$dates" | head -n 1) +checksum="$count - $date" -if [[ ! -z "$date" ]]; then + +if [[ ! -z "$checksum" ]]; then echo "Latest build: $prev" - echo "Last updated: $date" + echo "Last updated: $checksum" - if [[ "$date" != "$prev" ]]; then + if [[ "$checksum" != "$prev" ]]; then if [[ ! -z "$GH_PAT" ]]; then echo "-> Triggering new build" curl -X POST https://api.github.com/repos/Einundzwanzig-Podcast/einundzwanzig.space/dispatches \ @@ -26,5 +30,5 @@ if [[ ! -z "$date" ]]; then fi fi - echo $date > $file + echo $checksum > $file fi