View Single Post
  #764  
Old 06.06.2019, 11:18
bobolecoco bobolecoco is offline
Super Loader
 
Join Date: Aug 2015
Location: France
Posts: 27
Default

Quote:
Originally Posted by bingo View Post
Hi ,

i would like a script that would allow me to download just a small chunk of lots of files (maybe 1 or 10 MB) (and possibly auto delete them afterwards as well)

Is something like this what you want ?
Code:
var numberOfMB = 10

for (i = getAllDownloadLinks().length - 1; i >= 0; i--) {
    if (getAllDownloadLinks()[i].getBytesLoaded() > numberOfMB * 1024 * 1024) {
        getAllDownloadLinks()[i].setEnabled(false);
    }
}
It will check if more than (here 10) MB of the file are already downloaded. If that's the case, it will disable the link.

You can add this line (after or instead of "getAllDownloadLinks()[i].setEnabled(false);") :
Code:
removeDownloadLinkByUUID(getAllDownloadLinks()[i].getUUID());
//or
getAllDownloadLinks()[i].remove();
It will remove the link from the download list.

You can also look for the deleteFile() method to erase the downloaded file in combination with the getPath() method.
Reply With Quote