diff options
author | Antti Ajanki <antti.ajanki@iki.fi> | 2013-04-13 13:26:56 +0300 |
---|---|---|
committer | Antti Ajanki <antti.ajanki@iki.fi> | 2013-04-14 18:58:27 +0300 |
commit | 5c52f40217d467beec4b2d891c08194593bd9489 (patch) | |
tree | 5f20db8297a787b504c486f51ca349d9cb9cdd0b /templates | |
parent | eaf81f840a08fb991f024ebdbe9368bbd1a488ad (diff) | |
download | vdr-plugin-webvideo-5c52f40217d467beec4b2d891c08194593bd9489.tar.gz vdr-plugin-webvideo-5c52f40217d467beec4b2d891c08194593bd9489.tar.bz2 |
Fix Katsomo by downloading from the mobile site
Not all streams work
Diffstat (limited to 'templates')
-rwxr-xr-x | templates/bin/katsomo-dl | 42 | ||||
-rw-r--r-- | templates/katsomo.fi/description.xsl | 6 | ||||
-rw-r--r-- | templates/katsomo.fi/program.xsl | 20 | ||||
-rw-r--r-- | templates/katsomo.fi/searchresults.xsl | 23 | ||||
-rw-r--r-- | templates/katsomo.fi/video.xsl | 39 |
5 files changed, 79 insertions, 51 deletions
diff --git a/templates/bin/katsomo-dl b/templates/bin/katsomo-dl new file mode 100755 index 0000000..73d39ab --- /dev/null +++ b/templates/bin/katsomo-dl @@ -0,0 +1,42 @@ +#!/bin/sh + +# Downloads a video from katsomo.fi. The first parameter is the stream +# URL, the optional second parameter is the output file. +# +# Because the main stream is Silverlight, which can't be downloaded, +# get the mobile stream. + +if [ "x$1" = "x" ]; then + echo "Expected URL missing" 1>&2 + exit 1 +fi + +OUTPUT_FILE="$2" +if [ "x$OUTPUT_FILE" = "x" ]; then + OUTPUT_FILE="-" +fi + +# Convert http://www.katsomo.fi/?progId=xxx URL into mobile site URL +# and parse the stream URL from the HTML. + +MOBILE_PAGE=`echo ${1} | sed "s/www/m/"` +STREAM_URL=`curl -A iPhone -L --max-redirs 10 $MOBILE_PAGE 2>/dev/null | grep "video\/mp4" | sed "s/<.*src=\"//" | sed "s/\"\/>//" | sed "s/^ *//g"` + +if [ "x$STREAM_URL" = "x" ]; then + echo "Failed to find the stream URL in $MOBILE_PAGE" 1>&2 + exit 1 +fi + +# The STREAM_URL points to an m3u playlist, using avconv to download +# the stream. + +if [ "x$OUTPUT_FILE" = "x-" -o -p "$OUTPUT_FILE" ]; then + # Transcode into a streamable format + avconv -y -i "$STREAM_URL" -f flv -vcodec libx264 -acodec libmp3lame -ab 192k -ar 22050 "$OUTPUT_FILE" +else + # Would use -acodec copy, but due to a bug avconv sometimes fails + # with a non-monotonic timestamp error. + avconv -y -i "$STREAM_URL" -vcodec copy -acodec mp2 -ab 128k "$OUTPUT_FILE" +fi + +exit $? diff --git a/templates/katsomo.fi/description.xsl b/templates/katsomo.fi/description.xsl index 1a7d39b..c45d174 100644 --- a/templates/katsomo.fi/description.xsl +++ b/templates/katsomo.fi/description.xsl @@ -34,8 +34,6 @@ </xsl:choose> </xsl:variable> -<xsl:variable name="pid" select="substring-after($docurl, 'progId=')"/> - <wvmenu> <title><xsl:value-of select="$title"/></title> @@ -50,10 +48,10 @@ </textarea> </xsl:when> - <xsl:when test="$pid"> + <xsl:when test="$docurl"> <link> <label>Download this video</label> - <stream>wvt:///katsomo.fi/video.xsl?param=pid,<xsl:value-of select="$pid"/>&param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream> + <stream>wvt:///katsomo.fi/video.xsl?param=videopage,<xsl:value-of select="str:encode-uri($docurl, true())"/>&param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream> </link> </xsl:when> </xsl:choose> diff --git a/templates/katsomo.fi/program.xsl b/templates/katsomo.fi/program.xsl index 63def55..8c7907e 100644 --- a/templates/katsomo.fi/program.xsl +++ b/templates/katsomo.fi/program.xsl @@ -6,37 +6,31 @@ exclude-result-prefixes="str"> <xsl:template match="div[contains(@class, 'item')]"> - <xsl:variable name="episodetitle"> - <xsl:value-of select="normalize-space(div[@class='row2']/a)"/> - </xsl:variable> - <xsl:variable name="programtitle"> - <xsl:value-of select="normalize-space(id('program_content')/h1)"/> - </xsl:variable> <xsl:variable name="title"> <xsl:choose> - <xsl:when test="$programtitle = $episodetitle"> - <xsl:value-of select="$programtitle"/> + <xsl:when test="normalize-space(div[@class='row3']/span)"> + <xsl:value-of select="concat(normalize-space(div[@class='row2']/a), ': ', normalize-space(div[@class='row3']/span))"/> </xsl:when> <xsl:otherwise> - <xsl:value-of select="concat($programtitle, ': ', $episodetitle)"/> + <xsl:value-of select="concat(normalize-space(div[@class='row2']/a), ': ', normalize-space(div[@class='row1']/span))"/> </xsl:otherwise> </xsl:choose> </xsl:variable> - + <xsl:choose> <xsl:when test="div[@class='row1']/span[@class='live']"> <xsl:variable name="upcoming" select="concat(div[@class='row1']/span[@class='live'], ' ', div[@class='row1']/span[contains(@class, 'time')])"/> <link> - <label><xsl:value-of select="normalize-space(concat(div[@class='row2']/a, ' ', $upcoming))"/></label> + <label><xsl:value-of select="concat($title, ' ', $upcoming)"/></label> <ref>wvt:///katsomo.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div[@class='row2']/a/@href, true())"/>&param=live,<xsl:value-of select="str:encode-uri($upcoming, true())"/></ref> </link> </xsl:when> <xsl:otherwise> <link> - <label><xsl:value-of select="div[@class='row2']/a"/></label> + <label><xsl:value-of select="$title"/></label> <ref>wvt:///katsomo.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri(div[@class='row2']/a/@href, true())"/></ref> - <stream>wvt:///katsomo.fi/video.xsl?param=pid,<xsl:value-of select="substring-after(div[@class='row2']/a/@href, 'progId=')"/>&param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream> + <stream>wvt:///katsomo.fi/video.xsl?param=videopage,<xsl:value-of select="div[@class='row2']/a/@href"/>&param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream> </link> </xsl:otherwise> </xsl:choose> diff --git a/templates/katsomo.fi/searchresults.xsl b/templates/katsomo.fi/searchresults.xsl index bb6cae2..09341f9 100644 --- a/templates/katsomo.fi/searchresults.xsl +++ b/templates/katsomo.fi/searchresults.xsl @@ -5,40 +5,21 @@ xmlns:str="http://exslt.org/strings" exclude-result-prefixes="str"> -<!-- Helper function for extracting progId from href --> -<xsl:template name="extract_pid"> - <xsl:param name="href"/> - - <xsl:choose> - <xsl:when test="contains(substring-after($href, 'progId='), '&')"> - <xsl:value-of select="substring-before(substring-after($href, 'progId='), '&')"/> - </xsl:when> - <xsl:otherwise> - <xsl:value-of select="substring-after($href, 'progId=')"/> - </xsl:otherwise> - </xsl:choose> -</xsl:template> - <!-- Create video link --> <xsl:template name="video_link"> <xsl:param name="title"/> <xsl:param name="href"/> - <xsl:variable name="pid"> - <xsl:call-template name="extract_pid"> - <xsl:with-param name="href" select="$href"/> - </xsl:call-template> - </xsl:variable> <link> <label><xsl:value-of select="$title"/></label> <ref>wvt:///katsomo.fi/description.xsl?srcurl=<xsl:value-of select="str:encode-uri($href, true())"/></ref> - <stream>wvt:///katsomo.fi/video.xsl?param=pid,<xsl:value-of select="$pid"/>&param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream> + <stream>wvt:///katsomo.fi/video.xsl?param=videopage,<xsl:value-of select="str:encode-uri($href, true())"/>&param=title,<xsl:value-of select="str:encode-uri($title, true())"/></stream> </link> </xsl:template> <xsl:template match="id('search_episodes')/div"> <xsl:call-template name="video_link"> - <xsl:with-param name="title" select="normalize-space(h4/a)"/> + <xsl:with-param name="title" select="concat(normalize-space(h4/a), ' ', p[@class='date'])"/> <xsl:with-param name="href" select="h4/a/@href"/> </xsl:call-template> </xsl:template> diff --git a/templates/katsomo.fi/video.xsl b/templates/katsomo.fi/video.xsl index dee8d21..484e464 100644 --- a/templates/katsomo.fi/video.xsl +++ b/templates/katsomo.fi/video.xsl @@ -1,27 +1,40 @@ <?xml version="1.0" encoding="UTF-8"?> -<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> +<xsl:stylesheet version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:str="http://exslt.org/strings" + exclude-result-prefixes="str"> <xsl:param name="title">katsomo_video</xsl:param> -<xsl:param name="pid"/> +<xsl:param name="videopage"/> <xsl:template name="mediaurl"> -<xsl:param name="title"/> -<xsl:param name="pid"/> -<mediaurl> - <title><xsl:value-of select="$title"/></title> - <url> - <xsl:if test="$pid"> - <xsl:value-of select="concat('http://www.katsomo.fi/metafile.asx?p=', $pid, '&bw=800')"/> - </xsl:if> - </url> -</mediaurl> + <xsl:param name="title"/> + <xsl:param name="videopage"/> + + <xsl:variable name="absoluteurl"> + <xsl:choose> + <xsl:when test="contains($videopage, 'www.katsomo.fi')"> + <xsl:value-of select="$videopage"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="concat('http://www.katsomo.fi', $videopage)"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + + <mediaurl> + <title><xsl:value-of select="$title"/></title> + <url priority="50"> + <xsl:if test="$videopage">wvt:///bin/katsomo-dl?contenttype=video/x-flv&arg=<xsl:value-of select="str:encode-uri($absoluteurl, true())"/></xsl:if> + </url> + </mediaurl> </xsl:template> <xsl:template match="/"> <xsl:call-template name="mediaurl"> <xsl:with-param name="title" select="$title"/> - <xsl:with-param name="pid" select="$pid"/> + <xsl:with-param name="videopage" select="$videopage"/> </xsl:call-template> </xsl:template> |