|
|
|
@ -233,7 +233,7 @@ index 3e5f3b7..8eeaeda 100644
|
|
|
|
|
return (fb,lb)
|
|
|
|
|
|
|
|
|
|
diff --git a/urlgrabber/grabber.py b/urlgrabber/grabber.py
|
|
|
|
|
index e090e90..ffd5a10 100644
|
|
|
|
|
index e090e90..daa478d 100644
|
|
|
|
|
--- a/urlgrabber/grabber.py
|
|
|
|
|
+++ b/urlgrabber/grabber.py
|
|
|
|
|
@@ -49,11 +49,26 @@ GENERAL ARGUMENTS (kwargs)
|
|
|
|
@ -1225,7 +1225,7 @@ index e090e90..ffd5a10 100644
|
|
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
|
# DEPRECATED FUNCTIONS
|
|
|
|
|
@@ -1621,6 +1924,458 @@ def retrygrab(url, filename=None, copy_local=0, close_connection=0,
|
|
|
|
|
@@ -1621,6 +1924,460 @@ def retrygrab(url, filename=None, copy_local=0, close_connection=0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
@ -1637,17 +1637,19 @@ index e090e90..ffd5a10 100644
|
|
|
|
|
+
|
|
|
|
|
+ @staticmethod
|
|
|
|
|
+ def update(url, dl_size, dl_time, ug_err, baseurl=None):
|
|
|
|
|
+ _TH.load()
|
|
|
|
|
+
|
|
|
|
|
+ # Use hostname from URL. If it's a file:// URL, use baseurl.
|
|
|
|
|
+ # If no baseurl, do not update timedhosts.
|
|
|
|
|
+ host = urlparse.urlsplit(url).netloc.split('@')[-1] or baseurl
|
|
|
|
|
+ if not host: return
|
|
|
|
|
+
|
|
|
|
|
+ _TH.load()
|
|
|
|
|
+ speed, fail, ts = _TH.hosts.get(host) or (0, 0, 0)
|
|
|
|
|
+ now = time.time()
|
|
|
|
|
+
|
|
|
|
|
+ if ug_err is None:
|
|
|
|
|
+ # defer first update if the file was small. BZ 851178.
|
|
|
|
|
+ if not ts and dl_size < 1e6: return
|
|
|
|
|
+
|
|
|
|
|
+ # k1: the older, the less useful
|
|
|
|
|
+ # k2: <500ms readings are less reliable
|
|
|
|
|
+ # speeds vary, use 10:1 smoothing
|
|
|
|
|