JDownloader Community - Appwork GmbH
 

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,672
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,672
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,672
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: 81,051
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,672
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: 81,051
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,602
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: 81,051
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: 81,051
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
  #181  
Old 08.09.2017, 19:29
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,051
Default

@or3n: you know the script only works for packages, not individual links?
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 08.09.2017 at 19:32.
Reply With Quote
  #182  
Old 08.09.2017, 20:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,602
Default

Quote:
Originally Posted by 0r3n View Post
... The script for saving comments doesn't work for couple of weeks now ...
The script is working fine. For which site do you use the script? Does that plugin still write the description to the comments field?
Reply With Quote
  #183  
Old 10.09.2017, 08:58
0r3n
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
@or3n: you know the script only works for packages, not individual links?
Hi Jiaz, yes.


Quote:
Originally Posted by mgpai View Post
The script is working fine. For which site do you use the script? Does that plugin still write the description to the comments field?
I'm trying to use it for Instagram, I noticed that comments doesn't appear in JDownloader as before but thought maybe it's internal issue and that they are there anyway.
so if the comments doesn't appear in JDownloader "comments" column it's a plugin issue?
Reply With Quote
  #184  
Old 11.09.2017, 19:08
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,051
Default

@0r3n: wait for plugin update. comment handling was broken because of instagram site changes
__________________
JD-Dev & Server-Admin
Reply With Quote
  #185  
Old 12.09.2017, 20:16
facecat
Guest
 
Posts: n/a
Default

hi
sorry to disturb you for that but the mgpai script for sorting files by duration (https://board.jdownloader.org/showpo...&postcount=159) cant be started for every "files" but only "bundle" we dont have "file finished" trigger in "event scripter" is it possible to fix that by something more inside the script or a new trigger

ps : if i select "interval" i have an error (https://i.imgur.com/jzou6a2.png)
thx in advance
Reply With Quote
  #186  
Old 12.09.2017, 20:28
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,051
Default

You have to use the trigger "Download Stopped" as commented in the script
__________________
JD-Dev & Server-Admin
Reply With Quote
  #187  
Old 12.09.2017, 20:50
facecat
Guest
 
Posts: n/a
Default

ho my bad sry thank you im gonna try this
Reply With Quote
  #188  
Old 14.09.2017, 00:47
0r3n
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
@0r3n: wait for plugin update. comment handling was broken because of instagram site changes
Thanks Jiaz, after the update everything is working
Reply With Quote
  #189  
Old 14.09.2017, 10:02
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,051
Default

@03rn: you're welcome
__________________
JD-Dev & Server-Admin
Reply With Quote
  #190  
Old 17.09.2017, 10:53
Informativ Informativ is offline
Registered / Inactive
 
Join Date: Nov 2016
Posts: 106
Default

good morning,
will it work for me? (deleted files in download folder)

Code:
// Delete from download folder, any file/folder which contains user specified keywords
// Trigger required: "A Download Stopped"

package.getDownloadFolder().forEach(function(file) {
    var re = /.*(ajax-loader|url).*/;
    var junkFile = re.test(file.getName());
    var junkFolder = re.test(file.getParent().getName());

    if (junkFile) file.delete();
    if (junkFolder) file.getParent().deleteRecursive();
});
other question:

I want the download to be finished, check if there is a pdf file, if so, this is started
F:\Downloads\files\PDFConverter.exe "%DEPACKFOLDER%" "%DEPACKFOLDER%" -c PNG -p 1 -pd 4x5
"%DEPACKFOLDER%" = DownloadFolder

is that possible?

Last edited by Informativ; 17.09.2017 at 11:00. Reason: edit
Reply With Quote
  #191  
Old 18.09.2017, 07:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,602
Default

Quote:
Originally Posted by Informativ View Post
... will it work for me? (deleted files in download folder) ...
The script will not work in its present form. You have to to get the download links for the package and then query and delete them.

If you always want to delete such files, it is better to use linkfilter and prevent the links from being added to JD in the first place, rather than downloading, and deleting them later using event scripter.

Quote:
Originally Posted by Informativ View Post
I want the download to be finished, check if there is a pdf file, if so, this is started ...
Code:
// Run external program if package contains 'pdf' file
// Trigger: "Package finished"

var pdf = package.getDownloadLinks().some(function(link) {
    return getPath(link.getDownloadPath()).getExtension() == "pdf";
});

if (pdf) {
    var downloadFolder = package.getDownloadFolder();
    var converter = "f:/downloads/files/pdfConverter.exe";
    callAsync(function() {}, converter, downloadFolder, downloadFolder, "-c", "PNG", "-p", "1", "-pd", "4x5");
}
Reply With Quote
  #192  
Old 18.09.2017, 13:40
Informativ Informativ is offline
Registered / Inactive
 
Join Date: Nov 2016
Posts: 106
Default

hi mgpai,
if no pdf available, that comes
Spoiler:

Quote:
The script will not work in its present form. You have to to get the download links for the package and then query and delete them.

If you always want to delete such files, it is better to use linkfilter and prevent the links from being added to JD in the first place, rather than downloading, and deleting them later using event scripter.
that a option, but over word is better
Reply With Quote
  #193  
Old 18.09.2017, 13:49
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,051
Default

looks like copy/paste error or invalid script. error is about syntax error in script
__________________
JD-Dev & Server-Admin
Reply With Quote
  #194  
Old 02.10.2017, 09:06
Informativ Informativ is offline
Registered / Inactive
 
Join Date: Nov 2016
Posts: 106
Default

hi,
is it possible to stop this part and then restart it?
Spoiler:
Reply With Quote
  #195  
Old 07.10.2017, 23:23
pachi
Guest
 
Posts: n/a
Default

Hi.
Textbox contents in messagebox is invisible height.
How change height?

Code:
alert("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");

Last edited by pachi; 08.10.2017 at 05:47.
Reply With Quote
  #196  
Old 08.10.2017, 10:26
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,602
Default

Quote:
Originally Posted by pachi View Post
Textbox contents in messagebox is invisible height. How change height?
Know issue. Workaround: Add "\r\n" at the end of the object/string.

Code:
alert("myString"+"\r\n");
Reply With Quote
  #197  
Old 08.10.2017, 10:56
pachi
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by mgpai View Post
Know issue. Workaround: Add "\r\n" at the end of the object/string.

Code:
alert("myString"+"\r\n");
Thank you!
Reply With Quote
  #198  
Old 09.10.2017, 11:11
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,051
Default

__________________
JD-Dev & Server-Admin
Reply With Quote
  #199  
Old 15.10.2017, 00:52
Tyler Tyler is offline
Registered / Inactive
 
Join Date: Jul 2010
Posts: 581
Default

Quote:
Originally Posted by fred_gaou View Post
Hi,

Here is a script to help you to auto clean/format filename during the link grabbing process. This is done automatically in background for each added link.

You can set some options at the top of the script.

This is useful in any case as soon as you notice a recurring pattern in your filenames that you'll want to get rid of or format.

if you set custom filename for video files such as:
Code:
[*CHANNEL*] (*PLAYLIST_NAME* *PLAYLIST_POSITION[00]*) *DATE[YY.MM.dd]* - *VIDEO_NAME*.*EXT*
it will be perfect for playlist but not for one video file only because then you will end with a filename with empty brackets:
Code:
[Any Youtuber Channel] ( ) 17.03.11 - Video Title
This script will take care of it removing those bracket:
Code:
[Any Youtuber Channel] 17.03.11 - Video Title
Code:
// LINK NAME CLEANER (auto)
// Trigger required: Packagizer Hook

/* *************************************************************************
Set the characters that will be removed from both ends of the filename.
Be sure to double escape special chars such as "\\s" instead of "\s".
****************************************************************************/

var leadAndTrailTrimChars = "\\s-_";

/* *************************************************************************
Set the characters that will be replaced with whitespace.
Be sure to double escape special chars such as "\\s" instead of "\s".
****************************************************************************/

var charToSpace = "_";

/* *************************************************************************
Set the words or phrases to remove. Words/phrases must be separated with | such as
"word one|word two|word three"
Be sure to double escape special chars such as "\\s" instead of "\s".
****************************************************************************/

var wordsToRemove = "with subtitles";

/***************************************************************************/

if (linkcheckDone) {


    /* =========================== INITIALIZE ============================ */

    var myPackagizerLink = link;
    var fileName = myPackagizerLink.getName();
    var re, ext;

    // Remove the extension from the end and save it for later.
    // And make it lower case at the same time.
    ext = fileName.slice((fileName.lastIndexOf(".") - 1 >>> 0) + 2);
    if (ext !== "") {
        ext = "." + ext.toLowerCase();
    }

    // If extension exists, then we will work with the filename without extension
    fileName = fileName.substr(0, (fileName.length - ext.length));

    /* ========================= REGEX PATTERNS ========================== */

    // Remove these words/phrase : wordsToRemove
    re = new RegExp("\\b(?:" + wordsToRemove + ")\\b", "gi");
    fileName = fileName.replace(re, "");

    // Replace these characters with whitespace : charToSpace
    re = new RegExp("[" + charToSpace + "]", "gi");
    fileName = fileName.replace(re, " ");

    // Delete empty bracket content. "( )", "[ ]" or "{ }" will be removed from filename.    
    re = new RegExp("(\\(\\s+?\\))|(\\[\\s+?\\])|({\\s+?})", "gi");
    fileName = fileName.replace(re, "");

    /* ====== ALWAYS APPLY NEXT REPLACEMENTS AT THE END OF PROCESS ======= */

    // Remove unwanted characters from both ends of the filename
    re = new RegExp("^[" + leadAndTrailTrimChars + "]*(.+?)[" + leadAndTrailTrimChars + "]*$", "gi");
    fileName = fileName.replace(re, "$1");

    // Replace multiple spaces with only one
    re = new RegExp("\\s\\s+", "gi");    
    fileName = fileName.replace(re, " ");

    // Removes whitespace from both ends of the filename (just to be sure)
    fileName = fileName.trim();

    /* ====== APPLY NEW FILE NAME ======= */
    myPackagizerLink.setName(fileName + ext);
}
can you fix this?

says ReferenceError: "linkcheckDone" is not defined. (#28)
Reply With Quote
  #200  
Old 15.10.2017, 03:03
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Default

Quote:
Originally Posted by Tyler View Post
can you fix this?

says ReferenceError: "linkcheckDone" is not defined. (#28)
It works here on last JD 2.0 #617. So nothing to fix.
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:31.
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.