summaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorAntti Ajanki <antti.ajanki@iki.fi>2010-07-23 22:45:50 +0300
committerAntti Ajanki <antti.ajanki@iki.fi>2010-07-23 22:45:50 +0300
commit1a7c069c64f3daaf1fa67951d3cbbe2be85a89a5 (patch)
tree9f4d6ada9912f87ebfdd3c247d2c60577f2e193d /templates
parent4a7f56626ead4b8a18376c0b10537f1440625ba6 (diff)
downloadvdr-plugin-webvideo-1a7c069c64f3daaf1fa67951d3cbbe2be85a89a5.tar.gz
vdr-plugin-webvideo-1a7c069c64f3daaf1fa67951d3cbbe2be85a89a5.tar.bz2
Fix Youtube, use only only video URLs that really exist in fmt_url_map
Diffstat (limited to 'templates')
-rw-r--r--templates/youtube/navigation.xsl2
-rw-r--r--templates/youtube/video.xsl94
2 files changed, 60 insertions, 36 deletions
diff --git a/templates/youtube/navigation.xsl b/templates/youtube/navigation.xsl
index a5fd1c7..a9df76f 100644
--- a/templates/youtube/navigation.xsl
+++ b/templates/youtube/navigation.xsl
@@ -11,7 +11,7 @@
<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>
+ <stream>wvt:///youtube/video.xsl?srcurl=http://www.youtube.com/get_video_info?video_id=<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>
diff --git a/templates/youtube/video.xsl b/templates/youtube/video.xsl
index d38a99e..f2791da 100644
--- a/templates/youtube/video.xsl
+++ b/templates/youtube/video.xsl
@@ -1,47 +1,71 @@
<?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>
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:str="http://exslt.org/strings"
+ xmlns:map="mapping"
+ exclude-result-prefixes="str map">
+
+<!-- Mapping from Youtube fmt parameter (key) to webvideo priority
+ score (value) -->
+<map:associativearray>
+ <map:item key="17" value="40"/>
+ <map:item key="5" value="50"/>
+ <map:item key="34" value="52"/>
+ <map:item key="35" value="54"/>
+ <map:item key="18" value="60"/>
+ <map:item key="43" value="65"/>
+ <map:item key="22" value="70"/>
+ <map:item key="45" value="75"/>
+ <map:item key="37" value="80"/>
+</map:associativearray>
+
+<xsl:template name="fmturl">
+ <xsl:variable name="fmt">
+ <xsl:value-of select="str:split(., '|')[1]"/>
+ </xsl:variable>
+ <xsl:variable name="url">
+ <xsl:value-of select="str:split(., '|')[2]"/>
+ </xsl:variable>
+
+ <xsl:if test="$url">
+ <url>
+ <xsl:attribute name="priority">
+ <xsl:choose>
+ <xsl:when test="document('')/*/map:associativearray/map:item[@key=$fmt]">
+ <xsl:value-of select="document('')/*/map:associativearray/map:item[@key=$fmt]/@value"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="50"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:attribute>
+ <xsl:value-of select="$url"/>
+ </url>
+ </xsl:if>
+</xsl:template>
<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>
+ <xsl:variable name="titleparam">
+ <xsl:choose>
+ <xsl:when test="contains(substring-after(., '&amp;title='), '&amp;')">
+ <xsl:value-of select="substring-before(substring-after(., '&amp;title='), '&amp;')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="substring-after(., '&amp;title=')"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
+ <xsl:value-of select="str:decode-uri(str:replace($titleparam, '+', ' '))"/>
</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>
+ <xsl:for-each select="str:split(str:decode-uri(substring-before(substring-after(., '&amp;fmt_url_map='), '&amp;')), ',')">
+ <xsl:call-template name="fmturl"/>
+ </xsl:for-each>
+
</mediaurl>
</xsl:template>