JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1201  
Old 11.03.2020, 13:20
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 902
Default

Quote:
Originally Posted by BJN01 View Post
[just for peace of mind, with these commands I'm only going to delete the links of files "to be downloaded", I don't delete files already on HD or in download right?]
Yes. Only links from linkgrabber tab will be matched/removed,

Quote:
p.s= can all linkgrabber links be saved to a txt file?
Code:
// Save linkgrabber urls to text file
// Trigger: Toolbar Button Pressed

if (name == "Export linkgrabber links") {
    var myFolder = JD_HOME; // Set any existing folder to save files (Default location: <JDownloader> install folder)
    var date = new Date().toString().substr(4, 17).replace(":", ".");
    var myFile = getPath(myFolder + "/linkgrabber urls - " + date + ".txt");

    var urls = getAllCrawledLinks().map(function(link) {
        return link.getUrl();
    })

    if (urls.length) writeFile(myFile, urls.join("\r\n") + "\r\n", true);
}
Reply With Quote
  #1202  
Old 11.03.2020, 14:26
BJN01 BJN01 is offline
JD Beta
 
Join Date: Jan 2020
Posts: 56
Default

many thanks again
Reply With Quote
  #1203  
Old 11.03.2020, 16:37
Bunter fisch Bunter fisch is offline
Wind Gust
 
Join Date: Mar 2019
Posts: 40
Default

Hi,

my JDownloader is running headless on my raspberry pi. i want to automaticcally restart jdownloader when new updates are available and no download is runnung. There is a script to realize that here: https://board.jdownloader.org/showpo...&postcount=881

In an other thread i've got the information that i can create this script with jdownloader on my desktop running the gui version and then copy all to the raspberry pi.

Here is a description how to create a new button and run a script; https://support.jdownloader.org/Know...rticle/View/46. What trigger do i need to run the script when new updates are available and jdownloader is in idle?
Reply With Quote
  #1204  
Old 11.03.2020, 17:15
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 902
Default

Quote:
Originally Posted by Bunter fisch View Post
my JDownloader is running headless on my raspberry pi. i want to automaticcally restart jdownloader when new updates are available and no download is runnung.
You don't need to add any button. The script uses 'interval' as trigger.

You can install the eventscripter in JD GUI and setup/test the script in in it and copy the 'EventScripter.scripts' JSON data from its 'value' column and paste it in the headless JD using WebUI.

Alternatively, after installing the script in JD GUI, you can copy the "org.jdownloader.extensions.eventscripter.EventScripterExtension.scripts.json" file from JD GUI to the headless version.

This is the script in JSON format, which can be added (using WebuI) in 'EventScripter.scripts' advanced setting of headless JD.

Code:
[ {
  "eventTrigger" : "INTERVAL",
  "enabled" : true,
  "name" : "Update JD when idle",
  "script" : "// Update when JD is Idle\n// Trigger Required: \"Interval\"\n// Set interval to 600000 (10 mins.) or more.\n\ndisablePermissionChecks();\n\n(function() {\n    if (callAPI(\"update\", \"isUpdateAvailable\") == false) return;\n    if (callAPI(\"linkcrawler\", \"isCrawling\")) return;\n    if (callAPI(\"linkgrabberv2\", \"isCollecting\")) return;\n    if (callAPI(\"extraction\", \"getQueue\").length > 0) return;\n    if (callAPI(\"downloadcontroller\", \"getCurrentState\") != \"IDLE\") return;\n    callAPI(\"update\", \"restartAndUpdate\");\n})();",
  "eventTriggerSettings" : {
    "lastFire" : 1583942603250,
    "interval" : 600000,
    "isSynchronous" : false
  },
  "id" : 1583942586078
} ]

Please note, Eventscripter extension must be installed/enabled for it to work.
Reply With Quote
  #1205  
Old 11.03.2020, 19:51
AlphaSlayer AlphaSlayer is offline
DSL User
 
Join Date: Sep 2019
Posts: 38
Default

@mgpai so I have a weird problem with the auto link checker script. So youtube videos work fine but I'm trying to add another websites links but for some reason, it says there are no links (when I only have that link(s) in the text file). If I add the link manually it finds everything fine. Could it be because I have a special link crawler rule for this site?
Reply With Quote
  #1206  
