2013-03-02 21:26:28 +01:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2013-03-01 23:39:42 +01:00
|
|
|
from __future__ import absolute_import
|
2013-02-12 19:23:56 +01:00
|
|
|
import subprocess
|
|
|
|
import re
|
|
|
|
import shlex
|
|
|
|
|
2013-03-17 19:55:19 +01:00
|
|
|
from svtplay_dl.log import log
|
2013-12-30 01:35:08 +01:00
|
|
|
from svtplay_dl.utils import is_py2
|
2013-02-12 19:23:56 +01:00
|
|
|
|
|
|
|
def download_rtmp(options, url):
|
|
|
|
""" Get the stream from RTMP """
|
|
|
|
args = []
|
|
|
|
if options.live:
|
|
|
|
args.append("-v")
|
|
|
|
|
|
|
|
if options.resume:
|
|
|
|
args.append("-e")
|
|
|
|
|
2013-05-05 12:57:42 +02:00
|
|
|
extension = re.search(r"(\.[a-z0-9]+)$", url)
|
2013-02-12 19:23:56 +01:00
|
|
|
if options.output != "-":
|
|
|
|
if not extension:
|
2013-12-29 18:38:39 +01:00
|
|
|
options.output = "%s.flv" % options.output
|
2013-02-12 19:23:56 +01:00
|
|
|
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:
|
2013-12-30 01:35:08 +01:00
|
|
|
if is_py2:
|
2013-03-10 13:43:22 +01:00
|
|
|
args += shlex.split(options.other.encode("utf-8"))
|
|
|
|
else:
|
|
|
|
args += shlex.split(options.other)
|
2013-02-12 19:23:56 +01:00
|
|
|
command = ["rtmpdump", "-r", url] + args
|
|
|
|
try:
|
|
|
|
subprocess.call(command)
|
|
|
|
except OSError as e:
|
|
|
|
log.error("Could not execute rtmpdump: " + e.strerror)
|
|
|
|
|