JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1201  
Old 11.03.2020, 14:20
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
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, 15:26
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

many thanks again
Reply With Quote
  #1203  
Old 11.03.2020, 17: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, 18:15
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
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, 20:51
AlphaSlayer AlphaSlayer is offline
Registered / Inactive
 
Join Date: Sep 2019
Posts: 40
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 12.03.2020, 00:17
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
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, 07:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
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, 11:49
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
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 11:54.
Reply With Quote
  #1209  
Old 12.03.2020, 12:59
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
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, 15: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, 17:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
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, 21:39
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
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, 07:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
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, 07:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
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, 08:23
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
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, 10:06
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
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, 11:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
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, 11:26
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
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, 11:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
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, 13:09
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
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 14:08.
Reply With Quote
  #1221  
Old 13.03.2020, 14:35
Bunter fisch Bunter fisch is offline
Wind Gust
 
Join Date: Mar 2019
Posts: 40
Default

Quote:
Originally Posted by mgpai View Post
Yes. A restart is required after installing the Eventscripter extension.
At the Moment there are no available updates. If all is working i dont see New updates. Is there any way to check whether restart worked? In a log file or simply by writing a text file the home dir?
Reply With Quote
  #1222  
Old 13.03.2020, 15:10
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
Default

Quote:
Originally Posted by Bunter fisch View Post
Is there any way to check whether restart worked? In a log file or simply by writing a text file the home dir?
You can check the timestamps of update logs in "JD\logs\updatehistory" folder. Alternatively, you can add the following code in the script (insert before the restart and update call line) to log a custom message in "JD\logs\<session id>\ScriptEnvironment.log" file:

Code:
log("JD was restarted by a script to apply updates");
Reply With Quote
  #1223  
Old 13.03.2020, 15:20
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
Default

Quote:
Originally Posted by BJN01 View Post
.... 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"?
Script environment does not have any methods to send key strokes. You'll have to again use an external utility (like autohotkey or autoit) in the script to do that.

What is the nature of those commands? If it is something which can be run from a script, you can use one with a "A Download Started" trigger.
Reply With Quote
  #1224  
Old 13.03.2020, 17:29
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Hello there!

PSP referred me here.

I am looking for a script, which would open finished *AND* unfinished files in the download-list via Double-Click. (The "Open Link" in the Link-Double-Click-Actions in the advanced settings only opens finished files. ... a ticket has been created already here: http://svn.jdownloader.org/issues/87766)

And I am also looking for a script, which would add single files from the link-list to the download-list via Double-Click. (A ticket for that has also been created here: http://svn.jdownloader.org/issues/87757)

Can this even be accomplished through a script?

Best Greetings!

Last edited by Sokub; 13.03.2020 at 18:05.
Reply With Quote
  #1225  
Old 13.03.2020, 18:14
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
Default

Quote:
Originally Posted by Sokub View Post
I am looking for a script, which would open finished AND unfinished files in the download-list via Double-Click. (The "Open Link" in the Link-Double-Click-Actions in the advanced settings only opens finished files ...
You can achieve this without a script. Just create a file association for 'part' file extension with your preferred player. You can then double-click the partial file in JD to open in that player. (Might not be possible to open files which are being downloaded as separate streams and need to be muxed after the download is finished).

Please note, most players lock the file while it is being played, which means if the download is finished while it is still being played, JD will not be able to rename it by removing the 'part' extension from the file, and you will end up with two files. One with 'part' extension and the other with the actual/original file extension.

Note: There are players which do not lock playing files, for e.g. PotPlayer.

Quote:
And I am also looking for a script, which would add single files from the link-list to the download-list via Double-Click.
Currently, only context menu commands can trigger an eventscripter script.
Reply With Quote
  #1226  
Old 13.03.2020, 18:56
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Thank you mgpai, for your fast reply!


Quote:
Originally Posted by mgpai View Post
You can achieve this without a script. Just create a file association for 'part' file extension with your preferred player. You can then double-click the partial file in JD to open in that player.

Where would I create this file association? Within my system this is already working, i.e. in my file browser these .part files are opened. But not from within JD.

Can this file association be set in JD too?

BTW: VLC lets JD also rename the .part file it is currently playing.
Reply With Quote
  #1227  
Old 13.03.2020, 19:33
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
Default

Quote:
Originally Posted by Sokub View Post
Where would I create this file association? Within my system this is already working, i.e. in my file browser these .part files are opened. But not from within JD. Can this file association be set in JD too?
File association is a OS setting, not a JD setting. For the file to be opened when double-clicking it, it should be associated with a program. This will be used to open the file if you have selected "Open File" for double-click action in advanced settings.

There are several methods (depending on your OS) to do this. One way for e.g. is to right-click on the 'part' file, choose an application to open it with and select 'save as default' or 'always use this program to open this type of file'.

Code:
BTW: VLC lets JD also rename the .part file it is currently playing.

Test to make sure it allows JD to rename the file. I just checked with VLC on my Windows PC. The file was locked and JD was unable to rename it. The 'part' file also remained on disk after the download was finished.

While both have worked fine in my case, it would be better to do a google search for settings specific to your OS, both in respect of double-click and player behaviour.
Reply With Quote
  #1228  
Old 13.03.2020, 21:58
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Quote:
Originally Posted by mgpai View Post
File association is a OS setting, not a JD setting. For the file to be opened when double-clicking it, it should be associated with a program. This will be used to open the file if you have selected "Open File" for double-click action in advanced settings.
Yes, like I wrote, it is all set in my OS (Linux Mint KDE) and works fine from the file manager for instance. But in JD it only works for finished files. Not for unfinished.

Quote:
Test to make sure it allows JD to rename the file. I just checked with VLC on my Windows PC. The file was locked and JD was unable to rename it. The 'part' file also remained on disk after the download was finished.
Yes, I did test! Perfectly fine with VLC in Linux Mint KDE. The file gets renamed, the .part-file disappears. All while the file is playing on VLC.
Reply With Quote
  #1229  
Old 13.03.2020, 22:14
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
@BJN01
...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
Let clarify a few things. I might be able to be at service.

1) Do you need to script to save both link with name or only the link?

because this script bellow which you mentioned only save all links and No names
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);
}

