JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #2701  
Old 24.11.2023, 00:05
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 647
Default

Great, thank you!

Is the URL added correctly(?):


Code:
//play a sound if the Internet connection had not been re-established after 4 minutes when reconnecting

sleep(240000);
var myhtmlSourceString = getPage("https://jdownloader.org/");
if (!myhtmlSourceString.includes("text/html")) {
    alert("We're still offline'");
    playWavAudio("I:/Eigene Dateien/Sounds - Audio/Mr.(s01e01) - kann sprechen (1961-01-05, 1961.wav");

What trigger do I have to use? One of them?

Before a Reconnect
After a Reconnect
__________________
Aktuelles Windows
Reply With Quote
  #2702  
Old 24.11.2023, 00:28
FBD's Avatar
FBD FBD is offline
Mega Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 65
Default

Quote:
Originally Posted by Dockel View Post
Is the URL added correctly(?):
No, i used "http :// ifconfig .me/mime" (without the spaces of course, have to add them otherwise the forum will remove the url). You can use any website to test, you just have to adjust the test string "text/html" to match the url you use. If the test-string is *not* found on the page - because the webpage could not be loaded - it will play the alert sound.

Quote:
Originally Posted by Dockel View Post
What trigger do I have to use? One of them?
If you want the test to be executed after jdownloader executed a reconnect, you'd use the "After a Reconnect" trigger. To run the test after a download failed, you add it to the other code i posted with the trigger "A download stopped":

Code:
var myDownloadLink = link;
if (!myDownloadLink.isFinished() && myDownloadLink.getBytesLoaded() > 0) {
    playWavAudio(JD_HOME+"/themes/standard/org/jdownloader/sounds/captcha.wav");

    sleep(240000);
    var myhtmlSourceString = getPage("http :// ifconfig .me/mime"); // remove spaces in url!
    if (!myhtmlSourceString.includes("text/html")) {
        alert("We're still offline'");
        playWavAudio("alert_alert_alert.wav");
    }
}
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #2703  
Old 24.11.2023, 00:56
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 647
Default

This should happen: play a sound if the Internet connection had not been re-established after 4 minutes when reconnecting

Quote:
If you want the test to be executed after jdownloader executed a reconnect, you'd use the "After a Reconnect" trigger.
So JD starts a reconnect, but the Inernet connection cannot be established. So the reconnect failed. To achieve that, I have this script / settings now:

__________________
Aktuelles Windows
Reply With Quote
  #2704  
Old 24.11.2023, 01:06
FBD's Avatar
FBD FBD is offline
Mega Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 65
Default

Quote:
Originally Posted by Dockel View Post
This should happen: play a sound if the Internet connection had not been re-established after 4 minutes when reconnecting
You mixed those up, sorry if i wasn't clear enough, so for clarity;

Script that waits 4 minutes after a reconnect triggered by jDownloader and alerts you if the internet connection was not re-established:

Code:
// Activate trigger: After a reconnect
// Remove spaces in test-url!
sleep(240000);
var myhtmlSourceString = getPage("http :// ifconfig .me/mime"); // remove spaces in url!
if (!myhtmlSourceString.includes("text/html")) {
    alert("We're still offline after a reconnect");
    playWavAudio("alert_alert_alert.wav");
}


Script that detects if the internet connection randomly goes down during downloading:

Code:
// Activate trigger: A download stopped
var myDownloadLink = link;
if (!myDownloadLink.isFinished() && myDownloadLink.getBytesLoaded() > 0) {
    alert("Internet connection lost");
    playWavAudio(JD_HOME+"/themes/standard/org/jdownloader/sounds/captcha.wav");
}
Note: Detecting if the internet connection is down is not a perfect absolute test... it would also be triggered if just the host you're downloading from is suddenly/temporarily unreachable.

You can have both scripts activated and running at the same time
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader

Last edited by FBD; 24.11.2023 at 01:25. Reason: Added note
Reply With Quote
  #2705  
Old 24.11.2023, 01:26
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 647
Default

Very sorry for my confusion.

Now I seem to have made it. Both scripts running. I'll see if I've really done everything right on the next failed reconnects / interrupted connection.

Thank you very much for your help and scripts!
__________________
Aktuelles Windows
Reply With Quote
  #2706  
Old 24.11.2023, 21:26
FBD's Avatar
FBD FBD is offline
Mega Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 65
Post Event Scripter Script: check if file in download list already exists

Another script i quickly put together for a user request, may be useful to others too:

What this script does:
- by clicking on a toolbar-button...
- without actually having to start downloads...
- it will check all links in your download list...
- and disable all links where the file already exists on your disk...
- (additionally checking more folders for existing files)...
- and finally shows you a report of disabled links - or if none found

Code:
// Check if file in download list already exists and disable or remove link without starting downloads (FBD)
// Trigger : "Toolbar Button Pressed"
// Toolbar Button Name: "FileCheck"

// Uncomment if you know what you're doing
// disablePermissionChecks();

if (name == "FileCheck") {
    var myFilePackage = getAllFilePackages();
    var folders = [];
    var report = [];

    // Uncomment to ADDITIONALLY check if file exists in these folders
    // folders.push("/media/store0/download","D:/Downloads","C:Downloads2");

    var myDownloadLinks = getAllDownloadLinks();
    for (a = 0; a < myDownloadLinks.length; a++) {

        var link = myDownloadLinks[a];
        var myFilePackage = link.getPackage();
        var linkName = link.getName();
        
        var allfolders = folders;
        allfolders.push(myFilePackage.getDownloadFolder()); // regular download folder

        allfolders.forEach(function(folder) {
            // uncomment to ignore disabled links
            //if (!link.isEnabled()) return;

            var file = getPath(folder + "/" + linkName);
            if (!file.exists()) return;
        
            report.push("Package \"" + myFilePackage.getName()
                        + "\" Folder: \"" + folder + "\""
                        + "\" File: \"" + linkName + "\""
                        );

            // Deactivate Link
            link.setEnabled(false);
        
            // Uncomment to also remove link from download list
            // link.remove();
        });
    }
    
    // comment this if you don't want to see a report
    if (report.length > 0) {
        setAdvancedAlert(true);
        alert("The following links have been disabled because the files already exist:\n\n" + report.join("\n"));
    } else {
        alert("Check completed. No existing files found.");
    }
}
Note: The filename check may fail in rare cases when the final filename changes as the download actually starts. In that case the standard file-exists check of jDownloader will kick in.
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #2707  
Old 25.11.2023, 15:54
JKA JKA is offline
Junior Loader
 
Join Date: Nov 2023
Posts: 12
Default

I have a request: i need a script that automatically runs the reconnect command when my internet connection has been offline for like... 3 minutes.

My internet connection can glitch out and a reconnect can permanently take it offline unless the reconnect command is run again, which it doesnt do without such a script.

Any help would be greatly appreciated! Thank you so much in advance!
Reply With Quote
  #2708  
Old 25.11.2023, 18:22
FBD's Avatar
FBD FBD is offline
Mega Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 65
Default

Quote:
Originally Posted by JKA View Post
I have a request: i need a script that automatically runs the reconnect command when my internet connection has been offline for like... 3 minutes.

My internet connection can glitch out and a reconnect can permanently take it offline unless the reconnect command is run again, which it doesnt do without such a script.
You can use a slightly modified version of a script i posted before:

Code:
// Try another reconnect if internet connection is not back up after 180 seconds (FBD)
// Activate trigger: After a reconnect
// Remove spaces in test-url!

sleep(180000); // Waiting time after a reconnect in milliseconds

var myhtmlSourceString = getPage("http :// ifconfig .me/mime"); // <- remove spaces in url!

if (!myhtmlSourceString.includes("text/html")) {
    // trigger reconnect
    doReconnect();   
}
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #2709  
Old 25.11.2023, 18:26
JKA JKA is offline
Junior Loader
 
Join Date: Nov 2023
Posts: 12
Default

Quote:
Originally Posted by FBD View Post
You can use a slightly modified version of a script i posted before:

Code:
// Try another reconnect if internet connection is not back up after 180 seconds (FBD)
// Activate trigger: After a reconnect
// Remove spaces in test-url!

sleep(180000); // Waiting time after a reconnect in milliseconds

var myhtmlSourceString = getPage("http :// ifconfig .me/mime"); // <- remove spaces in url!

if (!myhtmlSourceString.includes("text/html")) {
    // trigger reconnect
    doReconnect();   
}
i will test it out tonight!
Thank you so much, you really made my day!
Reply With Quote
  #2710  
Old 25.11.2023, 18:52
JKA JKA is offline
Junior Loader
 
Join Date: Nov 2023
Posts: 12
Default

FBD? i still got issues with the reconnect not reconnecting despite 40 minute wait times.

is there perhaps some way to send a reconnect command when jdownloader 2 hasnt downloaded anything for 3 minutes?

or is that impossible?
Reply With Quote
  #2711  
Old 25.11.2023, 19:31
FBD's Avatar
FBD FBD is offline
Mega Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 65
Default

Quote:
Originally Posted by JKA View Post
FBD? i still got issues with the reconnect not reconnecting despite 40 minute wait times.

is there perhaps some way to send a reconnect command when jdownloader 2 hasnt downloaded anything for 3 minutes?

or is that impossible?
That's possible but probably not a good idea. Eventually all your downloads are finished or all downloads are waiting for slots - you would not want to trigger a reconnect then. The script should do the job, did you set trigger for the script "After a reconnect"?

Maybe the reconnect fails and the event will not be triggered at all, changing it to "Before a reconnect" could fix that, but you should increase the waiting time by the time a reconnect usually takes for you.
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #2712  
Old 25.11.2023, 19:37
JKA JKA is offline
Junior Loader
 
Join Date: Nov 2023
Posts: 12
Default

Quote:
Originally Posted by FBD View Post
That's possible but probably not a good idea. Eventually all your downloads are finished or all downloads are waiting for slots - you would not want to trigger a reconnect then. The script should do the job, did you set trigger for the script "After a reconnect"?

Maybe the reconnect fails and the event will not be triggered at all, changing it to "Before a reconnect" could fix that, but you should increase the waiting time by the time a reconnect usually takes for you.
i did and i wouldnt mind if the script kept reconnecting endlessly.
running it in several VMs, each equipped with one instance of jdownloader2 and nordvpn to get around geo-restrictions. (the re-connect is triggered via a batch script to make nordvpn chose a random server and then connect)
Reply With Quote
  #2713  
Old 25.11.2023, 20:01
FBD's Avatar
FBD FBD is offline
Mega Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 65
Default

Quote:
Originally Posted by JKA View Post
i did and i wouldnt mind if the script kept reconnecting endlessly.
running it in several VMs, each equipped with one instance of jdownloader2 and nordvpn to get around geo-restrictions. (the re-connect is triggered via a batch script to make nordvpn chose a random server and then connect)
In that case it would be much more reliable if your script just waits a few minutes after a reconnect and checks if the connection has been established again - and if not to try again.
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #2714  
Old 25.11.2023, 20:04
JKA JKA is offline
Junior Loader
 
Join Date: Nov 2023
Posts: 12
Default

Quote:
Originally Posted by FBD View Post
In that case it would be much more reliable if your script just waits a few minutes after a reconnect and checks if the connection has been established again - and if not to try again.
true, problem is that wait times by hosters can trip-up the reconnect. one singular download beginning, 40 minute wait time, reconnect just isnt happening.

that and that after a reconnect, at times, downloads just dont start up again either. the "Play" button up top is greyed out, downloads are ready to go, no wait time and its not downloading any of them.

see why i thought that reconnect upon a certain time of no download may kill three birds with one stone?

EDIT:

also keep getting this error:



this is the script as ive used it:



trigger after reconnect

Last edited by JKA; 25.11.2023 at 20:21.
Reply With Quote
  #2715  
Old 25.11.2023, 20:30
FBD's Avatar
FBD FBD is offline
Mega Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 65
Default

Quote:
Originally Posted by JKA View Post
see why i thought that reconnect upon a certain time of no download may kill three birds with one stone?
Ok, at your own risc. But if you have a setup with mutiple virtual machines and vpns you probably know about that.

Script checks 3 times over 3 minutes, if average download speed is 0 three times in a row, triggers reconnect.

Code:
// Force reconnect if no downloads for 3 minutes (FBD)
// Activate trigger: Interval -> 300000 (should be > 3 minutes)
// DISABLE Synchronous execution

var trigger = 0;

for (var i = 0; i < 3; i++) {
    var avgSpeed = getAverageSpeed();
    if (avgSpeed > 0) { 
        trigger = 0;
        break;
    }
    trigger++;
    sleep(60000)
}

if (trigger == 3) {
    // 3 minutes without average download speed - trigger reconnect
    doReconnect();   
}
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #2716  
Old 25.11.2023, 20:31
JKA JKA is offline
Junior Loader
 
Join Date: Nov 2023
Posts: 12
Default

Quote:
Originally Posted by FBD View Post
Ok, at your own risc. But if you have a setup with mutiple virtual machines and vpns you probably know about that.

Script checks 3 times over 3 minutes, if average download speed is 0 three times in a row, triggers reconnect.

Code:
// Force reconnect if no downloads for 3 minutes (FBD)
// Activate trigger: Interval -> 300000 (should be > 3 minutes)
// DISABLE Synchronous execution

var trigger = 0;

for (var i = 0; i < 3; i++) {
    var avgSpeed = getAverageSpeed();
    if (avgSpeed > 0) { 
        trigger = 0;
        break;
    }
    trigger++;
    sleep(60000)
}

if (trigger == 3) {
    // 3 minutes without average download speed - trigger reconnect
    doReconnect();   
}
cant wait to give this a whirl!
Thanks so much, wish me luck!

EDIT: HOT DAMN! <3
it genuinely works now!
Also set the scheduler to do "Start Downloads" every minute, just to be on the safe side and it not stopping with "PLAY"-button greyed out anymore. Maybe not the most elegant solution, but... Hey, it works, thats all that matters!

THANKS FBD!

Last edited by JKA; 25.11.2023 at 21:34.
Reply With Quote
  #2717  
Old 26.11.2023, 16:04
JustARandomDude JustARandomDude is offline
Modem User
 
Join Date: Nov 2023
Posts: 2
Default How to fix "missing ; before statement (#2)" in my script

I want to move every extracted file after the whole archive has been extracted to a different directory. But the run and the testcompile fail with:
Quote:
missing ; before statement (#2)
Code:
disablePermissionChecks();
var extractedFilePaths[] = myArchive.getExtractedFilePaths();
var destinationFolder = "/output/EXTRACTED_FINISHED/";
for (i = 0; i < extractedFilePaths.length; i++) {
    var extractedFilePath = extractedFilePaths[i];
    extractedFilePath.moveTo(destinationFolder);
}
Could you please have a look and show me my noob mistake?
Thank you in advance!
Reply With Quote
  #2718  
Old 26.11.2023, 18:51
FBD's Avatar
FBD FBD is offline
Mega Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 65
Default

Quote:
Originally Posted by JustARandomDude View Post
Could you please have a look and show me my noob mistake?
Thank you in advance!
Code:
var extractedFilePaths = myArchive.getExtractedFilePaths();
The [ ] in the script help screen are just to indicate that the return value is an array, you're not supposed to have them in your program.
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader
Reply With Quote
  #2719  
Old 26.11.2023, 19:26
JKA JKA is offline
Junior Loader
 
Join Date: Nov 2023
Posts: 12
Default

FBD? Könnte man das oben-angegebene reconnect script vielleicht auch irgendwie auf 2 minuten kürzen?
so das, weiß nicht, vielleicht zweimal misst ob die durchschnitts downloadgeschwindigkeit 0 ist innerhalb von 2 minuten und wenn ja dann reconnect?
Glaube 3 minuten könnte vielleicht doch etwas großzügig bemessen gewesen sein meinerseits
Reply With Quote
  #2720  
Old 26.11.2023, 19:31
FBD's Avatar
FBD FBD is offline
Mega Loader
 
Join Date: Nov 2018
Location: https://web.libera.chat/#jDownloader
Posts: 65
Default

Quote:
Originally Posted by JKA View Post
FBD? Könnte man das oben-angegebene reconnect script vielleicht auch irgendwie auf 2 minuten kürzen?
so das, weiß nicht, vielleicht zweimal misst ob die durchschnitts downloadgeschwindigkeit 0 ist innerhalb von 2 minuten und wenn ja dann reconnect?
Glaube 3 minuten könnte vielleicht doch etwas großzügig bemessen gewesen sein meinerseits
Ändere
Code:
for (var i = 0; i < 3; i++) {
zu
Code:
for (var i = 0; i < 2; i++) {
und
Code:
if (trigger == 3) {
zu
Code:
if (trigger == 2) {
Dazu könnte man dann das Interval fürs script auch etwas herabsetzen, das aber nicht zu knapp machen, der reconnect dauert ja auch noch etwas.
__________________
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 23:38.
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 - 2024, Jelsoft Enterprises Ltd.