1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-12-11 04:14:18 +01:00
svtplay-dl/lib/svtplay_dl/fetcher/rtmp.py

48 lines
1.3 KiB
Python
Raw Normal View History

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 -*-
from __future__ import absolute_import
2013-02-12 19:23:56 +01:00
import subprocess
import shlex
from svtplay_dl.log import log
2013-12-30 01:35:08 +01:00
from svtplay_dl.utils import is_py2
2014-04-21 16:50:24 +02:00
from svtplay_dl.fetcher import VideoRetriever
from svtplay_dl.output import output
2013-02-12 19:23:56 +01:00
2015-09-15 20:10:32 +02:00
2014-04-21 16:50:24 +02:00
class RTMP(VideoRetriever):
def name(self):
2014-07-13 15:19:12 +02:00
return "rtmp"
2014-04-21 16:50:24 +02:00
def download(self):
""" Get the stream from RTMP """
args = []
if self.options.live:
args.append("-v")
2013-02-12 19:23:56 +01:00
2014-04-21 16:50:24 +02:00
if self.options.resume:
args.append("-e")
2013-02-12 19:23:56 +01:00
file_d = output(self.options, "flv", False)
if file_d is None:
return
args += ["-o", self.options.output]
2014-04-21 16:50:24 +02:00
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)
2014-04-21 16:50:24 +02:00
if self.options.verbose:
args.append("-V")
2014-04-21 16:50:24 +02:00
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)
2013-02-12 19:23:56 +01:00