2) Now, to follow that, assuming you still use the script above, do you need:
-a. all 'links, file names or just links' from linkgrabber?
-b. or only the specific one you had in mind?
-c. or the New ones you just added a second ago?

3) when you open SaveLinkFile.txt file in notepad, what do you do to it? Are you deleting links? Are you adding names? and you save it as 'dd-mmm-yyyy TEXT.txt'?


Quote:
I think I will modify with the above code and keep the use of real files (in the end they are light weight txt)
It'll be easier if I have a full picture of you are trying to achieve from all of the above. Let me know.




Quote:
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"?
as @mgpai mentioned, there is no native key strocks in jd but autoit can be called to do that.

Quote:
I read the page but I think at the moment it is a little too much beyond my current skills and needs.
I could help you started with 'autoit' to send 'F2' key. Let me know what 'F2' does because 'F2' function in jd is to Rename. Do you need to send F2 to another program?
Reply With Quote
  #1230  
Old 14.03.2020, 00:24
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

@zreenmkr = ???
sorry but now I don't understand, the script I posted now worked (it does what I need).
when I posted it I was still in the "development" phase (say)
I had put it because I had a doubt about the "process" that I followed in the script, namely:

- select the link in the tab linkgrabber
- delete the old example.txt file (SaveLinkFile.txt)
- write the info i want in the new txt file

-open the new txt file with notepad.exe

the question was << to have a notepad open with the info pasted inside do I have to write a real file? can't it be done virtually with some command to avoid deleting files? >>

and mgpai answered this question

Quote:
mgpai
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.

if you are interested in the current result is this:

Code:
// "select link, paste them in a tx and open it"
// N.B = add button (event scrip trigger) in linkgrabber contextmenu
//trigger : linkgrabber contextmenu button press
if (name == "Save LinkGrabber selez + open txt") {

    var SaveLinkFile = getPath(JD_HOME + "/tmp/SaveLinkFile.txt");
    var textEditor = "notepad.exe";
    var links = lgSelection.getLinks(); 
    var urls = [];

    for (i = 0; i < links.length; i++) {
        var link = links[i];
        var fileName = link.getName();
        var GrabberURL = link.getContentURL();
        urls.push(fileName + " , " + GrabberURL);
    }

      if (SaveLinkFile.exists()) SaveLinkFile.delete(); // delete the old file "savelinkfile.txt"    
    if (urls.length) writeFile(SaveLinkFile, urls.join("\r\n"), true);
    callSync(textEditor, SaveLinkFile); //now i edit the file and "save as " it .
}
--> select link in linkgrabber tab
--> TD mouse / linkgrabber contextmenu /run script
--> I see notepad (SaveLinkFile.txt) , now I , edit - add - write - delete what i want and " save as" (changing path and name every time as needed ) .



