JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1561  
Old 25.10.2020, 08:39
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

Thank you very much!

I have to replace the last two of these (three related) scripts with that new one, is it right:


Is there a way to mark (by color or so) / recognize scripts belonging together in the Even Scripter?
__________________
Aktuelles Windows

Last edited by Dockel; 25.10.2020 at 08:41.
Reply With Quote
  #1562  
Old 25.10.2020, 08:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Dockel View Post
I have to replace the last two of these (three related) scripts with that new one, is it right:
Yes. Correct.
Reply With Quote
  #1563  
Old 25.10.2020, 08:57
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

OK, all done. Works great! Many thanks again!
__________________
Aktuelles Windows
Reply With Quote
  #1564  
Old 26.10.2020, 18:57
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

Quote:
Originally Posted by Dockel View Post
Is there a way to mark (by color or so) / recognize scripts belonging together in the Even Scripter?
Nice idea! For example in edit dialog you can specify a colour, okay?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1565  
Old 26.10.2020, 20:31
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

Yes, that would be great, of course! Thank you!

So here, may be a second (colored) arrow (within a column or so):
__________________
Aktuelles Windows
Reply With Quote
  #1566  
Old 27.10.2020, 06:21
abrenoch abrenoch is offline
JD Alpha
 
Join Date: Apr 2010
Posts: 21
Default

Could someone maybe help me out please?

I am trying to make a 'new crawler job' script, but the 'var myCrawlerJob = job;' line to get the added job doesn't seem to work. it always results in an undefined variable.

Thanks in advance!
Reply With Quote
  #1567  
Old 27.10.2020, 07:52
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by abrenoch View Post
I am trying to make a 'new crawler job' script, but the 'var myCrawlerJob = job;' line to get the added job doesn't seem to work. it always results in an undefined variable.
Appears to be working fine. Can you post the script here or provide more information it?
Reply With Quote
  #1568  
Old 27.10.2020, 09:36
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@Dockel: It would prefer "color picker" within the already existing edit dialog

@abrenoch: please provide your script and also what trigger you are using
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1569  
Old 27.10.2020, 09:43
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default

Quote:
@Dockel: It would prefer "color picker" within the already existing edit dialog
Sorry, I do not know what that means, but I assume, whatever you will build will be good.
__________________
Aktuelles Windows
Reply With Quote
  #1570  
Old 28.10.2020, 03:18
abrenoch abrenoch is offline
JD Alpha
 
Join Date: Apr 2010
Posts: 21
Default

Quote:
Originally Posted by Jiaz View Post
@abrenoch: please provide your script and also what trigger you are using
Here is the code I am fiddling with:

Code:
// Trigger required: "New Crawler Job".
var myCrawlerJob = job;
function log(content) {
  writeFile(JD_HOME + "/log.txt", JSON.stringify(content) + "\r\n", true);
}
log(Date.now())
log(myCrawlerJob)
That is the same trigger I am using. If I pass something like "**External links are only visible to Support Staff** (but it could be anything), I only ever get this output:

1603847718298
undefined

Per the help section, it seems like I should be getting something:
// ========= Properties for the EventTrigger 'New Crawler Job' =========
var myCrawlerJob = job;

I'm just trying to test things at this point

Last edited by abrenoch; 28.10.2020 at 03:28.
Reply With Quote
  #1571  
Old 28.10.2020, 10:41
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

Working fine here. Have you made sure to set the trigger to "New Crawler Job"?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1572  
Old 28.10.2020, 11:53
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by abrenoch View Post
// ========= Properties for the EventTrigger 'New Crawler Job' =========
var myCrawlerJob = job;
It is a sandbox object, and as such you cannot 'stringify' it. You have to use the corresponding object methods to access the listed properties and then write them to a file.
Reply With Quote
  #1573  
Old 28.10.2020, 13:45
abrenoch abrenoch is offline
JD Alpha
 
Join Date: Apr 2010
Posts: 21
Default

Quote:
Originally Posted by Jiaz View Post
Working fine here. Have you made sure to set the trigger to "New Crawler Job"?
Yup, absolutely certain. Event tried removing that job and remaking it. I do have some updates available so I'll try again after applying those.

Quote:
Originally Posted by mgpai View Post
It is a sandbox object, and as such you cannot 'stringify' it. You have to use the corresponding object methods to access the listed properties and then write them to a file.
I was trying that as well... But when I tried to 'getSourceUrl' I would only ever get a "cannot call method getSourceUrl of undefined". I'll try again after updating, but I had that thought as well and calling a method didn't seem to help.
Reply With Quote
  #1574  
Old 28.10.2020, 14:14
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@abrenoch: no updates because no issues. Just tried and worked fine on first try.
Can you show a screenshot of the eventscripter extension, table/list of scripts
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1575  
Old 28.10.2020, 23:55
abrenoch abrenoch is offline
JD Alpha
 
Join Date: Apr 2010
Posts: 21
Default

Quote:
Originally Posted by Jiaz View Post
@abrenoch: no updates because no issues. Just tried and worked fine on first try.
Can you show a screenshot of the eventscripter extension, table/list of scripts


Sending the url to this forum post, for example, yielded a couple triggers but always an 'undefined' job:

1603922086067
undefined
1603922097095
undefined

Thanks for the help!
Reply With Quote
  #1576  
Old 29.10.2020, 11:58
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

As mgpai already explained, you cannot JSON.stringify on the job as it is no Object/Map that supports JSON conversion.
You have to write out the fields you are interested in
Quote:
/* === CrawlerJob === */
/* ========= Methods =========*/
var myList = myCrawlerJob.getArchivPasswords();
var myString = myCrawlerJob.getOrigin();
var myString = myCrawlerJob.getPassword();
var myString = myCrawlerJob.getSourceUrl();
var myString = myCrawlerJob.getText();
var myString = myCrawlerJob.getUUID();
var myBoolean = myCrawlerJob.isAssignJobID();
var myBoolean = myCrawlerJob.isDeepAnalysisEnabled();
myCrawlerJob.setAssignJobID(myBoolean);
myCrawlerJob.setDeepAnalysisEnabled(myBoolean);
myCrawlerJob.setPassword(myString);
myCrawlerJob.setText(myString);
__________________
JD-Dev & Server-Admin

Last edited by raztoki; 29.10.2020 at 12:38.
Reply With Quote
  #1577  
Old 30.10.2020, 05:56
dereks10 dereks10 is offline
Vacuum Cleaner
 
Join Date: Sep 2020
Posts: 16
Default

Hey guys, ive been looking to enable some sort of multi directory duplicate check, just like it is now, except multiple directories ( 2nd - 3rd ssd , external hdds ) etc. I searched a good while, came upon this thread, and have searched it. Didnt find a final solution, anyone point me in the right direction?
Thanks.
Reply With Quote
  #1578  
Old 30.10.2020, 08:06
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by dereks10 View Post
... ive been looking to enable some sort of multi directory duplicate check, just like it is now, except multiple directories ( 2nd - 3rd ssd , external hdds ) etc.
JD checks if a file exists, only in the save location/folder of the link (not the sub-folders).

Scanning/matching entire contents of multiple drives using a script is resource intensive and time consuming. By the time a dupe is detected, the file would have triggered captcha and/or will be partially downloaded.

The download locations are usually limited to certain folders. Optimal method would be to use a script to specify/scan only those folders and disable the links.

Such a script can be found HERE.
Reply With Quote
  #1579  
Old 04.11.2020, 16:56
GreenXIII GreenXIII is offline
Bandwidth Beast
 
Join Date: Mar 2013
Posts: 145
Default

Hi. I've been wondering if it's possible to tidy up my download list with a script.

Is it possible to combine multiple downloaded links, with the same package name and same download directory, into a single package?

I've got over 127,000 downloaded links that I keep to avoid adding duplicates. If I could combine packages and sort files within them from newest to oldest, it would look much more organized.

EDIT: if matching both package name and directory is too much, I'd say grouping by directory and using its name as the package name would suffice.

Last edited by GreenXIII; 04.11.2020 at 19:56.
Reply With Quote
  #1580  
Old 04.11.2020, 17:06
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@GreenXIII: should be possible , maybe mgpai can help you with it He's the script master of the universe
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1581  
Old 05.11.2020, 06:46
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by GreenXIII View Post
... 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);
                })
            }
        }
    })
}
Reply With Quote
  #1582  