Old 11.03.2020, 23:17
BJN01 BJN01 is offline
JD Beta
 
Join Date: Jan 2020
Posts: 56
Default

I'm trying to set a command that takes the links of the linkgrabber, opens the notepad and pastes it inside the links leaving it open [so as to save the txt with name and destinations as needed] ...
The script from which I took inspiration opens notepad ( but starts from an existing file ) , so I too had to use existing files:

Code:
// Save Linkgrabber to txt and open Notepad (to "save" the txt with name and destinations as needed)
// Trigger: Toolbar Button Pressed
if (name == "Save Linkgrabber to txt") {

    var SaveLinkFile = getPath(JD_HOME + "/tmp/SaveLinkFile.txt");
    var textEditor = "notepad.exe";
    var urls = getAllCrawledLinks().map(function(link) {
        return link.getUrl();
    })
    if (SaveLinkFile.exists()) SaveLinkFile.delete();//.deleteRecursive();???
    if (urls.length) writeFile(SaveLinkFile, urls.join("\r\n"), true);
    //if (urls.length) writeFile(myFile, urls.join("\r\n") + "\r\n", true);  // ?? what they mean   urls.join("\r\n") + "\r\n" 
    callSync(textEditor, SaveLinkFile);
}

( what they mean << urls.join("\r\n") + "\r\n" >> r & n what do they indicate? )

a) what should I correct to say "replace the contest of the txt "? [ no add ]
[now i delete the txt (I think)...]
b) what difference do delete and deleteRecursive have?
c) Am I forced to work on real files?
[can't links be sent directly to the notepad without first writing them to a file?]



In this script , if i have the links in a txt is there a way to make them read / add in the addpattern?

Code:
// Remove crawledlinks which match user-specified pattern

var patterns = [];
var addPattern = function(pattern) {
    patterns[patterns.length] = pattern;
}

addPattern(/microsoft.com\/.+/i);
addPattern(/apple.com\/robots.txt/i);
addPattern(/google.com/i);
addPattern(/robots.txt$/i);

getAllCrawledLinks().forEach(function(link) {
    patterns.forEach(function(pattern) {
        var url = link.getUrl();
        if (pattern.test(url)) link.remove();
    })
})
addPattern(--> read link.txt) ?

I've tried something like this, but I'm definitely missing something

Code:
var textEditor = "notepad.exe";
    var patternFile = getPath(JD_HOME + "/tmp/ks.txt");
    callSync(textEditor, patternFile);
     addPattern = readFile(patternFile);
[ the link are written for example h**ps://example.c##/folder1/folder2/A9CFCE64B70308.jpg ]
Reply With Quote
  #1207  
Old 12.03.2020, 06:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 902
Default

Quote:
Originally Posted by AlphaSlayer View Post
I'm trying to add another websites links but for some reason, it says there are no links (when I only have that link(s) in the text file). If I add the link manually it finds everything fine. Could it be because I have a special link crawler rule for this site?
The links are processed automatically only when there is a dedicated plugin or matching link crawler rule. If not, you may need to enable 'deedDecrypt' for those links in the script.

When you added the link manually, did you add a single link or multiple links? If you add a single link manually, JD automatically deep anaylses it to find any downloaded content from that link, even if there is not dedicated plugin or crawler rule.
Reply With Quote
  #1208  
Old 12.03.2020, 10:49
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 169
Default

Quote:
I'm trying to set a command that takes the links of the linkgrabber, opens the notepad and pastes it inside the links leaving it open
hey @BJN01, i'm just curious myself. for the first part of your questions, why do you need the urls to paste in an empty notepad without saving it. again, this is just for my benefit, has nothing to do with your intention.

I'm thinking you might need to call vbs or shell script to do this for you.

Code:
    var urls = getAllCrawledLinks().map(function(link) {
        return link.getUrl();
    })
I haven't tested the code yet, just a quick answer. This is similar to a for loop which gather all urls into an array.

Quote:
( what they mean << urls.join("\r\n") + "\r\n" >> r & n what do they indicate? )
'\r\n' is return carriage and new line. In notepad.exe for example you don't see the actual text as '\r\n' but instead line1 above line2 and so on. (other useful ones '\t' for tab, '\s' for space, might want to read up on regexpression)

Code:
urls.join("\r\n") + "\r\n"
convert array urls into string where each url is put into a different line.

Last edited by zreenmkr; 12.03.2020 at 10:54.
Reply With Quote
  #1209  
Old 12.03.2020, 11:59
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 902
Default

Quote:
Originally Posted by BJN01 View Post
In this script , if i have the links in a txt is there a way to make them read / add in the addpattern?
Code:
// Remove linkgrabber links which are present in user-specified text file

var textfile = JD_HOME + "/tmp/linklist.txt";
var linklist = readFile(getPath(textfile)).trim();

getAllCrawledLinks().forEach(function(link) {
    if (linklist.indexOf(link.getUrl()) > -1) link.remove();
})
Reply With Quote
  #1210  
Old 12.03.2020, 14:48
Bunter fisch Bunter fisch is offline
Wind Gust
 
Join Date: Mar 2019
Posts: 40
Default

Quote:
Originally Posted by mgpai View Post
Please note, Eventscripter extension must be installed/enabled for it to work.
I tried to enable it but it doesn't work. when i pressed "install" it runs and runs and runs. after 45 minutes i cancled. There are available updates and i didn't restart because i wanted to try the script. Do i need to restart before i enable the extention?
Reply With Quote
  #1211  
Old 12.03.2020, 16:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 902
Default

Quote:
Originally Posted by Bunter fisch View Post
Do i need to restart before i enable the extention?
Yes. A restart is required after installing the Eventscripter extension.
Reply With Quote
  #1212  
Old 12.03.2020, 20:39
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 169
Default

a) show/hide help window resize able? sometime it takes 1/3 of the window real estate other time 2/3.

b) possible to set alert window custom size?

c) duplicated crawledlinks is highlited in red in linkgrabber that's already been added in downloads. is there a way to return the isHighlitedRed files? e.g (isFinished, isEnabled in downloads)
Reply With Quote
  #1213  
Old 13.03.2020, 06:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 902
Default

Quote:
Originally Posted by BJN01 View Post
a) what should I correct to say "replace the contest of the txt "? [ no add ]
There is an option to to append (true) or not append (false), but there is no option to overwrite. You will just have to delete the old file and create a new one.

Alternatively, you can replace the existing content with zero length string, before adding new content.

Code:
writeFile(myFile, "", true); // clear old content
writeFile(myFile, newContent, true); // add new content

Quote:
b) what difference do delete and deleteRecursive have?
deleteRecursive (also delete any sub-folder content)

Quote:
c) Am I forced to work on real files? [can't links be sent directly to the notepad without first writing them to a file?]
Not possible with default options of 'notepad'. You can use 'autoit' or similar scripting solution or find a text editor which will allow setting content via CLI parameter.

Code:
www.autoitscript.com/autoit3/docs/tutorials/notepad/notepad.htm
Reply With Quote
  #1214  
Old 13.03.2020, 06:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 902
Default

Quote:
Originally Posted by zreenmkr View Post
a) show/hide help window resize able? ...
b) possible to set alert window custom size?
c) ... is there a way to return the isHighlitedRed files? ...
a) No.
b) No.
c) There aren't any methods which can return hightlighted links. But, since they are dupes, you can use a function to compare crawled link urls with download link urls and return crawled link objects which contain duplicate urls.
Reply With Quote
  #1215  
Old 13.03.2020, 07:23
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 169
Default

good pointer. thanks.

could toolbar button or contextmenu action be intercepted? I accidentally right click on a packagename and open hundreds of tabs in the browser. Open in Browser. If there is a possibility, then I'm thinking get length of crawled in package if it greater than say 20 crawled then terminate the action.
Reply With Quote
  #1216  
Old 13.03.2020, 09:06
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 169
Default

regex to match last occurrence. Looked into backtracking but still confused

Code:
    var file = 'Stay healthy by walking everyday by John Doe';

    //workaround
    var regex = /(.*?)by\s(.*?)/i;
    var authorName = file.replace(regex, '$2');
    var authorName = authorName.replace(regex, '$2');

    alert(file + '\r\n' + 'authorName: ' + authorName);
Reply With Quote
  #1217  
Old 13.03.2020, 10:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 902
Default

