Quote:
Originally Posted by GreenXIII
... combine multiple downloaded links, with the same package name and same download directory, into a single package?
|
Keep a backup of your link list before testing/using the script.
Code:
/*
Merge download packages which have matching name and download folder, sorting links in descending order by ID.
Trigger: Toolbar button pressed
Customize main toolbar > Add a new "Eventscripter Trigger" button > Rename it to "Merge Packages" (case-sensitive) > Change Icon (optional)
*/
if (name == "Merge Packages") {
getAllFilePackages().forEach(function(package) {
if (package) {
var packages = [];
getAllFilePackages().forEach(function(package2) {
if (package2.name + package2.downloadFolder == package.name + package.downloadFolder) {
packages.push(package2);
}
})
if (packages.length > 1) {
var linkIds = [];
packages.forEach(function(package3) {
package3.downloadLinks.forEach(function(link) {
linkIds.push(link.UUID);
})
})
linkIds.sort().forEach(function(linkId) {
callAPI("downloadsV2", "moveLinks", [linkId], -1, package.UUID);
})
}
}
})
}