Old 05.11.2020, 14:11
DragoBleaPiece DragoBleaPiece is offline
Baby Loader
 
Join Date: Jun 2020
Posts: 7
Default

Quote:
Originally Posted by mgpai View Post
Code:
/*
    Toggle packagizer extension
    Trigger: Toolbar Button Pressed
    Customize main toolbar > Add a new 'Eventscripter Trigger' button > Rename it to "Toggle Packagizer" (without quotes, case-sensitive) > Change Icon (optional)
*/

if (name == "Toggle Packagizer") {
    var interfaceName = "org.jdownloader.controlling.packagizer.PackagizerSettings",
        key = "PackagizerEnabled",
        value = callAPI("config", "get", interfaceName, null, key),
        message = "Packagizer " + (value ? "disabled." : "enabled.");

    callAPI("config", "set", interfaceName, null, key, !value) && alert(message);
}
Hello, Script Master!
Can we use this script for enabling/disabling particular packagizer rules, not all of em? Thank you so much
Reply With Quote
  #1583  
Old 05.11.2020, 14:15
DragoBleaPiece DragoBleaPiece is offline
Baby Loader
 
Join Date: Jun 2020
Posts: 7
Default

Quote:
Originally Posted by mgpai View Post
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);
                })
            }
        }
    })
}
I wanna put all my link that i have into one package, rite now it's all over the place. Could you help me plz? Thx in advance
Reply With Quote
  #1584  
Old 05.11.2020, 14:45
DragoBleaPiece DragoBleaPiece is offline
Baby Loader
 
Join Date: Jun 2020
Posts: 7
Default

I don't know where should i ask about this. So, i wanna put all my download URLs after the file has been downloaded into a file (txt or smth), and for the next download, the URL should be checked first with that file containing finished download URLs
Any solution for this? Thank you
Reply With Quote
  #1585  
Old 06.11.2020, 12:39
GreenXIII GreenXIII is offline
Bandwidth Beast
 
Join Date: Mar 2013
Posts: 145
Default

Quote:
Originally Posted by mgpai View Post
Keep a backup of your link list before testing/using the script.

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") {

...
}[/CODE]
Thank you very much. But the script is not working for me.
I'm setting the script to start as JDownloader starts, is that correct?
I'm getting a "ReferenceError: "name" is not defined (#7)" error when JD2 loads.
Reply With Quote
  #1586  
Old 06.11.2020, 12:52
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@GreenXIII: made sure to set the correct trigger event type?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1587  
Old 07.11.2020, 00:08
GreenXIII GreenXIII is offline
Bandwidth Beast
 
Join Date: Mar 2013
Posts: 145
Default

Quote:
Originally Posted by Jiaz View Post
@GreenXIII: made sure to set the correct trigger event type?
Ok, found my mistake, had to configure the toolbar button and set the script to "Toolbar button pressed"

It's working! But it's very slow. I think it does one link per second. Isn't there a way to make it check the packagenames instead of each link at a time?

EDIT: it was slow because it was running all morning and afternoon. After I restarted JD and ran it again, it got fast again.

EDIT: also, it ignores uppercases/lowercases and treat them as different

Last edited by GreenXIII; 07.11.2020 at 00:26.
Reply With Quote
  #1588  
Old 07.11.2020, 08:00
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by GreenXIII View Post
... it's very slow. I think it does one link per second. Isn't there a way to make it check the packagenames instead of each link at a time?
It does match only package names and download folders. But, the additional task of sorting links in a desired order can considerably slow it down. Can also be caused by insufficient memory. You can try allocating more memory to JD.

