JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 14.10.2015, 06:51
karimmaster101 karimmaster101 is offline
DSL User
 
Join Date: Jun 2014
Posts: 37
Default Asking for script to restart JDownloader2

I want to make Jdownloader2 restart if the download speed under 30 KB. I don't have any previous knowledge with Javascript to write the script, your help is much appreciated.

It will be great too if you provide me with script to restart jdownloader2 after specifics periods like every 2 hour or so.

Thanks in advance
Reply With Quote
  #2  
Old 14.10.2015, 09:35
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

In EventScripter (Settings-EventScripter) there is a button for 'Example Scripts', it resets a download if speed is slower than 50 kb/s. Reset = Restart from beginning!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #3  
Old 14.10.2015, 09:36
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

__________________
JD-Dev & Server-Admin
Reply With Quote
  #4  
Old 14.10.2015, 15:22
karimmaster101 karimmaster101 is offline
DSL User
 
Join Date: Jun 2014
Posts: 37
Default

Quote:
Originally Posted by Jiaz View Post
In EventScripter (Settings-EventScripter) there is a button for 'Example Scripts', it resets a download if speed is slower than 50 kb/s. Reset = Restart from beginning!
Thank you very much. That is what I want except the reset action.
Is there any way to restart JD itself?

// Some of Youtube videos stop downloading after some progress. The only way to resume them is by restarting JD itself. I have tried Stop/Start again but it didn't work. So, the reset action will lose any progress while the file could resume.
Reply With Quote
  #5  
Old 14.10.2015, 15:41
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

Please provide a logfile for the youtube issue. Menu -> Help -> Create log and give logID
No, at the moment it is not possible. That's why I created the ticket.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #6  
Old 14.10.2015, 16:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,545
Default

Will this work?

Trigger : Interval

Code:
//check if downloads are running at all
if (isDownloadControllerRunning() && !isDownloadControllerStopping()) {
    var running = getRunningDownloadLinks();
    //loop through all running Downloads
    for (var i = 0; i < running.length; i++) {
        //check if host is youtube.com
        if (running[i].getHost() == "youtube.com") {
            //check if the download has been running at least 30 seconds
            if (running[i].getDownloadDuration() > 30000) {
                //check if the current speed is below 30kb/s
                if (running[i].getSpeed() < 30 * 1024) {
                    //restart JD
                    callAPI("system", "restartJD")
                }

            }
        }
    }
}
Reply With Quote
  #7  
Old 14.10.2015, 16:37
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

test it nothing bad can happen
__________________
JD-Dev & Server-Admin
Reply With Quote
  #8  
Old 15.10.2015, 08:36
karimmaster101 karimmaster101 is offline
DSL User
 
Join Date: Jun 2014
Posts: 37
Default

Quote:
Originally Posted by mgpai View Post
Will this work?

Trigger : Interval

Code:
//check if downloads are running at all
if (isDownloadControllerRunning() && !isDownloadControllerStopping()) {
    var running = getRunningDownloadLinks();
    //loop through all running Downloads
    for (var i = 0; i < running.length; i++) {
        //check if host is youtube.com
        if (running[i].getHost() == "youtube.com") {
            //check if the download has been running at least 30 seconds
            if (running[i].getDownloadDuration() > 30000) {
                //check if the current speed is below 30kb/s
                if (running[i].getSpeed() < 30 * 1024) {
                    //restart JD
                    callAPI("system", "restartJD")
                }

            }
        }
    }
}

Thank you verrry much. It works like a charm.
If you wouldn't mind, what about -instead of restarting JD- disabling the current link so JD goes to the next link and starting it?!
Reply With Quote
  #9  
Old 15.10.2015, 09:28
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,545
Default

Code:
//check if downloads are running at all
if (isDownloadControllerRunning() && !isDownloadControllerStopping()) {
    var running = getRunningDownloadLinks();
    //loop through all running Downloads
    for (var i = 0; i < running.length; i++) {
        //check if host is youtube.com
        if (running[i].getHost() == "youtube.com") {
            //check if the download has been running at least 30 seconds
            if (running[i].getDownloadDuration() > 30000) {
                //check if the current speed is below 30kb/s
                if (running[i].getSpeed() < 30 * 1024) {
                    //Get link UUID
                    var long1 = [running[i].getUUID()]
                        //Disable Link
                    callAPI("downloadsV2", "setEnabled", false, long1, [])
                }

            }
        }
    }
}

Last edited by mgpai; 15.10.2015 at 09:30.
Reply With Quote
  #10  
Old 15.10.2015, 09:33
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

@mgpai: nice work! *thumbs up*
__________________
JD-Dev & Server-Admin
Reply With Quote
  #11  
Old 15.10.2015, 09:34
karimmaster101 karimmaster101 is offline
DSL User
 
Join Date: Jun 2014
Posts: 37
Default

Thaaaaaaaaaaaaaaaaaaanks
Reply With Quote
  #12  
Old 15.10.2015, 09:35
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,545
Default

@Jiaz... Thanks

@karimmaster101... You are welcome.
Reply With Quote
  #13  
Old 15.10.2015, 09:44
coalado's Avatar
coalado coalado is offline
JD Manager
 
Join Date: Feb 2009
Posts: 1,980
Default

If you want JD to autostart the downloads after a restart, you should enable the option either in the advanced config, or via this eventscript line:

Code:
callAPI("config", "set", "org.jdownloader.settings.GeneralSettings",null, "autostartdownloadoption", "ALWAYS");
__________________
Reply With Quote
  #14  
Old 29.08.2019, 07:42
Fetter Biff
Guest
 
Posts: n/a
Default

How could one change the script that it automatically restarts JD if all downloads together have a speed less than 30 kb/h or 0 kb/h and after unzipping (if it unzipps, if not just restart after that speed)?
Reply With Quote
  #15  
Old 29.08.2019, 10:15
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

@Fetter Biff: Ich schlage vor, du fragst direkt mgpai um Hilfe!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #16  
Old 29.08.2019, 10:28
Fetter Biff
Guest
 
Posts: n/a
Default

Ist gut, er wird das hier ja bestimmt auch sehen. Oder meinst Du, ich sollte ihn noch anders ansprechen?
Reply With Quote
  #17  
Old 29.08.2019, 10:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,545
Default

Quote:
Originally Posted by Fetter Biff View Post
How could one change the script that it automatically restarts JD if all downloads together have a speed less than 30 kb/h or 0 kb/h and after unzipping (if it unzipps, if not just restart after that speed)?
Guess same/similar request was made and a script has already been provided in post #446520
Reply With Quote
  #18  
Old 29.08.2019, 11:24
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

@mgpai: Thanks!

@Fetter Biff: Da siehste
__________________
JD-Dev & Server-Admin
Reply With Quote
  #19  
Old 29.08.2019, 11:28
Fetter Biff
Guest
 
Posts: n/a
Default

Ja, vielen Dank nochmals!
Reply With Quote
  #20  
Old 29.08.2019, 16:01
Fetter Biff
Guest
 
Posts: n/a
Default

Is JD restarted only if there was a download downloaded faster than the time set in the script before which now has finished? Or even if there was no download before?

Cannot get it to work at the moment:




Is that correct?
Reply With Quote
  #21  
Old 29.08.2019, 16:08
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,524
Default

@Fetter Biff: the script only triggers when speed is 0, if you want other condition, ask mgpai for help with modification of script
__________________
JD-Dev & Server-Admin
Reply With Quote
  #22  
Old 29.08.2019, 16:25
Fetter Biff
Guest
 
Posts: n/a
Default

Ja, ich dachte, das täte ich, in dem ich hier fragte.

The speed is null but it does not trigger obviously.
Reply With Quote
  #23  
Old 29.08.2019, 17:09
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,545
Default

With default settings, if there are active downloads and the the speed is 0 for more than 120 seconds and there is no linkchecking/crawling/extraction activity, the script will (should) restart JD.

You can also find me in JD chat if you want any assistance with troubleshooting.
Reply With Quote
  #24  
Old 29.08.2019, 20:16
Fetter Biff
Guest
 
Posts: n/a
Default

Alright. I will go on trying.

Chat, OK, many thanks!
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 18:37.
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.