JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #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: 962
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: 962
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
Mega Loader
 
Join Date: Feb 2018
Posts: 60
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: 962
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
Mega Loader
 
Join Date: Feb 2018
Posts: 60
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: 962
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
Mega Loader
 
Join Date: Feb 2018
Posts: 60
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
JD Addict
 
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 Beta
 
Join Date: Jan 2020
Posts: 56
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
JD Addict
 
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
JD Addict
 
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: 962
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
Mega Loader
 
Join Date: Feb 2018
Posts: 60
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
JD Addict
 
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: 962
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 Beta
 
Join Date: Jan 2020
Posts: 56
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
Mega Loader
 
Join Date: Feb 2018
Posts: 60
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: 962
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
Mega Loader
 
Join Date: Feb 2018
Posts: 60
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 10:52.
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.