From c5986e3bc647752052780ac277294c83b1fd5e9d Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 6 Jul 2012 19:38:32 +0200 Subject: o Only creating .atom if there has been any new shows, makes conditional gets possible. --- tv.nrk.no.xsl | 9 +++------ update-feed.sh | 24 +++++++++++++++++++++++- 2 files changed, 26 insertions(+), 7 deletions(-) mode change 100644 => 100755 update-feed.sh 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 @@ - New shows - urn:trygvis:tv.nrk.no,recent - + Recently Sent from NRK + urn:trygvis:2012,07,tv.nrk.no,recently-sent @@ -19,7 +16,7 @@ <xsl:value-of select='normalize-space(a)'/> diff --git a/update-feed.sh b/update-feed.sh old mode 100644 new mode 100755 index f0a7508..4afd168 --- 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 -- cgit v1.2.3