From 60af70bb9d1166e0595a2b9e7a0aa03ecf0e59de Mon Sep 17 00:00:00 2001 From: Olof Johansson Date: Tue, 12 Feb 2013 19:23:56 +0100 Subject: [PATCH] Breakout rtmp fetcher to own module --- lib/svtplay/rtmp.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 lib/svtplay/rtmp.py diff --git a/lib/svtplay/rtmp.py b/lib/svtplay/rtmp.py new file mode 100644 index 0000000..6c1bb64 --- /dev/null +++ b/lib/svtplay/rtmp.py @@ -0,0 +1,37 @@ +import subprocess +import re +import shlex + +from lib.svtplay.log import log + +def download_rtmp(options, url): + """ Get the stream from RTMP """ + args = [] + if options.live: + args.append("-v") + + if options.resume: + args.append("-e") + + extension = re.search("(\.[a-z0-9]+)$", url) + if options.output != "-": + if not extension: + extension = re.search("-y (.+):[-_a-z0-9\/]", options.other) + if not extension: + options.output = "%s.flv" % options.output + else: + options.output = "%s%s" % (options.output, extension.group(1)) + else: + options.output = options.output + extension.group(1) + log.info("Outfile: %s", options.output) + args += ["-o", options.output] + if options.silent or options.output == "-": + args.append("-q") + if options.other: + args += shlex.split(options.other) + command = ["rtmpdump", "-r", url] + args + try: + subprocess.call(command) + except OSError as e: + log.error("Could not execute rtmpdump: " + e.strerror) +