From 1a7c069c64f3daaf1fa67951d3cbbe2be85a89a5 Mon Sep 17 00:00:00 2001 From: Antti Ajanki Date: Fri, 23 Jul 2010 22:45:50 +0300 Subject: Fix Youtube, use only only video URLs that really exist in fmt_url_map --- templates/youtube/navigation.xsl | 2 +- templates/youtube/video.xsl | 94 +++++++++++++++++++++++++--------------- 2 files changed, 60 insertions(+), 36 deletions(-) (limited to 'templates') 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 @@ - wvt:///youtube/video.xsl?srcurl=http://www.youtube.com/watch?v= + wvt:///youtube/video.xsl?srcurl=http://www.youtube.com/get_video_info?video_id= wvt:///youtube/description.xsl?srcurl= 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 @@ - - - - - - - - - - - - - - - - - - - - - - - + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:str="http://exslt.org/strings" + xmlns:map="mapping" + exclude-result-prefixes="str map"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - <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(., '&title='), '&')"> + <xsl:value-of select="substring-before(substring-after(., '&title='), '&')"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="substring-after(., '&title=')"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <xsl:value-of select="str:decode-uri(str:replace($titleparam, '+', ' '))"/> - http://www.youtube.com/get_video?video_id=&t=&fmt=22 - http://www.youtube.com/get_video?video_id=&t=&fmt=18 - http://www.youtube.com/get_video?video_id=&t= + + + + -- cgit v1.2.3