summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tv.nrk.no.xsl9
-rwxr-xr-x[-rw-r--r--]update-feed.sh24
2 files changed, 26 insertions, 7 deletions
diff --git a/tv.nrk.no.xsl b/tv.nrk.no.xsl
index 18d59a9..a825181 100644
--- a/tv.nrk.no.xsl
+++ b/tv.nrk.no.xsl
@@ -5,11 +5,8 @@
<xsl:output indent="yes"/>
<xsl:template match="/html">
<feed>
- <title>New shows</title>
- <id>urn:trygvis:tv.nrk.no,recent</id>
- <!--
- <updated>2003-12-13T18:30:02Z</updated>
- -->
+ <title>Recently Sent from NRK</title>
+ <id>urn:trygvis:2012,07,tv.nrk.no,recently-sent</id>
<xsl:for-each select="//li">
<xsl:call-template name="li"/>
</xsl:for-each>
@@ -19,7 +16,7 @@
<entry>
<id><xsl:value-of select="a/@href"/></id>
<!--
- <id>urn:trygvis:tv.nrk.no,item,<xsl:value-of select='normalize-space(a)'/></id>
+ <id>urn:trygvis:2012,07,tv.nrk.no,item,<xsl:value-of select='normalize-space(a)'/></id>
-->
<title><xsl:value-of select='normalize-space(a)'/></title>
<updated><xsl:value-of select="a/strong/time/@datetime"/></updated>
diff --git a/update-feed.sh b/update-feed.sh
index f0a7508..4afd168 100644..100755
--- a/update-feed.sh
+++ b/update-feed.sh
@@ -1,3 +1,25 @@
#!/bin/bash
-curl -s http://tv.nrk.no/listobjects/recentlysent | dos2unix |xmllint --html --dropdtd --xmlout - 2> /dev/null | xmlstarlet tr ./tv.nrk.no.xsl > tv.nrk.no.atom
+set -e
+set -x
+
+checksum() {
+ [ -r $1 ] && md5sum $1 | cut -f 1 -d ' '
+}
+
+fetch() {
+ curl -s http://tv.nrk.no/listobjects/recentlysent | dos2unix | xmllint --html --dropdtd --xmlout - 2> /dev/null > tv.nrk.no.html.new
+
+ if [ -r tv.nrk.no.html -a "`checksum tv.nrk.no.html.new`" == "`checksum tv.nrk.no.html`" ]
+ then
+ rm -f tv.nrk.no.html.new
+ echo "Already up to date."
+ exit 0
+ fi
+
+ mv tv.nrk.no.html.new tv.nrk.no.html
+}
+
+fetch
+
+cat tv.nrk.no.html | xmlstarlet tr ./tv.nrk.no.xsl > tv.nrk.no.atom