diff options
author | Antti Ajanki <antti.ajanki@iki.fi> | 2010-10-26 22:08:07 +0300 |
---|---|---|
committer | Antti Ajanki <antti.ajanki@iki.fi> | 2010-10-26 22:08:07 +0300 |
commit | 20f619bb2dbed736de51245651b0321f46e73e94 (patch) | |
tree | 82664dfed006c4f13f1b7016901fbe244328339e /templates | |
parent | ac3fa72b3d3b82a20572d03c9d8a4f0296f7d636 (diff) | |
download | vdr-plugin-webvideo-20f619bb2dbed736de51245651b0321f46e73e94.tar.gz vdr-plugin-webvideo-20f619bb2dbed736de51245651b0321f46e73e94.tar.bz2 |
extract Youtube video params from the webpage, because get_video_info fails on copyright restricted videos
Diffstat (limited to 'templates')
-rw-r--r-- | templates/www.metacafe.com/navigation.xsl | 2 | ||||
-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 | 84 | ||||
-rw-r--r-- | templates/www.youtube.com/videopage.xsl | 74 |
5 files changed, 75 insertions, 89 deletions
diff --git a/templates/www.metacafe.com/navigation.xsl b/templates/www.metacafe.com/navigation.xsl index a4cb8e0..72e5d65 100644 --- a/templates/www.metacafe.com/navigation.xsl +++ b/templates/www.metacafe.com/navigation.xsl @@ -8,7 +8,7 @@ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <label><xsl:value-of select="title" /></label> <xsl:choose> <xsl:when test="starts-with(id, 'yt-')"> - <stream>wvt:///www.youtube.com/video.xsl?srcurl=http://www.youtube.com/get_video_info?video_id=<xsl:value-of select="substring(id, 4)"/></stream> + <stream>wvt:///www.youtube.com/videopage.xsl?srcurl=http://www.youtube.com/watch?v=<xsl:value-of select="substring(id, 4)"/></stream> </xsl:when> <xsl:otherwise> <stream>wvt:///www.metacafe.com/videopage.xsl?srcurl=<xsl:value-of select="link"/></stream> diff --git a/templates/www.youtube.com/description.xsl b/templates/www.youtube.com/description.xsl index 6567adb..453c152 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/video.xsl?srcurl=http://www.youtube.com/get_video_info?video_id=<xsl:value-of select="/atom:entry/media:group/yt:videoid"/></stream> + <stream>wvt:///www.youtube.com/videopage.xsl?srcurl=http://www.youtube.com/watch?v=<xsl:value-of select="media:group/yt:videoid"/></stream> </link> </wvmenu> diff --git a/templates/www.youtube.com/navigation.xsl b/templates/www.youtube.com/navigation.xsl index 91f6189..0dd1fd8 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/video.xsl?srcurl=http://www.youtube.com/get_video_info?video_id=<xsl:value-of select="media:group/yt:videoid"/></stream> + <stream>wvt:///www.youtube.com/videopage.xsl?srcurl=http://www.youtube.com/watch?v=<xsl:value-of select="media:group/yt:videoid"/></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 deleted file mode 100644 index 12e1cf5..0000000 --- a/templates/www.youtube.com/video.xsl +++ /dev/null @@ -1,84 +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" - 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 name="mediaurl"> -<xsl:param name="videoinfo"/> -<xsl:param name="title"/> - -<mediaurl> - <title> - <xsl:variable name="titleparam"> - <xsl:choose> - <xsl:when test="$title"> - <xsl:value-of select="$title"/> - </xsl:when> - <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, '&fmt_url_map='), '&')), ',')"> - <xsl:call-template name="fmturl"/> - </xsl:for-each> - -</mediaurl> -</xsl:template> - -<xsl:template match="/"> - <xsl:call-template name="mediaurl"> - <xsl:with-param name="videoinfo" select="."/> - </xsl:call-template> -</xsl:template> - -</xsl:stylesheet> diff --git a/templates/www.youtube.com/videopage.xsl b/templates/www.youtube.com/videopage.xsl index 5f1b174..a82583d 100644 --- a/templates/www.youtube.com/videopage.xsl +++ b/templates/www.youtube.com/videopage.xsl @@ -1,9 +1,79 @@ <?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" + xmlns:map="mapping" + exclude-result-prefixes="str map"> -<xsl:import href="video.xsl"/> +<!-- 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 name="mediaurl"> + <xsl:param name="videoinfo"/> + <xsl:param name="title"/> + + <mediaurl> + <title> + <xsl:variable name="titleparam"> + <xsl:choose> + <xsl:when test="$title"> + <xsl:value-of select="$title"/> + </xsl:when> + <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, '&fmt_url_map='), '&')), ',')"> + <xsl:call-template name="fmturl"/> + </xsl:for-each> + + </mediaurl> +</xsl:template> <xsl:template match="/"> <xsl:variable name="videoinfo"> |