Quote:
as @mgpai mentioned, there is no native key strocks in jd but autoit can be called to do that.

Quote:
I read the page but I think at the moment it is a little too much beyond my current skills and needs.
I could help you started with 'autoit' to send 'F2' key. Let me know what 'F2' does because 'F2' function in jd is to Rename. Do you need to send F2 to another program?
(F2 it was an example !)


In JD there is a command: <<clear filtered links>>
( setting\user interface\linkgrabber botton bar .....
the icon is a gray funnel)
I matched it with a shost cut (ctrl + del)

so when I have the JD window open I activate it by pressing the two keys (ctrl + del).
I had hypothesized to insert this operation (or the pressure of the 2 keys) in a script in order to execute the command.

now I'm starting trying to work on the autohotkey script which should simply say "hold down ctrl + delete key to JD ".
but i dont know if it work the way i think ....
Reply With Quote
  #1231  
Old 14.03.2020, 03:55
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
the question was << to have a notepad open with the info pasted inside do I have to write a real file? can't it be done virtually with some command to avoid deleting files? >>
I think I know what you are trying to do now. Autoit would do. I'll post an update later.


This is something I would do.
Code:
// "select link, paste them in a tx and open it"
// N.B = add button (event scrip trigger) in linkgrabber contextmenu
//trigger : linkgrabber contextmenu button press


//--------------------------------------------------------
disablePermissionChecks(); //no prompting persmision dialog
//enablePermissionChecks(); //required prompting permision

//--------------------------------------------------------
//setDisableOnException(true); // enable/disable script on error exceptions
//setNotifyOnException(Boolean); // enable/disable notification on exceptions


//if (name == "Save LinkGrabber selez + open txt") {

    textEditor = "notepad.exe"; //global
    var dateTime = _dateTime();
    var aPath = JD_HOME + '\\tmp';
    //var aPath = 'C:\\archive\\_jd_linkgrabber';
    var textFileName = 'SaveLinkFile'
    var fileExt = ".txt"
    var namesAndUrls = [];

    //select 1 or multiple files
    var selections = lgSelection.getLinks();
    for (i = 0; i < selections.length; i++) {
        var selection = selections[i];
        var fileName = selection.getName();
        var url = selection.getContentURL();
        //nameAndUrl.push(fileName + " , " + url);
        namesAndUrls.push('Name: ' + fileName + "\r\n" + 'Link: ' + url + "\r\n");
    }

    var textFile = getPath(aPath + "\\" + dateTime + " - " + textFileName + fileExt);
    var selectedFiles = namesAndUrls.join('\r\n', true);
    var userInputText = _getUserInputText(selections);
    var finalText = dateTime + '\r\n' +
        '-------------------------' + '\r\n' +
        selectedFiles + '\r\n' + '\r\n' +
        '-------------------------' + '\r\n' +
        'Note: ' + userInputText;

    //if (textFile.exists()) {
    //    alert('File Already Exists: \r\n' + textFile);
    //} else {
    if (selections.length) {
        writeFile(textFile, finalText, true);
        callSync(textEditor, textFile); //now i edit the file and "save as " it .
    }
    //}
}

//---return userinput custom text---
function _getUserInputText(selected) {
    if (selected.length) {
        var userInputText = getPath(JD_HOME + "/tmp/_userinput.txt");
        if (!userInputText.exists()) {
            userInputText.delete();
            writeFile(userInputText, "Replace this text with new custom text, save file and exit", true);
            //writeFile(userInputText, "", true);
        }

        callSync(textEditor, userInputText);
        var customText = readFile(userInputText);
        if (customText.length) {
            return customText;
        } else {
            return '---No User Input Text Available---'
        }
    }
}

//---retrieve current date time---
function _dateTime() {
    var date = new Date();
    var dateTime = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toJSON(); //yyyy-mm-ssThh:mm:ss.msZ
    var finalDateTime = dateTime.substr(0, 23).replace("T", "_-_").replace(/:/g, ".");
    return finalDateTime
}

