View Single Post
  #2195  
Old 31.05.2022, 19:48
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by TomNguyen View Post
... give HIGHEST priority for files smaller than 100MB (and if possible, give HIGHER priority for files size from 100MB to 1GB), then other files (bigger than 1GB) are random download order (random "HIGH", "DEFAULT", "LOW", "LOWER", "LOWEST" priorities)...
Hi @ TomNguyen,

Code:
/*
    Set priority
    Trigger: Download controller started
*/

getAllDownloadLinks().forEach(function(link) {
    if (!link.finished && link.bytesTotal > -1) {
        var size = link.bytesTotal / 1e6;
        var priority = size < 100 ? "HIGHEST" : size < 1000 ? "HIGHER" : random();

        link.priority != priority && (link.priority = priority);
    }
})

function random() {
    var array = ["HIGH", "DEFAULT", "LOW", "LOWER", "LOWEST"];
    var index = Math.floor(Math.random() * array.length);

    return array[index];
}
Reply With Quote