Skip to content

Instantly share code, notes, and snippets.

@silvasur
Last active Dec 25, 2015
Embed
What would you like to do?
Fetch the latest cartoon from ruthe.de and build an Atom-Feed. You can use this with newsreaders that accept commands as a feed source (e.g. newsbeuter)
#!/bin/sh
# Released under the WTFPL (wtfpl.org).
URL="http://www.ruthe.de"
toonid=`curl -s $URL | sed -n 's/^.*archiv\.php\?.*id=\([0-9]*\).*/\1/p' | sed 1q`
now=`date +%Y-%m-%dT%H:%M:%SZ`
echo -n "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<feed xmlns=\"http://www.w3.org/2005/Atom\">
<title>Ruthe.de</title>
<link href=\"$URL\" />
<id>$URL/</id>
<author>
<name>Ralph Ruthe</name>
<uri>$URL/</uri>
</author>
<updated>$now</updated>
<entry>
<title>Neuer Cartoon ($toonid)</title>
<id>$URL/index.php?pic=$toonid</id>
<updated>$now</updated>
<summary>Neuer Cartoon!</summary>
<link rel=\"alternate\" href=\"$URL/index.php?pic=$toonid\" />
</entry>
</feed>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment