diff options
author | Antti Ajanki <antti.ajanki@iki.fi> | 2011-07-07 18:49:00 +0300 |
---|---|---|
committer | Antti Ajanki <antti.ajanki@iki.fi> | 2011-07-07 19:05:02 +0300 |
commit | d9c351d21c08cecceee47f8d4d13f8c5fec57922 (patch) | |
tree | b32f78e026f0f0c53fa734393d4773d404219e25 | |
parent | bd88072b5df85c392917e4bce11a40c0058c4657 (diff) | |
download | vdr-plugin-webvideo-d9c351d21c08cecceee47f8d4d13f8c5fec57922.tar.gz vdr-plugin-webvideo-d9c351d21c08cecceee47f8d4d13f8c5fec57922.tar.bz2 |
Streaming support for external downloaders
-rw-r--r-- | src/libwebvi/webvi/request.py | 24 | ||||
-rwxr-xr-x | templates/bin/ruutu-dl | 10 | ||||
-rwxr-xr-x | templates/bin/yle-dl | 10 |
3 files changed, 40 insertions, 4 deletions
diff --git a/src/libwebvi/webvi/request.py b/src/libwebvi/webvi/request.py index cab15f7..313a82e 100644 --- a/src/libwebvi/webvi/request.py +++ b/src/libwebvi/webvi/request.py @@ -22,6 +22,7 @@ import cStringIO import re import download import sys +import tempfile import utils import json2xml import asyncurl @@ -312,10 +313,33 @@ class Request: self.setup_downloader(url, None, None, self.finished_check_url, self.processing['HTTP-headers'], True) + elif url.startswith('wvt://'): + if not url.startswith('wvt:///bin/'): + self.request_done(406,'Streaming not supported') + + fifo = self.create_fifo() + fifourl = url + '&arg=' + fifo + + # Unlink fifo when downloader has finished. Note: If the + # reader doesn't read the fifo for some reason, the writer + # process will deadlock and the fifo is never unlinked. + self.setup_downloader(fifourl, None, None, + lambda x, y: os.unlink(fifo)) + self.writewrapper('file://' + fifo) + self.request_done(0, None) else: self.writewrapper(url) self.request_done(0, None) + def create_fifo(self): + while True: + fifoname = tempfile.mktemp() + try: + os.mkfifo(fifoname, 0600) + return fifoname + except IOError: + pass + def send_mainmenu(self): """Build the XML main menu from the module description files in the hard drive. diff --git a/templates/bin/ruutu-dl b/templates/bin/ruutu-dl index a418e26..855b38a 100755 --- a/templates/bin/ruutu-dl +++ b/templates/bin/ruutu-dl @@ -2,7 +2,8 @@ # Downloads a video stream from ruutu.fi to stdout using # rtmpdump(-yle). The first parameter is the rtmp URL, the second -# parameter is the video page URL. +# parameter is the video page URL, the optional third parameter is the +# output file. RTMPDUMP= @@ -31,6 +32,11 @@ if [ "x$2" = "x" ]; then exit 1 fi -$RTMPDUMP -q -r "$1" -W http://n.sestatic.fi/sites/all/modules/media/Nelonen_mediaplayer_5.3.2.swf -p "$2" -o - +OUTFILE="$3" +if [ "x$OUTFILE" = "x" ]; then + OUTFILE=- +fi + +$RTMPDUMP -q -r "$1" -W http://n.sestatic.fi/sites/all/modules/media/Nelonen_mediaplayer_5.3.2.swf -p "$2" -o "$OUTFILE" exit $? diff --git a/templates/bin/yle-dl b/templates/bin/yle-dl index a317b12..fdaf845 100755 --- a/templates/bin/yle-dl +++ b/templates/bin/yle-dl @@ -1,7 +1,8 @@ #!/bin/sh # Downloads a video stream from Yle Areena to stdout using yle-dl -# script. The first parameter is the video page URL. +# script. The first parameter is the video page URL. Second parameter +# is the output file (optional). YLEDL=yle-dl @@ -17,6 +18,11 @@ if [ "x$1" = "x" ]; then exit 1 fi -$YLEDL $1 -q -o - +OUTFILE="$2" +if [ "x$OUTFILE" = "x" ]; then + OUTFILE=- +fi + +$YLEDL $1 -q -o "$OUTFILE" exit $? |