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

Added some comments about the functions

This commit is contained in:
Johan Andersson 2011-03-16 16:24:21 +01:00
parent 3fc33a4c5f
commit 14a463c0bf

View File

@ -6,6 +6,7 @@ import os
import subprocess import subprocess
def getdata(url): def getdata(url):
""" Get the page to parse it for streams """
request = urllib2.Request(url) request = urllib2.Request(url)
request.add_header = [('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')] request.add_header = [('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')]
response = urllib2.urlopen(request) response = urllib2.urlopen(request)
@ -14,6 +15,7 @@ def getdata(url):
return data return data
def calc_data(byte, total): def calc_data(byte, total):
""" Print some info about how much we have downloaded """
percent = float(byte) / total percent = float(byte) / total
percent = round(percent*100, 2) percent = round(percent*100, 2)
sys.stdout.write("Downloaded %d of %d bytes (%.2f%%)\r" % (byte, total, percent)) sys.stdout.write("Downloaded %d of %d bytes (%.2f%%)\r" % (byte, total, percent))
@ -21,10 +23,12 @@ def calc_data(byte, total):
sys.stdout.write('\n') sys.stdout.write('\n')
def getrtmp(url, output): def getrtmp(url, output):
""" Get the stream from RTMP """
command = ["/usr/bin/rtmpdump", "-r", url, "-o", output] command = ["/usr/bin/rtmpdump", "-r", url, "-o", output]
subprocess.call(command) subprocess.call(command)
def gethttp(url, output): def gethttp(url, output):
""" Get the stream from HTTP """
response = urllib2.urlopen(url) response = urllib2.urlopen(url)
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)