summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-07-06 19:38:32 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-07-06 19:38:32 +0200
commitc5986e3bc647752052780ac277294c83b1fd5e9d (patch)
treeefa33cbf42d27cde67ee52867d5f50b0a17c334b
parentc208c0abc01ed5c46774f0cabdc52f4a5b9d8a4b (diff)
downloadtv.nrk.no-to-atom-c5986e3bc647752052780ac277294c83b1fd5e9d.tar.gz
tv.nrk.no-to-atom-c5986e3bc647752052780ac277294c83b1fd5e9d.tar.bz2
tv.nrk.no-to-atom-c5986e3bc647752052780ac277294c83b1fd5e9d.tar.xz
tv.nrk.no-to-atom-c5986e3bc647752052780ac277294c83b1fd5e9d.zip
o Only creating .atom if there has been any new shows, makes conditional gets possible.
-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