summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorAntti Ajanki <antti.ajanki@iki.fi>2011-06-12 15:18:36 +0300
committerAntti Ajanki <antti.ajanki@iki.fi>2011-06-12 15:18:36 +0300
commit541779154be54e113ddd8bfac7245aed484e9ced (patch)
tree3c4384f255b27db0c930defd14052374af9febbe /templates
parentbd478ec0ef43d29f47a8892d558280cdd05a1dbb (diff)
downloadvdr-plugin-webvideo-541779154be54e113ddd8bfac7245aed484e9ced.tar.gz
vdr-plugin-webvideo-541779154be54e113ddd8bfac7245aed484e9ced.tar.bz2
Fix Katsomo, add encoding attribute to <submission> node
Diffstat (limited to 'templates')
-rw-r--r--templates/katsomo.fi/description.xsl55
-rw-r--r--templates/katsomo.fi/mainmenu.xsl15
-rw-r--r--templates/katsomo.fi/navigation.xsl48
-rw-r--r--templates/katsomo.fi/program.xsl36
-rw-r--r--templates/katsomo.fi/search.xsl2
-rw-r--r--templates/katsomo.fi/searchresults.xsl64
-rw-r--r--templates/katsomo.fi/video.xsl26
-rw-r--r--templates/katsomo.fi/videopage.xsl31
-rw-r--r--templates/www.katsomo.fi/videopage.xsl15
9 files changed, 203 insertions, 89 deletions
diff --git a/templates/katsomo.fi/description.xsl b/templates/katsomo.fi/description.xsl
new file mode 100644
index 0000000..59c313b
--- /dev/null
+++ b/templates/katsomo.fi/description.xsl
@@ -0,0 +1,55 @@
+<?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:param name="docurl"/>
+<xsl:param name="live"/>
+
+<xsl:template match="/">
+<xsl:variable name="episodetitle">
+ <xsl:choose>
+ <xsl:when test="contains(/html/head/meta[@name='title']/@content, ' - Katsomo')">
+ <xsl:value-of select="substring-before(/html/head/meta[@name='title']/@content, ' - Katsomo')"/>
+ </xsl:when>
+ <xsl:when test="contains(/html/head/meta[@name='title']/@content, ' - MTV3 Katsomo')">
+ <xsl:value-of select="substring-before(/html/head/meta[@name='title']/@content, ' - MTV3 Katsomo')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="/html/head/meta[@name='title']/@content"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+
+<xsl:variable name="title" select="normalize-space(concat(id('program_content')/h1, ' ', $episodetitle))"/>
+
+<xsl:variable name="pid" select="substring-after($docurl, 'progId=')"/>
+
+<wvmenu>
+ <title><xsl:value-of select="$title"/></title>
+
+ <textarea>
+ <label><xsl:value-of select="/html/head/meta[@name='description']/@content"/></label>
+ </textarea>
+
+ <xsl:choose>
+ <xsl:when test="$live">
+ <textarea>
+ <label><xsl:value-of select="$live"/></label>
+ </textarea>
+ </xsl:when>
+
+ <xsl:when test="$pid">
+ <link>
+ <label>Download this video</label>
+ <stream>wvt:///katsomo.fi/video.xsl?param=pid,<xsl:value-of select="$pid"/>&amp;param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream>
+ </link>
+ </xsl:when>
+ </xsl:choose>
+
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/katsomo.fi/mainmenu.xsl b/templates/katsomo.fi/mainmenu.xsl
index 2bf3d3a..1e43126 100644
--- a/templates/katsomo.fi/mainmenu.xsl
+++ b/templates/katsomo.fi/mainmenu.xsl
@@ -5,6 +5,14 @@
xmlns:str="http://exslt.org/strings"
exclude-result-prefixes="str">
+<xsl:template match="id('all_programs_tab1')//a">
+ <link>
+ <label><xsl:value-of select="normalize-space(string(.))"/></label>
+ <ref>wvt:///katsomo.fi/program.xsl?srcurl=<xsl:value-of select="str:encode-uri(@href, true())"/></ref>
+ </link>
+</xsl:template>
+
+
<xsl:template match="/">
<wvmenu>
<title>MTV3 Katsomo</title>
@@ -14,12 +22,7 @@
<ref>wvt:///katsomo.fi/search.xsl</ref>
</link>
- <xsl:for-each select="id('mainMenu')/li[a/@href != '/']">
- <link>
- <label><xsl:value-of select="a"/></label>
- <ref>wvt:///katsomo.fi/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(a/@href, true())"/></ref>
- </link>
- </xsl:for-each>
+ <xsl:apply-templates select="id('all_programs_tab1')//a"/>
</wvmenu>
</xsl:template>
diff --git a/templates/katsomo.fi/navigation.xsl b/templates/katsomo.fi/navigation.xsl
deleted file mode 100644
index 15aa98f..0000000
--- a/templates/katsomo.fi/navigation.xsl
+++ /dev/null
@@ -1,48 +0,0 @@
-<?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.fi/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.fi/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.fi/program.xsl b/templates/katsomo.fi/program.xsl
new file mode 100644
index 0000000..f1c527a
--- /dev/null
+++ b/templates/katsomo.fi/program.xsl
@@ -0,0 +1,36 @@
+<?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="div[contains(@class, 'item')]">
+ <xsl:choose>
+ <xsl:when test="div[@class='row1']/span[@class='live']">
+ <xsl:variable name="upcoming" select="concat(div[@class='row1']/span[@class='live'], ' ', div[@class='row1']/span[contains(@class, 'time')])"/>
+
+ <link>
+ <label><xsl:value-of select="normalize-space(concat(div[@class='row2']/a, ' ', $upcoming))"/></label>
+ <ref>wvt:///katsomo.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div[@class='row2']/a/@href, true())"/>&amp;param=live,<xsl:value-of select="str:encode-uri($upcoming, true())"/></ref>
+ </link>
+ </xsl:when>
+ <xsl:otherwise>
+ <link>
+ <label><xsl:value-of select="div[@class='row2']/a"/></label>
+ <ref>wvt:///katsomo.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div[@class='row2']/a/@href, true())"/></ref>
+ <stream>wvt:///katsomo.fi/video.xsl?param=pid,<xsl:value-of select="substring-after(div[@class='row2']/a/@href, 'progId=')"/>&amp;param=title,<xsl:value-of select="normalize-space(str:encode-uri(concat(id('program_content')/h1, ' ', div[@class='row2']/a), true()))"/></stream>
+ </link>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<xsl:template match="/">
+<wvmenu>
+ <title><xsl:value-of select="/html/head/meta[@name='title']/@content"/></title>
+
+ <xsl:apply-templates select="//div[@class='content episode']/div[contains(@class, 'item') and not(contains(@class, 'not-free'))]"/>
+</wvmenu>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/katsomo.fi/search.xsl b/templates/katsomo.fi/search.xsl
index aaecfd6..619708d 100644
--- a/templates/katsomo.fi/search.xsl
+++ b/templates/katsomo.fi/search.xsl
@@ -15,7 +15,7 @@
<button>
<label>Hae</label>
- <submission>wvt:///katsomo.fi/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri('http://katsomo.fi/search.do?keywords={query}&amp;treeId=9992', true())"/></submission>
+ <submission encoding='iso-8859-1'>wvt:///katsomo.fi/searchresults.xsl?srcurl=<xsl:value-of select="str:encode-uri('http://katsomo.fi/search.do?keywords={query}&amp;treeId=33992', true())"/></submission>
</button>
</wvmenu>
</xsl:template>
diff --git a/templates/katsomo.fi/searchresults.xsl b/templates/katsomo.fi/searchresults.xsl
index 3b0ab8d..bb6cae2 100644
--- a/templates/katsomo.fi/searchresults.xsl
+++ b/templates/katsomo.fi/searchresults.xsl
@@ -5,27 +5,69 @@
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(.)"/>
+<!-- Helper function for extracting progId from href -->
+<xsl:template name="extract_pid">
+ <xsl:param name="href"/>
+
+ <xsl:choose>
+ <xsl:when test="contains(substring-after($href, 'progId='), '&amp;')">
+ <xsl:value-of select="substring-before(substring-after($href, 'progId='), '&amp;')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring-after($href, 'progId=')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+<!-- Create video link -->
+<xsl:template name="video_link">
+ <xsl:param name="title"/>
+ <xsl:param name="href"/>
+ <xsl:variable name="pid">
+ <xsl:call-template name="extract_pid">
+ <xsl:with-param name="href" select="$href"/>
+ </xsl:call-template>
+ </xsl:variable>
<link>
<label><xsl:value-of select="$title"/></label>
- <stream>wvt:///katsomo.fi/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>
+ <ref>wvt:///katsomo.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri($href, true())"/></ref>
+ <stream>wvt:///katsomo.fi/video.xsl?param=pid,<xsl:value-of select="$pid"/>&amp;param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream>
</link>
</xsl:template>
+<xsl:template match="id('search_episodes')/div">
+ <xsl:call-template name="video_link">
+ <xsl:with-param name="title" select="normalize-space(h4/a)"/>
+ <xsl:with-param name="href" select="h4/a/@href"/>
+ </xsl:call-template>
+</xsl:template>
+
+<xsl:template match="id('search_clips')/div">
+ <xsl:call-template name="video_link">
+ <xsl:with-param name="title" select="normalize-space(concat(p/a[1], ' ', h4/a))"/>
+ <xsl:with-param name="href" select="h4/a/@href"/>
+ </xsl:call-template>
+</xsl:template>
+
<xsl:template match="/">
<wvmenu>
- <title>Hakutulokset: <xsl:value-of select="id('searchResults')/div/div[@class='description']/span"/></title>
+ <title><xsl:value-of select="/html/head/title"/></title>
+
+ <!-- Program search results require javascript. This is not a -->
+ <!-- problem because all programs are listed on the main page -->
+ <!-- anyway. -->
+ <!-- <xsl:apply-templates select="id('search_results')/div[contains(@class, 'item')]"/> -->
- <xsl:if test="not(id('resultList')/div[@class='item'])">
- <textarea>
- <label><xsl:value-of select="normalize-space(id('siteMapList')/p)"/></label>
- </textarea>
- </xsl:if>
+ <textarea>
+ <label>Jaksot</label>
+ </textarea>
+ <xsl:apply-templates select="id('search_episodes')/div[contains(@class, 'item')]"/>
- <xsl:apply-templates select="id('resultList')/div[@class='item']/h6/a[not(@class='programType')]"/>
+ <textarea>
+ <label>Klipit</label>
+ </textarea>
+ <xsl:apply-templates select="id('search_clips')/div[contains(@class, 'item')]"/>
</wvmenu>
</xsl:template>
diff --git a/templates/katsomo.fi/video.xsl b/templates/katsomo.fi/video.xsl
index 9d20c49..dee8d21 100644
--- a/templates/katsomo.fi/video.xsl
+++ b/templates/katsomo.fi/video.xsl
@@ -1,18 +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:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-<xsl:param name="title">katsomovideo</xsl:param>
+<xsl:param name="title">katsomo_video</xsl:param>
+<xsl:param name="pid"/>
-<xsl:template match="/">
+<xsl:template name="mediaurl">
+<xsl:param name="title"/>
+<xsl:param name="pid"/>
<mediaurl>
<title><xsl:value-of select="$title"/></title>
-
- <url><xsl:value-of select='substring-before(substring-after(//script, "metaUrl&apos;: &apos;"), "&apos;")'/></url>
+ <url>
+ <xsl:if test="$pid">
+ <xsl:value-of select="concat('http://www.katsomo.fi/metafile.asx?p=', $pid, '&amp;bw=800')"/>
+ </xsl:if>
+ </url>
</mediaurl>
</xsl:template>
+<xsl:template match="/">
+ <xsl:call-template name="mediaurl">
+ <xsl:with-param name="title" select="$title"/>
+ <xsl:with-param name="pid" select="$pid"/>
+ </xsl:call-template>
+</xsl:template>
+
</xsl:stylesheet>
diff --git a/templates/katsomo.fi/videopage.xsl b/templates/katsomo.fi/videopage.xsl
index 591a81b..76eb44e 100644
--- a/templates/katsomo.fi/videopage.xsl
+++ b/templates/katsomo.fi/videopage.xsl
@@ -5,12 +5,33 @@
xmlns:str="http://exslt.org/strings"
exclude-result-prefixes="str">
+<xsl:template name="main">
+<xsl:variable name="episodetitle">
+ <xsl:choose>
+ <xsl:when test="contains(/html/head/meta[@name='title']/@content, ' - Katsomo')">
+ <xsl:value-of select="substring-before(/html/head/meta[@name='title']/@content, ' - Katsomo')"/>
+ </xsl:when>
+ <xsl:when test="contains(/html/head/meta[@name='title']/@content, ' - MTV3 Katsomo')">
+ <xsl:value-of select="substring-before(/html/head/meta[@name='title']/@content, ' - MTV3 Katsomo')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="/html/head/meta[@name='title']/@content"/>
+ </xsl:otherwise>
+ </xsl:choose>
+</xsl:variable>
+
+<xsl:variable name="pid" select="substring-before(substring-after(/html/body/script[contains(., 'userNav.play(')], 'userNav.play('), ',')"/>
+
+<xsl:if test="$pid">
+ <mediaurl>
+ <title><xsl:value-of select="$episodetitle"/></title>
+ <url><xsl:value-of select="concat('http://www.katsomo.fi/metafile.asx?p=', $pid, '&amp;bw=800')"/></url>
+ </mediaurl>
+</xsl:if>
+</xsl:template>
+
<xsl:template match="/">
-<!-- direct URLs on katsomo.fi not yet supported -->
-<mediaurl>
- <title></title>
- <url></url>
-</mediaurl>
+ <xsl:call-template name="main"/>
</xsl:template>
</xsl:stylesheet>
diff --git a/templates/www.katsomo.fi/videopage.xsl b/templates/www.katsomo.fi/videopage.xsl
index 591a81b..7496df8 100644
--- a/templates/www.katsomo.fi/videopage.xsl
+++ b/templates/www.katsomo.fi/videopage.xsl
@@ -1,16 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?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:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:import href="../katsomo.fi/videopage.xsl"/>
<xsl:template match="/">
-<!-- direct URLs on katsomo.fi not yet supported -->
-<mediaurl>
- <title></title>
- <url></url>
-</mediaurl>
+ <xsl:call-template name="main"/>
</xsl:template>
</xsl:stylesheet>