#!/bin/sh tirto() { id="tirto" host="https://tirto.id" validateFeed "$id" "$host" cat $tmp \ | shup "body" "a" \ | grep " $tmp # Check if content and pubdate are empty, meaning not an article content=$(cat $tmp | shup "body" "div" "article" "div[content-text-editor]" | grep "\S" | sed "s/^\s*//" | awk '{printf ("%s", $0)}' | sed "s/.*<\/script>//") pubdate=$(cat $tmp | grep "datePublished" | grep -o "[0-9]*-[0-9]*-[0-9]*\s[0-9]*:[0-9]*:[0-9]*" | sed "s/$/+0700/" | xargs -i date -d {} -R) [ ! -z "$content" ] && [ ! -z "$pubdate" ] \ && title=$(cat $tmp | shup "title" | sed "s///" | sed "s/<\/title>//" | sed "s/^\s*//" | grep "\S") \ && printf "\n\n%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 }