diff options
author | Antti Ajanki <antti.ajanki@iki.fi> | 2012-09-18 21:50:19 +0300 |
---|---|---|
committer | Antti Ajanki <antti.ajanki@iki.fi> | 2012-09-18 21:50:19 +0300 |
commit | c9a2dafe2a6dc59641c5b02817e3b574f0924930 (patch) | |
tree | 2976432d595b3198bae6f774dc9a84429c495692 | |
parent | b27b9f78c71761dc4b9df224c29ab6a11776575a (diff) | |
download | vdr-plugin-webvideo-c9a2dafe2a6dc59641c5b02817e3b574f0924930.tar.gz vdr-plugin-webvideo-c9a2dafe2a6dc59641c5b02817e3b574f0924930.tar.bz2 |
Youtube fixes
-rw-r--r-- | templates/www.youtube.com/description.xsl | 2 | ||||
-rw-r--r-- | templates/www.youtube.com/navigation.xsl | 2 | ||||
-rw-r--r-- | templates/www.youtube.com/video.xsl | 93 |
3 files changed, 95 insertions, 2 deletions
diff --git a/templates/www.youtube.com/description.xsl b/templates/www.youtube.com/description.xsl index b8cc9b9..83e53d2 100644 --- a/templates/www.youtube.com/description.xsl +++ b/templates/www.youtube.com/description.xsl @@ -64,7 +64,7 @@ <link> <label>Download this video</label> - <stream>wvt:///www.youtube.com/videopage.xsl?srcurl=http://www.youtube.com/watch?v=<xsl:value-of select="/atom:entry/media:group/yt:videoid"/></stream> + <stream>wvt:///www.youtube.com/video.xsl?srcurl=http://www.youtube.com/get_video_info?%26video_id=<xsl:value-of select="/atom:entry/media:group/yt:videoid"/>%26el=detailpage%26ps=default%26eurl=%26gl=US%26hl=en</stream> </link> </wvmenu> diff --git a/templates/www.youtube.com/navigation.xsl b/templates/www.youtube.com/navigation.xsl index 0dd1fd8..43ffd45 100644 --- a/templates/www.youtube.com/navigation.xsl +++ b/templates/www.youtube.com/navigation.xsl @@ -11,7 +11,7 @@ <xsl:template match="atom:entry"> <link> <label><xsl:value-of select="atom:title"/></label> - <stream>wvt:///www.youtube.com/videopage.xsl?srcurl=http://www.youtube.com/watch?v=<xsl:value-of select="media:group/yt:videoid"/></stream> + <stream>wvt:///www.youtube.com/video.xsl?srcurl=http://www.youtube.com/get_video_info?%26video_id=<xsl:value-of select="media:group/yt:videoid"/>%26el=detailpage%26ps=default%26eurl=%26gl=US%26hl=en</stream> <ref>wvt:///www.youtube.com/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(atom:link[@rel='self']/@href, true())"/></ref> </link> </xsl:template> diff --git a/templates/www.youtube.com/video.xsl b/templates/www.youtube.com/video.xsl new file mode 100644 index 0000000..c78d4ab --- /dev/null +++ b/templates/www.youtube.com/video.xsl @@ -0,0 +1,93 @@ +<?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: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"/> <!-- 176x144 3GP --> + <map:item key="5" value="50"/> <!-- 320x240 FLV --> + <map:item key="34" value="52"/> <!-- 640x360 FLV --> + <map:item key="35" value="54"/> <!-- 854x480 FLV --> + <map:item key="18" value="60"/> <!-- 640x360 MP4 --> + <map:item key="43" value="65"/> <!-- 640x360 WebM --> + <map:item key="44" value="67"/> <!-- 854x480 WebM --> + <map:item key="22" value="70"/> <!-- 720p MP4 --> + <map:item key="45" value="75"/> <!-- 720p WebM --> + <map:item key="37" value="80"/> <!-- 1080p MP4 --> +</map:associativearray> + +<xsl:template name="fmturl"> + <xsl:variable name="fmt"> + <xsl:for-each select="str:tokenize(., '&')"> + <xsl:if test="starts-with(., 'itag=')"> + <xsl:value-of select="substring-after(., 'itag=')"/> + </xsl:if> + </xsl:for-each> + </xsl:variable> + <xsl:variable name="url"> + <xsl:for-each select="str:tokenize(., '&')"> + <xsl:if test="starts-with(., 'url=')"> + <xsl:value-of select="str:decode-uri(substring-after(., 'url='))"/> + </xsl:if> + </xsl:for-each> + </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 name="mediaurl"> + <xsl:param name="videoinfo"/> + + <mediaurl> + <title> + <xsl:variable name="titleparam"> + <xsl:choose> + <xsl:when test="contains(substring-after($videoinfo, '&title='), '&')"> + <xsl:value-of select="substring-before(substring-after($videoinfo, '&title='), '&')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="substring-after($videoinfo, '&title=')"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:value-of select="str:decode-uri(str:replace($titleparam, '+', ' '))"/> + </title> + + <xsl:for-each select="str:split(str:decode-uri(substring-before(substring-after($videoinfo, '&url_encoded_fmt_stream_map='), '&')), ',')"> + <xsl:call-template name="fmturl"/> + </xsl:for-each> + + </mediaurl> +</xsl:template> + +<xsl:template name="main"> + <xsl:call-template name="mediaurl"> + <xsl:with-param name="videoinfo" select="."/> + </xsl:call-template> +</xsl:template> + +<xsl:template match="/"> + <xsl:call-template name="main"/> +</xsl:template> + +</xsl:stylesheet> |