Last edited by zreenmkr; 14.03.2020 at 05:55.
Reply With Quote
  #1232  
Old 14.03.2020, 05:46
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
@BJN01
...notepad open with the info pasted inside...
autoit cmd to pass var to notepad.exe
hxxps://workupload.com/file/dd5yQzu2
pwd: bjn01

Code:
// "select link, paste them in a tx and open it"
// N.B = add button (event scrip trigger) in linkgrabber contextmenu
// Trigger : linkgrabber contextmenu button press

//--------------------------------------------------------------------------------------------------------------
//IMPORTANT: Create sub-folder '_bin' in JD_HOME then download and copy 'notepadCmd.exe' to dir
//--------------------------------------------------------------------------------------------------------------


//--------------------------------------------------------
disablePermissionChecks(); //no prompting persmision dialog
//enablePermissionChecks(); //required prompting permision


//--------------------------------------------------------
if (name == "Save LinkGrabber selez + open txt") {

    var dateTime = _dateTime();
    var exePath = JD_HOME + '\\_bin';
    var exeCmd = 'notepadCmd.exe'
    var textEditor = getPath(exePath + "\" + exeCmd);
    var namesAndUrls = [];

    if (!textEditor.exists()) {
        alert("EXE FILE NOT FOUND!\r\n" + "Create subfolder '_bin' and copy '" + exeCmd + "' to:\r\n\r\n" + exePath);
    } else {

        //select 1 or multiple files
        var selections = lgSelection.getLinks();
        for (i = 0; i < selections.length; i++) {
            var selection = selections[i];
            var fileName = selection.getName();
            var url = selection.getContentURL();
            //nameAndUrl.push(fileName + " , " + url);
            namesAndUrls.push('Name: ' + fileName + "\r\n" + 'Link: ' + url + "\r\n");
        }

        var selectedFiles = namesAndUrls.join('\r\n', true);
        var finalText = dateTime + '\r\n' +
            '-------------------------' + '\r\n' +
            selectedFiles;

        if (selections.length) {
            callSync(textEditor, '-notepad', finalText);
        }
    }
}

//--------------------------------------------------------
//---retrieve current date time---
function _dateTime() {
    var date = new Date();
    var dateTime = new Date(date.getTime() - (date.getTimezoneOffset() * 60000)).toJSON(); //yyyy-mm-ssThh:mm:ss.msZ
    var finalDateTime = dateTime.substr(0, 23).replace("T", "_-_").replace(/:/g, ".");
    return finalDateTime
}


Quote:
In JD there is a command: <<clear filtered links>>
( setting\user interface\linkgrabber botton bar .....
the icon is a gray funnel)
I matched it with a shost cut (ctrl + del)

so when I have the JD window open I activate it by pressing the two keys (ctrl + del).

autoit send Ctrl+Del
hxxps://workupload.com/file/y68E8GBS
pwd: bjn01

Code:
function hotkeyCtrlDel()
    var exePath = JD_HOME + '\\_bin';
    var exeCmd = 'jdHotkey.exe'
    var hotkey = getPath(exePath + "\\" + exeCmd);
    callSync(hotkey, '-hkey');
}

Last edited by zreenmkr; 14.03.2020 at 07:16. Reason: autoit file updated
Reply With Quote
  #1233  
Old 14.03.2020, 06:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
Default

Quote:
Originally Posted by Sokub View Post
... works fine from the file manager for instance ...
Can use a script till the developers provide a solution, but will need to use context menu command instead of double-click, provided the OS will allow opening the file from it. Let me know if you'd want to try it.
Reply With Quote
  #1234  
Old 14.03.2020, 11:18
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Quote:
Originally Posted by mgpai View Post
Can use a script till the developers provide a solution, but will need to use context menu command instead of double-click, provided the OS will allow opening the file from it. Let me know if you'd want to try it.

Does the double-click work on your Windows-System for unfinished files? Have you tried it?

And yes, I would like to try the script for the context menu, if double-click won't work for me (for now). ... Right now in the context menu, the option "Open file" is greyed out for unfinished files but works fine for finished ones.
Reply With Quote
  #1235  