Quote:
Originally Posted by GreenXIII View Post
...it ignores uppercases/lowercases and treat them as different
That is the default behavior, which is in line with case-sensitive file systems. To ignore both package and folder case, replace the following code:
Code:
if (package2.name + package2.downloadFolder == package.name + package.downloadFolder) {

with:
Code:
if ((package2.name + package2.downloadFolder).toLowerCase() == (package.name + package.downloadFolder).toLowerCase()) {
Reply With Quote
  #1589  
Old 07.11.2020, 08:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by DragoBleaPiece View Post
Can we use this script for enabling/disabling particular packagizer rules, not all of em?
While possible, will require you to create separate buttons for each rule you want to disable, which may not be practical. A better option would be to make the rule more restrictive and force it to match only under certain conditions.

Quote:
Originally Posted by DragoBleaPiece View Post
I wanna put all my link that i have into one package, rite now it's all over the place.
Feature already present in GUI. You can select links and use the context menu command "Move to new package". Please note that the corresponding files existing on disk will also be moved to single/same folder. You can disable the following advanced setting to move only the links and keep the files in their original location.

Code:
GeneralSettings.movefilesifdownloaddestinationchangesenabled

Quote:
Originally Posted by DragoBleaPiece View Post
... i wanna put all my download URLs after the file has been downloaded into a file (txt or smth), and for the next download, the URL should be checked first with that file containing finished download URLs
THIS thread contains a script for similar request.
Reply With Quote
  #1590  
Old 10.11.2020, 12:45
GreenXIII GreenXIII is offline
Bandwidth Beast
 
Join Date: Mar 2013
Posts: 145
Default

I've been using this script for restarting downloads that are too slow. It works, many sites get a faster DL speed after resuming.
But it has two flaws: I don't think it excludes non-resumable downloads. And it restarts the download way too fast. Some sites don't like that. For example, video.fc2 gets corrupted videos due to it.

Code:
// Stop and restart slow links.
// Trigger Required: "Interval" (Recommended: 30000 or more).
// IMPORTANT: Enable "Synchronous execution of script" (checkbox).

var minSpeed = 500; // (KiB/s) <- minimum download speed per link.
var minDuration = 1; // (minutes) <- minimum download duration per link.

var links = getRunningDownloadLinks();

for (i = 0; i < links.length; i++) {
    var link = links[i];
    if (link.getDownloadDuration() < minDuration * 60 * 1000) continue;
    if (link.getSpeed() > minSpeed * 1024) continue;
    link.abort();
    sleep(30000); //I've added this, but it's not working
}
I'd like it to do one of two things (or both, via a toggeable variable):
1) Go to another download and come back after that to the current one;
2) Have a longer timer between retrying the current download.

I haven't tried a non-resumable download yet, but if the script doesn't ignore those, I'd like it to do so.
Reply With Quote
  #1591  
Old 10.11.2020, 13:54
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by GreenXIII View Post
... script for restarting downloads that are too slow ...
Code:
/*
    Skip/Unskip resumable links, based on user-specified speed and duration
    Trigger: Interval (Recommended 60000 or more)
*/

var links = [];

getRunningDownloadLinks().forEach(function(link) {
    if (
        link.resumeable &&
        link.downloadDuration > 60 * 1000 && // minimum download duration (milliseconds)
        link.speed < 500 * 1024 // minimum speed (bytes)
    ) {
        link.skipped = true;
        links.push(link);
    }
})

if (links.length) {
    sleep(30000); // time to wait before unskipping links (milliseconds);

    links.forEach(function(link) {
        link.skipped = false;
    })
}
Reply With Quote
  #1592  
Old 11.11.2020, 17:05
Rodark Rodark is offline
Modem User
 
Join Date: Aug 2020
Posts: 4
Default

is there a script that when a download speed drops at 130kbs, it can stop all downloads and immediately restart them?
i found one but it takes time to stop and restart
im downloading from a site that has only a 64~kbps per download(max 2) BUT when the download starts, it starts with max speed and drops.
Meaning, when i start the download its 6-7Mbps and it gradually drops to 130kbps . So i need a script that when it drops at that, it stop and restarts asap. the one im using it takes a couple of minutes to restart

Last edited by Rodark; 11.11.2020 at 17:12.
Reply With Quote
  #1593  
Old 11.11.2020, 17:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Rodark View Post
is there a script that when a download speed drops at 130kbs, it can stop all downloads and immediately restart them?
i found one but it takes time to stop and restart
Which script did you use? Stopping downloads usually takes a few seconds.
Reply With Quote
  #1594  
Old 11.11.2020, 17:23
Rodark Rodark is offline
Modem User
 
