JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 17.10.2015, 06:19
Nice2MeetYou Nice2MeetYou is offline
DSL User
 
Join Date: Oct 2015
Posts: 36
Default Minimum speed?

I use 2 max chunks per download and very often when the first one finishes the speed drops a lot since one of the connections isn't working anymore. However if I press stop and start again I get maximum speed even with only 1 connection. So my question is, is there any way to tell jd to restart once the speed drops below a certain value?
Reply With Quote
  #2  
Old 17.10.2015, 06:22
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 16,117
Default

settings > event scripter > Reset a Download if the speed is low

raztoki
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #3  
Old 17.10.2015, 06:44
Nice2MeetYou Nice2MeetYou is offline
DSL User
 
Join Date: Oct 2015
Posts: 36
Default

Thank you. What about restart instead of reset?

I changed the code to

Code:
            if (running[i].getSpeed() < 1400 * 1024) {
                //reset the download
                stopDownloads();
                startDownloads();
            }
however after the downloads stop they don't start back up.

The code that is there resets the download which is not what I want.

Code:
            if (running[i].getSpeed() < 50 * 1024) {
                //reset the download
                running[i].reset();
            }
However if I modify it to the following it stops the downloads but it doesn't start them back again.

Code:
            if (running[i].getSpeed() < 50 * 1024) {
                //reset the download
                stopDownloads();
                startDownloads();
            }

Last edited by Lram32; 17.10.2015 at 15:34. Reason: merged multiple posts, please use edit.
Reply With Quote
  #4  
Old 17.10.2015, 15:06
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 16,117
Default

please wait for coalado to respond
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #5  
Old 19.10.2015, 13:26
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 63,432
Default


Please wait, we need to add this method first


stop/start does not work, because those are async methods. stop tells controller to stop. start does only work when controller is stopped!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #6  
Old 19.10.2015, 15:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 544
Default

You can use this workaround in the meanwhile. Insert the following code between the "stop" and "start" commands.

Code:
do {}
while (!isDownloadControllerIdle());

Also, the example script is meant to query and control individual links, "disable" and "enable" commands are perhaps a better fit for the script. In its current form, the script will stop and restart the downloads, even if a single link in the list of running downloads falls below the specified threshold.

If you wish to use "start" and "stop" commands, it is better to base your script on total download speed using getTotalSpeed().
Reply With Quote
  #7  
Old 19.10.2015, 16:25
Nice2MeetYou Nice2MeetYou is offline
DSL User
 
Join Date: Oct 2015
Posts: 36
Default

Thanks. The do {} while () trick made the difference
What are the consequences of having this script run every single second? Doesn't it use more processing power or make jd or the pc any slower?
Reply With Quote
  #8  
Old 19.10.2015, 18:23
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 63,432
Default

No real disadvantage Only when you script calculates the answer to all questions :p
__________________
JD-Dev & Server-Admin
Reply With Quote
  #9  
Old 25.10.2015, 11:55
Nice2MeetYou Nice2MeetYou is offline
DSL User
 
Join Date: Oct 2015
Posts: 36
Default

I modified it to this but I have noticed that a lot of times it restarts even though the speed is over 1mb.

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++) {
        if (running[i].getDownloadDuration() > 20000) {
            if (getTotalSpeed() < (1000 * 1024)) {
                stopDownloads();
                do {}
                while (!isDownloadControllerIdle());
                startDownloads();
            }

        }
    }
}
Reply With Quote
  #10  
Old 25.10.2015, 12:35
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 63,432
Default

there is new method for Download.abort() that will stop download and DowloadController will start it again when possible and resume
__________________
JD-Dev & Server-Admin
Reply With Quote
  #11  
Old 26.10.2015, 10:22
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 544
Default

Fluctuations in download speed can sometimes cause a momentary drop in speed. If such a drop occurs at the exact time the event scripter is making the query, it will trigger a restart of the download. Setting short intervals as trigger can increase the chances of such restarts. Experiment with longer intervals and/or decrease the miniumum total speed limit.

You do not need to query individual links if you use getTotalSpeed().

Code:
//Check running status and speed
if (isDownloadControllerRunning() && !isDownloadControllerStopping() && getTotalSpeed() < (1000 * 1024)) {
    // Stop and Start all Downloads               
    stopDownloads();
    do {}
    while (!isDownloadControllerIdle());
    startDownloads();
}

Here is a script using the new method jiaz mentioned earlier. It queries the current speed of individual links. Set (modify) the minimum speed limit in the script accordingly.

Trigger required : 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 the download has been running at least 60 seconds
        if (running[i].getDownloadDuration() > 60000) {
            //check if the current speed is below 64kb/s
            if (running[i].getSpeed() < 64 * 1024) {
                //Stop and resume the download when possible
                running[i].abort();
            }

        }
    }
}
Reply With Quote
  #12  
Old 26.10.2015, 19:14
Nice2MeetYou Nice2MeetYou is offline
DSL User
 
Join Date: Oct 2015
Posts: 36
Default

Thank you I ended up using the second method with getTotalSpeed() since I still wanna check if the running downloads have been running for a while.
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 09:34.
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.