JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1721  
Old 19.05.2021, 21:50
namyar namyar is offline
JD Beta
 
Join Date: Apr 2016
Posts: 51
Question

Quote:
Originally Posted by namyar View Post
Works like a charm, thank you very much!
It seems that due to this script, links aren't always automatically transfered to the downloads tab but have to be added manually. Link crawler is set to transfer and start downloads by default, yet it fails to do so on occasion.
Reply With Quote
  #1722  
Old 26.05.2021, 14:35
sancrage sancrage is offline
Baby Loader
 
Join Date: Jul 2018
Posts: 5
Default

Hello,

Sorry to bother you, but wonder if there is a way to rename the filename to be the same as the directory when I provide the save path?

Thanks.
Reply With Quote
  #1723  
Old 26.05.2021, 15:03
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by sancrage View Post
... wonder if there is a way to rename the filename to be the same as the directory when I provide the save path?
Currently it is only possible to dynamically update/sync filename and/or downloadpath with the packagename. There is no variable or placeholder to access the save path. You will have to set the save path first and then use a script to rename the file based on it.

If however there is common logic/pattern in genrating the save path, for e.g. based on file name, download url, source url, etc., you can use packagizer rule or script to set them both at the same time.

If you provide some working examples I can look into it.
Reply With Quote
  #1724  
Old 26.05.2021, 15:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by namyar View Post
It seems that due to this script, links aren't always automatically transfered to the downloads tab but have to be added manually. Link crawler is set to transfer and start downloads by default, yet it fails to do so on occasion.
The script is executed even before packagizer rules are applied, so it is very unlikely that it is caused by it. In other words, the problem cannot be resolved by modifying the script.

Please wait for feedback from @Jiaz. In the meanwhile, you can try increasing the following advanced setting:
Code:
LinkgrabberSettings.autoconfirmdelay
Reply With Quote
  #1725  
Old 04.06.2021, 15:38
A-Dude A-Dude is offline
I will play nice!
 
Join Date: Jun 2021
Posts: 3
Default

Hi there,

id like a modification of this script

https://board.jdownloader.org/showpo...&postcount=881

The script restart JD just when JD is in idle, but my JD is never in idle

Is it possible that when a new update is availible, JD doesn´t start new downloads but finish current running downloads and then do the restart?
Reply With Quote
  #1726  
Old 04.06.2021, 15:41
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

Quote:
Originally Posted by A-Dude View Post
Is it possible that when a new update is availible, JD doesn´t start new downloads but finish current running downloads and then do the restart?
@mgpai: set stopmark on running download, then downloads will finish and then idle and then restart, that should work, via api
downloadsV2/setStopMark(long linkId, long packageId)
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 04.06.2021 at 15:50.
Reply With Quote
  #1727  
Old 04.06.2021, 16:26
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Jiaz View Post
@mgpai: set stopmark on running download, then downloads will finish and then idle and then restart, that should work, via api downloadsV2/setStopMark(long linkId, long packageId)
New downloads can still start till the link/package with stop mark is finished.
Reply With Quote
  #1728  
Old 04.06.2021, 16:27
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

Quote:
Originally Posted by mgpai View Post
New downloads can still start till the link/package with stop mark is finished.
set stopmark on disabled link and no further downloads will start, else further downloads will stop once the stopmark link is finished/failed or at least tried once
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 04.06.2021 at 16:31.
Reply With Quote
  #1729  
Old 04.06.2021, 16:49
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Jiaz View Post
set stopmark on disabled link and no further downloads will start, else further downloads will stop once the stopmark link is finished/failed or at least tried once
Still a bit complicated since the trigger is interval. The stopmark will be set on each run. Also disabling a link just to set the stopmark is not an elegant solution. Will think of something.
Reply With Quote
  #1730  
Old 04.06.2021, 17:08
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by A-Dude View Post
Is it possible that when a new update is availible, JD doesn´t start new downloads but finish current running downloads and then do the restart?
Code:
/*
    if update is avaialble, finish running downloads and restart and update when JD is Idle
    Trigger Required: Interval
    Set Interval to 600000 or more
*/

