JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1581  
Old 05.11.2020, 05:46
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by GreenXIII View Post
... combine multiple downloaded links, with the same package name and same download directory, into a single package?
Keep a backup of your link list before testing/using the script.

Code:
/*
    Merge download packages which have matching name and download folder, sorting links in descending order by ID.
    Trigger: Toolbar button pressed
    Customize main toolbar > Add a new "Eventscripter Trigger" button > Rename it to "Merge Packages" (case-sensitive) > Change Icon (optional)
*/

if (name == "Merge Packages") {
    
    getAllFilePackages().forEach(function(package) {

        if (package) {
            var packages = [];

            getAllFilePackages().forEach(function(package2) {
                if (package2.name + package2.downloadFolder == package.name + package.downloadFolder) {
                    packages.push(package2);
                }
            })

            if (packages.length > 1) {
                var linkIds = [];

                packages.forEach(function(package3) {
                    package3.downloadLinks.forEach(function(link) {
                        linkIds.push(link.UUID);
                    })
                })

                linkIds.sort().forEach(function(linkId) {
                    callAPI("downloadsV2", "moveLinks", [linkId], -1, package.UUID);
                })
            }
        }
    })
}
Reply With Quote
  #1582  
Old 05.11.2020, 13:11
DragoBleaPiece DragoBleaPiece is offline
Baby Loader
 
Join Date: Jun 2020
Posts: 7
Default

Quote:
Originally Posted by mgpai View Post
Code:
/*
    Toggle packagizer extension
    Trigger: Toolbar Button Pressed
    Customize main toolbar > Add a new 'Eventscripter Trigger' button > Rename it to "Toggle Packagizer" (without quotes, case-sensitive) > Change Icon (optional)
*/

if (name == "Toggle Packagizer") {
    var interfaceName = "org.jdownloader.controlling.packagizer.PackagizerSettings",
        key = "PackagizerEnabled",
        value = callAPI("config", "get", interfaceName, null, key),
        message = "Packagizer " + (value ? "disabled." : "enabled.");

    callAPI("config", "set", interfaceName, null, key, !value) && alert(message);
}
Hello, Script Master!
Can we use this script for enabling/disabling particular packagizer rules, not all of em? Thank you so much
Reply With Quote
  #1583  
Old 05.11.2020, 13:15
DragoBleaPiece DragoBleaPiece is offline
Baby Loader
 
Join Date: Jun 2020
Posts: 7
Default

Quote:
Originally Posted by mgpai View Post
Keep a backup of your link list before testing/using the script.

Code:
/*
    Merge download packages which have matching name and download folder, sorting links in descending order by ID.
    Trigger: Toolbar button pressed
    Customize main toolbar > Add a new "Eventscripter Trigger" button > Rename it to "Merge Packages" (case-sensitive) > Change Icon (optional)
*/

if (name == "Merge Packages") {
    
    getAllFilePackages().forEach(function(package) {

        if (package) {
            var packages = [];

            getAllFilePackages().forEach(function(package2) {
                if (package2.name + package2.downloadFolder == package.name + package.downloadFolder) {
                    packages.push(package2);
                }
            })

            if (packages.length > 1) {
                var linkIds = [];

                packages.forEach(function(package3) {
                    package3.downloadLinks.forEach(function(link) {
                        linkIds.push(link.UUID);
                    })
                })

                linkIds.sort().forEach(function(linkId) {
                    callAPI("downloadsV2", "moveLinks", [linkId], -1, package.UUID);
                })
            }
        }
    })
}
I wanna put all my link that i have into one package, rite now it's all over the place. Could you help me plz? Thx in advance
Reply With Quote
  #1584  
Old 05.11.2020, 13:45
DragoBleaPiece DragoBleaPiece is offline
Baby Loader
 
Join Date: Jun 2020
Posts: 7
Default

I don't know where should i ask about this. So, i wanna put all my download URLs after the file has been downloaded into a file (txt or smth), and for the next download, the URL should be checked first with that file containing finished download URLs
Any solution for this? Thank you
Reply With Quote
  #1585  
Old 06.11.2020, 11:39
GreenXIII GreenXIII is offline
Bandwidth Beast
 
Join Date: Mar 2013
Posts: 145
Default

Quote:
Originally Posted by mgpai View Post
Keep a backup of your link list before testing/using the script.

Merge download packages which have matching name and download folder, sorting links in descending order by ID.
Trigger: Toolbar button pressed
Customize main toolbar > Add a new "Eventscripter Trigger" button > Rename it to "Merge Packages" (case-sensitive) > Change Icon (optional)
*/

if (name == "Merge Packages") {

...
}[/CODE]
Thank you very much. But the script is not working for me.
I'm setting the script to start as JDownloader starts, is that correct?
I'm getting a "ReferenceError: "name" is not defined (#7)" error when JD2 loads.
Reply With Quote
  #1586  
Old 06.11.2020, 11:52
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,084
Default

@GreenXIII: made sure to set the correct trigger event type?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1587  
Old 06.11.2020, 23:08
GreenXIII GreenXIII is offline
Bandwidth Beast
 
Join Date: Mar 2013
Posts: 145
Default

Quote:
Originally Posted by Jiaz View Post
@GreenXIII: made sure to set the correct trigger event type?
Ok, found my mistake, had to configure the toolbar button and set the script to "Toolbar button pressed"

It's working! But it's very slow. I think it does one link per second. Isn't there a way to make it check the packagenames instead of each link at a time?

EDIT: it was slow because it was running all morning and afternoon. After I restarted JD and ran it again, it got fast again.

EDIT: also, it ignores uppercases/lowercases and treat them as different

Last edited by GreenXIII; 06.11.2020 at 23:26.
Reply With Quote
  #1588  
Old 07.11.2020, 07:00
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by GreenXIII View Post
... it's very slow. I think it does one link per second. Isn't there a way to make it check the packagenames instead of each link at a time?
It does match only package names and download folders. But, the additional task of sorting links in a desired order can considerably slow it down. Can also be caused by insufficient memory. You can try allocating more memory to JD.

Quote:
Originally Posted by GreenXIII View Post
...it ignores uppercases/lowercases and treat them as different
That is the default behavior, which is in line with case-sensitive file systems. To ignore both package and folder case, replace the following code:
Code:
if (package2.name + package2.downloadFolder == package.name + package.downloadFolder) {

with:
Code:
if ((package2.name + package2.downloadFolder).toLowerCase() == (package.name + package.downloadFolder).toLowerCase()) {
Reply With Quote
  #1589  
Old 07.11.2020, 07:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by DragoBleaPiece View Post
Can we use this script for enabling/disabling particular packagizer rules, not all of em?
While possible, will require you to create separate buttons for each rule you want to disable, which may not be practical. A better option would be to make the rule more restrictive and force it to match only under certain conditions.

Quote:
Originally Posted by DragoBleaPiece View Post
I wanna put all my link that i have into one package, rite now it's all over the place.
Feature already present in GUI. You can select links and use the context menu command "Move to new package". Please note that the corresponding files existing on disk will also be moved to single/same folder. You can disable the following advanced setting to move only the links and keep the files in their original location.

Code:
GeneralSettings.movefilesifdownloaddestinationchangesenabled

Quote:
Originally Posted by DragoBleaPiece View Post
... i wanna put all my download URLs after the file has been downloaded into a file (txt or smth), and for the next download, the URL should be checked first with that file containing finished download URLs
THIS thread contains a script for similar request.
Reply With Quote
  #1590  
Old 10.11.2020, 11:45
GreenXIII GreenXIII is offline
Bandwidth Beast
 
Join Date: Mar 2013
Posts: 145
Default

I've been using this script for restarting downloads that are too slow. It works, many sites get a faster DL speed after resuming.
But it has two flaws: I don't think it excludes non-resumable downloads. And it restarts the download way too fast. Some sites don't like that. For example, video.fc2 gets corrupted videos due to it.

Code:
// Stop and restart slow links.
// Trigger Required: "Interval" (Recommended: 30000 or more).
// IMPORTANT: Enable "Synchronous execution of script" (checkbox).

var minSpeed = 500; // (KiB/s) <- minimum download speed per link.
var minDuration = 1; // (minutes) <- minimum download duration per link.

var links = getRunningDownloadLinks();

for (i = 0; i < links.length; i++) {
    var link = links[i];
    if (link.getDownloadDuration() < minDuration * 60 * 1000) continue;
    if (link.getSpeed() > minSpeed * 1024) continue;
    link.abort();
    sleep(30000); //I've added this, but it's not working
}
I'd like it to do one of two things (or both, via a toggeable variable):
1) Go to another download and come back after that to the current one;
2) Have a longer timer between retrying the current download.

I haven't tried a non-resumable download yet, but if the script doesn't ignore those, I'd like it to do so.
Reply With Quote
  #1591  
Old 10.11.2020, 12:54
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by GreenXIII View Post
... script for restarting downloads that are too slow ...
Code:
/*
    Skip/Unskip resumable links, based on user-specified speed and duration
    Trigger: Interval (Recommended 60000 or more)
*/

var links = [];

getRunningDownloadLinks().forEach(function(link) {
    if (
        link.resumeable &&
        link.downloadDuration > 60 * 1000 && // minimum download duration (milliseconds)
        link.speed < 500 * 1024 // minimum speed (bytes)
    ) {
        link.skipped = true;
        links.push(link);
    }
})

if (links.length) {
    sleep(30000); // time to wait before unskipping links (milliseconds);

    links.forEach(function(link) {
        link.skipped = false;
    })
}
Reply With Quote
  #1592  
Old 11.11.2020, 16:05
Rodark Rodark is offline
Modem User
 
Join Date: Aug 2020
Posts: 4
Default

is there a script that when a download speed drops at 130kbs, it can stop all downloads and immediately restart them?
i found one but it takes time to stop and restart
im downloading from a site that has only a 64~kbps per download(max 2) BUT when the download starts, it starts with max speed and drops.
Meaning, when i start the download its 6-7Mbps and it gradually drops to 130kbps . So i need a script that when it drops at that, it stop and restarts asap. the one im using it takes a couple of minutes to restart

Last edited by Rodark; 11.11.2020 at 16:12.
Reply With Quote
  #1593  
Old 11.11.2020, 16:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Rodark View Post
is there a script that when a download speed drops at 130kbs, it can stop all downloads and immediately restart them?
i found one but it takes time to stop and restart
Which script did you use? Stopping downloads usually takes a few seconds.
Reply With Quote
  #1594  
Old 11.11.2020, 16:23
Rodark Rodark is offline
Modem User
 
Join Date: Aug 2020
Posts: 4
Default

Quote:
Originally Posted by mgpai View Post
Which script did you use? Stopping downloads usually takes a few seconds.
sleep(waitTime * 60 * 1000);
startDownloads();
}

// Check if all downloads have been running for atleast the minimum duration.
function running() {
var links = getRunningDownloadLinks();
if (links.length > 0) {
for (i = 0; i < links.length; i++) {
var link = links[i];
if (link.getDownloadDuration() < minDuration * 60 * 1000) {
return false;
}
}
return true;
} else {
return false;
}
}
thats the one im using. found it on another page/thread

it isnt instant for me, it takes a little time to restart. so currently im manually stop/restarting. can it be modified to stop and restart on the spot if the speed is less than 140 kbps?
Reply With Quote
  #1595  
Old 11.11.2020, 16:58
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Rodark View Post
... stop and restart on the spot if the speed is less than 140 kbps?
Try this:
Code:
/*
    Restart download links if the current average speed is less than user-specified speed
    Trigger Required: Interval (Recommended 30000 or more)
*/    

var minSpeed = 140, // (KiB/s) <- minimum average download Speed
    minDuration = 60, // (seconds) <- minimum download duration per link
    running = getRunningDownloadLinks().every(function(link) {
        return link.downloadDuration > minDuration * 1000;
    });

if (running && getAverageSpeed() < minSpeed * 1024) {
    getRunningDownloadLinks().forEach(function(link) {
        link.abort();
    })
}
Reply With Quote
  #1596  
Old 11.11.2020, 17:39
Rodark Rodark is offline
Modem User
 
Join Date: Aug 2020
Posts: 4
Default

Quote:
Originally Posted by mgpai View Post
Try this:
Code:
/*
    Restart download links if the current average speed is less than user-specified speed
    Trigger Required: Interval (Recommended 30000 or more)
*/    

var minSpeed = 140, // (KiB/s) <- minimum average download Speed
    minDuration = 60, // (seconds) <- minimum download duration per link
    running = getRunningDownloadLinks().every(function(link) {
        return link.downloadDuration > minDuration * 1000;
    });

if (running && getAverageSpeed() < minSpeed * 1024) {
    getRunningDownloadLinks().forEach(function(link) {
        link.abort();
    })
}
thank you for this! it does take around a minute for it to realize it has dropped speed, but the stop/start action is instant! thanks mate
Reply With Quote
  #1597  
Old 11.11.2020, 17:48
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
Default

Quote:
Originally Posted by Rodark View Post
... it does take around a minute for it to realize it has dropped speed...
For faster response, you can reduce the script interval (recommended is 30000 ms) and also the minDuration (default in the script is 60 seconds).

The download will usually require a few seconds to reach max speed. Experiment with different values and keep them large enough to prevent false stop/start loops.
Reply With Quote
  #1598  
Old 11.11.2020, 18:03
Rodark Rodark is offline
Modem User
 
Join Date: Aug 2020
Posts: 4
Default

thanks for the info mate!
Reply With Quote
  #1599  
Old 12.11.2020, 13:59
little little is offline
DSL User
 
Join Date: Mar 2009
Posts: 39
Default

Quote:
Originally Posted by fred_gaou View Post
Hi,

Here is a script to help you to auto clean/format filename during the link grabbing process. This is done automatically in background for each added link.