Join Date: Aug 2020
Posts: 4
Default

Quote:
Originally Posted by mgpai View Post
Which script did you use? Stopping downloads usually takes a few seconds.
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;
}
}
thats the one im using. found it on another page/thread

it isnt instant for me, it takes a little time to restart. so currently im manually stop/restarting. can it be modified to stop and restart on the spot if the speed is less than 140 kbps?
Reply With Quote
  #1595  
Old 11.11.2020, 17:58
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Rodark View Post
... stop and restart on the spot if the speed is less than 140 kbps?
Try this:
Code:
/*
    Restart download links if the current average speed is less than user-specified speed
    Trigger Required: Interval (Recommended 30000 or more)
*/    

var minSpeed = 140, // (KiB/s) <- minimum average download Speed
    minDuration = 60, // (seconds) <- minimum download duration per link
    running = getRunningDownloadLinks().every(function(link) {
        return link.downloadDuration > minDuration * 1000;
    });

if (running && getAverageSpeed() < minSpeed * 1024) {
    getRunningDownloadLinks().forEach(function(link) {
        link.abort();
    })
}
Reply With Quote
  #1596  
Old 11.11.2020, 18:39
Rodark Rodark is offline
Modem User
 
Join Date: Aug 2020
Posts: 4
Default

Quote:
Originally Posted by mgpai View Post
Try this:
Code:
/*
    Restart download links if the current average speed is less than user-specified speed
    Trigger Required: Interval (Recommended 30000 or more)
*/    

var minSpeed = 140, // (KiB/s) <- minimum average download Speed
    minDuration = 60, // (seconds) <- minimum download duration per link
    running = getRunningDownloadLinks().every(function(link) {
        return link.downloadDuration > minDuration * 1000;
    });

if (running && getAverageSpeed() < minSpeed * 1024) {
    getRunningDownloadLinks().forEach(function(link) {
        link.abort();
    })
}
thank you for this! it does take around a minute for it to realize it has dropped speed, but the stop/start action is instant! thanks mate
Reply With Quote
  #1597  
Old 11.11.2020, 18:48
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Rodark View Post
... it does take around a minute for it to realize it has dropped speed...
For faster response, you can reduce the script interval (recommended is 30000 ms) and also the minDuration (default in the script is 60 seconds).

The download will usually require a few seconds to reach max speed. Experiment with different values and keep them large enough to prevent false stop/start loops.
Reply With Quote
  #1598  
Old 11.11.2020, 19:03
Rodark Rodark is offline
Modem User
 
Join Date: Aug 2020
Posts: 4
Default

thanks for the info mate!
Reply With Quote
  #1599  
Old 12.11.2020, 14:59
little little is offline
DSL User
 
Join Date: Mar 2009
Posts: 39
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
// Version 2017.11.14
/* *************************************************************************
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 = "avec sous-titres";

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

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 ======= */

    // Replace &amp; with &
    re = new RegExp("&amp;", "gi");
    fileName = fileName.replace(re, "&");

    // 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);
}
I wanted to try it :
Code:
java.lang.NullPointerException
        at org.jdownloader.extensions.eventscripter.ScriptThread$1.compare(ScriptThread.java:301)
        at org.jdownloader.extensions.eventscripter.ScriptThread$1.compare(ScriptThread.java:298)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1338)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1350)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1350)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1349)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1350)
        at java.base/java.util.Arrays.mergeSort(Arrays.java:1350)
        at java.base/java.util.Arrays.legacyMergeSort(Arrays.java:1317)
        at java.base/java.util.Arrays.sort(Arrays.java:1304)
        at java.base/java.util.ArrayList.sort(ArrayList.java:1721)
        at java.base/java.util.Collections.sort(Collections.java:179)
        at org.jdownloader.extensions.eventscripter.ScriptThread.cleanupClasses(ScriptThread.java:298)
        at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:178)
        at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:160)
Any idea on how to fix it ? Thank you very much.
Reply With Quote
  #1600  
Old 12.11.2020, 15:57
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

@little: please create a log, see https://support.jdownloader.org/Know...d-session-logs
and post logID here
__________________
JD-Dev & Server-Admin
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 18:55.
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.