1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 20:25:41 +01:00
svtplay-dl/lib/svtplay_dl/fetcher/rtmp.py
2014-08-21 22:10:16 +02:00

47 lines
1.3 KiB
Python

# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
from __future__ import absolute_import
import subprocess
import shlex
from svtplay_dl.log import log
from svtplay_dl.utils import is_py2
from svtplay_dl.fetcher import VideoRetriever
from svtplay_dl.output import output
class RTMP(VideoRetriever):
def name(self):
return "rtmp"
def download(self):
""" Get the stream from RTMP """
args = []
if self.options.live:
args.append("-v")
if self.options.resume:
args.append("-e")
file_d = output(self.options, self.options.output, "flv", False)
if hasattr(file_d, "read") is False:
return
args += ["-o", self.options.output]
if self.options.silent or self.options.output == "-":
args.append("-q")
if self.options.other:
if is_py2:
args += shlex.split(self.options.other.encode("utf-8"))
else:
args += shlex.split(self.options.other)
if self.options.verbose:
args.append("-V")
command = ["rtmpdump", "-r", self.url] + args
log.debug("Running: %s", " ".join(command))
try:
subprocess.call(command)
except OSError as e:
log.error("Could not execute rtmpdump: " + e.strerror)