summaryrefslogtreecommitdiff
path: root/update-feed.sh
diff options
context:
space:
mode:
Diffstat (limited to 'update-feed.sh')
-rwxr-xr-xupdate-feed.sh20
1 files changed, 8 insertions, 12 deletions
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