summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorAntti Ajanki <antti.ajanki@iki.fi>2010-07-23 20:55:11 +0300
committerAntti Ajanki <antti.ajanki@iki.fi>2010-07-23 20:55:11 +0300
commit310743fb9ebbf68b253b923a309cc5f635da89a1 (patch)
tree59c365db7459649344b4ab6d58fde1ceb362506d /templates
downloadvdr-plugin-webvideo-310743fb9ebbf68b253b923a309cc5f635da89a1.tar.gz
vdr-plugin-webvideo-310743fb9ebbf68b253b923a309cc5f635da89a1.tar.bz2
release 0.3.0
Diffstat (limited to 'templates')
-rwxr-xr-xtemplates/bin/ruutu-dl36
-rwxr-xr-xtemplates/bin/yle-dl22
-rw-r--r--templates/google/description.xsl22
-rw-r--r--templates/google/search.xsl38
-rw-r--r--templates/google/searchresults.xsl85
-rw-r--r--templates/google/service.xml7
-rw-r--r--templates/google/video.xsl19
-rw-r--r--templates/katsomo/mainmenu.xsl26
-rw-r--r--templates/katsomo/navigation.xsl48
-rw-r--r--templates/katsomo/search.xsl23
-rw-r--r--templates/katsomo/searchresults.xsl32
-rw-r--r--templates/katsomo/service.xml7
-rw-r--r--templates/katsomo/video.xsl18
-rw-r--r--templates/metacafe/categories.xsl33
-rw-r--r--templates/metacafe/channellist.xsl22
-rw-r--r--templates/metacafe/description.xsl47
-rw-r--r--templates/metacafe/navigation.xsl36
-rw-r--r--templates/metacafe/search.xsl36
-rw-r--r--templates/metacafe/service.xml7
-rw-r--r--templates/metacafe/video.xsl14
-rw-r--r--templates/ruutufi/description.xsl51
-rw-r--r--templates/ruutufi/mainmenu.xsl32
-rw-r--r--templates/ruutufi/program.xsl120
-rw-r--r--templates/ruutufi/search.xsl23
-rw-r--r--templates/ruutufi/series.xsl28
-rw-r--r--templates/ruutufi/service.xml7
-rw-r--r--templates/ruutufi/video.xsl23
-rw-r--r--templates/ruutufi/video2.xsl15
-rw-r--r--templates/subtv/description.xsl32
-rw-r--r--templates/subtv/mainmenu.xsl21
-rw-r--r--templates/subtv/navigation.xsl42
-rw-r--r--templates/subtv/service.xml7
-rw-r--r--templates/subtv/video.xsl19
-rw-r--r--templates/svtplay/categories.xsl19
-rw-r--r--templates/svtplay/description.xsl41
-rw-r--r--templates/svtplay/navigation.xsl74
-rw-r--r--templates/svtplay/programmenu.xsl56
-rw-r--r--templates/svtplay/service.xml7
-rw-r--r--templates/svtplay/video.xsl24
-rw-r--r--templates/vimeo/channels.xsl33
-rw-r--r--templates/vimeo/description.xsl59
-rw-r--r--templates/vimeo/groups.xsl33
-rw-r--r--templates/vimeo/mainmenu.xsl28
-rw-r--r--templates/vimeo/navigation.xsl22
-rw-r--r--templates/vimeo/search.xsl30
-rw-r--r--templates/vimeo/searchresults.xsl34
-rw-r--r--templates/vimeo/service.xml7
-rw-r--r--templates/vimeo/video.xsl14
-rw-r--r--templates/yleareena/description.xsl31
-rw-r--r--templates/yleareena/livebroadcasts.xsl46
-rw-r--r--templates/yleareena/livestream.xsl23
-rw-r--r--templates/yleareena/mainmenu.xsl35
-rw-r--r--templates/yleareena/navigation.xsl119
-rw-r--r--templates/yleareena/programlist.xsl22
-rw-r--r--templates/yleareena/search.xsl45
-rw-r--r--templates/yleareena/service.xml7
-rw-r--r--templates/yleareena/video.xsl18
-rw-r--r--templates/youtube/categories.xsl29
-rw-r--r--templates/youtube/description.xsl73
-rw-r--r--templates/youtube/navigation.xsl62
-rw-r--r--templates/youtube/search.xsl39
-rw-r--r--templates/youtube/service.xml7
-rw-r--r--templates/youtube/video.xsl48
63 files changed, 2083 insertions, 0 deletions
diff --git a/templates/bin/ruutu-dl b/templates/bin/ruutu-dl
new file mode 100755
index 0000000..be8d01e
--- /dev/null
+++ b/templates/bin/ruutu-dl
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+# Downloads a video stream from ruutu.fi to stdout using
+# rtmpdump(-yle). The first parameter is the rtmp URL, the second
+# parameter is the video page URL.
+
+RTMPDUMP=
+
+which rtmpdump > /dev/null 2>&1
+if [ $? = 0 ]; then
+ RTMPDUMP=rtmpdump
+else
+ which rtmpdump-yle > /dev/null 2>&1
+ if [ $? = 0 ]; then
+ RTMPDUMP=rtmpdump-yle
+ fi
+fi
+
+if [ "x$RTMPDUMP" = "x" ]; then
+ echo "ERROR: neither rtmpdump nor rtmpdump-yle not on \$PATH" 1>&2
+ exit 1
+fi
+
+if [ "x$1" = "x" ]; then
+ echo "Expected rtmp URL as parameter" 1>&2
+ exit 1
+fi
+
+if [ "x$2" = "x" ]; then
+ echo "Expected ruutu.fi video page URL as parameter" 1>&2
+ exit 1
+fi
+
+$RTMPDUMP -r $1 -q --swfUrl http://n.sestatic.fi/sites/all/modules/media/Nelonen_mediaplayer_4.6.swf --pageUrl $2 -o -
+
+exit $?
diff --git a/templates/bin/yle-dl b/templates/bin/yle-dl
new file mode 100755
index 0000000..a317b12
--- /dev/null
+++ b/templates/bin/yle-dl
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+# Downloads a video stream from Yle Areena to stdout using yle-dl
+# script. The first parameter is the video page URL.
+
+YLEDL=yle-dl
+
+which $YLEDL > /dev/null 2>&1
+if [ $? != 0 ]; then
+ echo "ERROR: $YLEDL is not on \$PATH" 1>&2
+ echo "Install rtmpdump-yle from http://users.tkk.fi/~aajanki/rtmpdump-yle/index.html" 1>&2
+ exit 1
+fi
+
+if [ "x$1" = "x" ]; then
+ echo "Expected Areena URL as parameter" 1>&2
+ exit 1
+fi
+
+$YLEDL $1 -q -o -
+
+exit $?
diff --git a/templates/google/description.xsl b/templates/google/description.xsl
new file mode 100644
index 0000000..b7cab19
--- /dev/null
+++ b/templates/google/description.xsl
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="//title"/></title>
+
+ <textarea>
+ <label><xsl:value-of select="//span[@id='long-desc']"/></label>
+ </textarea>
+ <textarea>
+ <label>Duration: <xsl:value-of select="//span[@id='video-duration']"/></label>
+ </textarea>
+ <textarea>
+ <label>Date: <xsl:value-of select="//span[@id='video-date']"/></label>
+ </textarea>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/google/search.xsl b/templates/google/search.xsl
new file mode 100644
index 0000000..a7a3ab0
--- /dev/null
+++ b/templates/google/search.xsl
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Google video search</title>
+
+ <textfield name="q">
+ <label>Search terms</label>
+ </textfield>
+
+ <itemlist name="so">
+ <label>Sort by</label>
+ <item value="0">Relevance</item>
+ <item value="3">Rating</item>
+ <item value="4">Popularity</item>
+ <item value="1">Date</item>
+ </itemlist>
+
+ <itemlist name="dur">
+ <label>Duration</label>
+ <item value="">All durations</item>
+ <item value="1">Short (&lt; 4 min)</item>
+ <item value="2">Medium (4-20 min)</item>
+ <item value="3">Long (&gt; 20 min)</item>
+ </itemlist>
+
+ <button>
+ <label>Search</label>
+ <submission>wvt:///google/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri('http://video.google.com/videosearch?q={q}&amp;so={so}&amp;dur={dur}', true())"/></submission>
+ </button>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/google/searchresults.xsl b/templates/google/searchresults.xsl
new file mode 100644
index 0000000..863d1d8
--- /dev/null
+++ b/templates/google/searchresults.xsl
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Search results</title>
+
+ <xsl:choose>
+ <xsl:when test="not(//div[@class='rl-item'])">
+ <textarea>
+ <label>
+ <xsl:text>Your search did not return any results.</xsl:text>
+ </label>
+ </textarea>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:for-each select="//div[@class='rl-item']">
+ <xsl:choose>
+ <xsl:when test="starts-with(div/@srcurl, 'http://www.youtube.com/')">
+ <link>
+ <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)" /></label>
+ <stream>wvt:///youtube/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></stream>
+ <ref>wvt:///youtube/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://gdata.youtube.com/feeds/api/videos/', substring-after(div/@srcurl, 'v='), '?v=2'), true())"/></ref>
+ </link>
+ </xsl:when>
+
+ <xsl:when test="starts-with(div/@srcurl, 'http://video.google.com/')">
+ <link>
+ <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)"/></label>
+ <stream>wvt:///google/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></stream>
+ <ref>wvt:///google/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></ref>
+ </link>
+ </xsl:when>
+
+ <xsl:when test="starts-with(div/@srcurl, 'http://www.metacafe.com/')">
+ <link>
+ <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)"/></label>
+ <stream>wvt:///metacafe/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl)"/></stream>
+ <ref>wvt:///metacafe/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl)"/></ref>
+ </link>
+ </xsl:when>
+
+ <xsl:when test="starts-with(div/@srcurl, 'http://vimeo.com/')">
+ <link>
+ <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)"/></label>
+ <stream>wvt:///vimeo/video.xsl?srcurl=http://www.vimeo.com/moogaloop/load/clip:<xsl:value-of select="substring-after(div/@srcurl, 'http://vimeo.com/')"/></stream>
+ <ref>wvt:///vimeo/description.xsl?srcurl=http://vimeo.com/api/v2/video/<xsl:value-of select="substring-after(div/@srcurl, 'http://vimeo.com/')"/>.xml</ref>
+ </link>
+ </xsl:when>
+
+ <xsl:when test="starts-with(div/@srcurl, 'http://svtplay.se/')">
+ <link>
+ <label><xsl:value-of select="normalize-space(div/div/div[@class='rl-title']/a)"/></label>
+ <stream>wvt:///svtplay/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></stream>
+ <ref>wvt:///svtplay/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div/@srcurl, true())"/></ref>
+ </link>
+ </xsl:when>
+
+ </xsl:choose>
+ </xsl:for-each>
+
+ <xsl:if test="//td[@class='prev']/a">
+ <link>
+ <label>Previous</label>
+ <ref>wvt:///google/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri(//td[@class='prev']/a/@href, true())"/></ref>
+ </link>
+ </xsl:if>
+
+ <xsl:if test="//td[@class='next']/a">
+ <link>
+ <label>Next</label>
+ <ref>wvt:///google/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri(//td[@class='next']/a/@href, true())"/></ref>
+ </link>
+ </xsl:if>
+ </xsl:otherwise>
+ </xsl:choose>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/google/service.xml b/templates/google/service.xml
new file mode 100644
index 0000000..3e02e93
--- /dev/null
+++ b/templates/google/service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<service>
+ <title>Google Video</title>
+ <ref>wvt:///google/search.xsl</ref>
+ <description>Google video search</description>
+</service>
diff --git a/templates/google/video.xsl b/templates/google/video.xsl
new file mode 100644
index 0000000..52d6d98
--- /dev/null
+++ b/templates/google/video.xsl
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+<mediaurl>
+ <title><xsl:value-of select="/html/head/title" /></title>
+ <xsl:for-each select="/html/body/script">
+ <xsl:variable name="videourl" select="str:decode-uri(substring-before(substring-after(., 'videoUrl\x3d'), '\x26'))"/>
+ <xsl:if test="$videourl">
+ <url><xsl:value-of select="$videourl"/></url>
+ </xsl:if>
+ </xsl:for-each>
+</mediaurl>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/katsomo/mainmenu.xsl b/templates/katsomo/mainmenu.xsl
new file mode 100644
index 0000000..b7ba1cf
--- /dev/null
+++ b/templates/katsomo/mainmenu.xsl
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>MTV3 Katsomo</title>
+
+ <link>
+ <label>Haku</label>
+ <ref>wvt:///katsomo/search.xsl</ref>
+ </link>
+
+ <xsl:for-each select="id('mainMenu')/li[a/@href != '/']">
+ <link>
+ <label><xsl:value-of select="a"/></label>
+ <ref>wvt:///katsomo/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(a/@href, true())"/></ref>
+ </link>
+ </xsl:for-each>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/katsomo/navigation.xsl b/templates/katsomo/navigation.xsl
new file mode 100644
index 0000000..e43753d
--- /dev/null
+++ b/templates/katsomo/navigation.xsl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:param name="docurl"/>
+
+<xsl:template match="ol[@class='categoryList']/li">
+ <link>
+ <label><xsl:value-of select="normalize-space(a)"/></label>
+ <ref>wvt:///katsomo/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(a/@href, true())"/></ref>
+ </link>
+</xsl:template>
+
+<xsl:template match="ol[@class='programList']/li">
+ <xsl:variable name="progId" select="substring-after(a/@href, 'progId=')"/>
+ <xsl:variable name="treeId" select="substring-after($docurl, 'treeId=')"/>
+ <xsl:variable name="title" select="normalize-space(a[string(.)])"/>
+
+ <link>
+ <label><xsl:value-of select="$title"/></label>
+ <stream>wvt:///katsomo/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://katsomo.fi/showContent.do?treeId=', $treeId, '&amp;progId=', $progId, '&amp;adData=%7B%22ad%22%3A%20%7B%7D%7D&amp;ajax=true&amp;serial=1'), true())"/>&amp;param=title,<xsl:value-of select="str:encode-uri($title, true())"/>&amp;HTTP-header=cookie,webtv.bandwidth%3D1000%3BautoFullScreen%3Dfalse%3Bwebtv.playerPlatform%3D0</stream>
+ </link>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="/html/head/meta[@name='title']/@content"/></title>
+
+ <xsl:if test="//ol[@class='categoryList']/li and //ol[@class='programList']/li">
+ <textarea>
+ <label>Ohjelmat</label>
+ </textarea>
+ </xsl:if>
+ <xsl:apply-templates select="//ol[@class='categoryList']/li"/>
+
+ <xsl:if test="//ol[@class='categoryList']/li and //ol[@class='programList']/li">
+ <textarea>
+ <label>Jaksot</label>
+ </textarea>
+ </xsl:if>
+ <xsl:apply-templates select="//ol[@class='programList']/li"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/katsomo/search.xsl b/templates/katsomo/search.xsl
new file mode 100644
index 0000000..c963b71
--- /dev/null
+++ b/templates/katsomo/search.xsl
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTf-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Haku</title>
+
+ <textfield name="query">
+ <label>Hakusana</label>
+ </textfield>
+
+ <button>
+ <label>Hae</label>
+ <submission>wvt:///katsomo/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri('http://katsomo.fi/search.do?keywords={query}&amp;treeId=9992', true())"/></submission>
+ </button>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/katsomo/searchresults.xsl b/templates/katsomo/searchresults.xsl
new file mode 100644
index 0000000..2747afc
--- /dev/null
+++ b/templates/katsomo/searchresults.xsl
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:template match="a">
+ <xsl:variable name="progId" select="substring-after(@href, 'progId=')"/>
+ <xsl:variable name="title" select="normalize-space(.)"/>
+
+ <link>
+ <label><xsl:value-of select="$title"/></label>
+ <stream>wvt:///katsomo/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://katsomo.fi/showContent.do?progId=', $progId, '&amp;adData=%7B%22ad%22%3A%20%7B%7D%7D&amp;ajax=true&amp;serial=1'), true())"/>&amp;param=title,<xsl:value-of select="str:encode-uri($title, true())"/>&amp;HTTP-header=cookie,webtv.bandwidth%3D1000%3BautoFullScreen%3Dfalse%3Bwebtv.playerPlatform%3D0</stream>
+ </link>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Hakutulokset: <xsl:value-of select="id('searchResults')/div/div[@class='description']/span"/></title>
+
+ <xsl:if test="not(id('resultList')/div[@class='item'])">
+ <textarea>
+ <label><xsl:value-of select="normalize-space(id('siteMapList')/p)"/></label>
+ </textarea>
+ </xsl:if>
+
+ <xsl:apply-templates select="id('resultList')/div[@class='item']/h6/a[not(@class='programType')]"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/katsomo/service.xml b/templates/katsomo/service.xml
new file mode 100644
index 0000000..b1bd0bc
--- /dev/null
+++ b/templates/katsomo/service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<service>
+ <title>MTV3 Katsomo</title>
+ <ref>wvt:///katsomo/mainmenu.xsl?srcurl=http%3A//katsomo.fi/</ref>
+ <description>Net TV service of the Finnish broadcasting company MTV3</description>
+</service>
diff --git a/templates/katsomo/video.xsl b/templates/katsomo/video.xsl
new file mode 100644
index 0000000..9d20c49
--- /dev/null
+++ b/templates/katsomo/video.xsl
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:param name="title">katsomovideo</xsl:param>
+
+<xsl:template match="/">
+<mediaurl>
+ <title><xsl:value-of select="$title"/></title>
+
+ <url><xsl:value-of select='substring-before(substring-after(//script, "metaUrl&apos;: &apos;"), "&apos;")'/></url>
+</mediaurl>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/metacafe/categories.xsl b/templates/metacafe/categories.xsl
new file mode 100644
index 0000000..7dc155e
--- /dev/null
+++ b/templates/metacafe/categories.xsl
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Metacafe</title>
+
+ <link>
+ <label>Search</label>
+ <ref>wvt:///metacafe/search.xsl</ref>
+ </link>
+
+ <link>
+ <label>Most viewed channels</label>
+ <ref>wvt:///metacafe/channellist.xsl?srcurl=/api/channels/</ref>
+ </link>
+
+ <xsl:for-each select="id('LeftCol')/ul/li/a">
+ <!-- '18+ Only' is empty unless family filter is off. Ignore the
+ category until I find a way to turn off the filter. -->
+ <xsl:if test="@title != '18+ Only'">
+ <link>
+ <label><xsl:value-of select="@title"/></label>
+ <ref>wvt:///metacafe/navigation.xsl?srcurl=/api/videos/-/<xsl:value-of select="substring-after(@href, '/videos/')"/></ref>
+ </link>
+ </xsl:if>
+ </xsl:for-each>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/metacafe/channellist.xsl b/templates/metacafe/channellist.xsl
new file mode 100644
index 0000000..2bb74ec
--- /dev/null
+++ b/templates/metacafe/channellist.xsl
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="item">
+ <link>
+ <label><xsl:value-of select="title" /> (<xsl:value-of select="videos"/> videos, avg. rank: <xsl:value-of select="avg_rank"/>)</label>
+ <ref>wvt:///metacafe/navigation.xsl?srcurl=/api/users/<xsl:value-of select="str:encode-uri(translate(title, ' ', '+'), true())"/>/channel?time=all_time</ref>
+ </link>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="/rss/channel/title"/></title>
+
+ <xsl:apply-templates select="/rss/channel/item"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/metacafe/description.xsl b/templates/metacafe/description.xsl
new file mode 100644
index 0000000..3cb7f2b
--- /dev/null
+++ b/templates/metacafe/description.xsl
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:media="http://search.yahoo.com/mrss/">
+
+<!-- Convert $seconds to hours:min:sec format -->
+<xsl:template name="pretty-print-seconds">
+ <xsl:param name="seconds"/>
+
+ <xsl:variable name="sec" select="$seconds mod 60"/>
+ <xsl:variable name="min" select="floor($seconds div 60) mod 60"/>
+ <xsl:variable name="hour" select="floor($seconds div 3600)"/>
+
+ <xsl:value-of select="concat($hour, ':', format-number($min, '00'), ':', format-number($sec, '00'))"/>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="/rss/channel/item/title"/></title>
+
+ <textarea>
+ <label><xsl:value-of select="/rss/channel/item/media:description"/></label>
+ </textarea>
+
+ <textarea>
+ <label>Duration: <xsl:call-template name="pretty-print-seconds">
+ <xsl:with-param name="seconds">
+ <xsl:value-of select="/rss/channel/item/media:content/@duration"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </label>
+ </textarea>
+
+ <textarea>
+ <label>Rating: <xsl:value-of select="/rss/channel/item/rank"/></label>
+ </textarea>
+
+ <textarea>
+ <label>published: <xsl:value-of select="/rss/channel/item/pubDate"/></label>
+ </textarea>
+
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/metacafe/navigation.xsl b/templates/metacafe/navigation.xsl
new file mode 100644
index 0000000..4ff821a
--- /dev/null
+++ b/templates/metacafe/navigation.xsl
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="item">
+ <link>
+ <label><xsl:value-of select="title" /></label>
+ <xsl:choose>
+ <xsl:when test="starts-with(id, 'yt-')">
+ <stream>wvt:///youtube/video.xsl?srcurl=http%3A//www.youtube.com/watch%3Fv=<xsl:value-of select="substring(id, 4)"/></stream>
+ </xsl:when>
+ <xsl:otherwise>
+ <stream>wvt:///metacafe/video.xsl?srcurl=<xsl:value-of select="link"/></stream>
+ </xsl:otherwise>
+ </xsl:choose>
+
+ <ref>wvt:///metacafe/description.xsl?srcurl=/api/item/<xsl:value-of select="id"/></ref>
+ </link>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="/rss/channel/title"/></title>
+
+ <xsl:apply-templates select="/rss/channel/item"/>
+
+ <xsl:if test="count(/rss/channel/item) = 0">
+ <textarea>
+ <label>No matching results.</label>
+ </textarea>
+ </xsl:if>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/metacafe/search.xsl b/templates/metacafe/search.xsl
new file mode 100644
index 0000000..205bd98
--- /dev/null
+++ b/templates/metacafe/search.xsl
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Metacafe Search</title>
+
+ <textfield name="vq">
+ <label>Keywords</label>
+ </textfield>
+
+ <itemlist name="orderby">
+ <label>Sort by</label>
+ <item value="updated">Most recent</item>
+ <item value="viewCount">View Count</item>
+ <item value="discussed">Most discussed</item>
+ </itemlist>
+
+ <itemlist name="time">
+ <label>Published</label>
+ <item value="all_time">Anytime</item>
+ <item value="today">During last 24 hours</item>
+ <item value="this_week">This week</item>
+ <item value="this_month">This month</item>
+ </itemlist>
+
+ <button>
+ <label>Search</label>
+ <submission>wvt:///metacafe/navigation.xsl?srcurl=http%3A//www.metacafe.com/api/videos%3Fvq=%7Bvq%7D%26orderby=%7Borderby%7D%26time=%7Btime%7D</submission>
+ </button>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/metacafe/service.xml b/templates/metacafe/service.xml
new file mode 100644
index 0000000..8e9fc33
--- /dev/null
+++ b/templates/metacafe/service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<service>
+ <title>Metacafe</title>
+ <ref>wvt:///metacafe/categories.xsl?srcurl=http%3A//www.metacafe.com/videos/</ref>
+ <description>Video sharing site specializing in short-form original content</description>
+</service>
diff --git a/templates/metacafe/video.xsl b/templates/metacafe/video.xsl
new file mode 100644
index 0000000..884e87f
--- /dev/null
+++ b/templates/metacafe/video.xsl
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+ <mediaurl>
+ <title><xsl:value-of select="normalize-space(id('ItemTitle'))"/></title>
+ <url><xsl:value-of select="str:decode-uri(substring-before(substring-after(//param[@name='flashvars']/@value, 'mediaURL='), '&amp;'))"/></url>
+ </mediaurl>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/ruutufi/description.xsl b/templates/ruutufi/description.xsl
new file mode 100644
index 0000000..ad04d79
--- /dev/null
+++ b/templates/ruutufi/description.xsl
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:param name="docurl"/>
+
+<!-- Convert $seconds to hours:min:sec format -->
+<xsl:template name="pretty-print-seconds">
+ <xsl:param name="seconds"/>
+
+ <xsl:variable name="sec" select="$seconds mod 60"/>
+ <xsl:variable name="min" select="floor($seconds div 60) mod 60"/>
+ <xsl:variable name="hour" select="floor($seconds div 3600)"/>
+
+ <xsl:value-of select="concat($hour, ':', format-number($min, '00'), ':', format-number($sec, '00'))"/>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="/Playerdata/Behavior/Program/@program_name"/></title>
+
+ <xsl:if test="/Playerdata/Behavior/Program/@description">
+ <textarea>
+ <label><xsl:value-of select="/Playerdata/Behavior/Program/@description"/></label>
+ </textarea>
+ </xsl:if>
+
+ <textarea>
+ <label><xsl:value-of select="/Playerdata/Behavior/Program/@episode_name"/></label>
+ </textarea>
+
+ <textarea>
+ <label>Kesto: <xsl:call-template name="pretty-print-seconds">
+ <xsl:with-param name="seconds">
+ <xsl:value-of select="/Playerdata/Behavior/Program/@episode_duration"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </label>
+ </textarea>
+
+ <link>
+ <label>Lataa</label>
+ <stream>wvt:///ruutufi/video.xsl?srcurl=<xsl:value-of select="str:encode-uri($docurl, true())"/></stream>
+ </link>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/ruutufi/mainmenu.xsl b/templates/ruutufi/mainmenu.xsl
new file mode 100644
index 0000000..1d70ac3
--- /dev/null
+++ b/templates/ruutufi/mainmenu.xsl
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Ruutu.fi</title>
+
+ <link>
+ <label>Haku</label>
+ <ref>wvt:///ruutufi/search.xsl</ref>
+ </link>
+
+ <link>
+ <label>Listaa sarjat</label>
+ <ref>wvt:///ruutufi/series.xsl?srcurl=http://www.ruutu.fi/ajax/media_get_netti_tv_series_list/all/false&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Uusimmat</label>
+ <ref>wvt:///ruutufi/program.xsl?srcurl=http://www.ruutu.fi/ajax/media_get_nettitv_media/all/video_episode/__/latestdesc/0/25/true/__&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Katsotuimmat</label>
+ <ref>wvt:///ruutufi/program.xsl?srcurl=http://www.ruutu.fi/ajax/media_get_nettitv_media/all/video_episode/__/most_watched/0/25/true/__&amp;postprocess=json2xml</ref>
+ </link>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/ruutufi/program.xsl b/templates/ruutufi/program.xsl
new file mode 100644
index 0000000..593036f
--- /dev/null
+++ b/templates/ruutufi/program.xsl
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:param name="docurl"/>
+
+<xsl:template match="dict">
+ <xsl:param name="mediatype" select="video"/>
+
+ <xsl:variable name="videoid">
+ <xsl:choose>
+ <xsl:when test="video_id_to_use">
+ <xsl:value-of select="video_id_to_use"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring-after(nodeurl, 'vid=')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <link>
+ <label>
+ <xsl:choose>
+ <xsl:when test="program_episode_name">
+ <xsl:value-of select="concat(program_episode_name, ' ', video_datetime_to_use)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="title"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </label>
+
+ <xsl:variable name="videourl">http://www.nelonen.fi/utils/video_config/%3Fq%3D<xsl:value-of select="$mediatype"/>/<xsl:value-of select="$videoid"/>%26site%3Dwww.ruutu.fi%26ageCheckURL%3Dhttp://sso.nelonenmedia.fi/ajax/check_age/%26current_page%3Dhttp://www.ruutu.fi/video</xsl:variable>
+
+ <ref>wvt:///ruutufi/description.xsl?srcurl=<xsl:value-of select="$videourl"/></ref>
+ <stream>wvt:///ruutufi/video.xsl?srcurl=<xsl:value-of select="$videourl"/></stream>
+ </link>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <xsl:variable name="start">
+ <xsl:value-of select="number(str:tokenize($docurl, '/')[9])"/>
+ </xsl:variable>
+
+ <!-- title -->
+ <title>
+ <xsl:choose>
+ <xsl:when test="/jsondocument/dict/video_episode/list/li[1]/dict/series_name">
+ <xsl:value-of select="/jsondocument/dict/video_episode/list/li[1]/dict/series_name"/>
+ </xsl:when>
+ <xsl:when test="/jsondocument/dict/video/list/li[1]/dict/clip_series_name">
+ <xsl:value-of select="/jsondocument/dict/video/list/li[1]/dict/clip_series_name"/>
+ </xsl:when>
+ <xsl:otherwise>Ruutu.fi</xsl:otherwise>
+ </xsl:choose>
+ </title>
+
+ <!-- Video links -->
+ <xsl:if test="not(/jsondocument/dict/video | /jsondocument/dict/video_episode)">
+ <textarea>
+ <label>Ei jaksoja</label>
+ </textarea>
+ </xsl:if>
+
+ <xsl:apply-templates select="/jsondocument/dict/video_episode/list/li/dict">
+ <xsl:with-param name="mediatype">video_episode</xsl:with-param>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="/jsondocument/dict/video/list/li/dict">
+ <xsl:with-param name="mediatype">video</xsl:with-param>
+ </xsl:apply-templates>
+
+ <xsl:if test="contains($docurl, '/video_episode/') and ($start = 0)">
+ <link>
+ <label>Klipit</label>
+ <ref>wvt:///ruutufi/program.xsl?srcurl=<xsl:value-of select="str:replace($docurl, '/video_episode/', '/video/')"/>&amp;postprocess=json2xml</ref>
+ </link>
+ </xsl:if>
+
+ <!-- prev/next links -->
+ <xsl:variable name="total">
+ <xsl:value-of select="number(/jsondocument/dict/total_count)"/>
+ </xsl:variable>
+
+ <xsl:variable name="urlend">
+ <xsl:text>/</xsl:text><xsl:value-of select="str:tokenize($docurl, '/')[10]"/><xsl:text>/</xsl:text><xsl:value-of select="str:tokenize($docurl, '/')[11]"/><xsl:text>/</xsl:text><xsl:value-of select="str:tokenize($docurl, '/')[12]"/>
+ </xsl:variable>
+
+ <xsl:variable name="prevstart">
+ <xsl:choose>
+ <xsl:when test="$start >= 25">
+ <xsl:value-of select="string($start - 25)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>0</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:if test="$start > 0">
+ <link>
+ <label>Edellinen</label>
+ <ref>wvt:///ruutufi/program.xsl?srcurl=<xsl:value-of select="str:encode-uri(str:replace($docurl, concat(string($start), $urlend), concat($prevstart, $urlend)), true())"/>&amp;postprocess=json2xml</ref>
+ </link>
+ </xsl:if>
+
+ <xsl:if test="$start + 25 &lt; $total">
+ <link>
+ <label>Seuraava</label>
+ <ref>wvt:///ruutufi/program.xsl?srcurl=<xsl:value-of select="str:encode-uri(str:replace($docurl, concat(string($start), $urlend), concat(string($start+25), $urlend)), true())"/>&amp;postprocess=json2xml</ref>
+ </link>
+ </xsl:if>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/ruutufi/search.xsl b/templates/ruutufi/search.xsl
new file mode 100644
index 0000000..07f2700
--- /dev/null
+++ b/templates/ruutufi/search.xsl
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTf-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Haku</title>
+
+ <textfield name="query">
+ <label>Hakusana</label>
+ </textfield>
+
+ <button>
+ <label>Hae</label>
+ <submission>wvt:///ruutufi/program.xsl?srcurl=<xsl:value-of select="str:encode-uri('http://www.ruutu.fi/search/search_new.php?params=%7B%22search%22%3A%22{query}%22%2C%22groups%22%3A%7B%22video%22%3A%7B%22types%22%3A%5B%22video_clip%22%5D%7D%2C%22video_episode%22%3A%7B%22types%22%3A%5B%22video_episode%22%5D%7D%2C%22audio%22%3A%7B%22types%22%3A%5B%22audio%22%5D%7D%7D%7D', true())"/>&amp;postprocess=json2xml</submission>
+ </button>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/ruutufi/series.xsl b/templates/ruutufi/series.xsl
new file mode 100644
index 0000000..2e8f4d2
--- /dev/null
+++ b/templates/ruutufi/series.xsl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:output method="xml" version="1.0" encoding="UTF-8" />
+
+<xsl:template match="dict">
+ <xsl:if test="is_video=1">
+ <link>
+ <label><xsl:value-of select="name"/></label>
+ <ref>wvt:///ruutufi/program.xsl?srcurl=http://www.ruutu.fi/ajax/media_get_nettitv_video/all/video_episode/<xsl:value-of select="str:encode-uri(str:encode-uri(url_encode_name, true()), true())"/>/latestdesc/0/25/true/__&amp;postprocess=json2xml</ref>
+ <!-- Yes, ruutu.fi really expects url_encode_name to be double-url-encoded! -->
+ </link>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Kaikki sarjat</title>
+
+ <xsl:apply-templates select="/jsondocument/list/li/dict"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/ruutufi/service.xml b/templates/ruutufi/service.xml
new file mode 100644
index 0000000..7a106aa
--- /dev/null
+++ b/templates/ruutufi/service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<service>
+ <title>ruutu.fi</title>
+ <ref>wvt:///ruutufi/mainmenu.xsl?srcurl=http%3A//www.ruutu.fi/</ref>
+ <description>Net TV service of the Finnish broadcasting company Nelonen</description>
+</service>
diff --git a/templates/ruutufi/video.xsl b/templates/ruutufi/video.xsl
new file mode 100644
index 0000000..e6af547
--- /dev/null
+++ b/templates/ruutufi/video.xsl
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:template match="/">
+<mediaurl>
+ <title><xsl:value-of select="concat(/Playerdata/Behavior/Program/@program_name, ' ', /Playerdata/Behavior/Program/@episode_name)"/></title>
+
+ <xsl:choose>
+ <xsl:when test="starts-with(/Playerdata/Clip/SourceFile, 'rtmp://')">
+ <url priority="50">wvt:///bin/ruutu-dl?contenttype=video/x-flv&amp;arg=<xsl:value-of select="str:encode-uri(/Playerdata/Clip/SourceFile, true())"/>&amp;arg=http://www.ruutu.fi/video</url>
+ </xsl:when>
+ <xsl:otherwise>
+ <url priority="50"><xsl:value-of select="/Playerdata/Clip/SourceFile"/></url>
+ </xsl:otherwise>
+ </xsl:choose>
+</mediaurl>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/ruutufi/video2.xsl b/templates/ruutufi/video2.xsl
new file mode 100644
index 0000000..39bef06
--- /dev/null
+++ b/templates/ruutufi/video2.xsl
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+<mediaurl>
+ <title><xsl:value-of select="concat(id('ruutuVideoInfo')/p[@class='name'], ' ', id('ruutuVideoInfo')/p[@class='timeStamp'])"/></title>
+
+ <url priority="50">wvt:///bin/ruutu-dl?contenttype=video/x-flv&amp;arg=<xsl:value-of select='substring-before(substring-after(//script[contains(., "vplayer1")], "providerURL&apos;, &apos;"), "&apos;")'/>&amp;arg=<xsl:value-of select="str:encode-uri($docurl, true())"/></url>
+</mediaurl>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/subtv/description.xsl b/templates/subtv/description.xsl
new file mode 100644
index 0000000..c914f3b
--- /dev/null
+++ b/templates/subtv/description.xsl
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:param name="title"/>
+<xsl:param name="desc"/>
+<xsl:param name="pubdate"/>
+<xsl:param name="pid"/>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="$title"/></title>
+
+ <textarea>
+ <label><xsl:value-of select="$desc"/></label>
+ </textarea>
+
+ <textarea>
+ <label><xsl:value-of select="$pubdate"/></label>
+ </textarea>
+
+ <link>
+ <label>Lataa</label>
+ <stream>wvt:///subtv/video.xsl?param=pid,<xsl:value-of select="$pid"/>&amp;param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream>
+ </link>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/subtv/mainmenu.xsl b/templates/subtv/mainmenu.xsl
new file mode 100644
index 0000000..2158295
--- /dev/null
+++ b/templates/subtv/mainmenu.xsl
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Subin netti-TV</title>
+
+ <xsl:for-each select="//div[@class='netissakaikki']/ul/li/a">
+ <link>
+ <label><xsl:value-of select="."/></label>
+ <ref>wvt:///subtv/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(@href, true())"/></ref>
+ </link>
+ </xsl:for-each>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/subtv/navigation.xsl b/templates/subtv/navigation.xsl
new file mode 100644
index 0000000..3c0b039
--- /dev/null
+++ b/templates/subtv/navigation.xsl
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:param name="docurl"/>
+<xsl:variable name="programname" select="id('page')/div[@class='ohjelma_yla ohjelmanavi']/h1"/>
+
+<xsl:template match="li">
+ <xsl:variable name="progId" select="substring-after(div[@class='outerwrap']//a/@href, '?')"/>
+ <xsl:variable name="title" select="concat($programname, ' - ', normalize-space(.//h5))"/>
+
+ <xsl:if test="$progId">
+ <link>
+ <label><xsl:value-of select="normalize-space(.//h5)"/></label>
+ <stream>wvt:///subtv/video.xsl?srcurl=<xsl:value-of select="str:encode-uri($docurl, true())"/>&amp;param=pid,<xsl:value-of select="$progId"/>&amp;param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream>
+ <ref>wvt:///subtv/description.xsl?param=title,<xsl:value-of select="str:encode-uri($title, true())"/>&amp;param=desc,<xsl:value-of select="str:encode-uri(.//span[@class='verho_content']/div, true())"/>&amp;param=pubdate,<xsl:value-of select="str:encode-uri(p[@class='julkaistu'], true())"/>&amp;param=pid,<xsl:value-of select="$progId"/></ref>
+ </link>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="$programname"/></title>
+
+ <xsl:choose>
+ <xsl:when test="id('uusimmat')/li">
+ <xsl:apply-templates select="id('uusimmat')/li"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <textarea>
+ <label>Ei jaksoja</label>
+ </textarea>
+ </xsl:otherwise>
+ </xsl:choose>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/subtv/service.xml b/templates/subtv/service.xml
new file mode 100644
index 0000000..6a7a44f
--- /dev/null
+++ b/templates/subtv/service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<service>
+ <title>Subtv</title>
+ <ref>wvt:///subtv/mainmenu.xsl?srcurl=http%3A//www.sub.fi/katsonetista/</ref>
+ <description>Sub is the third biggest commercial tv channel in Finland.</description>
+</service>
diff --git a/templates/subtv/video.xsl b/templates/subtv/video.xsl
new file mode 100644
index 0000000..32e5b1e
--- /dev/null
+++ b/templates/subtv/video.xsl
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:param name="title"/>
+<xsl:param name="pid"/>
+
+<xsl:template match="/">
+<mediaurl>
+ <title><xsl:value-of select="$title"/></title>
+
+ <url><xsl:value-of select="concat('http://www.katsomo.fi/metafile.asx?p=', $pid, '&amp;bw=800')"/></url>
+</mediaurl>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/svtplay/categories.xsl b/templates/svtplay/categories.xsl
new file mode 100644
index 0000000..bd64abd
--- /dev/null
+++ b/templates/svtplay/categories.xsl
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>SVT Play</title>
+
+ <xsl:for-each select="//div[@id='categorylist']//ul/li//a">
+ <link>
+ <label><xsl:value-of select="span[@class='category-header']"/></label>
+ <ref>wvt:///svtplay/navigation.xsl?srcurl=<xsl:value-of select="@href"/></ref>
+ </link>
+ </xsl:for-each>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/svtplay/description.xsl b/templates/svtplay/description.xsl
new file mode 100644
index 0000000..f3c3ae6
--- /dev/null
+++ b/templates/svtplay/description.xsl
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="div[@class='info']/ul">
+ <textarea>
+ <label>
+ <xsl:value-of select="normalize-space(li[@class='title']/div)"/>
+ </label>
+ </textarea>
+ <textarea>
+ <label>
+ <xsl:value-of select="normalize-space(li[@class='episode']/div)"/>
+ </label>
+ </textarea>
+ <textarea>
+ <label>
+ <xsl:value-of select="concat(normalize-space(li[1]/span[2]), ' ', normalize-space(li/span[2]/following-sibling::text()))"/>
+ </label>
+ </textarea>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title>
+ <xsl:choose>
+ <xsl:when test="normalize-space(//h1/a/img/@alt)">
+ <xsl:value-of select="concat(normalize-space(//h1/a/img/@alt), ' ', //div[@class='info']//h2)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat(normalize-space(//h1/a), ' ', //div[@class='info']//h2)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </title>
+
+ <xsl:apply-templates select="//div[@class='info']/ul"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/svtplay/navigation.xsl b/templates/svtplay/navigation.xsl
new file mode 100644
index 0000000..7071dfe
--- /dev/null
+++ b/templates/svtplay/navigation.xsl
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="text()" />
+
+<xsl:template match="div[@id='pb']">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="div[@id='sb']">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<xsl:template match="div[@id='se']">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- Programs -->
+<xsl:template match="div[@class='content']//ul/li/a[1]">
+ <link>
+ <label><xsl:value-of select="normalize-space(span)"/></label>
+ <ref>wvt:///svtplay/programmenu.xsl?srcurl=<xsl:value-of select="str:encode-uri(@href, true())"/></ref>
+ </link>
+</xsl:template>
+
+<!-- next/prev links -->
+<xsl:template match="div[@class='footer']/div[@class='pagination']/ul[@class='pagination program']/li">
+ <xsl:if test="@class='prev '">
+ <link>
+ <label><xsl:value-of select="a/img/@alt"/></label>
+ <ref>wvt:///svtplay/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(a/@href, true())"/></ref>
+ </link>
+ </xsl:if>
+
+ <xsl:if test="@class='next '">
+ <link>
+ <label><xsl:value-of select="a/img/@alt"/></label>
+ <ref>wvt:///svtplay/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(a/@href, true())"/></ref>
+ </link>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title>
+ <xsl:choose>
+ <xsl:when test="normalize-space(//h1)">
+ <xsl:value-of select="normalize-space(//h1)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="normalize-space(//h1/a/img/@alt)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </title>
+
+ <!-- In most categories the content is in pb and se nodes, except
+ for Nyheter and Sport, where the content is in sb and se nodes.
+ On the other hand, we can't match sb unconditionally because in
+ Öppet arkiv sb contains klips instead of programs! -->
+ <xsl:choose>
+ <xsl:when test="//div[@id='pb']">
+ <xsl:apply-templates select="//div[@id='pb']|//div[@id='se']"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:apply-templates select="//div[@id='sb']|//div[@id='se']"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/svtplay/programmenu.xsl b/templates/svtplay/programmenu.xsl
new file mode 100644
index 0000000..4bd120c
--- /dev/null
+++ b/templates/svtplay/programmenu.xsl
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="text()" />
+
+<xsl:template match="div[@id='pb']">
+ <xsl:apply-templates/>
+</xsl:template>
+
+<!-- Broadcasts -->
+<xsl:template match="div[@class='content']//ul/li/a">
+ <link>
+ <label><xsl:value-of select="normalize-space(span)"/></label>
+ <ref>wvt:///svtplay/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(@href, true())"/></ref>
+ <stream>wvt:///svtplay/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(@href, true())"/></stream>
+ </link>
+</xsl:template>
+
+<!-- next/prev links -->
+<xsl:template match="div[@class='footer']/div[@class='pagination']/ul[@class='pagination program']/li">
+ <xsl:if test="@class='prev '">
+ <link>
+ <label><xsl:value-of select="a/img/@alt"/></label>
+ <ref>wvt:///svtplay/programmenu.xsl?srcurl=<xsl:value-of select="str:encode-uri(a/@href, true())"/></ref>
+ </link>
+ </xsl:if>
+
+ <xsl:if test="@class='next '">
+ <link>
+ <label><xsl:value-of select="a/img/@alt"/></label>
+ <ref>wvt:///svtplay/programmenu.xsl?srcurl=<xsl:value-of select="str:encode-uri(a/@href, true())"/></ref>
+ </link>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title>
+ <xsl:choose>
+ <xsl:when test="normalize-space(//h1/a)">
+ <xsl:value-of select="normalize-space(//h1/a)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="normalize-space(//h1/a/img/@alt)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </title>
+
+ <xsl:apply-templates select="//div[@id='sb']"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/svtplay/service.xml b/templates/svtplay/service.xml
new file mode 100644
index 0000000..86a36f6
--- /dev/null
+++ b/templates/svtplay/service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<service>
+ <title>SVT Play</title>
+ <ref>wvt:///svtplay/categories.xsl?srcurl=http://svtplay.se/kategorier</ref>
+ <description>Swedish Television, online TV service</description>
+</service>
diff --git a/templates/svtplay/video.xsl b/templates/svtplay/video.xsl
new file mode 100644
index 0000000..af6aeb9
--- /dev/null
+++ b/templates/svtplay/video.xsl
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+<mediaurl>
+ <title>
+ <xsl:choose>
+ <xsl:when test="normalize-space(//h1/a/img/@alt)">
+ <xsl:value-of select="concat(normalize-space(//h1/a/img/@alt), ' ', //div[@class='info']//h2)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="concat(normalize-space(//h1/a), ' ', //div[@class='info']//h2)"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </title>
+
+ <url priority="50"><xsl:value-of select="substring-before(substring-after((//object/param[@name='flashvars'])[1]/@value, 'pathflv='), '&amp;')"/></url>
+ <url priority="40"><xsl:value-of select="//a[@class='external-player']/@href"/></url>
+</mediaurl>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/vimeo/channels.xsl b/templates/vimeo/channels.xsl
new file mode 100644
index 0000000..ae3c0d8
--- /dev/null
+++ b/templates/vimeo/channels.xsl
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Vimeo Channels</title>
+
+ <xsl:for-each select="//div[@class='title']/a">
+ <link>
+ <label><xsl:value-of select="."/></label>
+ <ref>wvt:///vimeo/navigation.xsl?srcurl=http://vimeo.com/api/v2/channel/<xsl:value-of select="str:split(@href, '/')[last()]"/>/videos.xml</ref>
+ </link>
+ </xsl:for-each>
+
+ <xsl:for-each select="//div[@class='pagination']/ul/li[@class='arrow']/a">
+ <link>
+ <xsl:if test="img/@alt = 'previous'">
+ <label>Previous</label>
+ </xsl:if>
+ <xsl:if test="img/@alt = 'next'">
+ <label>Next</label>
+ </xsl:if>
+ <ref>wvt:///vimeo/channels.xsl?srcurl=<xsl:value-of select="./@href"/></ref>
+ </link>
+ </xsl:for-each>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/vimeo/description.xsl b/templates/vimeo/description.xsl
new file mode 100644
index 0000000..a8797cd
--- /dev/null
+++ b/templates/vimeo/description.xsl
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<!-- Convert $seconds to hours:min:sec format -->
+<xsl:template name="pretty-print-seconds">
+ <xsl:param name="seconds"/>
+
+ <xsl:variable name="sec" select="$seconds mod 60"/>
+ <xsl:variable name="min" select="floor($seconds div 60) mod 60"/>
+ <xsl:variable name="hour" select="floor($seconds div 3600)"/>
+
+ <xsl:value-of select="concat($hour, ':', format-number($min, '00'), ':', format-number($sec, '00'))"/>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="/videos/video/title"/></title>
+ <textarea>
+ <label><xsl:value-of select="/videos/video/description"/></label>
+ </textarea>
+
+ <textarea>
+ <label>Duration: <xsl:call-template name="pretty-print-seconds">
+ <xsl:with-param name="seconds">
+ <xsl:value-of select="/videos/video/duration"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </label>
+ </textarea>
+
+ <textarea>
+ <label>Views: <xsl:value-of select="/videos/video/stats_number_of_plays"/></label>
+ </textarea>
+
+ <textarea>
+ <label>Likes: <xsl:value-of select="/videos/video/stats_number_of_likes"/></label>
+ </textarea>
+
+ <textarea>
+ <label>Published: <xsl:value-of select="/videos/video/upload_date"/></label>
+ </textarea>
+
+ <link>
+ <label>More videos by <xsl:value-of select="/videos/video/user_name"/></label>
+ <ref>wvt:///vimeo/navigation.xsl?srcurl=http://vimeo.com/api/v2/<xsl:value-of select="str:split(/videos/video/user_url, '/')[last()]"/>/videos.xml</ref>
+ </link>
+
+ <link>
+ <label>Download this video</label>
+ <stream>wvt:///vimeo/video.xsl?srcurl=http://www.vimeo.com/moogaloop/load/clip:<xsl:value-of select="/videos/video/id"/></stream>
+ </link>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/vimeo/groups.xsl b/templates/vimeo/groups.xsl
new file mode 100644
index 0000000..2379058
--- /dev/null
+++ b/templates/vimeo/groups.xsl
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Vimeo Groups</title>
+
+ <xsl:for-each select="//div[@class='title']/a">
+ <link>
+ <label><xsl:value-of select="."/></label>
+ <ref>wvt:///vimeo/navigation.xsl?srcurl=http://vimeo.com/api/v2/group/<xsl:value-of select="str:split(@href, '/')[last()]"/>/videos.xml</ref>
+ </link>
+ </xsl:for-each>
+
+ <xsl:for-each select="//div[@class='pagination']/ul/li[@class='arrow']/a">
+ <link>
+ <xsl:if test="img/@alt = 'previous'">
+ <label>Previous</label>
+ </xsl:if>
+ <xsl:if test="img/@alt = 'next'">
+ <label>Next</label>
+ </xsl:if>
+ <ref>wvt:///vimeo/groups.xsl?srcurl=<xsl:value-of select="./@href"/></ref>
+ </link>
+ </xsl:for-each>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/vimeo/mainmenu.xsl b/templates/vimeo/mainmenu.xsl
new file mode 100644
index 0000000..3667ed7
--- /dev/null
+++ b/templates/vimeo/mainmenu.xsl
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Vimeo</title>
+
+ <link>
+ <label>Search</label>
+ <ref>wvt:///vimeo/search.xsl?srcurl=http://www.vimeo.com/</ref>
+ </link>
+
+ <link>
+ <label>Channels</label>
+ <ref>wvt:///vimeo/channels.xsl?srcurl=http://www.vimeo.com/channels/all</ref>
+ </link>
+
+ <link>
+ <label>Groups</label>
+ <ref>wvt:///vimeo/groups.xsl?srcurl=http://www.vimeo.com/groups/all</ref>
+ </link>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/vimeo/navigation.xsl b/templates/vimeo/navigation.xsl
new file mode 100644
index 0000000..8583212
--- /dev/null
+++ b/templates/vimeo/navigation.xsl
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="video">
+ <link>
+ <label><xsl:value-of select="title"/></label>
+ <stream>wvt:///vimeo/video.xsl?srcurl=http://www.vimeo.com/moogaloop/load/clip:<xsl:value-of select="id"/></stream>
+ <ref>wvt:///vimeo/description.xsl?srcurl=http://vimeo.com/api/v2/video/<xsl:value-of select="id"/>.xml</ref>
+ </link>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Vimeo videos</title>
+
+ <xsl:apply-templates select="/videos/video"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/vimeo/search.xsl b/templates/vimeo/search.xsl
new file mode 100644
index 0000000..4939e25
--- /dev/null
+++ b/templates/vimeo/search.xsl
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Vimeo Search</title>
+
+ <textfield name="keywords">
+ <label>Search terms</label>
+ </textfield>
+
+ <itemlist name="orderby">
+ <label>Show me</label>
+ <item value="">most relevant</item>
+ <item value="/sort:newest">newest</item>
+ <item value="/sort:plays">most played</item>
+ <item value="/sort:likes">most liked</item>
+ </itemlist>
+
+ <button>
+ <label>Search</label>
+ <submission>wvt:///vimeo/searchresults.xsl?srcurl=<xsl:value-of select="concat(str:encode-uri('http://vimeo.com/videos/search:', true()), '{keywords}/', substring(id('xsrft')/@value, 0, 9), '{orderby}')"/>&amp;HTTP-header=cookie,xsrft%3D<xsl:value-of select="substring(id('xsrft')/@value, 0, 9)"/></submission>
+ </button>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/vimeo/searchresults.xsl b/templates/vimeo/searchresults.xsl
new file mode 100644
index 0000000..6f5d817
--- /dev/null
+++ b/templates/vimeo/searchresults.xsl
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Search results</title>
+
+ <xsl:for-each select="//div[@class='title']/a">
+ <link>
+ <label><xsl:value-of select="."/></label>
+ <stream>wvt:///vimeo/video.xsl?srcurl=http://www.vimeo.com/moogaloop/load/clip:<xsl:value-of select="str:split(@href, '/')[last()]"/></stream>
+ <ref>wvt:///vimeo/description.xsl?srcurl=http://vimeo.com/api/v2/video/<xsl:value-of select="str:split(@href, '/')[last()]"/>.xml</ref>
+ </link>
+ </xsl:for-each>
+
+ <xsl:for-each select="//div[@class='pagination']/ul/li[@class='arrow']/a">
+ <link>
+ <xsl:if test="img/@alt = 'previous'">
+ <label>Previous</label>
+ </xsl:if>
+ <xsl:if test="img/@alt = 'next'">
+ <label>Next</label>
+ </xsl:if>
+ <ref>wvt:///vimeo/searchresults.xsl?srcurl=<xsl:value-of select="./@href"/></ref>
+ </link>
+ </xsl:for-each>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/vimeo/service.xml b/templates/vimeo/service.xml
new file mode 100644
index 0000000..77af401
--- /dev/null
+++ b/templates/vimeo/service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<service>
+ <title>Vimeo</title>
+ <ref>wvt:///vimeo/mainmenu.xsl</ref>
+ <description>Vimeo is a video-centric social networking site</description>
+</service>
diff --git a/templates/vimeo/video.xsl b/templates/vimeo/video.xsl
new file mode 100644
index 0000000..3b1b7a9
--- /dev/null
+++ b/templates/vimeo/video.xsl
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+<mediaurl>
+ <title><xsl:value-of select="/xml/video/caption"/></title>
+
+ <url priority="50">http://www.vimeo.com/moogaloop/play/clip:<xsl:value-of select="/xml/video/nodeId"/>/<xsl:value-of select="/xml/request_signature"/>/<xsl:value-of select="/xml/request_signature_expires"/>/?q=sd</url>
+</mediaurl>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/yleareena/description.xsl b/templates/yleareena/description.xsl
new file mode 100644
index 0000000..2340cb2
--- /dev/null
+++ b/templates/yleareena/description.xsl
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="normalize-space(//h1[@class='cliptitle'])"/></title>
+ <textarea>
+ <label><xsl:value-of select="normalize-space(id('relatedinfo')//div[@class='relatedinfo-text description'])"/></label>
+ </textarea>
+ <textarea>
+ <!-- Kesto -->
+ <label><xsl:value-of select="id('relatedinfo')/div/div/div[@class='relatedinfo-text meta']/ul/li[contains(., 'Kesto')]"/></label>
+ </textarea>
+ <textarea>
+ <!-- Julkaistu -->
+ <label><xsl:value-of select="id('relatedinfo-more')/div/div[1]/ul/li[contains(., 'Julkaistu')]"/></label>
+ </textarea>
+ <textarea>
+ <!-- Kieli -->
+ <label><xsl:value-of select="id('relatedinfo-more')/div/div[2]/ul[1]/li[1]"/></label>
+ </textarea>
+ <textarea>
+ <!-- Kanava -->
+ <label><xsl:value-of select="id('relatedinfo')//div[@class='relatedinfo-text meta']/ul/li[1]"/></label>
+ </textarea>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/yleareena/livebroadcasts.xsl b/templates/yleareena/livebroadcasts.xsl
new file mode 100644
index 0000000..865fcee
--- /dev/null
+++ b/templates/yleareena/livebroadcasts.xsl
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template match="text()"/>
+
+<!-- Käynnissä olevat lähetykset -->
+<xsl:template match="div[@class='ongoing']//div[@class='showlistitem-description']">
+ <link>
+ <label><xsl:value-of select="a"/></label>
+ <stream>wvt:///yleareena/livestream.xsl?param=stream,<xsl:value-of select='substring-before(substring-after(a/@onclick, "stream&apos;, &apos;"), "&apos;")'/></stream>
+ </link>
+</xsl:template>
+
+<!-- "Aina suorana" -->
+<xsl:template match="div[contains(@class, 'live-container')]">
+ <link>
+ <label><xsl:value-of select="h2/span/a"/></label>
+ <stream>wvt:///yleareena/livestream.xsl?param=stream,<xsl:value-of select='substring-before(substring-after(h2/span/a/@onclick, "stream&apos;, &apos;"), "&apos;")'/></stream>
+ </link>
+</xsl:template>
+
+<!-- Tulevat lähetykset -->
+<xsl:template match="div[@class='upcoming']/div/div[@class='showlistitem-description']">
+ <textarea>
+ <label><xsl:value-of select="h3"/>, <xsl:value-of select="ul/li[1]"/></label>
+ </textarea>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Suorat lähetykset</title>
+
+ <xsl:apply-templates select="id('liveshows')/div[@class='ongoing']"/>
+
+ <xsl:apply-templates select="id('liveshows')/div/div[contains(@class, 'live-container')]"/>
+
+ <textarea>
+ <label>Tulossa seuraavaksi:</label>
+ </textarea>
+ <xsl:apply-templates select="id('liveshows')/div[@class='upcoming']"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/yleareena/livestream.xsl b/templates/yleareena/livestream.xsl
new file mode 100644
index 0000000..b6d7ee2
--- /dev/null
+++ b/templates/yleareena/livestream.xsl
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:param name="stream"></xsl:param>
+
+<xsl:template match="/">
+ <mediaurl>
+ <title>livestream-<xsl:value-of select="$stream"/></title>
+ <xsl:choose>
+ <xsl:when test="$stream">
+ <url>wvt:///bin/yle-dl?contenttype=video/x-flv&amp;arg=http%3A//areena.yle.fi/player/index.php%3Fstream%3D<xsl:value-of select="$stream"/>%26language%3Dfi</url>
+ </xsl:when>
+ <xsl:otherwise>
+ <url/>
+ </xsl:otherwise>
+ </xsl:choose>
+</mediaurl>
+
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/yleareena/mainmenu.xsl b/templates/yleareena/mainmenu.xsl
new file mode 100644
index 0000000..d17ede6
--- /dev/null
+++ b/templates/yleareena/mainmenu.xsl
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>YLE Areena</title>
+
+ <link>
+ <label>Haku</label>
+ <ref>wvt:///yleareena/search.xsl?srcurl=http://areena.yle.fi/haku</ref>
+ </link>
+
+ <link>
+ <label>Suorat lähetykset</label>
+ <ref>wvt:///yleareena/livebroadcasts.xsl?srcurl=http://areena.yle.fi/live</ref>
+ </link>
+
+ <link>
+ <label>Kaikki ohjelmat</label>
+ <ref>wvt:///yleareena/programlist.xsl?srcurl=http://areena.yle.fi/ohjelmat</ref>
+ </link>
+
+ <xsl:for-each select="//div[h4='Sisältö aihealueittain']/ul/li/a">
+ <link>
+ <label><xsl:value-of select="."/></label>
+ <ref><xsl:value-of select="concat('wvt:///yleareena/navigation.xsl?srcurl=', str:encode-uri(concat(./@href, '/feed/rss'), true()))"/></ref>
+ </link>
+ </xsl:for-each>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/yleareena/navigation.xsl b/templates/yleareena/navigation.xsl
new file mode 100644
index 0000000..bbf0ad7
--- /dev/null
+++ b/templates/yleareena/navigation.xsl
@@ -0,0 +1,119 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:param name="docurl"/>
+<xsl:param name="title" select="/rss/channel/title"/>
+
+<xsl:template name="prevnextlinks">
+ <!-- Add previous and next links for a navigation page.
+
+ Extract the current page number from the URL (the number after
+ /sivu/) and adds links to previous and following pages. If the
+ page number is missing, it is assumed to be 1.
+
+ BUG: if the last page has 20 links, an extra "next" link is
+ generated
+ -->
+
+ <xsl:variable name="page" select="number(substring-before(substring-after($docurl, '/sivu/'), '/'))"/>
+
+ <xsl:choose>
+ <xsl:when test="$page &gt; 1">
+
+ <xsl:variable name="urlprefix" select="substring-before($docurl, '/sivu/')"/>
+ <xsl:variable name="urlpostfix" select="substring-after(substring-after($docurl, '/sivu/'), '/')"/>
+
+ <xsl:variable name="prevurl" select="concat($urlprefix, '/sivu/', $page - 1, '/', $urlpostfix)"/>
+ <xsl:variable name="nexturl" select="concat($urlprefix, '/sivu/', $page + 1, '/', $urlpostfix)"/>
+
+ <link>
+ <label>Edellinen</label>
+ <ref>wvt:///yleareena/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri($prevurl, true())"/></ref>
+ </link>
+
+ <xsl:if test="count(/rss/channel/item) &gt;= 20">
+ <link>
+ <label>Seuraava</label>
+ <ref>wvt:///yleareena/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri($nexturl, true())"/></ref>
+ </link>
+ </xsl:if>
+ </xsl:when>
+
+ <xsl:otherwise>
+
+ <xsl:if test="count(/rss/channel/item) &gt;= 20">
+ <xsl:variable name="nexturl">
+ <xsl:choose>
+ <xsl:when test="contains($docurl, '/sivu/')">
+ <xsl:value-of select="concat(substring-before($docurl, '/sivu/'), '/sivu/2/', substring-after(substring-after($docurl, '/sivu/'), '/'))"/>
+ </xsl:when>
+
+ <xsl:when test="contains($docurl, '/feed/rss')">
+ <xsl:value-of select="str:replace($docurl, '/feed/rss', '/sivu/2/feed/rss')"/>
+ </xsl:when>
+
+ <xsl:otherwise>
+ <xsl:value-of select="concat($docurl, '/sivu/2')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <link>
+ <label>Seuraava</label>
+ <ref>wvt:///yleareena/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri($nexturl, true())"/></ref>
+ </link>
+ </xsl:if>
+
+ </xsl:otherwise>
+
+
+ </xsl:choose>
+</xsl:template>
+
+
+<xsl:template match="/rss/channel/item">
+ <link>
+ <label><xsl:value-of select="title"/></label>
+ <ref>wvt:///yleareena/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(link, true())"/></ref>
+ <stream>wvt:///yleareena/video.xsl?srcurl=<xsl:value-of select="str:encode-uri(link, true())"/>&amp;param=title,<xsl:value-of select="str:encode-uri(concat(title, '-', str:split(pubDate, ' ')[2], '-', str:split(pubDate, ' ')[3], '-', str:split(pubDate, ' ')[4]), true())"/></stream>
+ </link>
+</xsl:template>
+
+
+<xsl:template match="/">
+<wvmenu>
+ <xsl:choose>
+
+ <!-- Regular video links -->
+ <xsl:when test="/rss">
+ <title><xsl:value-of select="$title"/></title>
+
+ <xsl:apply-templates select="/rss/channel/item"/>
+
+ <xsl:call-template name="prevnextlinks"/>
+ </xsl:when>
+
+ <!-- No search results -->
+ <xsl:otherwise>
+ <title>Hae Areenasta: Ei osumia</title>
+
+ <textarea>
+ <xsl:choose>
+ <xsl:when test="//h4">
+ <label><xsl:value-of select="//h4"/></label>
+ </xsl:when>
+ <xsl:otherwise>
+ <label>Ei osumia</label>
+ </xsl:otherwise>
+ </xsl:choose>
+ </textarea>
+ </xsl:otherwise>
+
+ </xsl:choose>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/yleareena/programlist.xsl b/templates/yleareena/programlist.xsl
new file mode 100644
index 0000000..0a4ece4
--- /dev/null
+++ b/templates/yleareena/programlist.xsl
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="tr">
+ <link>
+ <label><xsl:value-of select="td[1]/a"/></label>
+ <ref>wvt:///yleareena/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat(td[1]/a/@href, '/feed/rss'), true())"/>&amp;param=title,<xsl:value-of select="str:encode-uri(td[1]/a, true())"/></ref>
+ </link>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Ohjelmat A-Ö</title>
+
+ <xsl:apply-templates select="id('programlist-ao')/table/tbody/tr[td]"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/yleareena/search.xsl b/templates/yleareena/search.xsl
new file mode 100644
index 0000000..fa487f4
--- /dev/null
+++ b/templates/yleareena/search.xsl
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:template match="fieldset">
+ <xsl:if test="select">
+ <itemlist>
+ <xsl:attribute name="name"><xsl:value-of select="select/@name"/></xsl:attribute>
+ <label><xsl:value-of select="label"/></label>
+ <xsl:for-each select="select/option|select/optgroup/option">
+ <item>
+ <xsl:attribute name="value"><xsl:value-of select="@value"/></xsl:attribute>
+ <xsl:value-of select="."/>
+ </item>
+ </xsl:for-each>
+ </itemlist>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Hae Areenasta</title>
+
+ <textfield name="keyword">
+ <label>Hakusana</label>
+ </textfield>
+
+ <xsl:apply-templates select="id('widesearch')/form/fieldset[not(contains(@class, 'search-keyword'))]"/>
+
+ <itemlist name="naytetaan_ulkomailla">
+ <label>Vain Suomen ulkopuolella katsottavat</label>
+ <item value="kaikki">Kaikki</item>
+ <item value="kylla">Kyllä</item>
+ </itemlist>
+
+ <button>
+ <label>Hae</label>
+ <submission>wvt:///yleareena/navigation.xsl?srcurl=http%3A//areena.yle.fi/haku/{category}/uusimmat/hakusana/{keyword}/kanava/{channel}/media/{mediatype}/julkaistu/{date}/kieli/{language}/naytetaan_ulkomailla/{naytetaan_ulkomailla}/feed/rss</submission>
+ </button>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/yleareena/service.xml b/templates/yleareena/service.xml
new file mode 100644
index 0000000..0d7aa03
--- /dev/null
+++ b/templates/yleareena/service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<service>
+ <title>YLE Areena</title>
+ <ref>wvt:///yleareena/mainmenu.xsl?srcurl=http%3A//areena.yle.fi/</ref>
+ <description>Video service by YLE, the Finland's national public service broadcasting company</description>
+</service>
diff --git a/templates/yleareena/video.xsl b/templates/yleareena/video.xsl
new file mode 100644
index 0000000..f0c2d6a
--- /dev/null
+++ b/templates/yleareena/video.xsl
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
+
+<xsl:param name="title"/>
+<xsl:param name="docurl"/>
+
+<xsl:template match="/">
+ <mediaurl>
+ <title><xsl:value-of select="$title"/></title>
+ <url>wvt:///bin/yle-dl?contenttype=video/x-flv&amp;arg=<xsl:value-of select="str:encode-uri($docurl, true())"/></url>
+</mediaurl>
+
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/youtube/categories.xsl b/templates/youtube/categories.xsl
new file mode 100644
index 0000000..080218b
--- /dev/null
+++ b/templates/youtube/categories.xsl
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ xmlns:app="http://www.w3.org/2007/app"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:yt="http://gdata.youtube.com/schemas/2007"
+ exclude-result-prefixes="str app atom yt">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Youtube</title>
+
+ <link>
+ <label>Search</label>
+ <ref>wvt:///youtube/search.xsl</ref>
+ </link>
+
+ <xsl:for-each select="/app:categories/atom:category[yt:browsable]">
+ <link>
+ <label><xsl:value-of select="@label"/></label>
+ <ref>wvt:///youtube/navigation.xsl?srcurl=http://gdata.youtube.com/feeds/api/standardfeeds/most_popular_<xsl:value-of select="str:encode-uri(@term, true())"/>%3Fmax-results%3D20%26v%3D2</ref>
+ </link>
+ </xsl:for-each>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/youtube/description.xsl b/templates/youtube/description.xsl
new file mode 100644
index 0000000..e728961
--- /dev/null
+++ b/templates/youtube/description.xsl
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:media="http://search.yahoo.com/mrss/"
+ xmlns:gd="http://schemas.google.com/g/2005"
+ xmlns:yt="http://gdata.youtube.com/schemas/2007"
+ exclude-result-prefixes="atom str media gd yt">
+
+<!-- Convert $seconds to hours:min:sec format -->
+<xsl:template name="pretty-print-seconds">
+ <xsl:param name="seconds"/>
+
+ <xsl:variable name="sec" select="$seconds mod 60"/>
+ <xsl:variable name="min" select="floor($seconds div 60) mod 60"/>
+ <xsl:variable name="hour" select="floor($seconds div 3600)"/>
+
+ <xsl:value-of select="concat($hour, ':', format-number($min, '00'), ':', format-number($sec, '00'))"/>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="/atom:entry/atom:title"/></title>
+ <textarea>
+ <label><xsl:value-of select="/atom:entry/media:group/media:description"/></label>
+ </textarea>
+
+ <textarea>
+ <label>Duration: <xsl:call-template name="pretty-print-seconds">
+ <xsl:with-param name="seconds">
+ <xsl:value-of select="/atom:entry/media:group/yt:duration/@seconds"/>
+ </xsl:with-param>
+ </xsl:call-template>
+ </label>
+ </textarea>
+
+ <textarea>
+ <label>Views: <xsl:value-of select="/atom:entry/yt:statistics/@viewCount"/></label>
+ </textarea>
+
+ <textarea>
+ <label>Rating: <xsl:value-of select="/atom:entry/gd:rating/@average"/></label>
+ </textarea>
+
+ <textarea>
+ <label>Published: <xsl:value-of select="str:replace(str:replace(/atom:entry/atom:published, '.000', ' '), 'T', ' ')"/></label>
+ </textarea>
+
+ <xsl:if test="/atom:entry/atom:link[@rel='http://gdata.youtube.com/schemas/2007#video.responses']">
+ <link>
+ <label>Video responses</label>
+ <ref>wvt:///youtube/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(/atom:entry/atom:link[@rel='http://gdata.youtube.com/schemas/2007#video.responses']/@href, true())"/></ref>
+ </link>
+ </xsl:if>
+
+ <xsl:if test="/atom:entry/atom:link[@rel='http://gdata.youtube.com/schemas/2007#video.related']">
+ <link>
+ <label>Related videos</label>
+ <ref>wvt:///youtube/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(/atom:entry/atom:link[@rel='http://gdata.youtube.com/schemas/2007#video.related']/@href, true())"/></ref>
+ </link>
+ </xsl:if>
+
+ <link>
+ <label>Download this video</label>
+ <stream>wvt:///youtube/video.xsl?srcurl=http://www.youtube.com/watch?v=<xsl:value-of select="/atom:entry/media:group/yt:videoid"/></stream>
+ </link>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/youtube/navigation.xsl b/templates/youtube/navigation.xsl
new file mode 100644
index 0000000..a5fd1c7
--- /dev/null
+++ b/templates/youtube/navigation.xsl
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:atom="http://www.w3.org/2005/Atom"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ xmlns:media="http://search.yahoo.com/mrss/"
+ xmlns:yt="http://gdata.youtube.com/schemas/2007"
+ exclude-result-prefixes="atom str media yt">
+
+<xsl:template match="atom:entry">
+ <link>
+ <label><xsl:value-of select="atom:title"/></label>
+ <stream>wvt:///youtube/video.xsl?srcurl=http://www.youtube.com/watch?v=<xsl:value-of select="media:group/yt:videoid"/></stream>
+ <ref>wvt:///youtube/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(atom:link[@rel='self']/@href, true())"/></ref>
+ </link>
+</xsl:template>
+
+<xsl:template match="atom:link">
+ <xsl:if test="@rel = 'previous'">
+ <link>
+ <label>Previous</label>
+ <ref>wvt:///youtube/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(@href, true())"/></ref>
+ </link>
+ </xsl:if>
+
+ <xsl:if test="@rel = 'next'">
+ <link>
+ <label>Next</label>
+ <ref>wvt:///youtube/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(@href, true())"/></ref>a
+ </link>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="/atom:feed/atom:title"/></title>
+
+ <xsl:if test="/atom:feed/atom:link[@rel='http://schemas.google.com/g/2006#spellcorrection']">
+ <link>
+ <label>Did you mean <xsl:value-of select="/atom:feed/atom:link[@rel='http://schemas.google.com/g/2006#spellcorrection']/@title"/>?</label>
+ <ref>wvt:///youtube/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(/atom:feed/atom:link[@rel='http://schemas.google.com/g/2006#spellcorrection']/@href, true())"/></ref>
+ </link>
+ </xsl:if>
+
+
+ <!-- Video links -->
+ <xsl:apply-templates select="/atom:feed/atom:entry"/>
+
+ <xsl:if test="count(/atom:feed/atom:entry) = 0">
+ <textarea>
+ <label>No match</label>
+ </textarea>
+ </xsl:if>
+
+ <!-- Next and prev links -->
+ <xsl:apply-templates select="/atom:feed/atom:link[@rel='previous']|/atom:feed/atom:link[@rel='next']"/>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/youtube/search.xsl b/templates/youtube/search.xsl
new file mode 100644
index 0000000..d28e3c6
--- /dev/null
+++ b/templates/youtube/search.xsl
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ exclude-result-prefixes="str">
+
+<xsl:template match="/">
+<wvmenu>
+ <title>Youtube Search</title>
+
+ <textfield name="q">
+ <label>Search terms</label>
+ </textfield>
+
+ <itemlist name="orderby">
+ <label>Sort by</label>
+ <item value="relevance">Relevance</item>
+ <item value="published">Date Added</item>
+ <item value="viewCount">View Count</item>
+ <item value="rating">Rating</item>
+ </itemlist>
+
+ <itemlist name="time">
+ <label>Uploaded</label>
+ <item value="all_time">Anytime</item>
+ <item value="today">Today</item>
+ <item value="this_week">This week</item>
+ <item value="this_month">This month</item>
+ </itemlist>
+
+ <button>
+ <label>Search</label>
+ <submission>wvt:///youtube/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri('http://gdata.youtube.com/feeds/api/videos?q={q}&amp;orderby={orderby}&amp;time={time}&amp;max-results=20&amp;safeSearch=none&amp;format=5&amp;v=2', true())"/></submission>
+ </button>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/youtube/service.xml b/templates/youtube/service.xml
new file mode 100644
index 0000000..f5719a6
--- /dev/null
+++ b/templates/youtube/service.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<service>
+ <title>YouTube</title>
+ <ref>wvt:///youtube/categories.xsl?srcurl=http://gdata.youtube.com/schemas/2007/categories.cat</ref>
+ <description>Video sharing service on which users worldwide can upload their videos</description>
+</service>
diff --git a/templates/youtube/video.xsl b/templates/youtube/video.xsl
new file mode 100644
index 0000000..d38a99e
--- /dev/null
+++ b/templates/youtube/video.xsl
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:strip-space elements="div" />
+
+<!-- old variables (before appr. April 2010) -->
+<xsl:variable name="t1" select="substring-before(substring-after(html/head/script[contains(., 'swfArgs') or contains(., 'SWF_ARGS')], '&quot;t&quot;: &quot;'), '&quot;')"/>
+<xsl:variable name="video_id1" select="substring-before(substring-after(html/head/script[contains(., 'swfArgs') or contains(., 'SWF_ARGS')], '&quot;video_id&quot;: &quot;'), '&quot;')"/>
+
+<!-- new variables -->
+<xsl:variable name="t2" select="substring-before(substring-after(//script[contains(., 'swfHTML')], '&amp;t='), '&amp;')"/>
+<xsl:variable name="video_id2" select="substring-before(substring-after(//script[contains(., 'swfHTML')], '&amp;video_id='), '&amp;')"/>
+
+<xsl:variable name="t">
+ <xsl:choose>
+ <xsl:when test="$t1"><xsl:value-of select="$t1"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$t2"/></xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+<xsl:variable name="video_id">
+ <xsl:choose>
+ <xsl:when test="$video_id1"><xsl:value-of select="$video_id1"/></xsl:when>
+ <xsl:otherwise><xsl:value-of select="$video_id2"/></xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+
+<xsl:template match="/">
+<mediaurl>
+ <title>
+ <xsl:choose>
+ <xsl:when test="/html/head/meta[@name='title']/@content">
+ <xsl:value-of select="/html/head/meta[@name='title']/@content"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="//div[@id='watch-vid-title']//h1"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </title>
+
+ <url priority="70">http://www.youtube.com/get_video?video_id=<xsl:value-of select="$video_id"/>&amp;t=<xsl:value-of select="$t"/>&amp;fmt=22</url>
+ <url priority="60">http://www.youtube.com/get_video?video_id=<xsl:value-of select="$video_id"/>&amp;t=<xsl:value-of select="$t"/>&amp;fmt=18</url>
+ <url priority="50">http://www.youtube.com/get_video?video_id=<xsl:value-of select="$video_id"/>&amp;t=<xsl:value-of select="$t"/></url>
+</mediaurl>
+</xsl:template>
+
+</xsl:stylesheet>