Quote:
Originally Posted by zreenmkr View Post
could toolbar button or contextmenu action be intercepted? ... If there is a possibility, then I'm thinking get length of crawled in package if it greater than say 20 crawled then terminate the action.
Possible only with context menu commands which execute a script. In this case, can check length of selected links array before opening them in a browser.

Quote:
regex to match last occurrence....
Use greedy quantifier when you want to get the longest match before the last occurrence.

Code:
var file = 'Stay healthy by walking everyday aby John Doe';

var regex = /.*by\s(.*)/i;
var authorName = file.replace(regex, '$1');

alert(file + '\r\n' + 'authorName: ' + authorName);
Reply With Quote
  #1218  
Old 13.03.2020, 10:26
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 169
Default

thanks

Quote:
Possible only with context menu commands which execute a script...
yea, 'Open in Browser' is one of the default funcs shipped with jd not a eventscripter user defined func. Only if it could be modified.
Reply With Quote
  #1219  
Old 13.03.2020, 10:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 902
Default

Quote:
Originally Posted by zreenmkr View Post
Only if it could be modified.
It can be disabled and replaced by a script based one.
Reply With Quote
  #1220  
Old 13.03.2020, 12:09
BJN01 BJN01 is offline
JD Beta
 
Join Date: Jan 2020
Posts: 56
Default

@mgpai , @zreenmkr = thanks for the answers and advice

Quote:
Originally Posted by zreenmkr View Post
hey @BJN01, i'm just curious myself. for the first part of your questions, why do you need the urls to paste in an empty notepad without saving it. again, this is just for my benefit, has nothing to do with your intention.
from my point of view it was a "simple" idea based on laziness (my):

the examples of scripts that saved data (link, file name, etc) that I found created txt type: dd-mmm-yyyy TEXT.txt in a specific dir on the hd [or they showed me the data in an alert window ([data])].

so for saving the data I had to:
-> select link i need and "save"
-> go and look for the dir
-> look for the txt file
-> open or rename the txt
-> save it and / or move it where I needed it

... = __ = too "tiring and noisy"

therefore the purpose of the scrip is to shorten everything, namely:
--> select link i need
--> run the script ( the script "copy" the link and open the txt in notepad)
--> now i can modify the notepad ad "save as " where i want


Quote:
Originally Posted by zreenmkr View Post
I'm thinking you might need to call vbs or shell script to do this for you.
you're probably right but I don't know how to do it and how to use it

Quote:
Originally Posted by zreenmkr View Post
Code:
    var urls = getAllCrawledLinks().map(function(link) {
        return link.getUrl();
    })
I haven't tested the code yet, just a quick answer. This is similar to a for loop which gather all urls into an array.
I don't know programming languages ​​and the like (I had used avisinth scipt many years ago ... but now I have forgotten almost everything) .... so I got by going to fish from other examples the pieces that seemed to me to be fine (trying to adapt them)


Quote:
Originally Posted by mgpai View Post
There is an option to to append (true) or not append (false), but there is no option to overwrite. You will just have to delete the old file and create a new one.

Alternatively, you can replace the existing content with zero length string, before adding new content.

Code:
writeFile(myFile, "", true); // clear old content
writeFile(myFile, newContent, true); // add new content
ok, i think i will use this method , i like it !

edit:
I did some tests but the command <<writeFile(myFile, "", true);>> does not delete the contents of the txt but adds a space ("")

Quote:
Originally Posted by mgpai View Post
Not possible with default options of 'notepad'. You can use 'autoit' or similar scripting solution or find a text editor which will allow setting content via CLI parameter.

Code:
www.autoitscript.com/autoit3/docs/tutorials/notepad/notepad.htm
I read the page but I think at the moment it is a little too much beyond my current skills and needs.
I think I will modify with the above code and keep the use of real files (in the end they are light weight txt)




I guess the answer is "doesn't exist" / "isn't there yet" but I try to ask it anyway:

having combined a shortcut to a command (of JD) (eg F2 or chtrl + F3 etc)
is there any string that tells jd something like:

at "download started" run the command combined with "F2"?

Last edited by BJN01; 13.03.2020 at 13:08.
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 05:05.
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 - 2020, Jelsoft Enterprises Ltd.