diff options
Diffstat (limited to 'templates/youtube/video.xsl')
-rw-r--r-- | templates/youtube/video.xsl | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/templates/youtube/video.xsl b/templates/youtube/video.xsl new file mode 100644 index 0000000..d38a99e --- /dev/null +++ b/templates/youtube/video.xsl @@ -0,0 +1,48 @@ +<?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')], '"t": "'), '"')"/> +<xsl:variable name="video_id1" select="substring-before(substring-after(html/head/script[contains(., 'swfArgs') or contains(., 'SWF_ARGS')], '"video_id": "'), '"')"/> + +<!-- new variables --> +<xsl:variable name="t2" select="substring-before(substring-after(//script[contains(., 'swfHTML')], '&t='), '&')"/> +<xsl:variable name="video_id2" select="substring-before(substring-after(//script[contains(., 'swfHTML')], '&video_id='), '&')"/> + +<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> + +<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> + </title> + + <url priority="70">http://www.youtube.com/get_video?video_id=<xsl:value-of select="$video_id"/>&t=<xsl:value-of select="$t"/>&fmt=22</url> + <url priority="60">http://www.youtube.com/get_video?video_id=<xsl:value-of select="$video_id"/>&t=<xsl:value-of select="$t"/>&fmt=18</url> + <url priority="50">http://www.youtube.com/get_video?video_id=<xsl:value-of select="$video_id"/>&t=<xsl:value-of select="$t"/></url> +</mediaurl> +</xsl:template> + +</xsl:stylesheet> |