summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2012-07-06 23:47:12 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2012-07-06 23:47:12 +0200
commitb0ffb988ac64d19c437cbcd40f7af9a580c8cb2e (patch)
treeeaca529776acb7e479892b5e3eb72be29e9dec1b
parent98d5dcad7e774b40a47b0b4e7552ad0d4b1ac309 (diff)
downloadtv.nrk.no-to-atom-b0ffb988ac64d19c437cbcd40f7af9a580c8cb2e.tar.gz
tv.nrk.no-to-atom-b0ffb988ac64d19c437cbcd40f7af9a580c8cb2e.tar.bz2
tv.nrk.no-to-atom-b0ffb988ac64d19c437cbcd40f7af9a580c8cb2e.tar.xz
tv.nrk.no-to-atom-b0ffb988ac64d19c437cbcd40f7af9a580c8cb2e.zip
o Better encoding of local filename.
-rw-r--r--tv.nrk.no.xsl5
-rwxr-xr-xupdate-feed.sh20
2 files changed, 12 insertions, 13 deletions
diff --git a/tv.nrk.no.xsl b/tv.nrk.no.xsl
index 736228a..4d46f05 100644
--- a/tv.nrk.no.xsl
+++ b/tv.nrk.no.xsl
@@ -18,13 +18,16 @@
<xsl:template name="li">
<entry>
<xsl:variable name='href' select='a/@href'/>
+ <!--
<xsl:variable name='filename' select='concat("tmp/", strings:encode-uri(normalize-space(a), true()), ".xml")'/>
+ -->
+ <xsl:variable name='filename' select='strings:replace(substring-after(normalize-space(@href), "http://tv.nrk.no/"), "/", "_")'/>
<xsl:variable name='show' select='document($filename)'/>
<id><xsl:value-of select="$href"/></id>
<title><xsl:value-of select='normalize-space(a)'/></title>
<updated><xsl:value-of select="a/strong/time/@datetime"/></updated>
<author><name>Trygve Laugstøl</name></author>
- <link><xsl:attribute name="href"><xsl:value-of select="a/@href"/></xsl:attribute></link>
+ <link><xsl:attribute name="href"><xsl:value-of select="$href"/></xsl:attribute></link>
<content type="xhtml" xml:lang="en">
<div xmlns="http://www.w3.org/1999/xhtml">
<xsl:copy-of select="$show/html:html//html:section[@id='information']/*"/>
diff --git a/update-feed.sh b/update-feed.sh
index 4922082..ef55874 100755
--- a/update-feed.sh
+++ b/update-feed.sh
@@ -19,31 +19,28 @@ fetch() {
mv tv.nrk.no.html.new tv.nrk.no.html
}
-fetch
+# fetch
mkdir -p tmp
cat tv.nrk.no.html | \
- xmlstarlet sel -N strings=http://exslt.org/strings -t -m '//a[@class="listobject-link"]' \
+ xmlstarlet sel \
+ -N strings=http://exslt.org/strings \
+ -N fn=http://www.w3.org/2005/xpath-functions \
+ -t -m '//a[@class="listobject-link"]' \
-v '@href' -v '" "' \
- -v 'strings:encode-uri(normalize-space(.), true())' -n \
+ -v 'strings:replace(substring-after(normalize-space(@href), "http://tv.nrk.no/"), "/", "_")' -n \
| while read url name
do
- if [ "$name" == "" -o -r "$name" ]
+ if [ "$name" == "" -o -r "tmp/$name" ]
then
continue
fi
echo Url: $url
echo Name: $name
- if [ -r "tmp/$name" ]
- then
- z="tmp/$name"
- else
- z="Jan 1 1970"
- fi
- curl -v -s -z "$z" -L "$url" -o "tmp/$name"
+ curl -s -L "$url" -o "tmp/$name"
rm -f "tmp/$name.html" "tmp/$name.xml"
set +e
cat "tmp/$name" | dos2unix | \
@@ -51,7 +48,6 @@ do
--new-inline-tags "time" \
--new-blocklevel-tags "article, hgroup, section, header, footer, mark, aside" \
> "tmp/$name.html"
- echo ret=$?
set -e
cat "tmp/$name.html" | xmllint --format --xmlout - >"tmp/${name}.xml"
done