JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #161  
Old 20.08.2017, 13:15
Luke M
Guest
 
Posts: n/a
Default

I'm trying to make a simple Packagizer Hook to replace "_" with " ":

Code:
if (link.getHost() == "myhost.com") {
	link.setName(link.name.replace(/_/g, " "))
}
getHost returns "http links", not the host name, so the compare always fails. The links are being added by the crawler, if that matters. What am I doing wrong?
Reply With Quote
  #162  
Old 20.08.2017, 14:08
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,659
Default

link gethost isn't the domain of the site, its the plugin names entry
hence 'http links' as its supported by directhttp plugin
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #163  
Old 20.08.2017, 14:44
Luke M
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by raztoki View Post
link gethost isn't the domain of the site, its the plugin names entry
hence 'http links' as its supported by directhttp plugin
How do you get the download URL?
Reply With Quote
  #164  
Old 20.08.2017, 15:32
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,659
Default

you can either use the package customiser and remove the chars with simple filename rule
contains *_* replace with $1$2

or you can use eventscripter, my guess would be myDownloadLink.getUrl()

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

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #165  
Old 20.08.2017, 16:37
Luke M
Guest
 
Posts: n/a
Default

This seems to work: (note: getURL not getUrl)

Code:
// Packagizer Hook to replace "_" with " "

if (/.*myhost\.com.*/.test(link.getURL())) {
	link.setName(link.name.replace(/_/g, " "))
}

Last edited by Luke M; 20.08.2017 at 16:41.
Reply With Quote
  #166  
Old 20.08.2017, 17:09
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,659
Default

good stuff

Have fun with your filename renamer ;]
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #167  
Old 29.08.2017, 21:00
tntsecurite
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by mgpai View Post
Convert AAC/M4A/OGG files to MP3.
Code:
// Convert aac/m4a/ogg files to mp3.
// Trigger required: "A Download Stopped".
// Requires ffmpeg/ffprobe. Uses JD ffmpeg/ffprobe settings if available.
// Overwrites destination file (mp3) if it already exists.

if (link.isFinished()) {
    var fileName = link.name.replace(/(.+)(\..+$)/, "$1");
    var fileType = link.name.replace(/(.+)(\..+$)/, "$2");
    var sourceFile = link.getDownloadPath();
    var audioFile = /\.(aac|m4a|ogg)$/.test(sourceFile);

    if (audioFile) {
        var downloadFolder = package.getDownloadFolder();
        var destFile = downloadFolder + "/" + fileName + ".mp3";
        var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
        var ffprobe = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypathprobe");
        var data = JSON.parse(callSync(ffprobe, "-v", "quiet", "-print_format", "json", "-show_streams", "-show_format", sourceFile));
        var streamsBitrate = data.streams[0].bit_rate ? data.streams[0].bit_rate : 0;
        var formatBitrate = data.format.bit_rate ? data.format.bit_rate : 0;
        var bitrate = Math.max(streamsBitrate, formatBitrate) / 1000;
        var deleteSourceFile = false; // Set this to true to delete source file after conversion.

        if (bitrate > 0) {
            callSync(ffmpeg, "-y", "-i", sourceFile, "-b:a", bitrate + "k", destFile);
            if (deleteSourceFile && getPath(destFile).exists()) deleteFile(sourceFile, false);
        }
    }
}
Hi Mgpai,

I'm new with JDownloader and i really like it. When i'm trying to copy the script above in my MyJDownloader eventscripter i'm receiving the following message: sorry failed to set value.
Would you know why ?

I'm using Jdownloader on my Dlink dns-325 nas to download audio file (m4a) but i would like them to be transfered in .mp3.

Thanks
Reply With Quote
  #168  
Old 29.08.2017, 21:02
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,342
Default

The most easiest way is to use a JDownloader with GUI, setup the script there via GUI and then copy/paste the value from advanced settings.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #169  
Old 29.08.2017, 21:16
tntsecurite
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
The most easiest way is to use a JDownloader with GUI, setup the script there via GUI and then copy/paste the value from advanced settings.
Hi Jiaz,
setup the script via GUI, do you mean in MyJDownloader ? Thats where i tried to copy the script to the event scripter in the setting and i got the error message. Not sure where i could have another GUI.

Thanks
Reply With Quote
  #170  
Old 29.08.2017, 22:18
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,659
Default

no he meant another JDownloader install with a GUI not webui.

gui jd
copy paste into the event scripter
then goto advanced > copy the advanced setting, this will contain all the json formatting/encoding > paste into the webui or just copy the json file across to the other system

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

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #171  
Old 29.08.2017, 22:35
tntsecurite
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by raztoki View Post
no he meant another JDownloader install with a GUI not webui.

gui jd
copy paste into the event scripter
then goto advanced > copy the advanced setting, this will contain all the json formatting/encoding > paste into the webui or just copy the json file across to the other system

