JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1081  
Old 19.02.2020, 13:48
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 72,894
Default

@mgpai
What he wants is not possible via link crawler rules.
He added a detailed description here:
https://board.jdownloader.org/showpo...3&postcount=11

To sum it up, what he wants is:
- Search that website for keywords
- Add the last X pages of the results
The website might also display a reCaptchaV2 on search attempt/Cloudflare

I told him that he will probably either need a very customized script or edit our official plugin and add the functionality he wants.

-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
  #1082  
Old 19.02.2020, 14:15
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by pspzockerscene View Post
@mgpai
What he wants is not possible via link crawler rules.
He added a detailed description here:

To sum it up, what he wants is:
- Search that website for keywords
- Add the last X pages of the results
The website might also display a reCaptchaV2 on search attempt/Cloudflare

I told him that he will probably either need a very customized script or edit our official plugin and add the functionality he wants.

-psp-
I had come across that post and am familiar with that site. Should be very much possible to achieve what he wants using the solution I provided.
  1. The main page is regularly updated with new releases. Instead of crawling 'search pages' (should also work just fine though), just create a linkcrawler rule which grabs links from the main url. Use 'deepPattern" or linkgrabber rule to filter the content.
  2. Add the 'source url' to JD at regular intervals (for e.g. every 60 minutes) using a script.
Reply With Quote
  #1083  
Old 19.02.2020, 14:28
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 72,894
Default

You are right but how would you manage the thing with the "keywords" he wants?
Also via link crawler rule --> Only allow it to pick-ip URLs containing the keywords?

-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
  #1084  
Old 19.02.2020, 15:18
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by pspzockerscene View Post
You are right but how would you manage the thing with the "keywords" he wants?
Also via link crawler rule --> Only allow it to pick-ip URLs containing the keywords?

-psp-
Yes. Specify 'deepPattern' or create linkgrabber filter rule.

That page lists only the most recent 15 releases, so will not take long to crawl. Shorter interval can be used if the page is updated frequently.

Linkcrawler rule > deeppattern > Create a html/url pattern which contains keywords. (best/most efficient option).

OR

Linkgrabber fiilter: Block urls which do not contain the keyword.
Reply With Quote
  #1085  
Old 19.02.2020, 15:21
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 72,894
Default

Hm you are right this could work --> And I'am wrong
Sometimes things are easier than expected at first glance.

-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
  #1086  
Old 20.02.2020, 02:21
RPNet-user's Avatar
RPNet-user RPNet-user is offline
Tornado
 
Join Date: Apr 2017
Posts: 237
Default

In the Linkcrawler rule I have tried several combinations for the deepPattern with a single key word and none of them worked, much less for two keywords separated by a space. Nothing is filtered, it adds everything, and crawls forever.

The linkgrabber filter will not work properly because it shows both the 'filtered' and the thousands of 'accepted' which continues to add everything else indefinitely, obviously because I'm unable to set a proper deepPattern.

Here are three variations of deeppatterns that I have tried and none worked:

"deepPattern" : "class="RARBG"><a href="([^"]+)""
"deepPattern" : "(http.+\\RARBG)"
"deepPattern" : "(**External links are only visible to Support Staff**


[ {
"enabled" : true,
"cookies" : null,
"updateCookies" : true,
"logging" : false,
"maxDecryptDepth" : 0,
"id" : 1582157977984,
"name" : "rmz.cr",
"pattern" : "**External links are only visible to Support Staff**,
"rule" : "DEEPDECRYPT",
"packageNamePattern" : null,
"passwordPattern" : null,
"formPattern" : null,
"deepPattern" : "class="RARBG"><a href="([^"]+)"",
"rewriteReplaceWith" : null
} ]

Last edited by RPNet-user; 20.02.2020 at 05:50.
Reply With Quote
  #1087  
Old 20.02.2020, 15:50
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 72,894
Default

How do you expect this to work?
Your rule does not even contain your keysowrds anywhere.
Anyways, here a blank example:
Code:
[ {
  "enabled" : true,
  "updateCookies" : true,
  "logging" : false,
  "maxDecryptDepth" : 1,
  "id" : 1422443765154,
  "name" : "rmz.cr example rule",
  "pattern" : "https?://rmz\\.cr/",
  "rule" : "DEEPDECRYPT",
  "packageNamePattern" : null,
  "passwordPattern" : null,
  "formPattern" : null,
  "deepPattern" : "(/release/keyword1[a-z0-9\\-]+keyword2[a-z0-9\\-]+keyword3)",
  "rewriteReplaceWith" : null
} ]
Here an example which grabs all "release" URLs containing the word "480p" (= only 1 keyword):
Code:
[ {
  "enabled" : true,
  "updateCookies" : true,
  "logging" : false,
  "maxDecryptDepth" : 1,
  "id" : 1422443765154,
  "name" : "rmz.cr example rule",
  "pattern" : "https?://rmz\\.cr/",
  "rule" : "DEEPDECRYPT",
  "packageNamePattern" : null,
  "passwordPattern" : null,
  "formPattern" : null,
  "deepPattern" : "(/release/[a-z0-9\\-]+480p[a-z0-9\\-]+)",
  "rewriteReplaceWith" : null
} ]
-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
  #1088  
Old 20.02.2020, 22:37
RPNet-user's Avatar
RPNet-user RPNet-user is offline
Tornado
 
Join Date: Apr 2017
Posts: 237
Default

@psp, Thanks

Yes my sample does contain the keyword as I was testing with the keyword 'RARBG', but obviously I was not using the proper syntax and regular expressions for the "pattern" : "https?://rmz\\.cr/" and the deepPattern: "/release/keyword[a-z0-9\\-]". Not that it matters anyway since it still will not work.

I tested your 480p sample and it does grab all 480p only, and I also tested 1080p by replacing 480p with 1080p and that also works, however, adding the second keyword does not work, for example when adding the keyword RARBG; so with your 480p sample I decided to replace the 480p with the keyword RARBG which is the same keyword I tested with before my previous post with incorrect syntax and it 'does not work'.

There is a single 1080p RARBG on the front page at the moment which the crawler does not add, however, when I use only the keyword 1080p it does add the 1080p RARBG with all other 1080p releases as well, which means that the linkcrawler rule does not work for keywords like 'RARBG' +added or by itself.

I also tried with just single keywords using only the release names like: VXT, ION10, etc. and none of them worked.
BTW, although a-z supposedly accepts either upper or lower case I also tested with the A-Z since some of these keywords are all upper case letters only and that still did not work.

Here is what I found so far, the regex will accept any keyword in the body of the title before/prior to the hyphen "-" that separates the trailing word, for example in the title: title.2020.720p.webrip.x264.aac-expresso regex will accept any keyword prior to "-expresso" but not after the hyphen "-".

@mgpai
How do you create a linkgrabber filter that blocks urls which do not contain the keyword?
So as not to show, not make visible, not include and 'not accept anything' other than the urls that contains that keyword?

Last edited by RPNet-user; 21.02.2020 at 05:02.
Reply With Quote
  #1089  
Old 21.02.2020, 00:10
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,667
Default

regex, (?!keyword|s)
regex101 dot com is good to help write patterns. Place in sample of content to match against with some that junk and you can see whats what.
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #1090  
Old 21.02.2020, 01:48
RPNet-user's Avatar
RPNet-user RPNet-user is offline
Tornado
 
Join Date: Apr 2017
Posts: 237
Default

Quote:
Originally Posted by raztoki View Post
regex, (?!keyword|s)
regex101 dot com is good to help write patterns. Place in sample of content to match against with some that junk and you can see whats what.
Thanks but that's not going to help if no pattern will accept those type of keywords.
Reply With Quote
  #1091  
Old 21.02.2020, 10:46
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,667
Default

sure you need to have some way to identify objects within the url for instance. you can either look for what you want,.
or
block everything that is not what you want. which is a negative look around ignore, you create a filter block for everything BUT what you want. Should work assuming the information is available within the url.
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #1092  
Old 21.02.2020, 13:59
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by RPNet-user View Post
... I decided to replace the 480p with the keyword RARBG ... and it 'does not work'.
While PSP has gone the extra mile and provided you example rules, it is up to you to fine tune it and make it work. The 'release' urls on that site do not seem to contain any 'uppercase' characters. Hence, if you use 'uppercase' characters in keywords, it will obiviously not match. Either use the correct case, or include the case-insensitive flag in the regex.

Quote:
...for example in the title: title.2020.720p.webrip.x264.aac-expresso regex will accept any keyword prior to "-expresso" but not after the hyphen "-".
The 'release' urls on that site also do not seem to contain any 'dot' characters. But, even if we take your string just as an example, it will also not match, as it contains '.' character while the regex doesn't. You have to modify it in order to match the string.

Example:
Code:
[.a-z0-9\\-]+

Quote:
How do you create a linkgrabber filter that blocks urls which do not contain the keyword?
The default selection in filter rule condition is 'contains'. Change it to 'contains not' to exclude urls which do not contain your keywords.

If you specify the correct 'deepPattern' in linkcrawler rule, you will not need to create the linkgrabber filter rule.

Quote:
Originally Posted by raztoki View Post
regex, (?!keyword|s)
regex101 dot com is good to help write patterns. Place in sample of content to match against with some that junk and you can see whats what.
I second that.
Reply With Quote
  #1093  
Old 21.02.2020, 14:15
RPNet-user's Avatar
RPNet-user RPNet-user is offline
Tornado
 
Join Date: Apr 2017
Posts: 237
Smile

Quote:
Originally Posted by mgpai View Post
While PSP has gone the extra mile and provided you example rules, it is up to you to fine tune it and make it work. The 'release' urls on that site do not seem to contain any 'uppercase' characters. Hence, if you use 'uppercase' characters in keywords, it will obiviously not match. Either use the correct case, or include the case-insensitive flag in the regex.



The 'release' urls on that site also do not seem to contain any 'dot' characters. But, even if we take your string just as an example, it will also not match, as it contains '.' character while the regex doesn't. You have to modify it in order to match the string.

@mgpai

The title sample that includes those dots is the name pattern that is used for the actual downloadable file names not the title of the posts, it was just an example to point out that none of the keywords after the hyphen "-" are been accepted by the regex keyword search, and yes I tried all those release names and several others after the hyphen in lowercase and none of them worked so the case does not appear to be affecting the functionality of the regex keyword search, and although I didn't use the "i" flag, I did test with A-Za-z0-9 to verify that it was not a case issue.

Anyway it is working now, I had to remove the keyword from the middle and add it after the last+quantifier so it looks like this: (/release/[a-z0-9\\-]+[a-z0-9\\-]+rmteam)
So the keywords after the hyphen will never work anywhere except in the last keyword placement of the regex regardless of the case.

The site is updating regularly with just 15 posts on the first page which includes both tv shows and movies(nonfiltered), however, on the top of their page there is an option to select "movies only" which then the url adds /l/m after the top level dname. At the bottom of each page they are numbered with links to each page in the format: /l/m/2, /l/m/3, and so on, so the second page looks like this: rmz.cr/l/m/2.
So if I wanted to add just the first five pages from the "/l/m/" to my crawl, then I assume that I would have to add/change this in the pattern and the deepPattern regex?

Scratch that, I believe that mgpai's script--> "Add urls to linkgrabber at user-defined intervals" will handle that.
I will test and post back with results.

Last edited by raztoki; 22.02.2020 at 04:26. Reason: insert /quote bbcode
Reply With Quote
  #1094  
Old 22.02.2020, 05:38
Germini
Guest
 
Posts: n/a
Default

Hi, I have tried the following script.



Quote:
Originally Posted by mgpai View Post
Convert AAC/M4A/OGG files to MP3.
Code:
// Convert aac/m4a/ogg files to mp3.
// Trigger required: "A Download Stopped".
// Requires ffmpeg/ffprobe. Uses JD ffmpeg/ffprobe settings if available.
// Overwrites destination file (mp3) if it already exists.

if (link.isFinished()) {
    var fileName = link.name.replace(/(.+)(\..+$)/, "$1");
    var fileType = link.name.replace(/(.+)(\..+$)/, "$2");
    var sourceFile = link.getDownloadPath();
    var audioFile = /\.(aac|m4a|ogg)$/.test(sourceFile);

    if (audioFile) {
        var downloadFolder = package.getDownloadFolder();
        var destFile = downloadFolder + "/" + fileName + ".mp3";
        var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
        var ffprobe = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypathprobe");
        var data = JSON.parse(callSync(ffprobe, "-v", "quiet", "-print_format", "json", "-show_streams", "-show_format", sourceFile));
        var streamsBitrate = data.streams[0].bit_rate ? data.streams[0].bit_rate : 0;
        var formatBitrate = data.format.bit_rate ? data.format.bit_rate : 0;
        var bitrate = Math.max(streamsBitrate, formatBitrate) / 1000;
        var deleteSourceFile = false; // Set this to true to delete source file after conversion.

        if (bitrate > 0) {
            callSync(ffmpeg, "-y", "-i", sourceFile, "-b:a", bitrate + "k", destFile);
            if (deleteSourceFile && getPath(destFile).exists()) deleteFile(sourceFile, false);
        }
    }
}

It worked perfect when downloading one file only. If I try to download multiple files It fails. I tried using and not using "Synchronous execution of script" but both didn't work for multiple files.

This is the error I am getting

Code:
net.sourceforge.htmlunit.corejs.javascript.EcmaError: SyntaxError: Unterminated object literal (#17)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3629)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.constructError(ScriptRuntime.java:3613)
	at net.sourceforge.htmlunit.corejs.javascript.NativeJSON.parse(NativeJSON.java:125)
	at net.sourceforge.htmlunit.corejs.javascript.NativeJSON.execIdCall(NativeJSON.java:97)
	at net.sourceforge.htmlunit.corejs.javascript.IdFunctionObject.call(IdFunctionObject.java:89)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpretLoop(Interpreter.java:1531)
	at script(:17)
	at net.sourceforge.htmlunit.corejs.javascript.Interpreter.interpret(Interpreter.java:798)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.call(InterpretedFunction.java:105)
	at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.doTopCall(ContextFactory.java:411)
	at org.jdownloader.scripting.JSHtmlUnitPermissionRestricter$SandboxContextFactory.doTopCall(JSHtmlUnitPermissionRestricter.java:119)
	at net.sourceforge.htmlunit.corejs.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3057)
	at net.sourceforge.htmlunit.corejs.javascript.InterpretedFunction.exec(InterpretedFunction.java:115)
	at net.sourceforge.htmlunit.corejs.javascript.Context.evaluateString(Context.java:1212)
	at org.jdownloader.extensions.eventscripter.ScriptThread.evalUNtrusted(ScriptThread.java:288)
	at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:180)
	at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:160)
After reading the whole topic I found some scripts which I modified to make it work for my purposes. If someone wants to improve it would be awesome but works for what I need it.

Code:
// Convert aac/m4a/ogg files to mp3 for youtube.com links
// Trigger required: "A Download Stopped".

var deleteSourceFile = true; // Set this to true to delete source file after conversion.
var sourceFile = link.getDownloadPath();
var filetype = getPath(link.getDownloadPath()).getExtension();
var filename = link.getName();
var extLength = filetype.length + 1
var newfilename = filename.substring(0, filename.length - extLength)
var downloadFolder = package.getDownloadFolder();
var destFile = downloadFolder + "\\" + newfilename + ".mp3";


if (link.isFinished()) {
    if (link.getHost() == "youtube.com") {
        if (filetype == "m4a" || filetype == "aac" || filetype == "ogg") {
            callSync(JD_HOME + "\\tools\\Windows\\ffmpeg\\x64\\ffmpeg.exe", "-v", "5", "-y", "-i", sourceFile, destFile)
        }
        if (deleteSourceFile && getPath(destFile).exists()) deleteFile(sourceFile, false);
    }
If somebody knows how to make Jdownloader to show "Demuxing/conversion" as status or similar when ffmpeg process is active It would be awesome.

Now I am trying to make the image from the video to be the cover. I will update when made. Also want to detect if there is a square to cut borders.

Greetings, Germini

Last edited by Germini; 22.02.2020 at 05:40.
Reply With Quote
  #1095  
Old 25.02.2020, 11:14
sherbee sherbee is offline
Registered / Inactive
 
Join Date: Mar 2019
Posts: 76
Default Shutdown trigger

Does have a trigger for shutdown?
I start 3rd party app on trigger JD start. Now I need to terminate when JD stops.
Reply With Quote
  #1096  
Old 25.02.2020, 11:54
sherbee sherbee is offline
Registered / Inactive
 
Join Date: Mar 2019
Posts: 76
Default An Error occured!

Hello script master!

Sometims download not complete. Status say "An Error occured!".

I want cycle through download list and find all "An Error occured!" and reset them. I want use existing interval script.

Now question:
1. Is links with this error included in running downloads from getRunningDownloadLinks()?
2. Or is better to check for myDownloadLink.getStatus()? Would value to check be "An Error occured!" like written in download list?
Reply With Quote
  #1097  
Old 25.02.2020, 12:37
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by sherbee View Post
Does have a trigger for shutdown? I start 3rd party app on trigger JD start. Now I need to terminate when JD stops.
While there isn't a "shutdown" trigger, you can first close the 3rd party app from the script and then use the MYJD API call to "exitJD" or "shutdownOS". You can either use a suitable trigger or create eventscripter button to execute the script.

Quote:
1. Is links with this error included in running downloads from getRunningDownloadLinks()?
No.

Quote:
2. Or is better to check for myDownloadLink.getStatus()? Would value to check be "An Error occured!" like written in download list?
Temporary messages cannot be accessed using "getStatus" method. Try the follwing method:
Code:
var myConditionalSkipReason = myDownloadLink.getConditionalSkipReason();
Reply With Quote
  #1098  
Old 26.02.2020, 13:34
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default Get DateTime for Event Scripter

Trying to get 'yyyy-mm-dd_-_hh-mm-ss', is there a better method? This is a little messy. Thanks

Code:
    var regex1 = /(\d{4})\-(\d{2})\-(\d{2})/;
    var regex2 = /(\d{2}):(\d{2}):(\d{2})/;
    var date = new Date().toJSON().substr(0, 10).replace(regex1, "$1-$2-$3");
    var time = new Date().toTimeString().substr(0, 9).replace(regex2, "$1-$2-$3");
    var dateTime = date + '_-_' + time
    alert(dateTime);
Reply With Quote
  #1099  
Old 26.02.2020, 14:01
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Code:
var dateTime = new Date().toJSON().substr(0, 19).replace("T", "_-_").replace(/:/g, "-");
Reply With Quote
  #1100  
Old 26.02.2020, 16:15
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 72,894
Default

Merged EventScripter threads.

-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
  #1101  
Old 26.02.2020, 23:40
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by mgpai View Post
Code:
var dateTime = new Date().toJSON().substr(0, 19).replace("T", "_-_").replace(/:/g, "-");

How do you refine it to local dateTime? plus able to chose 12hour and 24hour format?

with example above it returns 20:35 which is 08:35PM but my local time is 12:35PM
Reply With Quote
  #1102  
Old 27.02.2020, 06:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by zreenmkr View Post
How do you refine it to local dateTime? plus able to chose 12hour and 24hour format?

with example above it returns 20:35 which is 08:35PM but my local time is 12:35PM
Your original example converts the date into JSON format where the timezone offfset is zero, as denoted by the suffix "Z".

Use JS date object methods to convert it to your desired format.
Code:
www.w3schools.com/jsref/jsref_obj_date.asp
Reply With Quote
  #1103  
Old 27.02.2020, 09:23
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by mgpai View Post
Your original example converts the date into JSON format where the timezone offfset is zero, as denoted by the suffix "Z".

Use JS date object methods to convert it to your desired format.
Code:
www.w3schools.com/jsref/jsref_obj_date.asp
I've been there not familiar with timezone. I tried to get 'yyyy-mm-dd' but almost everything else return 'February 27, 2020'. JSON is one of a few that returns 'yyyy-mm-dd'


var n = new Date();
alert(n.toLocaleDateString("en-US")) //'February 27, 2020'

Is there anyway to convert ''February 27, 2020' to numeric 'yyyy-mm-dd'?
Reply With Quote
  #1104  
Old 27.02.2020, 09:35
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

I'm trying to have two scripts with trigger via 'Toolbar Button Pressed'
Button 1 is called 'This is script'
Button 2 is called 'This is script Child'
but when Button 1 is pressed both are executed at the same time. Could review examples bellow.


Code:
//Caller Script - Parent
//Trigger: Toolbar Button Pressed

if (name = 'This is script') {
   alert('script 1')
}

Code:
//Be called - Child
//Trigger: Toolbar Button Pressed

if (name = 'This is script Child') {
   alert('script 2')
}


Off topic: Is it possible to have script1 call script2? Thanks

Last edited by zreenmkr; 27.02.2020 at 09:38.
Reply With Quote
  #1105  
Old 27.02.2020, 10:04
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by zreenmkr View Post
Is there anyway to convert ''February 27, 2020' to numeric 'yyyy-mm-dd'?
Has to be formatted using JS code. Check 'stackoverflow.com' for examples. Easier method is to include an external date format library in your script.

Quote:
... but when Button 1 is pressed both are executed at the same time ...
You have used 'assignment operator' in the script.
Code:
if (name = 'This is script') {

Use 'comparision operator' instead.
Code:
if (name == 'This is script') {

Quote:
Off topic: Is it possible to have script1 call script2?
No. But you can include the code from script2 in script1 and execute it conditionally.
Reply With Quote
  #1106  
Old 27.02.2020, 10:24
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Use 'comparision operator' instead.
Code:
if (name == 'This is script') {

Sorry for he typo, comparison operator is what I had in the script. So any idea?

see attached for the created buttons.
Attached Images
File Type: png Toolbar Button Pressed.png (72.9 KB, 0 views)
Reply With Quote
  #1107  
Old 27.02.2020, 10:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by mgpai View Post
Has to be formatted using JS code
Example:
Code:
var myDate = function() {
    var t = new Date();
    var year = t.getFullYear();
    var month = ("0" + (t.getMonth() + 1)).slice(-2);
    var date = ("0" + t.getDate()).slice(-2);

    return [year, month, date].join("-");
}

alert(myDate());

Quote:
Originally Posted by zreenmkr View Post
...comparison operator is what I had in the script. So any idea?
Only the mods have access to the attachment. I have tested both scripts using comparision operator and they are working correctly.
Reply With Quote
  #1108  
Old 27.02.2020, 11:09
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Code:
var myDate = function() {
    var t = new Date();
    var year = t.getFullYear();
    var month = ("0" + (t.getMonth() + 1)).slice(-2);
    var date = ("0" + t.getDate()).slice(-2);

    return [year, month, date].join("-");
}

alert(myDate());
Sweet, thanks!!


Quote:
Only the mods have access to the attachment. I have tested both scripts using comparision operator and they are working correctly.
here is the attached on public imgur. See both scripts executed when Button 1 is pressed

screenshots

Last edited by zreenmkr; 27.02.2020 at 12:37.
Reply With Quote
  #1109  
Old 27.02.2020, 11:41
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

tried to create trigger 'Toolbar Button Pressed' in Right Click 'Open Menu Manger' but script didn't get executed
Reply With Quote
  #1110  
Old 27.02.2020, 11:50
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Talking

Quote:
here is the attached on public imgur. See both scripts executed when Button 1 is pressed
MY BAD! script Child has

Code:
if (name = 'This is script Child') {
instead of this, as pointed out.
Code:
if (name == 'This is script Child') {
Reply With Quote
  #1111  
Old 27.02.2020, 11:56
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by zreenmkr View Post
here is the attached on public imgur. See both scripts executed when Button 1 is pressed
Quote:
Originally Posted by zreenmkr View Post
tried to create trigger 'Toolbar Button Pressed' in Right Click 'Open Menu Manger' but script didn't get executed
Everything seems to fine in your screenshot. The only way I could reproduce the behaviour was by using 'asignment operators'.

Try creating a different one using instructions provided in this KB article.
Reply With Quote
  #1112  
Old 27.02.2020, 12:34
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
The only way I could reproduce the behaviour was by using 'asignment operators'.
Issue resolved itself as described above. sorry for wasting yourtime on this.

Quote:
Try creating a different one using instructions provided in this KB article.
I was able to create a functionional Button in 'Table Main Toolbar' but failed in 'Right Click Menu: Linkgrabber'. I've restarted jd, deleted and created w/out success.

One more thing. Is it normal for EventScripter to failed when code has mistakes in them. Code is triggered by Interval. When executed and error message popup. Went back in the editor and fixed the error but Script would not execute again until restart jd. (exit out jd/and reload). Is this a bug?
Reply With Quote
  #1113  
Old 27.02.2020, 13:32
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by zreenmkr View Post
Issue resolved itself as described above. sorry for wasting yourtime on this.
No problem. Only after I submitted my reply, I realised you had posted yours while I was composing mine.

Quote:
I was able to create a functionional Button in 'Table Main Toolbar' but failed in 'Right Click Menu: Linkgrabber'. I've restarted jd, deleted and created w/out success.
Your earlier test scripts work fine with context menu trigger too. Shoul also not require a restart. Check the code and button name (is case sensitve).

Quote:
Is it normal for EventScripter to failed when code has mistakes in them. Code is triggered by Interval. When executed and error message popup. Went back in the editor and fixed the error but Script would not execute again until restart jd. (exit out jd/and reload). Is this a bug?
Except in rare cases, (for e.g. interval script is executed and does not stop with errror, it will keep running in a loop till you quit JD) a restart is not required.

The script will be disabled on error. While there are methods which can be used to prevent it, I would recommend using it only for debugging.

Code:
setDisableOnException(myBoolean); // enable/disable script on exceptions
setNotifyOnException(myBoolean); // enable/disable notification on exceptions

You can also use the use JS error handling methods:
Code:
www.w3schools.com/js/js_errors.asp
Reply With Quote
  #1114  
Old 27.02.2020, 14:20
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
The script will be disabled on error. While there are methods which can be used to prevent it, I would recommend using it only for debugging.
Code:
setDisableOnException(myBoolean); // enable/disable script on exceptions
setNotifyOnException(myBoolean); // enable/disable notification on exceptions
Awesome, Thank!

yea, I gave 'JS error handling methods' a go before and for some odd reasons it kept saying "missing ';' before try" so I gave up (couldnt remember exactly). Now the switches above is easier to implement.

Disable Match Files
https
://
github.com/mgpai/resources/blob/master/jdownloader/eventscripter/scripts/netgearjd.js

This script utilized 92% of cpu power to the point where mouse movement was no longer possible. End task was not possible so It required hard reset. I have a few thousand links in Downloads tabs alone.

Last edited by zreenmkr; 27.02.2020 at 14:23.
Reply With Quote
  #1115  
Old 27.02.2020, 15:18
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by zreenmkr View Post
This script utilized 92% of cpu power to the point where mouse movement was no longer possible. End task was not possible so It required hard reset. I have a few thousand links in Downloads tabs alone.
Check memory stats during high cpu usage. 'Allocated' should always be reasonably lower than 'Max'.

Code:
Help > About JDownloader > Memory

You may need to increase memory allocation based on the number of links in JD and the text file.

Related post #414379
Reply With Quote
  #1116  
Old 27.02.2020, 23:39
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
A better option would be to use a script (Javascript) with packagizer hook in the Eventscripter extension, where you can control the exit accurately. It is also more convenient to search/add/remove keywords.
Quote above from post: Exit Packagizer Loop

Could you give an example where say one of Packgizer rules below return true then exit without trying the next rule bellow?

I want to sort books and group them into different packages. If none of new books match any given given Packagizer rules then group those in general ebooks package. As of right now, due to linear rules execution in Packagizer all ebooks will be grouped in '___Ebooks' Package although some books return true to some of prior rules.


<Condition Name> = _Book Of Animals
if <File Name> contains (birds|elephant) [x]RegExp
then <Package Name> = __Book Of Animals

<Condition Name> = _Book Of Cars
if <File Name> contains (bmw|honda|tesla) [x]RegExp
then <Package Name> = __Book Of Animals
...
<Condition Name> = _eBooks
if <File Type> is pdf,epub,mobi [x]RegExp
then <Package Name> = ___eBooks
Reply With Quote
  #1117  
Old 28.02.2020, 01:59
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Revisit prior resolved post above by @mgpai

Objective is to get dateTime in numeric format such as 'yyyy-mm-dd' with an alternative other than above.

toJSON() and toISOString() are a few that return this layout but timezone is not local as explained bellow.

Desired layout yyyy-mm-ss_-_hh-mm-ss
Code:
//@mgpai
var dateTime = new Date().toJSON().substr(0, 19).replace("T", "_-_").replace(/:/g, "-");
Quote:
@mgpai
Your original example converts the date into JSON format where the timezone offfset is zero, as denoted by the suffix "Z"

So here is the alternative
Code:
var date = new Date();
var n = date.getTimezoneOffset();
//alert(n); //return time different in #minutes

var dateTime = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toJSON();
//alert(dateTime); //yyyy-mm-ssThh:mm:ss.msZ - Converted to Local Time


var finalDateTime = dateTime.substr(0, 23).replace("T", "_-_").replace(/:/g, ".");
alert(finalDateTime ); Final modified yyyy-mm-ss_-_hh.mm.ss.ms
Reply With Quote
  #1118  
Old 28.02.2020, 07:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,590
Default

Quote:
Originally Posted by zreenmkr View Post
... example where say one of Packgizer rules below return true then exit without trying the next rule ...
Example code:
Code:
// Trigger: Packagizer Hook

var fn = link.getName();
var pn;

if (!pn && /birds|elephant/.test(fn)) pn = "animals";
if (!pn && /bmw|honda|tesla/.test(fn)) pn = "cars";
if (!pn && /.*\.(pdf|epub|mobi)$/.test(fn)) pn = "ebooks";

if (pn) link.setPackageName(pn);
Reply With Quote
  #1119  
Old 28.02.2020, 07:13
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

a) Is there a function to get filename or link on selected file in Downloads/LinkGrabber tab
b) and function that return all subfolders and a function return files in dir
Thanks
Reply With Quote
  #1120  
Old 28.02.2020, 07:37
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Is it possible to check file exist via regex?

Original fileName with spaces and/or underscore and/or hyphen ect... code below doesn't work.

Code:
var file = 'c:/docs/my(.*?)file(.*?)name(.*?)by(.*?)author.pdf'
 
if (!file.exists()) return;
alert('file exist');
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 00:15.
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.