summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntti Ajanki <antti.ajanki@iki.fi>2012-06-01 19:20:48 +0300
committerAntti Ajanki <antti.ajanki@iki.fi>2012-06-02 08:58:01 +0300
commitc198fe165884d2b41f70e987af32ee3a50e653b7 (patch)
tree3325378c072df21b185cb66673a81798a76a686e
parent41c82dd2513333d6eb646f1e9278b69fb03f6bbc (diff)
downloadvdr-plugin-webvideo-c198fe165884d2b41f70e987af32ee3a50e653b7.tar.gz
vdr-plugin-webvideo-c198fe165884d2b41f70e987af32ee3a50e653b7.tar.bz2
Support for the new Areena
-rw-r--r--src/unittest/testwebvi.py60
-rw-r--r--templates/areena.yle.fi/common.xsl13
-rw-r--r--templates/areena.yle.fi/description.xsl42
-rw-r--r--templates/areena.yle.fi/livebroadcasts.xsl38
-rw-r--r--templates/areena.yle.fi/livestream.xsl23
-rw-r--r--templates/areena.yle.fi/mainmenu.xsl92
-rw-r--r--templates/areena.yle.fi/navigation.xsl180
-rw-r--r--templates/areena.yle.fi/programlist.xsl22
-rw-r--r--templates/areena.yle.fi/search.xsl111
-rw-r--r--templates/areena.yle.fi/video.xsl13
-rw-r--r--templates/areena.yle.fi/videopage.xsl16
-rwxr-xr-xtemplates/bin/yle-dl2
12 files changed, 351 insertions, 261 deletions
diff --git a/src/unittest/testwebvi.py b/src/unittest/testwebvi.py
index 2af3c16..8f9430d 100644
--- a/src/unittest/testwebvi.py
+++ b/src/unittest/testwebvi.py
@@ -251,64 +251,54 @@ class TestServiceModules(unittest.TestCase):
ref = self.getServiceReference('../../templates/areena.yle.fi')
links = self.downloadAndExtractLinks(ref, 3, 'category')
- # The first is "Search", the second is "live", the third is
- # "all", the rest are navigation links.
- liveref = links[1].ref
- navigationref = links[3].ref
+ # The first is "Search", the second is "all tv", the rest are
+ # navigation links.
+ navigationref = links[1].ref
- # Navigation page
links = self.downloadAndExtractLinks(navigationref, 2, 'navigation')
- # Video link
- videolink = links[0]
- self.assertNotEqual(videolink.stream, None, 'No media object in a video link')
- self.assertNotEqual(videolink.ref, None, 'No description page in a video link')
-
- # Direct video page link
- queries, params = self.extractQueryParams(videolink.stream)
- self.assertTrue('srcurl' in queries, 'Required parameter missing in video link')
- videopageurl = queries['srcurl']
- videopageref = self.urlToWvtref(videopageurl)
- self.checkMediaUrl(videopageref)
+ videolink = None
+ for link in links:
+ if link.stream is not None:
+ videolink = link
+ break
- # live broadcasts
- links = self.downloadAndExtractLinks(liveref, 2, 'live broadcasts')
+ self.assertNotEqual(videolink, None, 'No media links')
+ self.assertNotEqual(videolink.stream, None, 'No media object in video link')
+ self.assertNotEqual(videolink.ref, None, 'No description in video link')
def testYLEAreenaSearch(self):
- menuobj = self.downloadMenuPage('wvt:///areena.yle.fi/search.xsl?srcurl=http://areena.yle.fi/haku', 'search')
- self.assertTrue(len(menuobj) >= 8, 'Too few items in search menu')
+ menuobj = self.downloadMenuPage('wvt:///areena.yle.fi/search.xsl', 'search')
+ self.assertTrue(len(menuobj) >= 9, 'Too few items in search menu')
self.assertTrue(isinstance(menuobj[0], menu.MenuItemTextField))
self.assertTrue(isinstance(menuobj[1], menu.MenuItemList))
- self.assertTrue(len(menuobj[1].items) >= 3)
self.assertTrue(isinstance(menuobj[2], menu.MenuItemList))
- self.assertTrue(len(menuobj[2].items) >= 2)
self.assertTrue(isinstance(menuobj[3], menu.MenuItemList))
- self.assertTrue(len(menuobj[3].items) >= 2)
self.assertTrue(isinstance(menuobj[4], menu.MenuItemList))
- self.assertTrue(len(menuobj[4].items) >= 3)
self.assertTrue(isinstance(menuobj[5], menu.MenuItemList))
- self.assertTrue(len(menuobj[5].items) >= 4)
self.assertTrue(isinstance(menuobj[6], menu.MenuItemList))
- self.assertTrue(len(menuobj[6].items) >= 2)
- self.assertTrue(isinstance(menuobj[7], menu.MenuItemSubmitButton))
+ self.assertTrue(isinstance(menuobj[7], menu.MenuItemList))
+ self.assertTrue(isinstance(menuobj[8], menu.MenuItemSubmitButton))
# Query term
menuobj[0].value = 'yle'
# Media: video
menuobj[1].current = 1
- # Category: all
- menuobj[2].current = 0
- # Channel: all
+ # Order: alphabetical
+ menuobj[2].current = 1
+ # Type: Episodes
menuobj[3].current = 0
- # Language: Finnish
- menuobj[4].current = 1
- # Uploaded: all
+ # Channel: all
+ menuobj[4].current = 0
+ # Language: all
menuobj[5].current = 0
- # Only outside Finland: no
+ # Subtitles: all
menuobj[6].current = 0
+ # Only outside Finland: no
+ menuobj[7].current = 0
- resultref = menuobj[7].activate()
+ resultref = menuobj[8].activate()
self.assertNotEqual(resultref, None)
self.downloadAndExtractLinks(resultref, 1, 'search result')
diff --git a/templates/areena.yle.fi/common.xsl b/templates/areena.yle.fi/common.xsl
new file mode 100644
index 0000000..5a5e88f
--- /dev/null
+++ b/templates/areena.yle.fi/common.xsl
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:template name="type_to_path">
+ <xsl:param name="type"/>
+ <xsl:choose>
+ <xsl:when test="$type = 'audio'">radio</xsl:when>
+ <xsl:otherwise>tv</xsl:otherwise>
+ </xsl:choose>
+</xsl:template>
+
+</xsl:stylesheet>
diff --git a/templates/areena.yle.fi/description.xsl b/templates/areena.yle.fi/description.xsl
index 7f16bc8..bb73095 100644
--- a/templates/areena.yle.fi/description.xsl
+++ b/templates/areena.yle.fi/description.xsl
@@ -1,35 +1,43 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
-<xsl:param name="docurl"/>
+<xsl:include href="common.xsl"/>
+
+<xsl:param name="title"/>
+
+<xsl:template match="/jsondocument/dict">
+<xsl:variable name = "typeurl">
+ <xsl:call-template name="type_to_path">
+ <xsl:with-param name="type" select="series/dict/type"/>
+ </xsl:call-template>
+</xsl:variable>
-<xsl:template match="/">
<wvmenu>
- <title><xsl:value-of select="normalize-space(//h1[@class='cliptitle'])"/></title>
+ <title><xsl:value-of select="normalize-space($title)"/></title>
<textarea>
- <label><xsl:value-of select="normalize-space(id('relatedinfo')//div[@class='relatedinfo-text description'])"/></label>
+ <label><xsl:value-of select="normalize-space(desc)"/></label>
</textarea>
<textarea>
- <!-- Kesto -->
- <label><xsl:value-of select="id('relatedinfo')/div/div/div[@class='relatedinfo-text meta']/ul/li[contains(., 'Kesto')]"/></label>
+ <label>Kesto: <xsl:value-of select="duration"/> min</label>
</textarea>
<textarea>
- <!-- Julkaistu -->
- <label><xsl:value-of select="id('relatedinfo-more')/div/div[1]/ul/li[contains(., 'Julkaistu')]"/></label>
+ <label>Julkaistu: <xsl:value-of select="translate(published, 'T', ' ')"/></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>
+ <label>
+ <xsl:choose>
+ <xsl:when test="type = 'audio'">Radio</xsl:when>
+ <xsl:otherwise>TV</xsl:otherwise>
+ </xsl:choose>
+ </label>
</textarea>
+
<link>
- <label>Download this video</label>
- <stream>wvt:///areena.yle.fi/videopage.xsl?srcurl=<xsl:value-of select="$docurl"/></stream>
+ <label>Lataa</label>
+ <stream>wvt:///areena.yle.fi/video.xsl?param=title,<xsl:value-of select="str:encode-uri($title, true())"/>&amp;param=type,<xsl:value-of select="str:encode-uri(type, true())"/>&amp;param=id,<xsl:value-of select="id"/></stream>
</link>
</wvmenu>
</xsl:template>
diff --git a/templates/areena.yle.fi/livebroadcasts.xsl b/templates/areena.yle.fi/livebroadcasts.xsl
index c29ad09..4ce91cd 100644
--- a/templates/areena.yle.fi/livebroadcasts.xsl
+++ b/templates/areena.yle.fi/livebroadcasts.xsl
@@ -1,30 +1,20 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings">
-<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:///areena.yle.fi/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')]">
+<xsl:template match="/jsondocument/dict/current/list/li/dict/pubContent/dict">
<link>
- <label><xsl:value-of select="h2/span/a"/></label>
- <stream>wvt:///areena.yle.fi/livestream.xsl?param=stream,<xsl:value-of select='substring-before(substring-after(h2/span/a/@onclick, "stream&apos;, &apos;"), "&apos;")'/></stream>
+ <label><xsl:value-of select="title"/></label>
+ <ref>wvt:///areena.yle.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://areena.yle.fi/tv/', id, '.json'), true())"/>&amp;param=title,<xsl:value-of select="str:encode-uri(title, true())"/>&amp;postprocess=json2xml</ref>
+ <stream>wvt:///areena.yle.fi/video.xsl?srcurl=&amp;param=title,<xsl:value-of select="str:encode-uri(title, true())"/>&amp;param=type,<xsl:value-of select="type"/>&amp;param=id,<xsl:value-of select="id"/></stream>
</link>
</xsl:template>
-<!-- Tulevat lähetykset -->
-<xsl:template match="div[@class='upcoming']/div/div[@class='showlistitem-description']">
+<xsl:template match="/jsondocument/dict/upcoming/list/li/dict/items/list/li/dict">
<textarea>
- <label><xsl:value-of select="h3"/>, <xsl:value-of select="ul/li[1]"/></label>
+ <label><xsl:value-of select="concat(translate(start, 'T', ' '), ' ', pubContent/dict/title)"/></label>
</textarea>
</xsl:template>
@@ -32,14 +22,16 @@
<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>Nyt suorana</label>
+ </textarea>
+ <xsl:apply-templates select="/jsondocument/dict/current/list/li/dict/pubContent/dict"/>
<textarea>
- <label>Tulossa seuraavaksi:</label>
+ <label>Tulossa</label>
</textarea>
- <xsl:apply-templates select="id('liveshows')/div[@class='upcoming']"/>
+ <xsl:apply-templates select="/jsondocument/dict/upcoming/list/li/dict/items/list/li/dict"/>
+
</wvmenu>
</xsl:template>
diff --git a/templates/areena.yle.fi/livestream.xsl b/templates/areena.yle.fi/livestream.xsl
deleted file mode 100644
index b6d7ee2..0000000
--- a/templates/areena.yle.fi/livestream.xsl
+++ /dev/null
@@ -1,23 +0,0 @@
-<?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/areena.yle.fi/mainmenu.xsl b/templates/areena.yle.fi/mainmenu.xsl
index e16ae0b..520d085 100644
--- a/templates/areena.yle.fi/mainmenu.xsl
+++ b/templates/areena.yle.fi/mainmenu.xsl
@@ -10,25 +10,97 @@
<link>
<label>Haku</label>
- <ref>wvt:///areena.yle.fi/search.xsl?srcurl=http://areena.yle.fi/haku</ref>
+ <ref>wvt:///areena.yle.fi/search.xsl</ref>
</link>
+ <!-- TV -->
+
+ <textarea>
+ <label>TV</label>
+ </textarea>
+
+ <link>
+ <label>Kaikki TV-ohjelmat</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/tv/kaikki.json%3Fkpl=100%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,TV-ohjelmat%20A-%C3%96&amp;postprocess=json2xml</ref>
+ </link>
+
+ <!-- TV categories -->
+ <link>
+ <label>Sarjat ja elokuvat</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/tv/sarjat-ja-elokuvat/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Sarjat%20ja%20elokuvat&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Viihde ja kulttuuri</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/tv/viihde-ja-kulttuuri/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Viihde%20ja%20kulttuuri&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Dokumentit ja fakta</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/tv/dokumentit-ja-fakta/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Dokumentit%20ja%20fakta&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Uutiset</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/tv/uutiset/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Uutiset&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Urheilu</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/tv/urheilu/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Urheilu&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Lapset</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/tv/lapset/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Lapset&amp;postprocess=json2xml</ref>
+ </link>
+
+ <!-- live -->
<link>
<label>Suorat lähetykset</label>
- <ref>wvt:///areena.yle.fi/livebroadcasts.xsl?srcurl=http://areena.yle.fi/live</ref>
+ <ref>wvt:///areena.yle.fi/livebroadcasts.xsl?srcurl=http://areena.yle.fi/tv/suora.json&amp;postprocess=json2xml</ref>
</link>
+ <!-- Radio -->
+
+ <textarea>
+ <label>Radio</label>
+ </textarea>
+
<link>
- <label>Kaikki ohjelmat</label>
- <ref>wvt:///areena.yle.fi/programlist.xsl?srcurl=http://areena.yle.fi/ohjelmat</ref>
+ <label>Kaikki radio-ohjelmat</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/radio/kaikki.json%3Fkpl=100%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Radio-ohjelmat%20A-%C3%96&amp;postprocess=json2xml</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:///areena.yle.fi/navigation.xsl?srcurl=', str:encode-uri(concat(./@href, '/feed/rss'), true()))"/></ref>
- </link>
- </xsl:for-each>
+ <link>
+ <label>Musiikki ja viihde</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/radio/musiikki-ja-viihde/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Musiikki%20ja%20viihde&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Äänikirjat ja kuunnelmat</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/radio/aanikirjat-ja-kuunnelmat/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,%C3%84%C3%A4nikirjat%20ja%20kuunnelmat&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Fakta ja kulttuuri</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/radio/fakta-ja-kulttuuri/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Kulttuuri&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Uutiset</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/radio/uutiset/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Uutiset&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Urheilu</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/radio/urheilu/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Urheilu&amp;postprocess=json2xml</ref>
+ </link>
+
+ <link>
+ <label>Lapset</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/radio/lapset/kaikki.json%3Fkpl=24%26jarjestys=ao%26sisalto=%26kanava=%26kieli=%26tekstitys=%26sivu=0&amp;param=seriestitle,Lapset&amp;postprocess=json2xml</ref>
+ </link>
</wvmenu>
</xsl:template>
diff --git a/templates/areena.yle.fi/navigation.xsl b/templates/areena.yle.fi/navigation.xsl
index 7e3c4a3..3538a74 100644
--- a/templates/areena.yle.fi/navigation.xsl
+++ b/templates/areena.yle.fi/navigation.xsl
@@ -4,115 +4,119 @@
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:include href="common.xsl"/>
+<xsl:param name="docurl"/>
+<xsl:param name="seriestitle"/>
+<xsl:param name="preferseries" select="'true'"/> <!-- Shows series when available instead of program -->
+
+<!-- Add previous and next links for a navigation page.
+
+ BUG: If the last page has exactly $numitems, an extra "next" link
+ is inserted.
+-->
<xsl:template name="prevnextlinks">
- <!-- Add previous and next links for a navigation page.
+ <xsl:param name="page" select="0"/> <!-- current page number -->
+ <xsl:param name="numitems" select="0"/> <!-- number of items on this page -->
+ <xsl:param name="maxitems" select="0"/> <!-- expected number of items per page -->
+
+ <xsl:if test="string(number($page)) != 'NaN'">
+ <xsl:variable name="urlprefix" select="concat(substring-before($docurl, '&amp;sivu='), '&amp;sivu=')"/>
+ <xsl:variable name="urlpostfix0" select="substring-after(substring-after($docurl, '&amp;sivu='), '&amp;')"/>
+ <xsl:variable name="urlpostfix">
+ <xsl:if test="urlpostfix0 != ''">
+ <xsl:value-of select="concat('&amp;', urlpostfix0)"/>
+ </xsl:if>
+ </xsl:variable>
- 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.
+ <xsl:variable name="prevurl" select="concat($urlprefix, $page - 1, $urlpostfix)"/>
+ <xsl:variable name="nexturl" select="concat($urlprefix, $page + 1, $urlpostfix)"/>
- BUG: if the last page has 20 links, an extra "next" link is
- generated
- -->
+ <!-- prev link -->
+ <xsl:if test="$page &gt; 0">
+ <link>
+ <label>Edellinen</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri($prevurl, true())"/>&amp;param=seriestitle,<xsl:value-of select="$seriestitle"/>&amp;param=preferseries,<xsl:value-of select="$preferseries"/>&amp;postprocess=json2xml</ref>
+ </link>
+ </xsl:if>
- <xsl:variable name="page" select="number(substring-before(substring-after($docurl, '/sivu/'), '/'))"/>
+ <!-- next link -->
+ <xsl:if test="$numitems &gt;= $maxitems">
+ <link>
+ <label>Seuraava</label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri($nexturl, true())"/>&amp;param=seriestitle,<xsl:value-of select="$seriestitle"/>&amp;param=preferseries,<xsl:value-of select="$preferseries"/>&amp;postprocess=json2xml</ref>
+ </link>
+ </xsl:if>
- <xsl:choose>
- <xsl:when test="$page &gt; 1">
+ </xsl:if>
+</xsl:template>
- <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)"/>
+<xsl:template match="results/list/li">
+ <xsl:variable name="typeurl">
+ <xsl:call-template name="type_to_path">
+ <xsl:with-param name="type" select="dict/type"/>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <xsl:variable name="seriestitle2">
+ <xsl:choose>
+ <xsl:when test="dict/series/dict/name != ''">
+ <xsl:value-of select="dict/series/dict/name"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="dict/title"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:choose>
+ <xsl:when test="dict/series and $preferseries = 'true'">
+ <!-- series link -->
<link>
- <label>Edellinen</label>
- <ref>wvt:///areena.yle.fi/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:///areena.yle.fi/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri($nexturl, true())"/></ref>
- </link>
- </xsl:if>
+ <label><xsl:value-of select="$seriestitle2"/></label>
+ <ref>wvt:///areena.yle.fi/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://areena.yle.fi/', $typeurl, '/', dict/series/dict/id, '.json?kpl=16&amp;sisalto=ohjelmat&amp;sivu=0'), true())"/>&amp;param=seriestitle,<xsl:value-of select="str:encode-uri($seriestitle2, true())"/>&amp;param=preferseries,false&amp;postprocess=json2xml</ref>
+ </link>
</xsl:when>
<xsl:otherwise>
+ <xsl:variable name="streamtitle">
+ <xsl:choose>
+ <xsl:when test="dict/series/dict/name = dict/title">
+ <xsl:value-of select="concat(dict/title, ' osa ', dict/episodeNumber)"/>
+ </xsl:when>
+ <xsl:when test="dict/series/dict/name != ''">
+ <xsl:value-of select="concat(dict/series/dict/name, ': ', dict/title)"/>
+ </xsl:when>
+ <xsl:when test="starts-with(dict/title, $seriestitle)">
+ <xsl:value-of select="concat(dict/title, '-', dict/published)"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="dict/title"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
- <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:///areena.yle.fi/navigation.xsl?srcurl=<xsl:value-of select="str:encode-uri($nexturl, true())"/></ref>
- </link>
- </xsl:if>
-
- </xsl:otherwise>
-
-
+ <link>
+ <label><xsl:value-of select="$streamtitle"/></label>
+ <ref>wvt:///areena.yle.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(concat('http://areena.yle.fi/', $typeurl, '/', dict/id, '.json'), true())"/>&amp;param=title,<xsl:value-of select="str:encode-uri($streamtitle, true())"/>&amp;postprocess=json2xml</ref>
+ <stream>wvt:///areena.yle.fi/video.xsl?srcurl=&amp;param=title,<xsl:value-of select="str:encode-uri($streamtitle, true())"/>&amp;param=type,<xsl:value-of select="dict/type"/>&amp;param=id,<xsl:value-of select="dict/id"/></stream>
+ </link>
+ </xsl:otherwise>
</xsl:choose>
</xsl:template>
-
-<xsl:template match="/rss/channel/item">
- <link>
- <label><xsl:value-of select="title"/></label>
- <ref>wvt:///areena.yle.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(link, true())"/></ref>
- <stream>wvt:///areena.yle.fi/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>
+ <title><xsl:value-of select="$seriestitle"/></title>
- <xsl:apply-templates select="/rss/channel/item"/>
+ <xsl:apply-templates select="/jsondocument/dict/search/dict/results/list/li"/>
- <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>
+ <xsl:call-template name="prevnextlinks">
+ <xsl:with-param name="page" select="number(jsondocument/dict/search/dict/params/dict/sivu)"/>
+ <xsl:with-param name="numitems" select="count(jsondocument/dict/search/dict/results/list/li)"/>
+ <xsl:with-param name="maxitems" select="number(jsondocument/dict/search/dict/params/dict/kpl)"/>
+ </xsl:call-template>
</wvmenu>
</xsl:template>
diff --git a/templates/areena.yle.fi/programlist.xsl b/templates/areena.yle.fi/programlist.xsl
deleted file mode 100644
index 58b3243..0000000
--- a/templates/areena.yle.fi/programlist.xsl
+++ /dev/null
@@ -1,22 +0,0 @@
-<?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:///areena.yle.fi/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/areena.yle.fi/search.xsl b/templates/areena.yle.fi/search.xsl
index 7508615..6ad0e1d 100644
--- a/templates/areena.yle.fi/search.xsl
+++ b/templates/areena.yle.fi/search.xsl
@@ -1,23 +1,6 @@
<?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:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<wvmenu>
@@ -27,17 +10,97 @@
<label>Hakusana</label>
</textfield>
- <xsl:apply-templates select="id('widesearch')/form/fieldset[not(contains(@class, 'search-keyword'))]"/>
+ <itemlist name="media">
+ <label>Media</label>
+ <item value="">TV &amp; radio</item>
+ <item value="video">TV</item>
+ <item value="radio">Radio</item>
+ </itemlist>
+
+ <itemlist name="order">
+ <label>Järjestys</label>
+ <item value="parasosuma">Paras osuma</item>
+ <item value="ao">A-Ö</item>
+ <item value="uusin">Uusin</item>
+ <item value="vielaehdit">Vielä ehdit</item>
+ </itemlist>
+
+ <itemlist name="content">
+ <label>Tyyppi</label>
+ <item value="">Ohjelmat</item>
+ <item value="muut">Muut videot ja audiot</item>
+ </itemlist>
+
+ <itemlist name="channel">
+ <label>Kanava</label>
+ <item value="">Kaikki</item>
+ <item value="yle-tv1">YLE TV1</item>
+ <item value="yle-tv2">YLE TV2</item>
+ <item value="yle-teema">YLE Teema</item>
+ <item value="yle-fst5">YLE FST5</item>
+ <item value="yle-radio-suomi">YLE Radio Suomi</item>
+ <item value="ylex">YleX</item>
+ <item value="yle-radio-1">YLE Radio 1</item>
+ <item value="yle-puhe">YLE Puhe</item>
+ <item value="radio-vega">Radio Vega</item>
+ <item value="radio-x3m">Radio X3M</item>
+ <item value="yle-s-mi-radio">YLE S&#225;mi Radio</item>
+ <item value="ylen-klassinen">Ylen klassinen</item>
+ <item value="etela-karjalan-radio">Etelä-Karjalan Radio</item>
+ <item value="etela-savon-radio">Etelä-Savon Radio</item>
+ <item value="kainuun-radio">Kainuun Radio</item>
+ <item value="kymenlaakson-radio">Kymenlaakson Radio</item>
+ <item value="lahden-radio">Lahden Radio</item>
+ <item value="lapin-radio">Lapin Radio</item>
+ <item value="oulu-radio">Oulu Radio</item>
+ <item value="pohjanmaan-radio">Pohjanmaan Radio</item>
+ <item value="pohjois-karjalan-radio">Pohjois-Karjalan Radio</item>
+ <item value="radio-hame">Radio Häme</item>
+ <item value="radio-ita-uusimaa">Radio Itä-Uusimaa</item>
+ <item value="radio-keski-pohjanmaa">Radio Keski-Pohjanmaa</item>
+ <item value="radio-keski-suomi">Radio Keski-Suomi</item>
+ <item value="radio-perameri">Radio Perämeri</item>
+ <item value="radio-savo">Radio Savo</item>
+ <item value="satakunnan-radio">Satakunnan Radio</item>
+ <item value="tampereen-radio">Tampereen Radio</item>
+ <item value="turun-radio">Turun Radio</item>
+ <item value="ylen-aikainen">Ylen aikainen</item>
+ <item value="ylen-lantinen">Ylen läntinen</item>
+ <item value="radio-vega-huvudstadsregionen">Radio Vega Huvudstadsregionen</item>
+ <item value="radio-vega-vastnyland">Radio Vega Västnyland</item>
+ <item value="radio-vega-aboland">Radio Vega Åboland</item>
+ <item value="radio-vega-osterbotten">Radio Vega Österbotten</item>
+ <item value="radio-vega-ostnyland">Radio Vega Östnyland</item>
+ </itemlist>
+
+ <itemlist name="language">
+ <label>Kieli</label>
+ <item value="">Kaikki</item>
+ <item value="fi">Suomi</item>
+ <item value="sv">Ruotsi</item>
+ <item value="smi">Saami</item>
+ <item value="en">Englanti</item>
+ </itemlist>
+
+ <itemlist name="subtitles">
+ <label>Tekstitys</label>
+ <item value="">Ei rajausta</item>
+ <item value="fin">Suomi</item>
+ <item value="fih">Suomi (ohjelmatekstitys)</item>
+ <item value="swe">Ruotsi</item>
+ <item value="swh">Ruotsi (ohjelmatekstitys)</item>
+ <item value="smi">Saami</item>
+ </itemlist>
- <itemlist name="naytetaan_ulkomailla">
- <label>Vain Suomen ulkopuolella katsottavat</label>
- <item value="kaikki">Kaikki</item>
- <item value="kylla">Kyllä</item>
+ <itemlist name="foreign">
+ <label>Esitysoikeudet ulkomailla</label>
+ <item value="0">Ei rajausta</item>
+ <item value="1">Kyllä</item>
</itemlist>
<button>
<label>Hae</label>
- <submission>wvt:///areena.yle.fi/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>
+ <submission>wvt:///areena.yle.fi/navigation.xsl?srcurl=http://areena.yle.fi/.json%3Fkpl=24%26q={keyword}%26media={media}%26jarjestys={order}%26sisalto={content}%26kanava={channel}%26kieli={language}%26tekstitys={subtitles}%26ulkomaat={foreign}%26sivu=0&amp;param=seriestitle,Hakutulokset&amp;param=preferseries,false&amp;postprocess=json2xml</submission>
</button>
</wvmenu>
</xsl:template>
diff --git a/templates/areena.yle.fi/video.xsl b/templates/areena.yle.fi/video.xsl
index efe3441..dba72fa 100644
--- a/templates/areena.yle.fi/video.xsl
+++ b/templates/areena.yle.fi/video.xsl
@@ -4,17 +4,26 @@
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings">
+<xsl:include href="common.xsl"/>
+
<xsl:param name="title"/>
-<xsl:param name="docurl"/>
+<xsl:param name="id"/>
+<xsl:param name="type"/> <!-- 'audio' or 'video' -->
<xsl:template name="mediaurl">
<xsl:param name="streamtitle"/>
+ <xsl:variable name="typeurl">
+ <xsl:call-template name="type_to_path">
+ <xsl:with-param name="type" select="series/dict/type"/>
+ </xsl:call-template>
+ </xsl:variable>
+
<mediaurl>
<title>
<xsl:value-of select="$streamtitle"/>
</title>
- <url>wvt:///bin/yle-dl?contenttype=video/x-flv&amp;arg=<xsl:value-of select="str:encode-uri($docurl, true())"/></url>
+ <url>wvt:///bin/yle-dl?contenttype=video/x-flv&amp;arg=<xsl:value-of select="str:encode-uri(concat('http://areena.yle.fi/', $typeurl, '/', $id), true())"/></url>
</mediaurl>
</xsl:template>
diff --git a/templates/areena.yle.fi/videopage.xsl b/templates/areena.yle.fi/videopage.xsl
deleted file mode 100644
index aac373a..0000000
--- a/templates/areena.yle.fi/videopage.xsl
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
-
-<xsl:import href="video.xsl"/>
-
-<xsl:param name="docurl"/>
-
-<xsl:template match="/">
- <xsl:call-template name="mediaurl">
- <xsl:with-param name="streamtitle" select="normalize-space(concat(//div[@class='basic']/h1, ' - ', //li[contains(text(), 'Julkaistu:')]/span))"/>
- </xsl:call-template>
-</xsl:template>
-
-</xsl:stylesheet>
diff --git a/templates/bin/yle-dl b/templates/bin/yle-dl
index fdaf845..8950607 100755
--- a/templates/bin/yle-dl
+++ b/templates/bin/yle-dl
@@ -9,7 +9,7 @@ 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
+ echo "Install yle-dl from https://github.com/aajanki/yle-dl" 1>&2
exit 1
fi