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