Quote:
Originally Posted by Amiganer
Setting an option should be no problem.
(Please put it in comments of the script, so it is not forgotten.)
|
Caution: This script will move finished links to a different package.
Code:
// Move finished link to user-defined package
// Trigger: A Download stopped
// IMPORTANT: Disable "GeneralSettings.movefilesifdownloaddestinationchangesenabled" in advanced settings
if (link.isFinished()) {
var newPkgName = "Already Downloaded"; // <- Package name to which the finished link will be moved
var linkIds = [link.getUUID()];
var destPackageID = null;
getAllFilePackages().some(function(package) {
if (package.getName() == newPkgName) {
destPackageID = package.getUUID();
return true;
}
})
if (destPackageID) {
callAPI("downloadsV2", "moveLinks", linkIds, null, destPackageID);
} else {
callAPI("downloadsV2", "movetoNewPackage", linkIds, null, newPkgName, null);
}
}
Quote:
Originally Posted by Amiganer
Is there a documentation for the EventScript? Till now I have not found anything....
|
A list of available methods (with some examples) can be found in the eventscripter script editor (Main Menu > Show/Hide Help). You can also use MYJD API methods in the eventscripter (using callAPI method).
Code:
my.jdownloader.org/developers
If you need additional info/help, you can post your queries here. You can also find me/Jiaz in JD Chat.
Added 2020.07.05
Code:
// Move finished links to user-defined package
// Trigger: Package Finished
// IMPORTANT: Disable "GeneralSettings.movefilesifdownloaddestinationchangesenabled" in advanced settings
var destPackageID,
linkIds = [],
date = new Date().toISOString().replace(/(.{4})-(.{2}).+/, "$1$2"),
newPkgName = "Already Downloaded " + date; // <- Package name to which the finished link will be moved
getAllFilePackages().some(function(package) {
if (package.name == newPkgName) {
destPackageID = package.UUID;
return true;
}
})
package.getDownloadLinks().forEach(function(link) {
if (link.finished) linkIds.push(link.UUID);
})
if (destPackageID) {
callAPI("downloadsV2", "moveLinks", linkIds, null, destPackageID);
} else {
callAPI("downloadsV2", "movetoNewPackage", linkIds, null, newPkgName, null);
}