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 shlex
|
|
|
|
|
2013-03-17 19:55:19 +01:00
|
|
|
from svtplay_dl.log import log
|
2014-04-21 16:50:24 +02:00
|
|
|
from svtplay_dl.fetcher import VideoRetriever
|
2018-05-13 01:45:40 +02:00
|
|
|
from svtplay_dl.utils.output import output, formatname
|
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):
|
2018-05-25 22:47:26 +02:00
|
|
|
@property
|
2014-05-01 17:13:46 +02:00
|
|
|
def name(self):
|
2014-07-13 15:19:12 +02:00
|
|
|
return "rtmp"
|
2014-05-01 17:13:46 +02:00
|
|
|
|
2014-04-21 16:50:24 +02:00
|
|
|
def download(self):
|
|
|
|
""" Get the stream from RTMP """
|
2018-05-13 01:45:23 +02:00
|
|
|
self.output_extention = "flv"
|
2014-04-21 16:50:24 +02:00
|
|
|
args = []
|
2018-05-13 13:06:45 +02:00
|
|
|
if self.config.get("live"):
|
2014-04-21 16:50:24 +02:00
|
|
|
args.append("-v")
|
2013-02-12 19:23:56 +01:00
|
|
|
|
2018-05-13 13:06:45 +02:00
|
|
|
if self.config.get("resume"):
|
2014-04-21 16:50:24 +02:00
|
|
|
args.append("-e")
|
2013-02-12 19:23:56 +01:00
|
|
|
|
2018-05-08 22:46:11 +02:00
|
|
|
file_d = output(self.output, self.config, "flv", False)
|
2014-10-13 00:14:20 +02:00
|
|
|
if file_d is None:
|
|
|
|
return
|
2018-05-13 01:45:40 +02:00
|
|
|
args += ["-o", formatname(self.output, self.config, "flv")]
|
|
|
|
if self.config.get("silent"):
|
2014-04-21 16:50:24 +02:00
|
|
|
args.append("-q")
|
2018-05-08 22:46:11 +02:00
|
|
|
if self.kwargs.get("other"):
|
|
|
|
args += shlex.split(self.kwargs.pop("other"))
|
2014-03-09 15:33:13 +01:00
|
|
|
|
2018-05-08 22:46:11 +02:00
|
|
|
if self.config.get("verbose"):
|
2014-04-21 16:50:24 +02:00
|
|
|
args.append("-V")
|
2014-03-09 15:33:13 +01:00
|
|
|
|
2014-04-21 16:50:24 +02:00
|
|
|
command = ["rtmpdump", "-r", self.url] + args
|
2017-10-09 22:35:33 +02:00
|
|
|
log.debug("Running: {0}".format(" ".join(command)))
|
2014-04-21 16:50:24 +02:00
|
|
|
try:
|
|
|
|
subprocess.call(command)
|
|
|
|
except OSError as e:
|
2017-10-09 22:35:33 +02:00
|
|
|
log.error("Could not execute rtmpdump: {0}".format(e.strerror))
|
2016-03-22 22:28:41 +01:00
|
|
|
return
|
|
|
|
self.finished = True
|