JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1161  
Old 06.03.2020, 15:02
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,495
Default

Quote:
Originally Posted by Dockel View Post
Is there a script which can add a comment to all the downloads / links being marked / selected (insead of having to do it for each single link separately?).
Possible, but you will have to also set the desired comment in the script (there will be no popup dialog where you can enter the comment).
Reply With Quote
  #1162  
Old 06.03.2020, 15:17
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 624
Default

So I each time before I would insert a comment had to open the script in the "Event scripter" and insert the text there anywhere in the script between some delimeters? Would I have to open the script manually (in the usual way) or may be with a button, shortcut in a more convenient way?
Reply With Quote
  #1163  
Old 06.03.2020, 17:47
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,495
Default

Quote:
Originally Posted by Dockel View Post
So I each time before I would insert a comment had to open the script in the "Event scripter" and insert the text there anywhere in the script between some delimeters? Would I have to open the script manually (in the usual way) or may be with a button, shortcut in a more convenient way?
Has to be added in the script, so you will have to go to the eventscripter panel and click edit script button to add/modify the comment.

Alternatively, I can provide a script which can read the comment from an existing link and then add it to the other links selected along with that link.

If you are running JD Windoes a workaround via VBS script might also be possible, but I will have to look into it.
Reply With Quote
  #1164  
Old 06.03.2020, 18:08
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Clean-up packagenames
// Trigger: Toolbar Button Pressed

