View Single Post
  #140  
Old 03.08.2017, 14:10
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,130
Default

Quote:
Originally Posted by Lpxatreyu View Post
... need between x (02.00am) - y (08.00am) my download list start otherwise stop all download.
Code:
// Time based download control
// Trigger: "Interval" (Recommended: 300000 ms)

var t1 = 2; // <- Set starting Hour (0-23)
var t2 = 8; // <- Set ending Hour (0-23)

var now = new Date();

if (now > time(t1) && now < time(t2)) {
    if (!isDownloadControllerRunning() && downloadsPending()) startDownloads();
} else {
    if (isDownloadControllerRunning()) stopDownloads();
}

//Functions
function time(hour) {
    return new Date().setHours(hour, 0, 0, 0)
}

function downloadsPending() {
    return getAllDownloadLinks().some(function(link) {
        return link.getFinalLinkStatus() == null;
    });
}
Reply With Quote