Old 14.03.2020, 12:29
zreenmkr zreenmkr is offline
Registered / Inactive
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Does the double-click work on your Windows-System for unfinished files? Have you tried it?
I tried assigning a default app to open *.part file in windows environment then double-click the file inside windows folder then it open up but not in jd.
Reply With Quote
  #1236  
Old 14.03.2020, 13:05
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
Default

Quote:
Originally Posted by Sokub View Post
Does the double-click work on your Windows-System for unfinished files? Have you tried it?

And yes, I would like to try the script for the context menu
Post by @zreenmkr confirms the same behaviour in Windows OS. I hadn't tested it myself. It was just my assumption. Sorry about that.

Code:
// Open partially download file for the selected download link
// Trigger: Downloadlist Contextmenu Button Pressed
// Customize download list context menu > Add a new "Eventscripter Trigger" button > Rename it to "Open PART file" (without quotes) > Change Icon (Optional)

if (name == "Open PART file") {
    var link = dlSelection.getContextLink();

    if (link) {
        var player = "/videolan/vlc/vlc"; // <- Set path to media player
        var partFile = getPath(link.getDownloadPath() + ".part");

        if (partFile.exists()) callAsync(null, player, partFile);
    }
}
Reply With Quote
  #1237  
Old 14.03.2020, 13:42
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

Quote:
Originally Posted by zreenmkr View Post
autoit send Ctrl+Del
hxxps://workupload.com/file/y68E8GBS
pwd: bjn01

Code:
function hotkeyCtrlDel()
    var exePath = JD_HOME + '\\_bin';
    var exeCmd = 'jdHotkey.exe'
    var hotkey = getPath(exePath + "\\" + exeCmd);
    callSync(hotkey, '-hkey');
}
I apologize in advance for the trivial question, but how do I use it?
a) the executable that c and in the zip mate it in a specific folder (if yes which one?) or do I put it where I want?
b)
in the code I guess I should indicate the path of the executable, but what does '\\_bin' mean?

p.s =
in theory if I click twice on the executable it should "say" to jd "the user (me) has pressed the key combination ctrl + del", therefore jd should execute the command that I have associated with that combination, right?

[I click twice, the exe is executed but Jd does nothing]

edit :
I tried to narrow the keys with autohotkei and I came up with a similar thing
Code:
WinWait, JDownloader 2, 
IfWinNotActive, JDownloader 2, , WinActivate, JDownloader 2, 
Send, {CTRLDOWN}{DEL}{CTRLUP}{ENTER}
return
and ...
it seems to work but (and I apologize again for the trivial question) how do I tell jd to run "JD-CtlrCancEnter.ahk" ?
or I have to recall in some way the executable / compiled "JD-CtlrCancEnter.exe"?

Last edited by BJN01; 14.03.2020 at 14:11.
Reply With Quote
  #1238  
Old 14.03.2020, 14:12
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Quote:
Originally Posted by zreenmkr View Post
I tried assigning a default app to open *.part file in windows environment then double-click the file inside windows folder then it open up but not in jd.
Thank you zreenmkr for testing this!

Quote:
Originally Posted by mgpai View Post
I hadn't tested it myself. It was just my assumption. Sorry about that.
No worries mgpai! Thank you for your time and effort helping me!

Thank you very much for the code too! It works good so far.

To make it perfect for me, I would like it to open both finished and unfinished files.
Can you modify the script for this case? Would you be so kind?
Reply With Quote
  #1239  
Old 14.03.2020, 15:01
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,601
Default

Quote:
Originally Posted by Sokub View Post
... I would like it to open both finished and unfinished files ...
Code:
// Open finished or partially download file for the selected download link
// Trigger: Downloadlist Contextmenu Button Pressed
// Customize download list context menu > Add a new "Eventscripter Trigger" button > Rename it to "[Script] Open file" (without quotes) > Change Icon (Optional)

if (name == "[Script] Open file") {
    var link = dlSelection.getContextLink();

    if (link) {
        var player = "/videolan/vlc/vlc"; // <- Set path to media player
        var file = getPath(link.getDownloadPath());

        if (file.exists()) {
            callAsync(null, player, file);
        } else {
            var partFile = getPath(file + ".part");

            if (partFile.exists()) {
                callAsync(null, player, partFile);
            }
        }
    }
}
Reply With Quote
  #1240  
Old 14.03.2020, 15:14
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Thank you very much mgpai! .... It works perfectly!

:-) ... <3
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 02:51.
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.