Quote:
Originally Posted by sherif011
... script to stop downloads when a predefined data limit is reached ...
|
It is possible to only determine the downloads finished during the day and not the actual bytes downloaded during the day. For this reason the calculated total might be slightly less the actual bytes downloaded, since it might also include bytes from pending downloads which were started during the previous day.
For a more accurate quota management, you may need to use a 3rd party program.
Code:
// Stop downloads when target reached
// Trigger: Interval (Recommended 60000 or more)
if (isDownloadControllerRunning()) {
var target = 20; // <- Set limit (in GB)
var actual = 0;
var t1 = new Date().setHours(0, 0, 0, 0);
getAllDownloadLinks().filter(function(link) {
var t2 = new Date(link.getFinishedDate());
return t2 > t1
}).forEach(function(link) {
actual += link.getBytesLoaded();
})
if (actual / 1e9 > target) stopDownloads();
}