This repository has been archived on 2021-11-29. You can view files and clone it, but cannot push or open issues or pull requests.
rsstube-bash-old/scripts/page-extractors/writefreely

22 lines
722 B
Plaintext

# check for explicit feed link
page_ext=`echo "$content" | grep -Po '(?<=<link rel="alternate" type="application/rss\+xml" title=").*?(?=" />)' | head -1 | tr '\0' '\n'`
page_ext=${page_ext##*href=\"}
# if explicit feed link not found (article, not author page), truncate post URL to get author URL
if [[ "$page_ext" == "" ]]
then
# check for invalid link that cannot be shortened
# I don't think this is necessary, but just in case
if [[ "${url:0:8}" != "https://" && "${url:0:7}" != "http://" ]] && [[ "${url%%/}" == */* ]] || [[ "${url%%/}" == http*://*/* ]]
then
# truncate tailing slash (if applicable)
rss=${url%%/}
# truncate last item
rss=${rss%/*}
# add /feed/
page_ext=${rss}/feed/
fi
fi