#!/bin/sh mediaformasi() { id="mediaformasi" host="https://mediaformasi.com" validateFeed "$id" "$host" cat $tmp \ | shup "article" "a" \ | grep -o "/" \ | while read line ; do url=$(echo $line | grep -o "http.*\">" | 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.*Z" | xargs -i date -d {} -R) \ && content=$(cat $tmp | shup "body" "main" "article" "div[js-post-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 }