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?
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
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
@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-
__________________
On vacation / im Urlaub
START: 2023-09-26
END: TBA
A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz
Do you have Nero installed?
That's true James
Quote:
Originally Posted by James
Die Leute verstehen einfach nicht dass nur weil man mit einer Waffe auch auf Menschen schießen kann dass ein Schützenverein kein Ort für Amoklaufideen ist
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.
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?
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("&","e");
//... omiss..
replace("–","-");
replace("I Can’t","I Can't");
//... omiss...
replace("Won’t","Won t");
replace("Didn’t","Didn t");
replace("I’m ","I m ");
replace("King’s","King s");
//.....omisss....
replace("Chapter_Chapter","Ch");
replace("ChCh","Ch");
replace("--","-");
//.....omisss.....
replace("☆ ","");
replace("【","[");
replace("】","]");
replace("①","");
replace(/[~]/g,"-");
replace(/["]/g," ");
replace(/[❤:/\*%^°]/g," ");
replace(""","");
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("&","e");
replace("I Can’t","I Can't");
replace("I’m ","I m ");
replace("King’s","King s");
replace("Chapter_Chapter","Ch");
//....omiss example ....
replace("【","[");
replace("】","]");
replace("①","");
replace(/[~]/g, "-");
replace(/["]/g, " ");
replace(/[❤:/\*%^?<>°]/g, "");
replace(""", "");
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
... 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:
... 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 19:24.
Reason: Variable was inside the loop. Moved it outside.
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");
})
}
@ 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?
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'.
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?
@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"
@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.
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 ??
}
... 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
... 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?
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 ...
....