JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #201  
Old 16.10.2017, 10:30
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

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

says ReferenceError: "linkcheckDone" is not defined. (#28)
Sounds like you've set wrong Event Trigger?! Trigger required: Packagizer Hook
Plus the script does not contain any linkcheckDone
__________________
JD-Dev & Server-Admin
Reply With Quote
  #202  
Old 17.10.2017, 04:26
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Question

What is the Advanced settings>EventScripter: API Panel Visible supposed to do?

I enabled it and restart JD2 and see no changes. I'd like to output some strings to debug my scripts in a convenient place (in the JD GUI) with log() function or else. How can I do that except checking the JD_HOME/logs/xxxx/ScriptEnvironment.log.0?
Reply With Quote
  #203  
Old 17.10.2017, 09:35
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

@fred_gaou:
it shows/hides the api help panel
You could either use alert() to open a window that shows debug info or write our debug to some sort of debug/log file. Or do you have something else in mind?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #204  
Old 17.10.2017, 18:32
pachi
Guest
 
Posts: n/a
Default strange syntax of color in script editor

Hi.

I escaped special characters.
and then as shown below resulted.

(run script is no problem.)



thank you.
Reply With Quote
  #205  
Old 17.10.2017, 18:54
pachi
Guest
 
Posts: n/a
Default Garbled other language in scripts editor.

Hi.
sorry for ask so many.

Garbled japanese language in scripts editor.
Exists Change font method?



thanks for support.
Reply With Quote
  #206  
Old 17.10.2017, 19:50
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

@pachi: try Settings-Avanced Settings-LAFSettings.fontname.
for example 'Arial Unicode MS' without '

I've created a ticket for the comment issue
__________________
JD-Dev & Server-Admin
Reply With Quote
  #207  
Old 17.10.2017, 19:54
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

Eventscripter does not yet support custom font from advanced settings
__________________
JD-Dev & Server-Admin
Reply With Quote
  #208  
Old 17.10.2017, 20:06
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Wink

Quote:
Originally Posted by Jiaz View Post
@fred_gaou:
it shows/hides the api help panel
You could either use alert() to open a window that shows debug info or write our debug to some sort of debug/log file. Or do you have something else in mind?
Using alert() to debug is doable. But I was asking just in case JD offered something like a debug console in the script panel or in a tab that would show all script output using the log() function. Those features won't prevent me from writing my script but would be a friendly way to do it.
Reply With Quote
  #209  
Old 17.10.2017, 20:07
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

Thanks for the feedback! I like the debug console idea
__________________
JD-Dev & Server-Admin
Reply With Quote
  #210  
Old 17.10.2017, 20:26
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Post [SCRIPT] Clean up and log finished packages

Trigger required: Interval
Please check the "Synchronous execution of script" box available in this edition panel to avoid multiple script executions at the same time and log file corruption (even if it should not happen anyway).
--------------------------------------
Author : freMea (myself)
Version : 2017.10.30
Download link: gist.github.com/freMea/f2787b6c74097a4ef16cd21904f71517
--------------------------------------

D E S C R I P T I O N

Every time interval the user specified (OPTIONS: interval - default is 5 minutes), the script runs in background to remove downloaded and completed packages from the download panel if they are older than specified time (OPTIONS: finished_since - default is 60 minutes).

It is a better solution than the built-in feature option that remove packages as soon as they are completed because you may need to check some information about it before it gets removed from the list.

In any case, with this script, even if you set it to remove finished packages as soon as they are downloaded, all the informations about downloaded packages that have been removed by the script will be logged in the chosen target folder (OPTIONS: logPath - default folder is "%temp%" and log file name is 'JD - removed packages.log").

This log file won't grow up endlessly, its size is controlled by option that remove entries that are older than specified age in days (OPTIONS: max_logged_days - default is 3).

-----
Note 1: %temp% is the default temporary folder that is used by the operating system and applications available to the currently logged on user. On Windows just write %temp% in the address bar of file explorer to open it.

If you want to customize the path (OPTIONS: logPath), I recommend to use / as a path separator no matter the OS you use, it will be translated correctly by JD even on Windows. Else if you want to use \ anyway, you will have to double it like c:\\path to\\my log.

Note 2: At first script execution, you'll be prompted to allow script to call JD API and to do other actions, all required to make it work.

(Use the OPTIONS section at the top of script to customize to your need)

Last edited by fred_gaou; 31.10.2017 at 01:19.
Reply With Quote
  #211  
Old 17.10.2017, 20:46
pachi
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
@pachi: try Settings-Avanced Settings-LAFSettings.fontname.
for example 'Arial Unicode MS' without '

I've created a ticket for the comment issue
all gui changed.
but just event script editor is not change...
thank you for reply.
Reply With Quote
  #212  
Old 17.10.2017, 20:52
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

@fred_gaou: Thanks for the script. I made the link visible

I suggest to use interval trigger and iterate through packages, check for finished state and finished date and then proceed. your script executes and actively waits 1 hour. Your script has some flaws! It doesn't check for removed/changed package. if you reset/add stuff to the package while the script is waiting, it will remove even if downloads are still in progress
__________________
JD-Dev & Server-Admin
Reply With Quote
  #213  
Old 17.10.2017, 21:33
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Question

Quote:
Originally Posted by Jiaz View Post
@fred_gaou: Thanks for the script. I made the link visible

I suggest to use interval trigger and iterate through packages, check for finished state and finished date and then proceed. your script executes and actively waits 1 hour. Your script has some flaws! It doesn't check for removed/changed package. if you reset/add stuff to the package while the script is waiting, it will remove even if downloads are still in progress
Yes, that was my primary idea but I was not sure how to do it. The script help panel have missed items like built-in object variables that are not documented (package in Packaged Finished context, link in Packagizer Hook context, interval in Interval context, for instance). I searched exhaustive list about those variables to the My.JDownloader API Documentation to no avail. Where I can find a doc about them?

Is there a way to get the creation date of a any file in a given path?
Reply With Quote
  #214  
Old 17.10.2017, 22:10
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Exclamation bug?

Let's say you have packages with disabled links (all are disabled for instance because of package context menu>disable).

Even if the progression is 0% if you use this script, it returns these packages as finished:

Code:
var aPackages = getAllFilePackages(); /*Get a list of all packages*/

var sText = ""; //will be filled with content (or not :-)

for (var i = 0; i < aPackages.length; i++) {
    var package = aPackages[i];
    var packageName = package.getName();
    var isFinished = package.isFinished();
    sText += "Package " + (i + 1) + " : " + packageName + " (finished: " + isFinished + ")\r\n";
}

alert(sText);
Workaround is to loop through the links in package to see if they are finished with isFinished().

Last edited by fred_gaou; 18.10.2017 at 01:07.
Reply With Quote
  #215  
Old 18.10.2017, 07:02
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Exclamation

Quote:
Originally Posted by Jiaz View Post
@fred_gaou: Thanks for the script. I made the link visible

I suggest to use interval trigger and iterate through packages, check for finished state and finished date and then proceed. your script executes and actively waits 1 hour. Your script has some flaws! It doesn't check for removed/changed package. if you reset/add stuff to the package while the script is waiting, it will remove even if downloads are still in progress
I rewrote my script with interval trigger but some JD bugs have to be solved before I can release it.
  • package.getFinishedDate() return -1 (reported in Problems & Bug Reports section).
  • package.isFinished() return true if package is disabled despite of none of its links being downloaded/finished. (reported in the above post).

I have to wait those bug to be solved to finish my script.
Reply With Quote
  #216  
Old 18.10.2017, 09:58
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

Quote:
Originally Posted by fred_gaou View Post
Yes, that was my primary idea but I was not sure how to do it. The script help panel have missed items like built-in object variables that are not documented (package in Packaged Finished context, link in Packagizer Hook context, interval in Interval context, for instance). I searched exhaustive list about those variables to the My.JDownloader API Documentation to no avail. Where I can find a doc about them?
I'm sorry but I don't understand. I've just checked 'Package Finished','Packagizer Hook' and methods of package/link are listed above. See FilePackage and PackagizerLink Section
__________________
JD-Dev & Server-Admin
Reply With Quote
  #217  
Old 18.10.2017, 10:00
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

Quote:
Originally Posted by fred_gaou View Post
Is there a way to get the creation date of a any file in a given path?
FilePath Object, you can get one via
Code:
var myFilePath = getPath(myString/*Path to a file or folder*/);/*Get a FilePath Object*/
__________________
JD-Dev & Server-Admin
Reply With Quote
  #218  
Old 18.10.2017, 10:02
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

Quote:
Originally Posted by fred_gaou View Post
  • package.getFinishedDate() return -1 (reported in Problems & Bug Reports section).
  • package.isFinished() return true if package is disabled despite of none of its links being downloaded/finished. (reported in the above post).

I have to wait those bug to be solved to finish my script.

getFinishedDate will be fixed with next Core update

isFinished is no bug. Disabled Links are not counted! Links must be enabled and in finished state.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #219  
Old 18.10.2017, 11:48
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

Quote:
Originally Posted by pachi View Post
all gui changed.
but just event script editor is not change...
thank you for reply.
will be fixed with next core update
__________________
JD-Dev & Server-Admin
Reply With Quote
  #220  
Old 18.10.2017, 21:11
pachi
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by Jiaz View Post
Eventscripter does not yet support custom font from advanced settings
Thank You for custom font support!
i was can use japanese in script editor.
Reply With Quote
  #221  
Old 19.10.2017, 00:07
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Default

Quote:
Originally Posted by Jiaz View Post
I'm sorry but I don't understand. I've just checked 'Package Finished','Packagizer Hook' and methods of package/link are listed above. See FilePackage and PackagizerLink Section
Don't worry, my script is ready with interval trigger and the algorithm you pointed. Just waiting next core update to deeply test it with getFinishedDate().
Reply With Quote
  #222  
Old 19.10.2017, 09:34
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

Update got released yesterday
__________________
JD-Dev & Server-Admin
Reply With Quote
  #223  
Old 19.10.2017, 20:04
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Default

Quote:
Originally Posted by Jiaz View Post
isFinished is no bug. Disabled Links are not counted! Links must be enabled and in finished state.
Well package.isFinished() returns true even if there are disable links whereas link.isFinished() returns false for disable links. There is some inconsistency for me. package.isFinished() should return false if it contains unfinished links, disabled or not. This is how the isFinished term is intuitively understood by the script programmer.
Reply With Quote
  #224  
Old 19.10.2017, 20:12
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

For links the internal state is checked. But for packages only enabled links are checked. For example via packagizer/manual disabled mirror links in case they are needed later. In that case package would never finish.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #225  
Old 22.10.2017, 22:09
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Lightbulb Scripts list

Hey,

What about creating a introducing post in this thread that would only contains:
  • links to posts or threads that offer scripts
  • their short description


This thread growing up, it contains now more help, requests and support, etc. than actually scripts. I supposed this thread must be currently overwhelming for new comers that want list of available scripts.
Reply With Quote
  #226  
Old 23.10.2017, 09:38
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

Good idea But I don't have time to do this, so anyone is welcome to create such a post and keep it updated. I will make it sticky then.
@mgpai
@fred_gaou
Help is welcome
__________________
JD-Dev & Server-Admin
Reply With Quote
  #227  
Old 24.10.2017, 19:00
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Question ES6 support

Could we hope to have ES6 features in our JS script?

Controlling variable scope is so much easier and cleaner with it as just an example.
Reply With Quote
  #228  
Old 24.10.2017, 19:28
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

@fred_gaou: I don't think so. The used javascript interpreter does only support very limited subset of features.
mozilla.github.io/rhino/compat/engines.html
If you need such advanced features, I think it would be simplier to use Eventscripter to call an external javascript interpreter that supports more javascript features.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #229  
Old 30.10.2017, 23:32
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Default

How about adding a button|link in JD settings/scripts toward this thread for user to see all available scripts?
Reply With Quote
  #230  
Old 31.10.2017, 01:27
fred_gaou fred_gaou is offline
Registered / Inactive
 
Join Date: Mar 2016
Location: France
Posts: 39
Lightbulb Clean up and log finished packages: script link

Hi,

I released my script you can find at some post before this one in this thread.

Here is the direct link:
Code:
board.jdownloader.org/showpost.php?p=410187&postcount=210
Later this week, I will create a welcome post for this thread that will content all the links to each script published here with a description. But I will need to have the right to post link or that an admin point me the right way to do it. I could write a draft and send it to an admin so he'll just have to post it, right?
Reply With Quote
  #231  
Old 02.11.2017, 10:51
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

@fred_gaou: You can post links that link to our board. Those are whitelisted.
Thanks for your contribution. Once such a *index* post exists, we can easily link it in eventscripter, great idea!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #232  
Old 06.11.2017, 13:42
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
Default Save Link URLs

Code:
// Save Link URLs
// Files will be created in default (Global) download folder
// Trigger Required: A Download Stopped

if (link.isFinished()) {
    var data = "<details><summary>" + link.getName() + "</summary><table>";

    var urls = {
        "Content": link.getContentURL(),
        "Container": link.getContainerURL(),
        "Origin": link.getOriginURL(),
        "Referrer": link.getReferrerURL()
    };

    for (x in urls) {
        if (urls[x]) data += "<tr><td>" + x + "</td><td> : <a href=\"" + urls[x] + "\">" + urls[x] + "</a></td></tr>";
    }

    data += "</table></details>";

    var folder = callAPI("config", "get", "org.jdownloader.settings.GeneralSettings", null, "DefaultDownloadFolder");
    var date = new Date().toDateString().substr(4);
    var file = folder + "/" + date + ".htm";

    writeFile(file, data, true);
}
Reply With Quote
  #233  
Old 10.11.2017, 15:52
animus animus is offline
Registered / Inactive
 
Join Date: Jan 2010
Posts: 48
Default

hi @mgpai
i am trying to find away to rename video files to the name of the archives name
example
mgpai.the.movie.rar contains fghjk.mp4 --rename--> mgpai.the.movie.mp4
edit
but of course not limited to mp4.mkv/mp4/avi/wmv/flv etc.

thanks

Last edited by animus; 10.11.2017 at 15:56.
Reply With Quote
  #234  
Old 12.11.2017, 13:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
Default

Quote:
Originally Posted by animus View Post
... i am trying to find away to rename video files to the name of the archives name ...
Packagizer has an option to rename files after extraction.
Reply With Quote
  #235  
Old 17.11.2017, 10:52
torrero007
Guest
 
Posts: n/a
Default Script for sending email after package finished

I came up with a way to send myself an email after a package is finished in JD. The trigger for the Event Scripter is "package finished". Here is the script:

Code:
//Add your script here. Feel free to use the available api properties and methods
callAsync(function(exitCode, stdOut, errOut) {}, "C:\\sendEmail.exe", "-o", "tls=yes", "-t", "someone@gmail.com", "-u", "Download Completed:", package.getName(), "-m", "Download completed:", package.getName(), "-f", "youremail@gmail.com", "-s", "smtp.gmail.com:587", "-xu", "yourusername", "-xp", "yourpassword");

Info
"C:\\sendEmail.exe" : the path were the sendEmail is in your PC
"-t", "someone@gmail.com" : the address which will notified
"-f", "youremail@gmail.com" : the address which will send the notification
"-xu", "yourusername" : your username on the "-f" account
"-xp", "yourpassword" : your password on the "-f" account

You will need a very simple program called "Sendemail". Download the version with TLS support.

You will also need to enable POP and IMAP in the Gmail account you will use to send the notification from (the "f" attribute email address). In addition you need to turn on the "Access for less secure apps" on this account or else the Gmail with block the access to the acount.

I would like to thank Jiaz for helping me start and finish it.

Hope it helps

Last edited by torrero007; 17.11.2017 at 14:32. Reason: corrections
Reply With Quote
  #236  
Old 25.11.2017, 15:19
ottoS ottoS is offline
Registered / Inactive
 
Join Date: May 2013
Posts: 17
Default How to build an interactive script?

Hi,

with the new trigger-functionality now we can start a script on button-press.
Very, very nice.
With this scenario I want to build an interactive script with an datetime-picker at script start.
For instance:
1. button pressed in JD-menu launches the script.
2. the script should launch a dialog box with a datetime-picker (at best there would be a cancel-button).
3. after input the script then processes the value ... (or abortes on cancel-button).

Now my question:
How to render the picker, because we have no html-canvas onto we can render the UI-elements (form, etc)?
(The only GUI-canvas I see is the alert-popup, but can it blown up to a multifunctional UI-element?)


Thx for reading this.
A lot more thanks for a reply.

Last edited by ottoS; 25.11.2017 at 19:16.
Reply With Quote
  #237  
Old 27.11.2017, 12:19
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

@ottoS: what for do you need the date picker exactly for? You could just let user enter input like hours:minutes:day...
__________________
JD-Dev & Server-Admin
Reply With Quote
  #238  
Old 29.11.2017, 14:50
MaybeGrimm MaybeGrimm is offline
Ultra Loader
 
Join Date: Nov 2017
Posts: 45
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Add metadata to image file, using external program
// Trigger: "A Download Stopped"
// External program required: ExifTool by Phil Harvey (**External links are only visible to Support Staff**
// IMPORTANT: Remove any command line parameters included in the executable. For e.g. in Windows OS, rename 'exiftool(-k).exe' to 'exiftool.exe'

if (link.isFinished()) {
    var filePath = link.getDownloadPath();
    var ext = getPath(filePath).getExtension();
    var supported = ["jpg", "tiff"]; // <- Specify supported file types.

    if (supported.indexOf(ext) > -1) {
        var comment = link.getComment();

        if (comment) {
            var exiftool = "c:/portable/exiftool/exiftool.exe"; // <- Set full path to "exiftool.exe"
            var tagName = "comment"; // <- For the comment to be visible in the OS file properties viewer, use OS compatible tag name.
            comment = comment.replace(/"/g, "'");
            callAsync(function() {}, exiftool, "-overwrite_original", "-" + tagName + "=" + comment, filePath);
        }
    }
}
I've tried, but seems it doesn't work for me. It simply doesn't save the comments. I've already changed the tag name in "system.comment" and "Comentarios" (my OS is in spanish) and still not working.
What I'm doing wrong?
Sorry for the questions.
Reply With Quote
Old 29.11.2017, 15:07
MaybeGrimm
Message deleted by Jiaz.
  #239  
Old 30.11.2017, 15:53
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
Default

@MaybeGrimm: The script which you have quoted, is used to embed comments to image file. In your other thread you mentioned you need a script which can create 'Single Info-file'. Can you please clarify as to which kind of script you are looking for?
Reply With Quote
  #240  
Old 30.11.2017, 23:11
MaybeGrimm MaybeGrimm is offline
Ultra Loader
 
Join Date: Nov 2017
Posts: 45
Default

Quote:
Originally Posted by mgpai View Post
@MaybeGrimm: The script which you have quoted, is used to embed comments to image file. In your other thread you mentioned you need a script which can create 'Single Info-file'. Can you please clarify as to which kind of script you are looking for?
The single info file was a second option, but what I wanted was that the comments appear in the file metadata. Just that I didn't tought that was possible, but it's what I prefer (and what this script does, if I don't misunderstand).
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 03:53.
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.