This is my "Package Finished" script.
It will run when I downloaded a YT Video to a specific directory.
The downloaded video will then be moved to a remote host by calling a shell script.
Should the moving fail, and so the video still be there, I pop up an alert and want to set the comment accordingly.
Unfortunately neither setting the comment on the package nor on the link does have any effect.
Can someone please guide me here?
Code:
// move YT Video to target
// Trigger Required: "Package Finished"
// Forum Post used as basis: https://board.jdownloader.org/showpost.php?p=386822&postcount=18
package.setComment("copying...");
var links = package.getDownloadLinks();
var failure = 0;
for (i = 0; i < links.length; i++) {
var link = links[i];
var file = link.getDownloadPath();
var pos = file.indexOf('/jdyt/');
if (pos >= 0) {
callSync('/Users/skeeve/bin/jdyt2target.bash', file.substr(0,pos+6), file.substr(pos+6));
var myFilePath = getPath(file);
if (myFilePath.exists()) {
++failure;
alert(comment);
var comment = "Couldn't copy " + file.substr(pos+6);
link.setComment(comment);
package.setComment(comment);
} else {
link.setComment("ok");
}
}
}
if (failure == 0) package.setComment("ok");