raztoki
Ok Thanks for the clarification raztoki.
Reply With Quote
  #172  
Old 31.08.2017, 11:48
Psychoteur
Guest
 
Posts: n/a
Default

Hello,
is there a way to do a dry run of the script ?

I'm trying to setup filebot using the provided link **External links are only visible to Support Staff****External links are only visible to Support Staff**

I don't understand how I'm supposed to add these scripts.
At first I thought I had to add both scripts inside the root path of jdownloader /usr/jdownloader

And then copy the *eventscript*.json inside */cfg/

Now, reading the thread here.
I did add both script *.js inside a gui jdownloader and then went inside advanced settings and copy/paste the json inside myjdownloader.

But I still got the error " Sorry, failed to set the new value".
Sorry, if the question is silly or the answer obvious !

Thanks.
Reply With Quote
  #173  
Old 01.09.2017, 12:21
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,342
Default

Most easist way to setup this is to use a JDownloader with GUI and setup two events (Filename is Eventtype) and then copy/paste the value from Settings-Advanced Settings-EventScripter.scripts to your other JDownloader
__________________
JD-Dev & Server-Admin
Reply With Quote
  #174  
Old 02.09.2017, 10:54
Psychoteur
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
Most easist way to setup this is to use a JDownloader with GUI and setup two events (Filename is Eventtype) and then copy/paste the value from Settings-Advanced Settings-EventScripter.scripts to your other JDownloader
So what I did the second time is the right way of doing but it doesn't work.
I get "" Sorry, failed to set the new value".
Reply With Quote
  #175  
Old 02.09.2017, 11:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Psychoteur View Post
So what I did the second time is the right way of doing but it doesn't work.
I get "" Sorry, failed to set the new value".
You may get that error if you are trying to paste the code inside the square brackets '[]' in web UI. Try removing those brackets first and then pasting the code. Alternatively, you can copy the "org.jdownloader.extensions.eventscripter.EventScripterExtension.scripts.json" file from 'JD Desktop' to 'JD Headless'.
Reply With Quote
  #176  
Old 06.09.2017, 18:55
Koto99
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Auto stop/restart downloads if the current average speed is below limit.
// Trigger Required: "Interval"

var minSpeed = 128; // (KiB/s) <- minimum average download Speed.
var minDuration = 1; // (minutes) <- minimum download duration per link.
var waitTime = 1; // (minutes) <- wait time before restart.

if (running() && getAverageSpeed() < minSpeed * 1024) {
    stopDownloads();
    sleep(waitTime * 60 * 1000);
    startDownloads();
}

// Check if all downloads have been running for atleast the minimum duration.
function running() {
    var links = getRunningDownloadLinks();
    if (links.length > 0) {
        for (i = 0; i < links.length; i++) {
            var link = links[i];
            if (link.getDownloadDuration() < minDuration * 60 * 1000) {
                return false;
            }
        }
        return true;
    } else {
        return false;
    }
}
This not Work
No Parts are stop and Start. No Reaction from Script?

Edit
Ok this Script Work. Restart Part under 600 kb

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 30 seconds
        if (running[i].getDownloadDuration() > 30000) {
            //check if the current speed is below 50kb/s
            if (running[i].getSpeed() < 600 * 1024) {
                //reset the download
                //running[i].reset();
                //stop the download and restart it
                running[i].abort();
            }

        }
    }
}
Example Script in JDownloader 2 :-)
Attached Images
File Type: png Unbenannt-2.png (61.6 KB, 2 views)
File Type: png Unbenannt-3.png (88.0 KB, 3 views)
File Type: png Unbenannt-4.png (146.9 KB, 4 views)

Last edited by Koto99; 06.09.2017 at 19:25.
Reply With Quote
  #177  
Old 07.09.2017, 12:13
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,342
Default

@Koto99: The script from mgpai works fine. His script is about global average speed while yours is about individual download speed thats huge difference. Your screenshot shows nearl 5mb/s but the script triggers at global average speed < 128 kb/s
__________________
JD-Dev & Server-Admin
Reply With Quote
  #178  
Old 07.09.2017, 16:52
Koto99
Guest
 
Posts: n/a
Default

Thanx

I missunderstod this.

Im Searching for Part Speed reset not Global Speed:)
Reply With Quote
  #179  
Old 07.09.2017, 17:03
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,342
Default

@Koto99: your modified script should work fine
__________________
JD-Dev & Server-Admin
Reply With Quote
  #180  
Old 08.09.2017, 15:00
0r3n
Guest
 
Posts: n/a
Default

Hi,

The script for saving comments doesn't work for couple of weeks now, I thought it was temporary issue but it still have a problem. comments aren't saved.

I'm not sure whether it's script related or JDownloader related.

could you please have a look? :-)

Thank you,
0r3n.
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 11:29.
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.