Skip to content

Instantly share code, notes, and snippets.

@marco79cgn
Created June 5, 2026 10:10
Show Gist options
  • Select an option

  • Save marco79cgn/82198297d559851ea6da51cfdf5dfdca to your computer and use it in GitHub Desktop.

Select an option

Save marco79cgn/82198297d559851ea6da51cfdf5dfdca to your computer and use it in GitHub Desktop.
Checks RSS feed for new content and sends push notification via ntfy.sh
#!/usr/bin/env bash
set -euo pipefail
# the rss feed url to check
FEED_URL="https://www.iphoneblog.de/feed/"
# temporary state file to compare
STATE_FILE="/tmp/rss-top-item.id"
mkdir -p "$(dirname "$STATE_FILE")"
# download rss feed content
feed="$(curl -fsSL "$FEED_URL")"
# extract title, link and guid of latest item on feed
title="$(
printf '%s' "$feed" |
xmllint --xpath 'string((//item)[1]/title)' -
)"
link="$(
printf '%s' "$feed" |
xmllint --xpath 'string((//item)[1]/link)' -
)"
guid="$(
printf '%s' "$feed" |
xmllint --xpath 'string((//item)[1]/guid)' -
)"
# if guid is missing: use link or title
item_id="${guid:-${link:-$title}}"
if [[ -z "$item_id" ]]; then
echo "Konnte kein RSS-Item auslesen." >&2
exit 1
fi
if [[ ! -f "$STATE_FILE" ]]; then
printf '%s\n' "$item_id" > "$STATE_FILE"
echo "Initialer Stand gespeichert."
exit 0
fi
old_id="$(cat "$STATE_FILE")"
if [[ "$item_id" != "$old_id" ]]; then
printf '%s\n' "$item_id" > "$STATE_FILE"
echo "Neues Item gefunden:"
echo "Titel: $title"
echo "Link: $link"
echo "Sende Push Benachrichtigung mit Link und Vorschaubild."
content="$(
printf '%s' "$feed" |
xmllint --xpath 'string((//item)[1]/*[local-name()="encoded"])' -
)"
image_url="$(
printf '%s\n' "$content" |
sed -n 's/.*<img[^>]* src="\([^"]*\)".*/\1/p' |
head -n 1
)"
# send push notification via ntfy.sh
result=$(/usr/bin/curl -s -X POST -H "Title: Neuer iPhoneblog Artikel" -H "Click: $link" -H "Tags: memo" -H "Attach: $image_url" -d "$title" https://ntfy.sh/******)
else
echo "Kein neues Item."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment