From 5c52f40217d467beec4b2d891c08194593bd9489 Mon Sep 17 00:00:00 2001 From: Antti Ajanki Date: Sat, 13 Apr 2013 13:26:56 +0300 Subject: Fix Katsomo by downloading from the mobile site Not all streams work --- README | 15 +++++------- TODO | 2 -- templates/bin/katsomo-dl | 42 ++++++++++++++++++++++++++++++++++ templates/katsomo.fi/description.xsl | 6 ++--- templates/katsomo.fi/program.xsl | 20 ++++++---------- templates/katsomo.fi/searchresults.xsl | 23 ++----------------- templates/katsomo.fi/video.xsl | 39 ++++++++++++++++++++----------- 7 files changed, 85 insertions(+), 62 deletions(-) create mode 100755 templates/bin/katsomo-dl diff --git a/README b/README index ef6fc07..dc0fe4b 100644 --- a/README +++ b/README @@ -14,21 +14,18 @@ Supported video sites: * Google Video [1] * Metacafe -* MTV3 Katsomo -* ruutu.fi [2] -* YLE Areena [3] +* MTV3 Katsomo [2] +* ruutu.fi [3] +* YLE Areena [4] * YouTube [1] Only videos hosted by Google, YouTube, Metacafe -[2] Requires rtmpdump: http://rtmpdump.mplayerhq.hu/ +[2] Experimental, requires curl and avconv -[3] Requires yle-dl: http://aajanki.github.com/yle-dl/ +[3] Requires rtmpdump: http://rtmpdump.mplayerhq.hu/ -Known problems: - -* MTV3 Katsomo: often the connection is lost before the video is fully - downloaded. +[4] Requires yle-dl: http://aajanki.github.com/yle-dl/ Because of the modular design it is possible to add support for new sites quite easily. See doc/developers.txt for more information. diff --git a/TODO b/TODO index 9b462aa..de9e597 100644 --- a/TODO +++ b/TODO @@ -18,5 +18,3 @@ Fix support for mplayer plugin Kill external downloader process when the player stops mid-stream youtube: webvi --url doesn't work. Workaround: youtube-dl - -katsomo.fi is broken 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:value-of select="$title"/> @@ -50,10 +48,10 @@ - + - wvt:///katsomo.fi/video.xsl?param=pid,&param=title, + wvt:///katsomo.fi/video.xsl?param=videopage,&param=title, 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"> - - - - - - - - + + - + - + - + wvt:///katsomo.fi/description.xsl?srcurl=&param=live, - + wvt:///katsomo.fi/description.xsl?srcurl= - wvt:///katsomo.fi/video.xsl?param=pid,&param=title, + wvt:///katsomo.fi/video.xsl?param=videopage,&param=title, 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"> - - - - - - - - - - - - - - - - - - - wvt:///katsomo.fi/description.xsl?srcurl= - wvt:///katsomo.fi/video.xsl?param=pid,&param=title, + wvt:///katsomo.fi/video.xsl?param=videopage,&param=title, - + 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 @@ - + katsomo_video - + - - - - <xsl:value-of select="$title"/> - - - - - - + + + + + + + + + + + + + + + + <xsl:value-of select="$title"/> + + wvt:///bin/katsomo-dl?contenttype=video/x-flv&arg= + + - + -- cgit v1.2.3