if (name == "Clean-up packagenames") {
    getAllCrawledPackages().forEach(function(package) {
        var curName = package.getName();
        var newName = curName;
        var replace = function(find, replace) {
            newName = newName.replace(find, replace);
        }

        replace("-Vol ", "-V0");
        replace(/[~]/g, "-");
        replace("Darkwing duck & co", "nada");
        replace(/[❤:/\*%^°"]/g, " ");

        if (curName != newName) package.setName(newName);
    })
}

thank you

it works and inserting variables into the script is simple [= I can do it! yahoo]
should i flag (enable) the synchronous script execution option?


@zreenmkr
Thanks for your help, soon i will test your scripts better but there is one thing i would like to know:

what are the "variables" ???
both if I do "test" they give me this error message :<"name" is not defined>

Last edited by BJN01; 06.03.2020 at 18:12.
Reply With Quote
  #1165  
Old 06.03.2020, 21:03
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 624
Default

Quote:
Has to be added in the script, so you will have to go to the eventscripter panel and click edit script button to add/modify the comment.
I guess, it would be too enconvenient so I could add the comments manually.

Quote:
Alternatively, I can provide a script which can read the comment from an existing link and then add it to the other links selected along with that link.
So I would add the comment (to be added to a special amount of links) to some link and would click an icon or so and that comment would be added the links being marked? Yes, that sounds good. Thank you!

Quote:
If you are running JD Windoes a workaround via VBS script might also be possible, but I will have to look into it.
Sorry? I have Win 10. Just a usual JD, I would say. Workaround? VBS? Do not know what that means, but somehow sounds good.
Reply With Quote
  #1166  
Old 06.03.2020, 23:10
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

hello , starting from the mgpai script I managed to make another one that changes the names of the file in the linkgrabber tab , and I activate it with <Toolbar Button Pressed>. (oddly it works., and from my point of view it is a success)

now I have 3 buttons with related scripts, for convenience I added an "alert" in 2 of these scripts .

Thanks to this I realized that regardless of which push button all 3 are executed.


it's normal ? is there a way to avoid it?
[I tried to select / deselect the synchronous script execution option but nothing has changed]
Reply With Quote
  #1167  
Old 06.03.2020, 23:14
AlphaSlayer AlphaSlayer is offline
Wind Gust
 
Join Date: Sep 2019
Posts: 40
Default

Quote:
Originally Posted by mgpai View Post
EDIT by psp: Thank you mgpai - I've removed my request- post above this one to keep the thread clean!

Code:
// Add single URL at user defined interval
// Trigger required: "Interval"

var setInterval = 60; // in minutes
var link = "http://jdownloader.org/download/index"; // Specify URL to be added

if (interval == setInterval * 60 * 1000) {
    callAPI("linkgrabberv2", "addLinks", {
        "deepDecrypt": true,
        "links": link
    });
} else {
    interval = setInterval * 60 * 1000;
}
Code:
// Add multiple URLs at user defined interval
// Trigger required: "Interval"

var setInterval = 60; // in minutes
var feeds = JD_HOME + "/feeds/links.txt"; // Full path to text file containing the urls

if (interval == setInterval * 60 * 1000) {
    callAPI("linkgrabberv2", "addLinks", {
        "deepDecrypt": true,
        "links": readFile(feeds)
    });
} else {
    interval = setInterval * 60 * 1000;
}
File used to test the script:
What would I need to add to this to make it start downloading after everything has been grabbed and to set it to download to a specific location with subfolder by package name enabled? THANKS!
Reply With Quote
  #1168  
Old 07.03.2020, 05:43
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
...I do "test" they give me this error message :<"name" is not defined>
Quote:
...I realized that regardless of which push button all 3 are executed

Am assuming you've created 'EventScripter Trigger' button. You need to give that each button a unique name and it is case sensitive.

1st Button
Code:
if (name == "My Button1 Name") {
//if button you rename from 'EventScripter Trigger' to '"My Button1 Name'. When this button is pressed then only this 1st codes in this body will be executed
}
2nd Button
Code:
if (name == "My Button2 Name") {
//if button you rename from 'EventScripter Trigger' to '"My Button2 Name'. When this button is pressed then only this 2nd codes in this body will be executed
}

Last edited by zreenmkr; 07.03.2020 at 05:59.
Reply With Quote
  #1169  
Old 07.03.2020, 05:50
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
...most sites have dedicated plugins, so you need to find them...
Thanks @raztoki & @pspzockerscene
Reply With Quote
  #1170  
Old 07.03.2020, 06:15
Loadrix Loadrix is offline
Modem User
 
Join Date: Jan 2019
Posts: 2
Default

I'm new to this, can't code and still try figure this out.

Is it possible if you download a video (MP4, MPEG, MKV) from a website (not youtube), to automatically extract the audio part of the video container and then delete the video? Also, is it possible to write a 2nd version of that script that includes also automatic re-encoding with lower bitrate (64kbps?) to drastically shrink the filesize of the audio file?

Last edited by Loadrix; 07.03.2020 at 06:28.
Reply With Quote
  #1171  
Old 07.03.2020, 06:58
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,495
Default

Quote:
Originally Posted by AlphaSlayer View Post
What would I need to add to this to make it start downloading after everything has been grabbed and to set it to download to a specific location with subfolder by package name enabled?
"deepDecrypt": true is not required for sites (like YT) which have dedicated plugins.

Code:
callAPI("linkgrabberv2", "addLinks", {
    "links": readFile(feeds),
    "autostart": true,
    "destinationFolder": "\\myFolder\\<jd:packagename>"
});

Optionally, use "LinkgrabberSettings.autoconfirmdelay" (Advanced Settings) to adjust the 'autostart delay'.
Reply With Quote
  #1172  
Old 07.03.2020, 07:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,495
Default

Quote:
Originally Posted by Loadrix View Post
Is it possible if you download a video (MP4, MPEG, MKV) from a website (not youtube), to automatically extract the audio part of the video container and then delete the video?
JD already has an option for this. In the linkgrabber tab, select the file and use context menu command "Convert to... > Extract Audio Stream".

Quote:
Also, is it possible to write a 2nd version of that script that includes also automatic re-encoding with lower bitrate (64kbps?) to drastically shrink the filesize of the audio file?
Find the 'ffmpeg' CLI command needed to convert the file and use 'callSync/callAsync' method to call it from eventscripter. If you need help adding it to the script, please provide the working CLI command here.
Reply With Quote
  #1173  
Old 07.03.2020, 07:09
AlphaSlayer AlphaSlayer is offline
Wind Gust
 
Join Date: Sep 2019
Posts: 40
Default

Quote:
Originally Posted by mgpai View Post
"deepDecrypt": true is not required for sites (like YT) which have dedicated plugins.

Code:
callAPI("linkgrabberv2", "addLinks", {
    "links": readFile(feeds),
    "autostart": true,
    "destinationFolder": "\\myFolder\\<jd:packagename>"
});

Optionally, use "LinkgrabberSettings.autoconfirmdelay" (Advanced Settings) to adjust the 'autostart delay'.
Ok sweet that worked but am I doing the download location wrong? It doesn't seem to send it to that folder and i've tried with the slashes both wasy /, \. Thanks again for the help and yes this is fro youtube. "destinationFolder": "C:\Users\Admin\Desktop\New folder\<jd:packagename>"
Reply With Quote
  #1174  
Old 07.03.2020, 07:35
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Is it possible if you download a video (MP4, MPEG, MKV) from a website (not youtube), to automatically extract the audio part of the video container and then delete the video? Also, is it possible to write a 2nd version of that script that includes also automatic re-encoding with lower bitrate (64kbps?) to drastically shrink the filesize of the audio file?
Adapted from @mgpai

Code:
// Extract Audio from Video then Convert to <custom> mp3 bitrate.
// Trigger required: "A Download Stopped".
// Requires ffmpeg/ffprobe. Uses JD ffmpeg/ffprobe settings if available.
// Overwrites destination file (mp3) if it already exists.


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

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


if (link.isFinished()) {
    var fileName = link.name.replace(/(.+)(\..+$)/, "$1");
    var fileType = link.name.replace(/(.+)(\..+$)/, "$2");
    var sourceFile = link.getDownloadPath();
    var videoFile = /\.(mp4|mkv|mov|avi|mpg|mpeg)$/.test(sourceFile);

    if (videoFile) {
        var downloadFolder = package.getDownloadFolder();
        var videoSourceFile = sourceFile;
        var audioDestFile = 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");

        //---------------------------------------------------------------
        //---extract & convert video to audio
        //---ffmpeg ref cmd: hxxps://gist.github.com/protrolium/e0dbd4bb0f1a396fcb55
        //---ffmpeg -i video.mp4 -f mp3 -ab 192000 -vn music.mp3
        //---------------------------------------------------------------

        var bitrate = 64000;
        //option 1 - CallSync
        callSync(ffmpeg, "-i", videoSourceFile, '-f', 'mp3', '-ab', bitrate, '-vn', audioDestFile);

        //Option 2 - callAsync
        //callAsync(function() {}, ffmpeg, '-i', videoSourceFile, '-f', 'mp3', '-ab', bitrate, '-vn', audioDestFile);

        var deleteSourceFile = false; // Set this to true to delete source file after conversion.
        if (deleteSourceFile && getPath(audioDestFile).exists()) deleteFile(videoSourceFile, false);

    }
}
Reply With Quote
  #1175  
Old 07.03.2020, 08:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,495
Default

Quote:
Originally Posted by Dockel View Post
Is there a script which can add a comment to all the downloads / links being marked / selected (insead of having to do it for each single link separately?).
The script will open a text file. Add your comment there and save/close it.

Code:
// Read comment from file and add it to selected links
// Trigger : Downloadlist Contextmenu Button Pressed
// Customize download list context menu > Add new 'Eventscripter Trigger' button > Rename it to "Add comment" (without quotes)

if (name == "Add comment") {
    var links = dlSelection.getLinks();

    if (links.length) {
        var textEditor = "notepad.exe";
        var commentFile = getPath(JD_HOME + "/tmp/commentFile.txt");
        if (!commentFile.exists()) writeFile(commentFile, "Replace this text with new comment, save file and exit", true);

        callSync(textEditor, commentFile);
        var comment = readFile(commentFile);

        if (comment.length) {
            links.forEach(function(link) {
                link.setComment(comment);
            })
        }
    }
}
Reply With Quote
  #1176  
Old 07.03.2020, 09:01
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
The script will open a text file. Add your comment there and save/close it.
I was going say ini file but good to know primitive way of things is still foolproof.

I would also want to see another line to open "/tmp/commentFile.txt" file to edit new comment but don't know if it is even possible to wait for notepad to close before continue. or perhaps a while loop to check and create new txt file everytime then remove it before exit script.

Last edited by zreenmkr; 07.03.2020 at 10:21.
Reply With Quote
  #1177  
Old 07.03.2020, 09:53
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 624
Default

Quote:
mgpai

The script will open a text file. Add your comment there and save/close it.

Thank you very much!

What do I have to do here (what does the txt file open?), mark one link or more or nonce at first?


Sorry, did a very stupid mistake, got it working, missed to activate the script by checking the box. Sorry again.

So the txt file has to be saved and closed after. When it closes the text is added, that is how to use it.

Last edited by Dockel; 07.03.2020 at 10:13.
Reply With Quote
  #1178  
Old 07.03.2020, 10:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,495
Default

Quote:
Originally Posted by Dockel View Post
What do I have to do here (what does the txt file open?), mark one link or more or nonce at first?
The script uses a text file as an alternative to input box.
  1. Select single/multiple files.
  2. Click 'Add comment' button.
  3. Type your 'comment' in the file which opens, save file on exit.
  4. The script will read the comment from the file and add it to all selcted links.
Note: Any existing comments will be over-written with the new comment.
Reply With Quote
  #1179  
Old 07.03.2020, 10:17
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

scratch that

Last edited by zreenmkr; 07.03.2020 at 10:19.
Reply With Quote
  #1180  
Old 07.03.2020, 10:54
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 624
Default

Quote:
Originally Posted by mgpai View Post
The script uses a text file as an alternative to input box.
  1. Select single/multiple files.
  2. Click 'Add comment' button.
  3. Type your 'comment' in the file which opens, save file on exit.
  4. The script will read the comment from the file and add it to all selcted links.
Note: Any existing comments will be over-written with the new comment.
Works great! Many thanks! Sorry again for my mistake.
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 11:46.
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 - 2023, Jelsoft Enterprises Ltd.