JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 14.10.2015, 06:51
karimmaster101 karimmaster101 is offline
JD Alpha
 
Join Date: Jun 2014
Posts: 22
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: 65,443
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: 65,443
Default

__________________
JD-Dev & Server-Admin
Reply With Quote
  #4  
Old 14.10.2015, 15:22
karimmaster101 karimmaster101 is offline
JD Alpha
 
Join Date: Jun 2014
Posts: 22
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: 65,443
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: 612
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: 65,443
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
JD Alpha
 
Join Date: Jun 2014
Posts: 22
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: 612
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: 65,443
Default

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

Thaaaaaaaaaaaaaaaaaaanks
Reply With Quote
  #12  
Old 15.10.2015, 09:35
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 612
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,983
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 Fetter Biff is offline
JD Legend
 
Join Date: Oct 2014
Posts: 836
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: 65,443
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 Fetter Biff is offline
JD Legend
 
Join Date: Oct 2014
Posts: 836
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: 612
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: 65,443
Default

@mgpai: Thanks!

@Fetter Biff: Da siehste
__________________
JD-Dev & Server-Admin
Reply With Quote
  #19  
Old 29.08.2019, 11:28
Fetter Biff Fetter Biff is offline
JD Legend
 
Join Date: Oct 2014
Posts: 836
Default

Ja, vielen Dank nochmals!
Reply With Quote
  #20  
Old 29.08.2019, 16:01
Fetter Biff Fetter Biff is offline
JD Legend
 
Join Date: Oct 2014
Posts: 836
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
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 14: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 - 2019, Jelsoft Enterprises Ltd.