1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 21:54:17 +01:00

Capture live streams using -l argument

This commit is contained in:
Johan Andersson 2011-03-19 18:29:29 +01:00
parent 96f717fa66
commit 83f790c7d1

View File

@ -23,14 +23,16 @@ def calc_data(byte, total):
if byte >= total: if byte >= total:
sys.stdout.write('\n') sys.stdout.write('\n')
def getrtmp(url, output): def getrtmp(url, output, live):
""" Get the stream from RTMP """ """ Get the stream from RTMP """
other = "" other, other2 = ""
if url[4:5] == "e": if url[4:5] == "e":
# For encrypted streams # For encrypted streams
other = "-l 2" other = "-l 2"
if live:
other2 = "-v"
command = ["/usr/bin/rtmpdump", "-r", url, "-o", output, other] command = ["/usr/bin/rtmpdump", "-r", url, "-o", output, other, other2]
subprocess.call(command) subprocess.call(command)
def gethttp(url, output): def gethttp(url, output):
@ -59,10 +61,14 @@ def main():
parser = OptionParser(usage=usage) parser = OptionParser(usage=usage)
parser.add_option("-o", "--output", parser.add_option("-o", "--output",
metavar="OUTPUT", help="Outputs to the given filename.") metavar="OUTPUT", help="Outputs to the given filename.")
parser.add_option("-l", "--live",
action="store_true", dest="live", default=False,
help="Enable for live streams")
(options, args) = parser.parse_args() (options, args) = parser.parse_args()
if len(args) != 1: if len(args) != 1:
parser.error("incorrect number of arguments") parser.error("incorrect number of arguments")
output = options.output output = options.output
live = options.live
data = getdata(args[0]) data = getdata(args[0])
match = re.search('dynamicStreams=(.*)\&amp\;background', data) match = re.search('dynamicStreams=(.*)\&amp\;background', data)
if match: if match:
@ -81,7 +87,7 @@ def main():
print "Outfile: ", output print "Outfile: ", output
if stream[0:4] == "rtmp": if stream[0:4] == "rtmp":
getrtmp(stream, output) getrtmp(stream, output, live)
else: else:
gethttp(stream, output) gethttp(stream, output)