summaryrefslogtreecommitdiffstats
path: root/pyload/network/HTTPDownload.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/network/HTTPDownload.py')
-rw-r--r--pyload/network/HTTPDownload.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/pyload/network/HTTPDownload.py b/pyload/network/HTTPDownload.py
index 0d331ca99..89e594640 100644
--- a/pyload/network/HTTPDownload.py
+++ b/pyload/network/HTTPDownload.py
@@ -59,19 +59,26 @@ class HTTPDownload(object):
self.progress = progress
@property
+
+
def speed(self):
last = [sum(x) for x in self.lastSpeeds if x]
return (sum(self.speeds) + sum(last)) / (1 + len(last))
@property
+
+
def arrived(self):
return sum([c.arrived for c in self.chunks])
@property
+
+
def percent(self):
if not self.size: return 0
return (self.arrived * 100) / self.size
+
def _copyChunks(self):
init = fs_encode(self.info.getChunkName(0)) #initial chunk name
@@ -104,6 +111,7 @@ class HTTPDownload(object):
move(init, fs_encode(self.filename))
self.info.remove() #remove info file
+
def download(self, chunks=1, resume=False):
""" returns new filename or None """
@@ -132,6 +140,7 @@ class HTTPDownload(object):
if self.nameDisposition and self.disposition: return self.nameDisposition
return None
+
def _download(self, chunks, resume):
if not resume:
self.info.clear()
@@ -280,15 +289,18 @@ class HTTPDownload(object):
self._copyChunks()
+
def updateProgress(self):
if self.progress:
self.progress(self.percent)
+
def findChunk(self, handle):
""" linear search to find a chunk (should be ok since chunk size is usually low) """
for chunk in self.chunks:
if chunk.c == handle: return chunk
+
def closeChunk(self, chunk):
try:
self.m.remove_handle(chunk.c)
@@ -297,6 +309,7 @@ class HTTPDownload(object):
finally:
chunk.close()
+
def close(self):
""" cleanup """
for chunk in self.chunks: