JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 23.03.2025, 13:19
Alhague Alhague is offline
JD Alpha
 
Join Date: Jan 2018
Posts: 24
Default disable any given download that stops for one of 3 reasons

Tried searching the forums but I haven't found a solution.

I was wondering if someone could help me with a script for the following problem:

Whenever any given download stops for one of following 3 reasons (or any reason for that matter, other than some kind of an user input), that particular download would get disabled by the script. What I mean is it needs to be actually greyed out.

So when the download stops at any time during it's progress and the 'status' field says one of the following:

-try restarting this link

-host problem

-temporarily unavailable - ETA 30 mins

That particular download would be disabled by the script and JD would move on to the next one.

This way when I go back to my PC I could see which files didn't finish in one go and are problematic. Basically I need to be able to finish the files in one go, without it ever stopping. If it stops during the download, I would delete the incomplete files and try again later, to see if I can hopefully finish them in one go, perhaps even on a different day.

Thanks ever so much if someone could create such a script for me. (I've never used scripts before, didn't even know JD has such a feature.)

Last edited by Alhague; 23.03.2025 at 13:22. Reason: added a prefix
Reply With Quote
  #2  
Old 24.03.2025, 23:24
FBD's Avatar
FBD FBD is offline
Fibre Channel User
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 117
Post

This slightly modified script from the old Event Scripter Thread does what you want.
You just need to enter the *exact* status messages of the links that need to be disabled and set an Interval for how often the script should run.
Enable the last line for a Test Run to get a list of current status messages for your downloads.

To see how the Event Scripter works, look at this support article: https://support.jdownloader.org/en/k...event-scripter

Code:
// Disable links on specific status (FBD)
// Trigger Required: Interval

disablePermissionChecks();
setAdvancedAlert(true);

var links = getAllDownloadLinks();
var statusList = [];

// Edit these lines with the *exact* status message of links to disable
var disableStatus = [ "Skipped - Captcha is required",
                      "Download limit has been reached",
                      "Your daily download limit has been reached"];
                      
for (i = 0; i < links.length; i++) {
    var link = links[i];
    statusList.push(link.getFinalName() + " -> " + link.getStatus());

    if (link.isEnabled() && disableStatus.indexOf(link.getStatus()) != -1) {
        // Disable the link
        link.setEnabled(false);
    }
}

// if you want a list of files and their *exact* status for a test-run 
// where you can copy and paste the current status enable this line:
// alert(statusList.join("\r\n"));
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #3  
Old 26.03.2025, 08:23
Alhague Alhague is offline
JD Alpha
 
Join Date: Jan 2018
Posts: 24
Default

That's lovely, thanks heaps for that.

Looks very promising. Will try it and report back.

...my first ever script, wish me luck!
Reply With Quote
  #4  
Old 30.03.2025, 14:25
Alhague Alhague is offline
JD Alpha
 
Join Date: Jan 2018
Posts: 24
Default

Works beautifully, thanks very much for this.

What do you suggest a reasonable interval setting would be for this?
Reply With Quote
  #5  
Old 30.03.2025, 15:41
FBD's Avatar
FBD FBD is offline
Fibre Channel User
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 117
Default

Quote:
Originally Posted by Alhague View Post
What do you suggest a reasonable interval setting would be for this?
Depends on what actually caused the problem, but 5 to 10 minutes seems like a good idea. That way you're unlikely to trigger website protections for connection too fast. Note that interval settings are in milliseconds, so five minutes would be an interval of 300000 ms.
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #6  
Old 30.03.2025, 16:43
Alhague Alhague is offline
JD Alpha
 
Join Date: Jan 2018
Posts: 24
Default

I see, cheers for that.

During my tests, I've come across yet another status message (these are on odysee.com by the way, that's where I'm using the script):

Segment:167 not loaded

I have a feeling the number '167' in that message is not constant. I could be wrong though.

In any case, for this 4th message, would it be possible to put just 'segment' and some wildcard between to quotes in the 'var disableStatus' section? To ensure the message is captured and acted upon, if that number happens to be random.
Reply With Quote
  #7  
Old 31.03.2025, 00:20
FBD's Avatar
FBD FBD is offline
Fibre Channel User
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 117
Default

Quote:
Originally Posted by Alhague View Post
Segment:167 not loaded

I have a feeling the number '167' in that message is not constant. I could be wrong though.

In any case, for this 4th message, would it be possible to put just 'segment' and some wildcard between to quotes in the 'var disableStatus' section? To ensure the message is captured and acted upon, if that number happens to be random.
No, the script checks for the *exact* match, but that's easily fixed:

Code:
// Disable links on specific status (FBD)
// Trigger Required: Interval

disablePermissionChecks();

var links = getAllDownloadLinks();
var statusList = [];

// Edit these lines with the status message of links to disable
// Each entry is handled as a case INsensitive regular expression!
var disableStatus = [ "^Skipped",
                      "limit.*reached",
                      "reached.*limit",
                      "Segment:[0-9]+" ];
                      
for (i = 0; i < links.length; i++) {
    var link = links[i];
    if (!link.isEnabled()) continue;

    var disableThis = 0;
    for (statusNo = 0; statusNo < disableStatus.length; statusNo++) {
        var disableReg = new RegExp(disableStatus[statusNo],"i");
        if (disableReg.test(link.getStatus())) {
            disableThis = 1;
            break;
        }
    }
    
    statusList.push(link.getFinalName() + " -> " + link.getStatus() + " -> disabled=" + disableThis);
    if (disableThis) link.setEnabled(false);
}

// if you want a list of files and their *exact* status for a test-run 
// where you can copy and paste the current status enable this line:
// alert(statusList.join("\r\n"));
I added a regular expression that should match your status message, you can still just enter the exact status messages, but if neccessary you can add regular expressions.
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #8  
Old 01.04.2025, 18:11
Alhague Alhague is offline
JD Alpha
 
Join Date: Jan 2018
Posts: 24
Default

Brilliant, thanks.

Was wondering, regarding the regular expressions method we now have:

If I do enter the exact status messages and use question marks or brackets in them between the quotes, do those need to be escaped somehow?

This is what I have at the moment in that section, haven't tested it yet:

Code:
var disableStatus = [ "Host problem?",
                      "Try restarting this link (plugin outdated?)",
                      "Segment:[0-9]+",                      
                      "Temporarily unavailable" ];

(those 4 are the specific status messages I've come across so far)
Reply With Quote
  #9  
Old 01.04.2025, 19:13
FBD's Avatar
FBD FBD is offline
Fibre Channel User
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 117
Default

Quote:
Originally Posted by Alhague View Post
If I do enter the exact status messages and use question marks or brackets in them between the quotes, do those need to be escaped somehow?
Yes, if you want to use any special charaters like . * [ ] { } - ? you need to "escape" them like this:

Code:
"Try restarting this link \(plugin outdated\?\)"

But as you don't have to match the *exact* status anymore, you can just as well use

Code:
"Try restarting this link"
and it will match all reasons that include this line no matter what follows it.
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #10  
Old 01.04.2025, 19:59
Alhague Alhague is offline
JD Alpha
 
Join Date: Jan 2018
Posts: 24
Default

Sounds fab.

In that case, could simply "Segment" also be used?

Without specifying in the regex that there would be a colon and some unknown numbers after it.
Reply With Quote
  #11  
Old 01.04.2025, 21:59
FBD's Avatar
FBD FBD is offline
Fibre Channel User
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 117
Default

Quote:
Originally Posted by Alhague View Post
Sounds fab.

In that case, could simply "Segment" also be used?

Without specifying in the regex that there would be a colon and some unknown numbers after it.
Yes of course. That's how regex work. Just using "s" would work too, but it would also be triggered by lots of other status messages, obviously.

So you would want to be specific enough not to get false positives on the check. In that case, just "Segment" will be fine. Every status that contains the word "segment" will trigger the script and have it disable the link.
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #12  
Old 02.04.2025, 09:52
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 74,693
Default

@Alhague
I suggest the following webtool for playing around & testing regular expressions:
regex101.com
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #13  
Old 05.04.2025, 20:21
Alhague Alhague is offline
JD Alpha
 
Join Date: Jan 2018
Posts: 24
Default

Quote:
Originally Posted by FBD View Post
Yes of course. That's how regex work. Just using "s" would work too, but it would also be triggered by lots of other status messages, obviously.

So you would want to be specific enough not to get false positives on the check. In that case, just "Segment" will be fine. Every status that contains the word "segment" will trigger the script and have it disable the link.

I see, cheers for that. Since then, I have encountered that 'segment' problem with several different numbers after it by the way.

Do you think 'synchronous execution' should be enabled for this script? I'm not too sure either way, even after reading that setting's description.

@pspzockerscene
Thanks for that webtool recommendation.
Reply With Quote
  #14  
Old 05.04.2025, 21:31
FBD's Avatar
FBD FBD is offline
Fibre Channel User
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 117
Default

Quote:
Originally Posted by Alhague View Post
Do you think 'synchronous execution' should be enabled for this script? I'm not too sure either way, even after reading that setting's description.
It does not really matter for this script as long as you don't set the interval to ridiculously short times. The script shoud be done within a few milliseconds and will only be re-triggered after the interval.

This setting is more relevant when you have other triggers, like A-Download-Finished, those events can be triggered several times at the same moment, then you have to consider if you want several instances of your script running at the same time.

For this script, it does not matter.
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #15  
Old 16.04.2025, 17:13
Alhague Alhague is offline
JD Alpha
 
Join Date: Jan 2018
Posts: 24
Default

I see, it makes sense now. Because this script finishes lightning fast, it doesn't matter either way.

I've been testing and observing, and the script works very well - thanks ever so much for your kind help with this.

There's one more phenomenon that's happening, I was wondering if we could add one more feature to this scipt - or perhaps if you could point me to one that does this.

I noticed that quite a few downloads get stuck, they hang at a random point during their progress. In these cases, none of those four status messages from above are shown. I just notice that there's no progress, several seconds pass, perhaps even 15-20 secs or more, and then it continues and finishes. However, the resulting files from such downloads end up being also corrupt.

When this unwanted 'pause' happens during a download, if it's stuck for say 2 seconds, could that link also be disabled?

Could perhaps the percentage value in the progress bar be observed, and if it doesn't increase for like 2 seconds, then action that and disable the download?
Reply With Quote
  #16  
Old 17.04.2025, 08:16
FBD's Avatar
FBD FBD is offline
Fibre Channel User
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 117
Default

Quote:
Originally Posted by Alhague View Post
I noticed that quite a few downloads get stuck, they hang at a random point during their progress. In these cases, none of those four status messages from above are shown. I just notice that there's no progress, several seconds pass, perhaps even 15-20 secs or more, and then it continues and finishes. However, the resulting files from such downloads end up being also corrupt.
This sounds more like a problem that shoud be looked into instead of working around it with a script. And I don't really see how a script could catch this as stalled downloads can happen because of a lot of reasons, connection problems or busy harddrives.

When this happens, it would be better to create a log and file the log-id with a support ticket explaining the problem so the developers can look into it.

How to create a log see -> https://support.jdownloader.org/en/k...d-session-logs
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #17  
Old 20.04.2025, 21:48
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 82,273
Default

Quote:
Originally Posted by FBD View Post
This sounds more like a problem that shoud be looked into instead of working around it with a script.
100% agree!

Quote:
Originally Posted by Alhague View Post
I noticed that quite a few downloads get stuck, they hang at a random point during their progress. In these cases, none of those four status messages from above are shown. I just notice that there's no progress, several seconds pass, perhaps even 15-20 secs or more, and then it continues and finishes.
Please create a log when this happens, see https://support.jdownloader.org/de/k...d-session-logs
Wait for when this happens /is happening right now and then create a log. Open the log dialog and close it several times. That way the log will contain several "point of time" records that are showing what is happening in that moment. then create log 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 13:28.
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.