var updateAvailable = callAPI("update", "isUpdateAvailable");

if (
    updateAvailable &&
    isDownloadControllerRunning() &&
    !getProperty("skipped", false)
) {
    getAllDownloadLinks().forEach(function(link) {
        if (!link.running && !link.finished) {
            link.skipped = true;
        }
    });

    setProperty("skipped", true, false);
}

if (
    updateAvailable &&
    !callAPI("linkcrawler", "isCrawling") &&
    !callAPI("linkgrabberv2", "isCollecting") &&
    !callAPI("extraction", "getQueue").length &&
    isDownloadControllerIdle()
) {
    callAPI("update", "restartAndUpdate");
}

Code:
/*
    if update is avaialble, finish running downloads and restart and update when JD is Idle
    Trigger Required: Interval
    Set Interval to 600000 or more
*/

var updateAvailable = callAPI("update", "isUpdateAvailable");

if (
    updateAvailable &&
    isDownloadControllerRunning() &&
    callAPI("downloadsV2", "getStopMark") == -1
) {
    callAPI("downloadsV2", "setStopMark", 0, 0);
}

if (
    updateAvailable &&
    !callAPI("linkcrawler", "isCrawling") &&
    !callAPI("linkgrabberv2", "isCollecting") &&
    !callAPI("extraction", "getQueue").length &&
    isDownloadControllerIdle()
) {
    callAPI("update", "restartAndUpdate");
}

Last edited by mgpai; 04.06.2021 at 18:40. Reason: Replaced script with one which uses new method.
Reply With Quote
  #1731  
Old 04.06.2021, 17:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Jiaz View Post
@mgpai: set stopmark on running download, then downloads will finish and then idle and then restart, that should work, via api downloadsV2/setStopMark(long linkId, long packageId)
This is more suitable, but difficult to control precisely, since it is toggle:
Code:
/toolbar/toggleStopAfterCurrentDownload
Reply With Quote
  #1732  
Old 04.06.2021, 17:22
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

@mgai: just set stopmark on any running download. I don't think that it's that impotant and the script will work fine again
I can also add new method to specifically set stopmark to stop new downloads instant, if you prefer that
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1733  
Old 04.06.2021, 17:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Jiaz View Post
@mgai: just set stopmark on any running download. I don't think that it's that impotant and the script will work fine again
The default behavior stopmark of is perfectly fine and as it should be. It might not be suitable in cases like this, especially if there are many downloads above the link/package on which the stopmark is set. If for e.g. connection is lost JD will try/skip several downloads and end up starting a new download way down the list, the stopmark could be set anywhere. It will not be an issue when the user sets the stopmark manually, since it is set specifically on a chosen link/package.

Quote:
I can also add new method to specifically set stopmark to stop new downloads instant, if you prefer that
This might be a one off case, and the current solution should work just fine.
Reply With Quote
  #1734  
Old 04.06.2021, 17:49
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

@mgpai:I can add new set stopmark method that also supports the *don'T start any new downloads* handling.

after next core update new logic for setStopMark
linkID and packageID = -1 = NONE, same as removeStopMark
linkID and packageID = 0 = HIDDEN, special mode to instant stop new downloads and just finish running ones
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 04.06.2021 at 18:00.
Reply With Quote
  #1735  
Old 04.06.2021, 18:10
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Jiaz View Post
after next core update new logic for setStopMark
Nice. Thanks Jiaz.
Reply With Quote
  #1736  
Old 04.06.2021, 18:12
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

Quote:
Originally Posted by mgpai View Post
Nice. Thanks Jiaz.
will be available in 5 mins
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1737  
Old 04.06.2021, 18:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Jiaz View Post
will be available in 5 mins
Updated the script with new method. Working fine. Thanks Jiaz.
Reply With Quote
  #1738  
Old 04.06.2021, 19:07
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

@mgpai: Thanks for the feedback
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1739  
Old 04.06.2021, 22:58
A-Dude A-Dude is offline
I will play nice!
 
Join Date: Jun 2021
Posts: 3
Default

Big thanks to mgpai and Jiaz!
I added the script (the first one for my JD ) and note the startup time.

