Thank you to anyone who has already donated - your generous donations helped make three months of treatment possible.

My brother Nate continues to fight stage IV Hodgkin's lymphoma. He's just 31, with a wife and baby girl. They have no active income (since he's been unable to return to work), no insurance, and cannot afford the treatment he needs. Nate and his family need your help. Please consider a donation, every dollar helps. Thanks.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
diff -ur lgogdownloader-1.15/include/curlhandle.h lgogdownloader-1.15_patched/include/curlhandle.h
--- lgogdownloader-1.15/include/curlhandle.h	2013-01-31 10:11:32.000000000 -0500
+++ lgogdownloader-1.15_patched/include/curlhandle.h	2013-02-01 00:49:15.678931094 -0500
@@ -43,6 +43,11 @@
 		std::string getResponse(std::string url);
 		~curlhandle();
     	Timer *timer;
+        // Amount of data downloaded since the beginning of this execution, in contrast with dltotal
+        // which is a full amount from all attempts and resumes.
+        double downloaded;
+        double previous_dlnow;
+        bool   first_time;
     protected:
     private:
     	CURL *curl_handle;
diff -ur lgogdownloader-1.15/Makefile lgogdownloader-1.15_patched/Makefile
--- lgogdownloader-1.15/Makefile	2013-01-31 10:11:32.000000000 -0500
+++ lgogdownloader-1.15_patched/Makefile	2013-01-31 23:27:04.661047505 -0500
@@ -15,7 +15,7 @@
 CFLAGS =  -std=c++0x -Wall -fexceptions
 RESINC = 
 LIBDIR = 
-LIB =  -lcurl -loauth -ljsoncpp -lhtmlcxx -lboost_system -lboost_filesystem -lboost_regex -lboost_program_options -ltinyxml -lrhash
+LIB =  -lcurl -loauth -ljsoncpp -lhtmlcxx -lboost_system -lboost_filesystem -lboost_regex -lboost_program_options -lboost_date_time -ltinyxml -lrhash
 LDFLAGS = 
 
 INC_DEBUG =  $(INC)
diff -ur lgogdownloader-1.15/src/curlhandle.cpp lgogdownloader-1.15_patched/src/curlhandle.cpp
--- lgogdownloader-1.15/src/curlhandle.cpp	2013-01-31 10:11:32.000000000 -0500
+++ lgogdownloader-1.15_patched/src/curlhandle.cpp	2013-02-01 01:50:12.100284763 -0500
@@ -4,15 +4,31 @@
  * To Public License, Version 2, as published by Sam Hocevar. See
  * http://sam.zoy.org/wtfpl/COPYING for more details. */
 
+#include <iomanip>
+#include <boost/date_time/posix_time/posix_time_types.hpp>
+
 #include "curlhandle.h"
 
+namespace bptime = boost::posix_time;
+
 int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
 {
     int length = 26;
 	time_t time_now = time(NULL); // current time
 	curlhandle *curl_handle = static_cast<curlhandle*>(clientp);
     time_t time_start = curl_handle->timer->time_start;
-    double rate = dlnow/(time_now - time_start)/1024; // average download speed in kB/
+
+    double rate(0.0L); // average download speed in B/s
+    if (curl_handle->first_time)
+    {
+       curl_handle->first_time = false;
+    }
+    else
+    {
+       curl_handle->downloaded += dlnow - curl_handle->previous_dlnow;
+       rate = curl_handle->downloaded/(time_now - time_start);
+    }
+    curl_handle->previous_dlnow = dlnow;
 
     double offset = static_cast<double>(curl_handle->getResumePosition());
     if (offset>0)
@@ -21,18 +37,44 @@
         dltotal += offset;
     }
 
+    bptime::time_duration eta(bptime::seconds((long)((dltotal - dlnow) / rate)));
+    std::string eta_str;
+    std::stringstream eta_ss;
+    if (eta.hours() > 23)
+    {
+       eta_ss << eta.hours() / 24 << "d " <<
+                 std::setfill('0') << std::setw(2) << eta.hours() % 24 << "h " <<
+                 std::setfill('0') << std::setw(2) << eta.minutes() << "m " <<
+                 std::setfill('0') << std::setw(2) << eta.seconds() << "s";
+    }
+    else if (eta.hours() > 0)
+    {
+       eta_ss << eta.hours() << "h " <<
+                 std::setfill('0') << std::setw(2) << eta.minutes() << "m " <<
+                 std::setfill('0') << std::setw(2) << eta.seconds() << "s";
+    }
+    else if (eta.minutes() > 0)
+    {
+       eta_ss << eta.minutes() << "m " <<
+                 std::setfill('0') << std::setw(2) << eta.seconds() << "s";
+    }
+    else
+    {
+       eta_ss << eta.seconds() << "s";
+    }
+
     double percent = dlnow / dltotal;
     int lengthnow = round(percent * length);
     int i=0;
     // Create progressbar
-    printf("%3.0f%% [",percent*100);
+    printf("\033[0K\r%3.0f%% [",percent*100);
     for (; i<lengthnow; i++) {
         printf("=");
     }
     for (; i<length; i++) {
         printf(" ");
     }
-    printf("] %0.2f/%0.2fMB @ %0.2fkB/s\r", dlnow/1024/1024, dltotal/1024/1024, rate);
+    printf("] %0.2f/%0.2fMB @ %0.2fkB/s ETA: %s\r", dlnow/1024/1024, dltotal/1024/1024, rate/1024, eta_ss.str().c_str());
     fflush(stdout);
 
 	return 0;
@@ -56,6 +98,10 @@
 }
 
 curlhandle::curlhandle()
+:
+   downloaded(0.0L),
+   previous_dlnow(0.0L),
+   first_time(true)
 {
     this->timer = new Timer();
     curl_global_init(CURL_GLOBAL_ALL);