#!/bin/sh kanau() { id="kanau" host="https://kanau.org" validateFeed "$id" "$host" cat $tmp \ | shup "article" "h2[title]" "a" \ | grep "" | cut -d '"' -f 1) # Check if post/entry/article already exist [ ! -z "$(grep "$url" "$dir/feeds/$id.xml")" ] && echo "Entry already exists." # Proceed if doesn't exist [ -z "$(grep "$url" "$dir/feeds/$id.xml")" ] && curl -s $url > $tmp \ && title=$(cat $tmp | shup "title" | sed "s///" | sed "s/<\/title>//" | sed "s/^\s*//" | grep "\S") \ && pubdate=$(cat $tmp | grep "<meta\sproperty=\"article:published_time\"" | grep -o "[0-9]*-[0-9]*-[0-9]*T.*0[0-9]:00" | xargs -i date -d {} -R) \ && content=$(cat $tmp | shup "body" "div" "main" "div" "div" "div" "div" "article" "div[entry-content]" | grep "\S" | sed "s/^\s*//" | awk '{printf("%s", $0)}') \ && printf "<!-- content -->\n<item>\n<title>%s\n%s\n%s\n%s\n\n\n" "$title" "$pubdate" "$url" "$url" "$content" > $tmp \ && sed -i "// { r $tmp d }" "$dir/feeds/$id.xml" \ && echo "Entry inserted." done }