Im realy happy now, my JD will be up to date and i don´t have to manually set stopmarks and trigger the restart
Reply With Quote
  #1740  
Old 07.06.2021, 12:31
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

@A-Dude: All thanks goes to mgpai
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1741  
Old 08.06.2021, 00:10
A-Dude A-Dude is offline
I will play nice!
 
Join Date: Jun 2021
Posts: 3
Default

So today there was an update and the script works fine.

There where two downloads running, first with 25 minutes left and second with 5h 20 min. After the first download was completed, no more download started. The second download was resumable, i stoped it manualy and after some minutes jdownloader did the restart.

How i understand the script, it starts every 10 minutes and if there an update it remove stopmarks and set new once.

And there is my new modification wish. Is it possible after setting stopmarks, to check if the running downloads are resumable, when yes -> stop downloads do the restart?
Reply With Quote
  #1742  
Old 08.06.2021, 14:07
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

Quote:
Originally Posted by A-Dude View Post
How i understand the script, it starts every 10 minutes and if there an update it remove stopmarks and set new once.
It only sets a new stopmark if none set yet.

Quote:
Originally Posted by A-Dude View Post
And there is my new modification wish. Is it possible after setting stopmarks, to check if the running downloads are resumable, when yes -> stop downloads do the restart?
Should be possible but always keep in mind that this could also mean *loosing* a captcha. Maybe you've solved a captcha just to see JDownloader 2 mins later
to update itself and ask again for a new captcha in my opinion I would just let the running downloads finish and then update JD
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1743  
Old 11.06.2021, 15:47
VanTuz VanTuz is offline
Linkgrabbing Monster
 
Join Date: Oct 2018
Posts: 80
Default

How to make it so that when downloading from e-hentai fails, a reconnection is automatically started, and then the download of files is restarted?
Reply With Quote
  #1744  
Old 11.06.2021, 16:01
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

@VanTuz: Why does the download fail? Can you provide a log? Sounds more like we should check/fix the plugin
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1745  
Old 11.06.2021, 16:15
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 70,918
Default

@VanTuz
This is probably not related to our EventScripter feature.
Please post your request via separate thread in this subforum or use older threads related to e(x)hentai e.g. this one.

-psp-
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #1746  
Old 19.06.2021, 16:14
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

Goodmorning everyone.

1)

I am using the script to automatically rename the files suggested to me in this topic at the time, and I have noticed that every now and then a file is "skipped"; [I solved it by creating a duplicate of the script commanded by "button"] , but, on a curiosity level, you can write a command inside the script to tell it like "run me N times in a row" ?


2)
is feasible a script (perhaps better by button) which:
-set interrupted - unfinished downloads to "resume"
-start the download
(and do it N times , at each time interval at the end of the download ?)


or a script that at the end of the download of the links of all the packages (not file by file) :
- find if there are interrupted / unfinished downloads
- If Yes --> set then to "resume"
-start the download.


rereading it seems a bit strange speech, but I hope you can understand what I meant.
Reply With Quote
  #1747  
Old 19.06.2021, 16:48
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by BJN01 View Post

1)
... you can write a command inside the script to tell it like "run me N times in a row" ?
Can you post the script, or if it is in the forum, a link to it?

Quote:
2)
.. is feasible a script ... set interrupted - unfinished downloads to "resume" ...?
By default JD will retry all pending download for as long/as many times as possible. If for any reason the downloads fail, it will be skipped with relevant status message and only then the download controller will be stopped.

What kind of status messages are displayed for the failed/interrupted downloads?
Reply With Quote
  #1748  
Old 19.06.2021, 18:55
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

1) the script is based on this :
https://board.jdownloader.org/showpo...postcount=1155 (page 58 , post n #1155)
but with:
- trigger "Hook packaging"
- change both by name of individual files and by packages
and it's something similar to this:

Spoiler:

Code:
/--------------------------------------------------------
// <Clean Names> ( file + package)
// Trigger: packaged Hook
//
// For Name Of the Package (PACKAGENAME)
//
disablePermissionChecks();
if (name = CupPH = "Clean-up packagenames Hook") {
    getAllCrawledPackages().forEach(function(package) {
        var curName = package.getName();
        var newName = curName;
        var replace = function(find, replace) {
            newName = newName.replace(find, replace);
        }

        replace("-Vol ","-V0");
        replace("Ch ","Ch");
        replace("-Chapter ","-Ch");
        replace("Ch_","Ch");     
        
        
 replace("chapter ","Ch");      
        replace("&amp;","e");
//... omiss..
        replace("&ndash;","-");
        replace("I Can&rsquo;t","I Can't");
//... omiss...
        replace("Won&rsquo;t","Won t");
        replace("Didn&rsquo;t","Didn t");
        replace("I&rsquo;m ","I m ");
        replace("King&rsquo;s","King s");
//.....omisss....
        replace("Chapter_Chapter","Ch");
        replace("ChCh","Ch");
       
        replace("--","-");
        //.....omisss.....
        replace("☆ ",""); 
        replace("【","["); 
        replace("】","]"); 
        replace("①",""); 
        replace(/[~]/g,"-");
        replace(/["]/g," ");
        replace(/[❤:/\*%^°]/g," "); 
        replace("&quot;","");
        replace("《","["); 
        replace("》","]"); 
        replace("「","["); 
        replace("」","]"); 


        if (curName != newName) package.setName(newName);
    })
}
//
// For the name of the file (FILENAME)
//
if (name = CupFH = "Clean-up filenames Hook") {
    getAllCrawledLinks().forEach(function(fileName) {
        var curName = fileName.getName();
        var newName = curName;
        var replace = function(find, replace) {
            newName = newName.replace(find, replace);
        }

        replace("Ch_","Ch");
       //.....omisss.... 
        replace("chapter ","Ch");
        replace("Chapter ","Ch");
        replace(" -Page_","-Page_"); 
        replace(" -Page_h","-Page_");    
            
        
        replace("☆ ","");     
        replace("&amp;","e");
        replace("I Can&rsquo;t","I Can't");
        replace("I&rsquo;m ","I m ");
        replace("King&rsquo;s","King s");
        replace("Chapter_Chapter","Ch");
        //....omiss example ....
        replace("【","["); 
        replace("】","]"); 
        replace("①",""); 
        replace(/[~]/g, "-");
        replace(/["]/g, " ");
        replace(/[❤:/\*%^?<>°]/g, ""); 
        replace("&quot;", "");
        replace("《","["); 
        replace("》","]"); 
        replace("「","["); 
        replace("」","]"); 


        if (curName != newName) fileName.setName(newName);
    })

}


as I said, I solved the "problem" by creating a copy of the scipt combined with "pressed toolbar button" trigger , and clicking on the associated button, the files that are "skipped" from time to time are renamed.


I imagine that if I write a command N times in the script this order is executed N times, but since the "lines" << replace ("AAA", "aaa"); >> are many, the script would become very long , and I would end up getting lost in it to insert other voices.

But could there be some simple lines to add at the end of the script to "double" the effect?

Code:
disablePermissionChecks();
if (name = CupPH = "Clean-up packagenames Hook") {
    getAllCrawledPackages().forEach(function(package) {
        var curName = package.getName();
        var newName = curName;
        var replace = function(find, replace) {
            newName = newName.replace(find, replace);
        }
        replace("-Vol ","-V0");
//..omiss other replace
        if (curName != newName) package.setName(newName);
    })
}

if (name = CupFH = "Clean-up filenames Hook") {
    getAllCrawledLinks().forEach(function(fileName) {
        var curName = fileName.getName();
        var newName = curName;
        var replace = function(find, replace) {
            newName = newName.replace(find, replace);
        }

        replace("Ch_","Ch");
       //.....omisss.... 
        if (curName != newName) fileName.setName(newName);
    })

}

*** repeat "N" times, or
*** execute function "CupFH", execute function "CupPH"



2) yes , after the skipped the dowload stop/end and we have the message of error for the file skipped .

I recently had some skipped files with "file not found" error ;
the files actually exist, but Cloudflare (without captcha) has a hand in it.
But I found that if I set "resume" and restart the dl they are downloaded
(with "restart" the filename changes, it doesn't go through the above script ... and it bothers me).

So I wonder if you can write a script that (at time intervals (e.g. 1 minute)), If detects skipped files :
-set then to "resume"
-start the download.
(a defined number of times (otherwise you risk an infinite loop))
-it there aren't skipped file --> do nothing
Reply With Quote
  #1749  
Old 19.06.2021, 19:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by BJN01 View Post
... as I said, I solved the "problem" by creating a copy of the scipt combined with "pressed toolbar button" trigger , and clicking on the associated button ...
The original script was for button pressed, so it requires a name check. If you are using it with packagizer hook, that is not required. Also your button pressed script contains errors. You should use the comparison operator (==), not "=" sign which assigns a value.

Your rename skipping can be most likely solved with a single script with some modifications. I will need more info on your current scripts/triggers. Find me in JD Chat when you are free:

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader

Quote:
... a script that ... detects skipped files ... set then to "resume" ... start the download.
Code:
/*
    Resume offline links
    Trigger: Download Controller Stopped
*/

var started = false;
    
getAllDownloadLinks().forEach(function(link) {
    
    if (link.finalLinkStatus == "OFFLINE") {

        if (!started) {
            startDownloads();
            started = true;
        }

        link.resume();
    }
})

An interval trigger might not be suitable for this use case. While this script runs only when download controller is stopped, it can result in a loop if the files are permanently offline. Can avoid it by using additional check for only those hosts which are affected by the problem described by you.

Last edited by mgpai; 19.06.2021 at 20:24. Reason: Variable was inside the loop. Moved it outside.
Reply With Quote
  #1750  
Old 21.06.2021, 08:03
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by BJN01 View Post
But could there be some simple lines to add at the end of the script to "double" the effect?
I couldn't quite understand at first what you meant by skipped. You can use this script to replace all occurrences of a string in the file/package names, with a single click.

Code:
/*
    Cleanup names
    Trigger : Toolbar button pressed
*/

if (name == "Cleanup packagenames") {
    getAllCrawledPackages().forEach(function(i) {
        var replace = function(a, b) {
            i.name = i.name.split(a).join(b);
        }

        replace("-Vol ", "-V0");
    })
}

if (name == "Cleanup filenames") {
    getAllCrawledLinks().forEach(function(i) {
        var replace = function(a, b) {
            i.name = i.name.split(a).join(b);
        }

        replace("Ch_", "Ch");
    })
}
Reply With Quote
  #1751  
Old 25.06.2021, 22:19
Far Far is offline
I will play nice!
 
Join Date: Jun 2021
Posts: 2
Default

Great scripts here, very useful, thanks to all contributors!
Reply With Quote
  #1752  
Old 28.06.2021, 01:34
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

@ mgpai
sorry for the late answer , I had unforeseen commitments and didn't have time to try to contact you.

1) x Resume offline links script :

for now I used the code you indicated but with trigger "toolbar button pressed" (I added a button in the toolbar)
Spoiler:

Code:
//Resume offline links and start DL
//trigger: toolbar button pressed
//name scipt =Resume Skipped And DL
//add button "event script" in toolbar and select this script 

var started = false;
    
getAllDownloadLinks().forEach(function(link) {
    
    if (link.finalLinkStatus == "OFFLINE") {

        if (!started) {
            startDownloads();
            started = true;
        }

        link.resume();
    }
})


I tried it and it works. (For what I have to do I have seen that it is enough for now). thanks.
For the trigger "Download Controller Stopped" you have to using additional check for specific hosts , but I don't know how to set them up and probably would be overkill for now.


2) <<...script to automatically rename the files ... every now and then a file is "skipped">>

I try to explain the "phenomenon" I noticed:

- copy link
- JD find the file and hook package
- Now the script "Autorename bla bla" with trigger "packagezer hook" do is job .

So , the package and file they should all be renamed according to the written rules of the script, like :
Code:
original file --------------------------------renamed file          

bla bla bla Vol 1 chapter 55 -----> bla bla bla V01-Ch55 
-fileExample chapter 55 01.jpg--->-fileExample ch-55_01.jpg
-fileExample chapter 55 02.jpg--->-fileExample ch-55_02.jpg
-fileExample chapter 55 03.jpg--->-fileExample ch-55_03.jpg
-fileExample chapter 55 XX.jpg--->-fileExample ch-55_XX.jpg
as I said, the process works perfectly 99% of the time , every now and then a file is "skipped" like this :
Code:
bla bla bla Vol 1 chapter 55 -----> bla bla bla V01-Ch55 
-fileExample chapter 55 01.jpg--->-fileExample ch-55_01.jpg
-fileExample chapter 55 02.jpg--->-fileExample ch-55_02.jpg
-fileExample chapter 55 03.jpg--->-fileExample chapter 55 03.jpg
-fileExample chapter 55 XX.jpg--->-fileExample ch-55_XX.jpg
As I said, I solved the "problem" by creating a copy of the scipt with "pressed toolbar button" trigger + button in toolbar ( and clicking on the associated button, the files that are "skipped" from time to time are renamed)

I would have thought about duplicating the script in order to have a "double" check of the names, but it seemed exaggerated ...
but if I wanted to do this test, is it possible to insert a delay in the execution of the second script?
Reply With Quote
  #1753  
Old 28.06.2021, 05:17
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by BJN01 View Post
every now and then a file is "skipped" like this ...
As mentioned before, the original script was written for toolbar button. The 'packagizer hook' is triggered twice. The script has to be modified to run only once. Also, skipping may occur if 'synchronous execution' is disabled when you are using it with 'packagizer hook'.
Reply With Quote
  #1754  
Old 01.07.2021, 20:58
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

@mgpai

hi, i have updates:

I have made some attempts to fix the script that renames files trying to fix "==" and the like ... but I have not had noticeable results . (most likely the corrections I should make exceed my knowledge on the subject )

BUT ...
Quote:
Also, skipping may occur if 'synchronous execution' is disabled when you are using it with 'packagizer hook'.
with the script without the corrections I have deselected (unchecked the box) at "synchronous execution"
... and problem solved ! no files are skipped.

So if everything continues to work, I'd say I've solved it for now.


p.s =
Quote:
...The 'packagizer hook' is triggered twice. ....
?? Why ?
I have only one script containing the 2 functions (file name + package name) so it should only run 1 time, or am I wrong / ignoring something I don't know?
Reply With Quote
  #1755  
Old 02.07.2021, 10:55
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,289
Default

@BJN01: The packagizer has two stages. One before the linkcheck, one after the linkcheck.
this event has two additional variables, "linkcheckDone" can be true/false and "state" can be "AFTER" and "BEFORE"
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1756  
Old 02.07.2021, 11:37
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Jiaz View Post
@BJN01: The packagizer has two stages. One before the linkcheck, one after the linkcheck.
Before and after linkcheck or before and after packagizer rules are applied? I was of the understanding that it was the latter, since linkcheckDone returns the same value (true) for both BEFORE and AFTER states, while if a package name is set/modified via packagizer rule, it is reflected only in the AFTER state and not in BEFORE state.
Reply With Quote
  #1757  
Old 04.07.2021, 11:06
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

@Jiaz / @mgpai : thanks for the clarifications .

rereading the topic from the beginning in search of "inspiration" I found something interesting:

https://board.jdownloader.org/showpo...&postcount=191
Spoiler:
Code:
Code:
// Run external program if package contains 'pdf' file
// Trigger: "Package finished"

var pdf = package.getDownloadLinks().some(function(link) {
    return getPath(link.getDownloadPath()).getExtension() == "pdf";
});

if (pdf) {
    var downloadFolder = package.getDownloadFolder();
    var converter = "f:/downloads/files/pdfConverter.exe";
    callAsync(function() {}, converter, downloadFolder, downloadFolder, "-c", "PNG", "-p", "1", "-pd", "4x5");
}

the script started the conversion of the pdf file after the download took place using specific software indicated by the user of the time.

I would like to modify it so that when DL finished it would open the php file in notepade, and I came up with something like this:

Code:
//trigger = packaged finisched
disablePermissionChecks();/*disable permission checks*/

var php = package.getDownloadLinks().some(function(link) {
    return getPath(link.getDownloadPath()).getExtension() == "php"; // ex "pdf"
});

if (php) {
    var downloadFolder = package.getDownloadFolder();
    //var converter = "f:/downloads/files/pdfConverter.exe";
    var textEditor = "notepad.exe";
//callAsync(function() {}, converter, downloadFolder, downloadFolder, "-c", "PNG", "-p", "1", "-pd", "4x5");
callAsync( textEditor , "????"); // how do i indicate the file to open if the name changes every time?
}
but I get to the error:
<<error : Can't find method org.jdownloader.extensions.eventscripter.sandboxobjects.ScriptEnvironment.callAsync(string,string,st ring). >>

how do i indicate the file to open if the name changes every time?

I guess I should create a variable like "phpFile" and have something like:
Code:
var phpFile = /*  how to find  php file */
callAsync( textEditor , phpFile );
but how do I locate the file? (path and name can change every time)




2)
in the drop-down menu of the linkgrabber there is the command "open link in browser", would it be possible to open a link with notepad without downloading the file? [ like << Open link in Notepad>> or << Open as Txt> ]

I have made some attempts but I cannot indicate "the link" that notepade has to open. (p.s = I did some tests and if in notepade in the window open / file name you paste the link + enter it opens the linked file, so it should be possible ... or not? )

Code:
// trigger =linkgrabber contextmenu button pressed
disablePermissionChecks();
if (name == "Open as txt"){
   
var textEditor = "notepad.exe";

var links = lgSelection.getLinks();
var urls = [];
for (i = 0; i < links.length; i++) {
        var link = links[i];}
callAsync(textEditor ,/* ???? */ ); // how do i indicate the link of the file to open ??
//alert (/***/); //how do i indicate the link of the file to open ??
}
any suggestions please ?
Reply With Quote
  #1758  
Old 04.07.2021, 15:01
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by BJN01 View Post
... when DL finished it would open the php file in notepade...
Code:
/*
    Open php file in text editor
    Trigger : A download stopped
*/

if (link.finished) {
    var file = getPath(link.downloadPath);

    if (file.extension == "php") {
        var editor = "notepad.exe";
        callAsync(null, editor, file);
    }
}

Quote:
Originally Posted by BJN01 View Post
... would it be possible to open a link with notepad without downloading the file? [ like << Open link in Notepad>> or << Open as Txt> ]
What do you mean by "without downloading"? Can you give an example?
Reply With Quote
  #1759  
Old 05.07.2021, 12:05
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

@mgpai : thanks x the script, it works perfectly.

Quote:
What do you mean by "without downloading"? Can you give an example?
it's probably not technically possible, but I was thinking something like:

- copy "link / url "
- JD "find" the file
- now the file are in the linkgrabber windows (in packages, with names etc.)


-1 left mouse click on a file
-pop-up menu appears
-in there is a command: "open in browser"

this command opens a browser page with the selected link (this link remains in the linkgrabber page and the file is not downloaded to the hd)

so I was wondering if it was possible to do a similar thing but open the file in notepad (or something similar).


...but I'm afraid I understand that you need to have a physical file on the hd to open it as txt.






as an "alternative" I would also have thought to work around I would have to download a temporary copy (to be deleted) and open it after DL ... but in doing so I would "use" the link in the linkgrabber window (which would then "disappear")...

then after selecting the file and "pressing" the command in the drop-down menu (eg "Open As Txt") , the script should:
- create a copy of the link in the linkgrabber window (assuming it is possible)
- start download the "copy link" as temporary file ( in a specific directory like " temp" os similar)
- open the file as txt in notepade ( or similar , {alert(filetemp)} ?? it's possible ? ) .
-... and finally delete the "temporary" file.
....
..
...I admit that re-reading it makes less and less sense ...
....

Last edited by BJN01; 05.07.2021 at 12:10.
Reply With Quote
  #1760  
Old 05.07.2021, 12:39
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by BJN01 View Post
... open the file in notepad (or something similar)
Are they direct links?
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 17:24.
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.