JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 11.02.2025, 16:19
FBD's Avatar
FBD FBD is offline
JD Adviser
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 109
Post Move mirror links to separate package when download started

This script when triggered moves mirror links to a separate (configurable) package, even when those links are disabled.
Trigger: Interval

Spoiler:
Code:
// Move mirrors (even disabled ones) for running downloads (FBD)
// Trigger : Interval (900000 = 15 mins seems good)

disablePermissionChecks();

var myDownloadLinks = getAllDownloadLinks();
var linkids = [];
var runningPackageName = "Running";

myDownloadLinks.forEach(function(link) {
    if (link.getBytesLoaded() > 0) { // File is loading
        return;
    }
    
    // already moved?
    var myFilePackage = myDownloadLink.getPackage();
    if (myFilePackage.getName() == runningPackageName) {
        return;
    }
    
    // check it
    var dlfile = getPath(link.getDownloadPath() + ".part");
    var dlsize = dlfile.getSize();
    if (dlsize > 0) { // download has started from mirror link
        link.setEnabled(false);
        linkids.push(link.UUID);
    }
});

if (linkids.length > 0) { // links found
    // find target package
    var target_package_id;
    getAllFilePackages().forEach(function(package) {
        // find target package
        if (package.getName() == runningPackageName) {
            target_package_id = package.getUUID();
        }
    });

    // move to existing package or create new one if not exists
    if (target_package_id) { // existing package
        linkids.sort().forEach(function(linkId) {
            callAPI("downloadsV2", "moveLinks", [linkId], -1, target_package_id);
        });
    } else { // create package
         callAPI("downloadsV2", "movetoNewPackage", linkids, null, runningPackageName, "");
    }
}

Direct download: raw.githubusercontent.com/FarBeyondDriven/JDscripts/refs/heads/main/MoveMirrorLinks.js
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 04:16.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.