mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-30 15:14:14 +01:00
Cosmetics
This commit is contained in:
parent
090fa40ba6
commit
97eb0a6c4a
33
svtplay-dl
33
svtplay-dl
@ -26,7 +26,7 @@ def getrtmp(url, output):
|
|||||||
""" Get the stream from RTMP """
|
""" Get the stream from RTMP """
|
||||||
other = ""
|
other = ""
|
||||||
if url[4:5] == "e":
|
if url[4:5] == "e":
|
||||||
""" For encrypted streams """
|
# For encrypted streams
|
||||||
other = "-l 2"
|
other = "-l 2"
|
||||||
|
|
||||||
command = ["/usr/bin/rtmpdump", "-r", url, "-o", output, other]
|
command = ["/usr/bin/rtmpdump", "-r", url, "-o", output, other]
|
||||||
@ -38,7 +38,7 @@ def gethttp(url, output):
|
|||||||
total_size = response.info().getheader('Content-Length').strip()
|
total_size = response.info().getheader('Content-Length').strip()
|
||||||
total_size = int(total_size)
|
total_size = int(total_size)
|
||||||
bytes_so_far = 0
|
bytes_so_far = 0
|
||||||
fd = open(output,"wb")
|
file_d = open(output,"wb")
|
||||||
|
|
||||||
while 1:
|
while 1:
|
||||||
chunk = response.read(8192)
|
chunk = response.read(8192)
|
||||||
@ -47,32 +47,33 @@ def gethttp(url, output):
|
|||||||
if not chunk:
|
if not chunk:
|
||||||
break
|
break
|
||||||
|
|
||||||
fd.write(chunk)
|
file_d.write(chunk)
|
||||||
calc_data(bytes_so_far, total_size)
|
calc_data(bytes_so_far, total_size)
|
||||||
|
|
||||||
fd.close()
|
file_d.close()
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
""" Main program """
|
||||||
argv = sys.argv[1]
|
argv = sys.argv[1]
|
||||||
DATA = getdata(argv)
|
data = getdata(argv)
|
||||||
MATCH = re.search('dynamicStreams=(.*)\&\;background', DATA)
|
match = re.search('dynamicStreams=(.*)\&\;background', data)
|
||||||
if MATCH:
|
if match:
|
||||||
new = MATCH.group(1)
|
new = match.group(1)
|
||||||
tmp = new.split("|")
|
tmp = new.split("|")
|
||||||
MATCH = re.search('url:(.*)\,', tmp[0])
|
match = re.search('url:(.*)\,', tmp[0])
|
||||||
else:
|
else:
|
||||||
MATCH = re.search('pathflv=(.*)\&\;background', DATA)
|
match = re.search('pathflv=(.*)\&\;background', data)
|
||||||
if not MATCH:
|
if not match:
|
||||||
print "Err: cant find stream"
|
print "Err: cant find stream"
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
STREAM = MATCH.group(1)
|
stream = match.group(1)
|
||||||
OUTPUT = os.path.basename(STREAM)
|
output = os.path.basename(stream)
|
||||||
|
|
||||||
if STREAM[0:4] == "rtmp":
|
if stream[0:4] == "rtmp":
|
||||||
getrtmp(STREAM, OUTPUT)
|
getrtmp(stream, output)
|
||||||
else:
|
else:
|
||||||
gethttp(STREAM, OUTPUT)
|
gethttp(stream, output)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
Loading…
Reference in New Issue
Block a user