You can set some options at the top of the script.

This is useful in any case as soon as you notice a recurring pattern in your filenames that you'll want to get rid of or format.

if you set custom filename for video files such as:
Code:
[*CHANNEL*] (*PLAYLIST_NAME* *PLAYLIST_POSITION[00]*) *DATE[YY.MM.dd]* - *VIDEO_NAME*.*EXT*
it will be perfect for playlist but not for one video file only because then you will end with a filename with empty brackets:
Code:
[Any Youtuber Channel] ( ) 17.03.11 - Video Title
This script will take care of it removing those bracket:
Code:
[Any Youtuber Channel] 17.03.11 - Video Title
Code:
// LINK NAME CLEANER (auto)
// Trigger required: Packagizer Hook
// Version 2017.11.14
/* *************************************************************************
Set the characters that will be removed from both ends of the filename.
Be sure to double escape special chars such as "\\s" instead of "\s".
****************************************************************************/

var leadAndTrailTrimChars = "\\s-_";

/* *************************************************************************
Set the characters that will be replaced with whitespace.
Be sure to double escape special chars such as "\\s" instead of "\s".
****************************************************************************/

var charToSpace = "_";

/* *************************************************************************
Set the words or phrases to remove. Words/phrases must be separated with | such as
"word one|word two|word three"
Be sure to double escape special chars such as "\\s" instead of "\s".
****************************************************************************/

var wordsToRemove = "avec sous-titres";

/***************************************************************************/

if (linkcheckDone) {


    /* =========================== INITIALIZE ============================ */

    var myPackagizerLink = link;
    var fileName = myPackagizerLink.getName();
    var re, ext;

    // Remove the extension from the end and save it for later.
    // And make it lower case at the same time.
    ext = fileName.slice((fileName.lastIndexOf(".") - 1 >>> 0) + 2);
    if (ext !== "") {
        ext = "." + ext.toLowerCase();
    }

    // If extension exists, then we will work with the filename without extension
    fileName = fileName.substr(0, (fileName.length - ext.length));

    /* ========================= REGEX PATTERNS ========================== */

    // Remove these words/phrase : wordsToRemove
    re = new RegExp("\\b(?:" + wordsToRemove + ")\\b", "gi");
    fileName = fileName.replace(re, "");

    // Replace these characters with whitespace : charToSpace
    re = new RegExp("[" + charToSpace + "]", "gi");
    fileName = fileName.replace(re, " ");

    // Delete empty bracket content. "( )", "[ ]" or "{ }" will be removed from filename.    
    re = new RegExp("(\\(\\s+?\\))|(\\[\\s+?\\])|({\\s+?})", "gi");
    fileName = fileName.replace(re, "");

    /* ====== ALWAYS APPLY NEXT REPLACEMENTS AT THE END OF PROCESS ======= */

    // Replace &amp; with &
    re = new RegExp("&amp;", "gi");
    fileName = fileName.replace(re, "&");

    // Remove unwanted characters from both ends of the filename
    re = new RegExp("^[" + leadAndTrailTrimChars + "]*(.+?)[" + leadAndTrailTrimChars + "]*$", "gi");
    fileName = fileName.replace(re, "$1");

    // Replace multiple spaces with only one
    re = new RegExp("\\s\\s+", "gi");
    fileName = fileName.replace(re, " ");

    // Removes whitespace from both ends of the filename (just to be sure)
    fileName = fileName.trim();

    /* ====== APPLY NEW FILE NAME ======= */
    myPackagizerLink.setName(fileName + ext);
}
I wanted to try it :
Code:
java.lang.NullPointerException
        at org.jdownloader.extensions.eventscripter.ScriptThread$1.compare(ScriptThread.java:301)
        at org.jdownloader.extensions.eventscripter.ScriptThread$1.compare(ScriptThread.java:298)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1338)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1350)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1350)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1349)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1350)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1350)
        at java.base/java.util.Arrays.legacyMergeSort(Arrays.java:1317)
        at java.base/java.util.Arrays.sort(Arrays.java:1304)
        at java.base/java.util.ArrayList.sort(ArrayList.java:1721)
        at java.base/java.util.Collections.sort(Collections.java:179)
        at org.jdownloader.extensions.eventscripter.ScriptThread.cleanupClasses(ScriptThread.java:298)
        at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:178)
        at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:160)
Any idea on how to fix it ? Thank you very much.
Reply With Quote
  #1600  
Old 12.11.2020, 14:57
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,084
Default

@little: please create a log, see https://support.jdownloader.org/Know...d-session-logs
and post logID here
__________________
JD-Dev & Server-Admin
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 12:45.
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 - 2023, Jelsoft Enterprises Ltd.