JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #841  
Old 07.07.2019, 13:06
dankmemer dankmemer is offline
Registered / Inactive
 
Join Date: Jun 2019
Posts: 8
Default

Quote:
Originally Posted by mgpai View Post
Looks like the user's requirement is similar to the one in **External links are only visible to Support Staff**... thread.
Yup that's exactly it. Did that ever get resolved? Or would a script be able to do that?

Right now I've been running an independent duplication search on the folders, but, but I often have to rescrape the same pages for updates, and in its current state it will redownload eveyrthing again since it doesn't know if there are new files or dupes in JDownloader, which ends up causing wear to the HDD after a while of doing this. (I have a ~12 million files so also imagine the time it takes to run that duplication software)
Reply With Quote
  #842  
Old 08.07.2019, 11:01
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

@dankmemer: you could create a history/textfile with all downloaded files and use a script that checks that history/file if the file already got downloaded in the past and then remove it.
is not available yet but I will try to find some time for it
__________________
JD-Dev & Server-Admin
Reply With Quote
  #843  
Old 12.07.2019, 02:52
thecoder2012's Avatar
thecoder2012 thecoder2012 is offline
Official 9kw.eu Support
 
Join Date: Feb 2013
Location: Internet
Posts: 1,324
Default

1. Support for nzblnk links with JDownloader + Eventscripter:
Spoiler:
Code:
//Scan for NZB urls and grab all data
//Trigger: New Crawler Job (Neuer Sammel-Job)
//
//Uncheck the advanced setting: LinkgrabberSettings.addlinksdialogcheck

var myCrawlerJob = job;
var myNewLinks = myCrawlerJob.getText();

if (myNewLinks.match(/nzblnk:\?/i)) {
    var newlines = myNewLinks.split(/\r\n|\r|\n/g);
    newlines.forEach(function(listentry) {
        if (listentry.match(/^nzblnk:\?/i)) {
            var linksplit = listentry.split(/\?/, 2);
            var valuesplit = linksplit[1].split(/\&/);

            var newname = "";
            var newhash = "";
            var newpass = "";
            valuesplit.forEach(function(value) {
                var lastsplit = value.split(/=/, 2);
                if (lastsplit[0] == "t") { //title
                    newname = lastsplit[1];
                }
                if (lastsplit[0] == "h") { //header
                    newhash = lastsplit[1];
                }
                if (lastsplit[0] == "p") { //password
                    newpass = lastsplit[1];
                }
            });

            if (newhash) {
                var html = "";
                var html2 = "";
                for (var i = 0; i < 3; ++i) {
                    try {
                        html = getPage("https" + "://www.nzbindex.com/search/rss?q=" + newhash);
                        html2 = getPage("https" + "://www.nzbking.com/search/?q=" + newhash);
                    } catch (e) {}
                    if (html != null && html != "" && html2 != null && html2 != "") {
                        break;
                    } else {
                        sleep(1000);
                    }
                }
                if (html != null && html != "" && html2 != null && html2 != "") {
                    var nzburl = html.match(/url="([^"]+)"/);
                    var nzburl2 = html2.match(/href="([^"]+)" class/);
                    var nzblink = "";
                    if (nzburl) {
                        nzblink = nzburl[1] + ".nzb";
                    }
                    if (nzburl2) {
                        nzblink = "https" + "://www.nzbking.com" + nzburl2[1] + "#.nzb";
                    }

                    if (nzblink) {
                        callAPI("linkgrabberv2", "addLinks", {
                            "deepDecrypt": false,
                            "packageName": newname,
                            "extractPassword": newpass,
                            "links": nzblink
                        });
                    } else {
                        //alert("Kein Ergebnis gefunden.");
                    }
                } else {
                    //alert("Kein erreichbares Ergebnis gefunden.");
                }
            }
        }
    });
}


2. Usenet password remover (passwordlist)
Spoiler:
Code:
// Usenet password remover (passwordlist)
// Trigger: Interval (e.g. 150000)
var links = getAllDownloadLinks();
var doublecheck = {};

for (var i = 0; i < links.length; i++) {
    var link = links[i];
    var usenet = link.getProperty("useNetFile");

    if (usenet != null) {
        var myArchive = link.getArchive();
        var passwords = "";
        var finalPassword = "";
        if (link.getArchive()) {
            if (myArchive.getInfo().hasOwnProperty("passwords")) {
                passwords = myArchive.getInfo().passwords;
            }
            if (myArchive.getInfo().hasOwnProperty("finalPassword")) {
                finalPassword = myArchive.getInfo().finalPassword;
            }
        }
        if (finalPassword == null) {
            finalPassword = ""
        }
        if (passwords == null) {
            passwords = ""
        }
        if (passwords != "" || finalPassword != "") {
            if (passwords != "") {
                doublecheck[passwords] = 1;
            }
            if (finalPassword != "") {
                doublecheck[finalPassword] = 1;
            }
        }
    }
}
var newpw = [];
var pwjson = callAPI("config", "get", "org.jdownloader.extensions.extraction.ExtractionConfig", "cfg/org.jdownloader.extensions.extraction.ExtractionExtension", "PasswordList");

for (var i = 0; i < pwjson.length; i++) {
    if (doublecheck[pwjson[i]] != 1) {
        newpw.push(pwjson[i]);
    }
}
callAPI("config", "set", "org.jdownloader.extensions.extraction.ExtractionConfig", "cfg/org.jdownloader.extensions.extraction.ExtractionExtension", "PasswordList", newpw);



3. Use NZB data (with prompt) and grab all data (prompt.js is required)
Spoiler:
Code:
// Use NZB data and grab all data
// Trigger: Toolbar Button Pressed
// Triggername: NZB
// System: Windows
// Required: prompt.js, board.jdownloader.org/showpost.php?p=446222&postcount=851
require(JD_HOME + "/eventscripter/system/prompt.js");

if (name == "NZB") {
    var newname = "";
    var newhash = "";
    var newpass = "";
    newname = prompt("Name", "Package name");
    if (newname != null) {
        newhash = prompt("Header/Hash", "Header/Hash data");
    }
    if (newname != null && newhash != null) {
        newpass = prompt("Passwort", "NZB file passwort");
    }

    if (newhash != null && newname != null) {
        if (newhash) {
            var html = "";
            var html2 = "";
            for (var i = 0; i < 3; ++i) {
                try {
                    html = getPage("https" + "://www.nzbindex.com/search/rss?q=" + newhash);
                    html2 = getPage("https" + "://www.nzbking.com/search/?q=" + newhash);
                } catch (e) {}
                if (html != null && html != "" && html2 != null && html2 != "") {
                    break;
                } else {
                    sleep(1000);
                }
            }
            if (html != null && html != "" && html2 != null && html2 != "") {
                var nzburl = html.match(/url="([^"]+)"/);
                var nzburl2 = html2.match(/href="([^"]+)" class/);
                var nzblink = "";
                if (nzburl) {
                    nzblink = nzburl[1] + ".nzb";
                }
                if (nzburl2) {
                    nzblink = "https" + "://www.nzbking.com" + nzburl2[1] + "#.nzb";
                }

                if (nzblink) {
                    callAPI("linkgrabberv2", "addLinks", {
                        "deepDecrypt": false,
                        "packageName": newname,
                        "extractPassword": newpass,
                        "links": nzblink
                    });
                } else {
                    //alert("Kein Ergebnis gefunden.");
                }
            } else {
                //alert("Kein erreichbares Ergebnis gefunden.");
            }
        }
    }
}


4. Scan for NZB urls and grab all data (with nzbmonkey)
Spoiler:
Code:
disablePermissionChecks();
setAdvancedAlert(true);
setNotifyOnException(true);

//Scan for NZB urls and grab all data (with nzbmonkey)
//Trigger: New Crawler Job (Neuer Sammel-Job)
//
//Uncheck the advanced setting: LinkgrabberSettings.addlinksdialogcheck
//
// Nzbmonkey: github.com/nzblnk/nzb-monkey/releases

// Config
var nzbmonkey = JD_HOME + "/eventscripter/nzbmonkey.exe"; /* <- Set full path to nzbmonkey */
var nzbmonkey_save = "C:/Users/YOURUSER/Downloads/nzbmonkey"; // save path in nzbmonkey for nzb files
var my_nzbdata = "--help"; //test

// Script
var myCrawlerJob = job;
var myNewLinks = myCrawlerJob.getText();

// Example:
// nzblnk:?t=NAME&h=HEADER&p=PASS

if (myNewLinks.match(/nzblnk:\?/i)) {
    var newlines = myNewLinks.split(/\r\n|\r|\n/g);
    newlines.forEach(function(listentry) {
        if (listentry.match(/^nzblnk:\?/i)) {
            var linksplit = listentry.split(/\?/, 2);
            var valuesplit = linksplit[1].split(/\&/);

            var newname = "";
            var newhash = "";
            var newpass = "";
            valuesplit.forEach(function(value) {
                var lastsplit = value.split(/=/, 2);
                if (lastsplit[0] == "t") { //title
                    newname = lastsplit[1];
                }
                if (lastsplit[0] == "h") { //header
                    newhash = lastsplit[1];
                }
                if (lastsplit[0] == "p") { //password
                    newpass = lastsplit[1];
                }
            });

            if (newhash) {
                callAsync(function(exitCode, stdOut, errOut) {
                    if (stdOut.match('optional arguments')) {
                        my_nzbdata = listentry;
                        var linksplit = my_nzbdata.split(/\?/, 2);
                        var valuesplit = linksplit[1].split(/\&/);

                        var newname = "";
                        var newhash = "";
                        var newpass = "";
                        valuesplit.forEach(function(value) {
                            var lastsplit = value.split(/=/, 2);
                            if (lastsplit[0] == "t") { //title
                                newname = lastsplit[1];
                            }
                            if (lastsplit[0] == "h") { //header
                                newhash = lastsplit[1];
                            }
                            if (lastsplit[0] == "p") { //password
                                newpass = lastsplit[1];
                            }
                        });
                        var myFilePath = "";
                        if (newpass != "") {
                            myFilePath = getPath(nzbmonkey_save + "/" + newname + "{{" + newpass + "}}.nzb");
                        } else {
                            myFilePath = getPath(nzbmonkey_save + "/" + newname + ".nzb");
                        }
                        deleteFile(myFilePath, false);

                        callAsync(function(exitCode, stdOut, errOut) {
                            if (stdOut.match('Saving NZB-file ... OK')) {
                                if (myFilePath.exists()) {
                                    try {
                                        callAPI("linkgrabberv2", "addLinks", {
                                            "deepDecrypt": false,
                                            "packageName": newname,
                                            "extractPassword": newpass,
                                            "links": "file:"+"//" + myFilePath
                                        });
                                    }catch(e){}
                                } else {
                                    alert("Kein Ergebnis gefunden.");
                                }
                            }
                        }, nzbmonkey, "\"" + my_nzbdata + "\"");
                    }
                }, nzbmonkey, my_nzbdata);
            }
        }
    });
}


5. And for ftps/ftpes links (JD can ftps as ftp in most cases):
Spoiler:
Code:
//Scan for FTPs urls
//Trigger: New Crawler Job (Neuer Sammel-Job)
//
//Uncheck the advanced setting: LinkgrabberSettings.addlinksdialogcheck

var myCrawlerJob = job;
var myNewLinks = myCrawlerJob.getText();

var addlinks = "";
var newlines = myNewLinks.split(/\r\n|\r|\n/g);
newlines.forEach(function(listentry) {
    if (listentry.match(/^ftps:|^ftpes/i)) {
        listentry = listentry.replace(/^ftps/i, "ftp"); //as workaround
        listentry = listentry.replace(/^ftpes/i, "ftp"); //as workaround
        addlinks += listentry + "\n";
    }
});
if (addlinks != "") {
    callAPI("linkgrabberv2", "addLinks", {
        "deepDecrypt": false,
        "links": addlinks
    });
}



6. Use yt-dl if possible (and if JDownloader has no plugin)
Spoiler:
Code:
// Use yt-dl if possible
// Trigger: New Crawler Job (Neuer Sammel-Job)
// Required: Synchronous execution of script
// Uncheck the advanced setting: LinkgrabberSettings.addlinksdialogcheck

// Config
var all_links = false; //true/false - Use ytdl for all supported links (and not JD)

// Script
var downloadfolder = callAPI("config", "get", "org.jdownloader.settings.GeneralSettings", null, "defaultdownloadfolder");
setAdvancedAlert(true);

var myCrawlerJob = job;
var myNewLinks = myCrawlerJob.getText();
var errors = "";

var ytdl = JD_HOME + getEnvironment().getPathSeparator() + "you" + "tube-dl";
if (getEnvironment().isWindows()) {
    ytdl += ".exe";
}
if (!getPath(ytdl).exists() && getEnvironment().isWindows()) {
    var br = getBrowser();
    br.setFollowRedirects(true);
    br.getDownload(ytdl, "https" + "://yt-dl.org/latest/you" + "tube-dl.exe"); //ffmpeg.zeranoe.com/builds/
    sleep(1000);
}
if (getPath(ytdl).exists()) {
    var ytdl_output = callSync(ytdl);
    if (ytdl_output.match("You must provide at least one URL")) {
        var new_ytdl_extractors = callSync(ytdl, "--list-extractors");

        var checklinks = 0;
        var hosts = callAPI("plugins", "getAllPluginRegex");
        var newlines = myNewLinks.split(/\r\n|\r|\n/g);
        newlines.forEach(function(listentry) {
            if (getCheck(listentry.toLowerCase(), hosts) && getCheckDL(getHost(listentry.toLowerCase()), new_ytdl_extractors)) {
                checklinks = 1;
                downloadfolder = downloadfolder.replace("<jd:packagename>", getHost(listentry.toLowerCase()));
                var new_ytdl_output = callSync(ytdl, "--no-check-certificate", "--no-progress", "--no-call-home", "-i", "-o", downloadfolder + getEnvironment().getPathSeparator() + "%(title)s-%(id)s.%(ext)s", listentry);
                if (!new_ytdl_output.match("Download completed")) {
                    errors += "ERROR:\n" + listentry + "\n" + downloadfolder + getEnvironment().getPathSeparator() + "\n" + new_ytdl_output + "\n";
                }
            }
        });
        if (errors != "") {
            if (getEnvironment().isHeadless() == true) {
                log(errors);
            } else {
                alert(errors);
            }
        }
    } else {
        if (getEnvironment().isHeadless() == true) {
            log("Software yt-dl under " + ytdl + " not ready:\n" + ytdl_output + "\n");
        } else {
            alert("Software yt-dl under " + ytdl + " not ready:\n" + ytdl_output + "\n");
        }
    }
    if (checklinks != "" && errors == "") {
        myCrawlerJob.setDeepAnalysisEnabled(false);
        myCrawlerJob.setText("");
    }
}

function getCheckDL(url, extractors) {
    var newextractors = extractors.split(/\r\n|\r|\n/g);

    var found = 0;
    newextractors.forEach(function(extractorentry) {
        var extractorentry_good = "";
        if ((extractorentry.split(/:/))[0].length > 5) {
            extractorentry_good = (extractorentry.split(/:/))[0];
        } else {
            extractorentry_good = extractorentry;
        }
        if (url.match(extractorentry_good.toLowerCase()) && extractorentry_good.length > 3) {
            found = 1;
        }
    });
    if (found == 1) {
        return true;
    } else {
        return false;
    }
}

function getCheck(url, obj) {
    if (all_links == true) {
        return true;
    }
    for (var prop in obj) { //prop=host,obj[prop]=regex
        if (url.match(prop.toLowerCase())) {
            return false;
        }
    }
    return true;
}

function getHost(url) {
    var hostname;
    if (url.indexOf("//") > -1) {
        hostname = url.split('/')[2];
    } else {
        hostname = url.split('/')[0];
    }
    hostname = hostname.split(':')[0];
    hostname = hostname.split('?')[0];

    return hostname;
}
__________________
Join 9kw.eu Captcha Service now and let your JD continue downloads while you sleep.

Last edited by thecoder2012; 12.02.2020 at 06:13.
Reply With Quote
  #844  
Old 14.07.2019, 10:06
SMS SMS is offline
Mega Loader
 
Join Date: Jun 2019
Posts: 66
Default

Quote:
Originally Posted by mgpai View Post
Which directory should be compared? Download directory or extraction directory? Please give a working example.
If file to be downloaded is called foo.zip, but the download directory already contains a subdirectory called foo, then foo.zip shouldn't be downloaded (for example by using link.setEnabled(false);).
Reply With Quote
  #845  
Old 14.07.2019, 11:39
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,592
Default

Quote:
Originally Posted by SMS View Post
If file to be downloaded is called foo.zip, but the download directory already contains a subdirectory called foo, then foo.zip shouldn't be downloaded (for example by using link.setEnabled(false);).
Code:
// Disable all download link(s) of an archive, if the download folder contains a sub-folder with archive name
// Trigger: A Download Started

var archive = link.getArchive();
var archiveLinks = archive && getPath(link.getPackage().getDownloadFolder() + "/" + archive.getName()).exists() ? archive.getDownloadLinks() : [];

archiveLinks.forEach(function(link) {
    link.setEnabled(false);
    // var partFile = getPath(link.getDownloadPath() + ".part");
    // if (partFile.exists()) partFile.delete();
})
Reply With Quote
  #846  
Old 18.07.2019, 13:31
animus animus is offline
Registered / Inactive
 
Join Date: Jan 2010
Posts: 48
Lightbulb

hi @magpai

I download lot of movies etc

most of them are in multiple archives and renamed to keep it away from DMCA etc.I rename the archive back to original based on the page.

this is 3 part question.

#01-

I asked as a feature but jiaz directed me to you so here it is.

I want jdownloader to extract the archive to a folder named after the archives name (which is possible through jdownload extractor) without the folder structure inside the archive

For example Underworld 2.rar--->underworld 2 cd1 , underworld cd2 , covers , subtitles (these are all folders)

i want jdownloader to download the archive and extract the archive to folder thats set but not in a structure on the archive.i just want to see the avi/mp4/mkv files ,cover pictures and the subtitle files.
I think there is a setting in winrar that dismisses the folder structure.
is it possible?if possible how to manuplate the script (remove or add file extensions like jpeg txt etc to remove afterwards)

Addendum here: Is it possible to scripts triggering other scripts or do you need to do it in one script?

#02-

After the first thing happened a second script (or part) could be triggered (?) to rename the files that have been extracted, to the folder name (so basicly the archives name)

#03
after the second script (or part) happened a third script (or part) to get rid of the redundant subfolder like

D:/Media/TV/Stranger Things/Stranger Things S03e03.../Stranger Things S03e03...mp4

to

D:/Media/TV/Stranger Things/Stranger Things S03e03...mp4

I know that #2 is possible i asked something similar before you but it didnt really worked as well as i thought it would.#3 should be possible i think.

And a quick question does these scripts work with other jdownloader 2 installations.diffirent os - I have a rpi (uses debian based os) which i use as a download station with remote interface uses jdownloader.jar a portable kind of installation.

I know its a lot but i gotta ask.#01 is the part i am after but all three could be nice

Keep up the good work

Last edited by animus; 18.07.2019 at 13:48.
Reply With Quote
  #847  
Old 18.07.2019, 14:56
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,592
Default

Quote:
Originally Posted by animus View Post
i want jdownloader to download the archive and extract the archive to folder thats set but not in a structure on the archive.i just want to see the avi/mp4/mkv files ,cover pictures and the subtitle files.
Will be done by the script

Quote:
Originally Posted by animus View Post
is it possible?if possible how to manuplate the script (remove or add file extensions like jpeg txt etc to remove afterwards)
In Archive Extractor 'filter' section, match unwanted files using regular expression to remove them.

Quote:
Originally Posted by animus View Post
After the first thing happened a second script (or part) could be triggered (?) to rename the files that have been extracted, to the folder name (so basicly the archives name)
Use packagzier to rename extracted files. This may fail if renaming results in duplicate files.

Quote:
Originally Posted by animus View Post
after the second script (or part) happened a third script (or part) to get rid of the redundant subfolder like
If I have understood your question correclty, this should also be done by the script.

Quote:
Originally Posted by animus View Post
And a quick question does these scripts work with other jdownloader 2 installations.diffirent os - I have a rpi (uses debian based os) which i use as a download station with remote interface uses jdownloader.jar a portable kind of installation.
Yes.

Script:
Code:
// Move extracted files to base folder and remove empty sub-folders.
// Trigger: Archive Extraction Finished

var filePaths = archive.getExtractedFilePaths();

filePaths.forEach(function(filePath) {
    filePath.moveTo(archive.getExtractToFolder());
})

filePaths.concat(filePaths.reverse()).forEach(function(filePath) {
    var subFolder = getPath(filePath.toString().replace(filePath.getName(), ""));
    subFolder.delete();
})

Please test the script with non-critical files and make sure it is working correctly.
Reply With Quote
  #848  
Old 24.07.2019, 19:52
hokagai hokagai is offline
Registered / Inactive
 
Join Date: Jul 2019
Posts: 5
Default

Help please, to donwload each file in a different folder path

please how to assign each file to download in a specific folder and import it to jdownloader . i can't do it manually because it's thousand files.

for exemple:

file1 to c:\1
file2 to c:\2
file3 to c:\3
....

thanks alot
Reply With Quote
  #849  
Old 24.07.2019, 20:09
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,592
Default

Quote:
Originally Posted by hokagai View Post
... how to assign each file to download in a specific folder and import it to jdownloader ...
Have replied to your email.
Reply With Quote
  #850  
Old 28.07.2019, 13:29
maze maze is offline
Baby Loader
 
Join Date: Apr 2019
Posts: 8
Default

Hello everyone,
Is there any way to move files from default directory to another directory after completed download (each link)?
I have readed few posts on this forum (but mostly about extraction to separate directory).

Situaltion:
Device got small ammount of internal memory, so I mounted network drive (not NAS). One disavantage - You can't download directly on that network drive (Some Error, all files got 0 bytes).

Thanks for any help.

@edit:
Found script on forum, but trigger is 'Download Stopped'. I got whole package of ~500GB, is possible to move each single completed download to another directory? How to do that?

// Move finished non-archive files, to user defined folder
// Trigger required: "A Download Stopped"

var destFolder = "/var/www/mydir"; // <- Set destination folder.

if (link.isFinished() && !link.getArchive()) {
getPath(link.getDownloadPath()).moveTo(destFolder);
}

Last edited by maze; 29.07.2019 at 16:55.
Reply With Quote
  #851  
Old 31.07.2019, 12:04
Agita
Guest
 
Posts: n/a
Default Util Functions

Code:
setTimeout(function f [, number delay = 0 [, object ...]])
Spoiler:

JD_HOME/eventscripter/system/setTimeout.js
Code:
/*jslint browser */
/*global callAsync, sleep, JD_HOME */
function setTimeout() {
    "use strict";

    var args = [];
    Array.prototype.push.apply(args, arguments); // (...args) not working in jd2

    if (args.length === 0) {
        return;
    }

    var func = args.shift();
    var time = args.shift() || 0;

    callAsync(function() {
        sleep(time);
        func.apply(null, args);
    }, JD_HOME + "/eventscripter/system/bin/dummy.bat");
}
JD_HOME/eventscripter/system/bin/dummy.bat
Code:
@echo off
setlocal
set hmmm=hmmmmmm
Example
Code:
// Trigger Required: "Interval"
// Options recommended: 10000ms, synchronous

require(JD_HOME + "/eventscripter/system/setTimeout.js");

function f(arr) {
    alert(arr.join(" "));
}

setTimeout(f, 5000, ["hello", "world"]);
alert("setTimeout() is not blocking!");


Code:
confirm(string message) : bool
Spoiler:

JD_HOME/eventscripter/system/confirm.js
Code:
/*jslint browser, long */
/*global getEnvironment, callSync, JD_HOME, alert */
function confirm(message) {
    "use strict";

    message = message.replace("\r", "\\r");
    message = message.replace("\n", "\\n");
    var env = getEnvironment();
    switch (env.getOSFamily()) {
    case "WINDOWS":
        return !(!callSync(JD_HOME + "/eventscripter/system/bin/confirm.bat", "JD2 - EventScripter", message));
    default:
        alert("Soryy, your OS is yet not supported for confirm()");
    }
}
JD_HOME/eventscripter/system/bin/confirm.bat
Code:
@echo off
SETLOCAL EnableDelayedExpansion

SET _title=%~1
SET _text=%~2

set _text=%_text:\r="&vbCr&"%
set _text=%_text:\n="&vbLf&"%

:uniqueTempVbs
set "vbsFileName=%TEMP%\~%RANDOM%.vbs"
if exist "%vbsFileName%" goto :uniqueTempVbs

ECHO Wscript.Echo MsgBox("!_text!",1,"!_title!")>%vbsFileName%
FOR /f "delims=/" %%G IN ('cscript //nologo %vbsFileName%') DO set _input=%%G
DEL %vbsFileName%

if "%_input%" EQU "1" (
    ECHO 1
)

ENDLOCAL
Example
Code:
// Trigger Required: "Interval"
// Options recommended: 3000ms, synchronous

require(JD_HOME + "/eventscripter/system/confirm.js");

var ret = confirm("Confirm?");
alert(ret);


Code:
prompt(string title, string text) : string
Spoiler:

JD_HOME/eventscripter/system/prompt.js
Code:
/*jslint browser, long */
/*global getEnvironment, callSync, JD_HOME, alert */
function prompt(text, defaultText) {
    "use strict";

    text = text.replace("\r", "\\r");
    text = text.replace("\n", "\\n");
    var env = getEnvironment();
    var ret = null;
    switch (env.getOSFamily()) {
    case "WINDOWS":
        ret = callSync(JD_HOME + "/eventscripter/system/bin/prompt.bat", "JD2 - EventScripter", text, defaultText);
        ret = (
            (ret)
            ? ret.substring(1, ret.length - 2)
            : null
        ); // remove the leading "1". Its just a dummy to catch the null return
        break;
    default:
        alert("Sorry, your OS is yet not supported for ExDialog-prompt()");
    }
    return ret;
}
JD_HOME/eventscripter/system/bin/prompt.bat
Code:
@echo off
SETLOCAL EnableDelayedExpansion

SET _title=%~1
SET _text=%~2
SET _default=%~3

set _text=%_text:\r="&vbCr&"%
set _text=%_text:\n="&vbLf&"%

:uniqueTempVbs
set "vbsFileName=%TEMP%\~%RANDOM%.vbs"
if exist "%vbsFileName%" goto :uniqueTempVbs

ECHO Wscript.Echo Inputbox("!_text!","!_title!","!_default!")>%vbsFileName%
FOR /f "delims=/" %%G IN ('cscript //nologo %vbsFileName%') DO set _input=%%G
DEL %vbsFileName%

if "%_input%" NEQ "" (
    echo 1%_input%
)

ENDLOCAL
Example
Code:
// Trigger Required: "Interval"
// Options recommended: 3000ms, synchronous

require(JD_HOME + "/eventscripter/system/prompt.js");

alert(prompt("title", "Hello world"));

Last edited by Agita; 31.07.2019 at 12:52.
Reply With Quote
  #852  
Old 31.07.2019, 12:49
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,592
Default

Quote:
Originally Posted by maze View Post
I got whole package of ~500GB, is possible to move each single completed download to another directory? How to do that?
Post #391131
Reply With Quote
  #853  
Old 02.08.2019, 18:16
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

@maze: what filesystem do you use for mounting your remote share. this should not happen and sounds like configuration error
__________________
JD-Dev & Server-Admin
Reply With Quote
  #854  
Old 02.08.2019, 18:18
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

@Agita: don't expect too much JS support. JDownloader uses very basic/limited JS environment
__________________
JD-Dev & Server-Admin
Reply With Quote
  #855  
Old 05.08.2019, 10:13
Fetter Biff
Guest
 
Posts: n/a
Default Default Kann man JD automatisch neu starten lassen, so wie er 0 MB/s lädt?

Kann man JD automatisch neu starten lassen, so wie er 0 MB/s lädt / nichts mehr runterlädt, aber nur, wenn er nicht entpackt?
Reply With Quote
  #856  
Old 05.08.2019, 19:36
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,592
Default

Quote:
Originally Posted by Fetter Biff View Post
Kann man JD automatisch neu starten lassen, so wie er 0 MB/s lädt / nichts mehr runterlädt, aber nur, wenn er nicht entpackt?
In addition to the extraction check, I have also included linkcrawler and linkcollector check. You can remove/comment them out if they are not required. Hope I have understood your requirement correctly.

Code:
// Restart JD if download speed in 0 and JD is idle.
// Trigger: Interval (Recommended: 60000 or more).
// IMPORTANT: Enable "Synchronous execution of script" checkbox in the top panel.

var mySeconds = 120; // (in seconds) <- Restart JD if speed remains at zero for this duration.

if (isSpeedZero()) {
    var elapsed = 0;
    while (isSpeedZero() && elapsed < mySeconds) {
        elapsed++;
        sleep(1000);
    }
    if (isSpeedZero() && isIdle()) callAPI("system", "restartJD");
}

//Functions
function isSpeedZero() {
    return getRunningDownloadLinks().length && !getTotalSpeed();
}

function isIdle() {
    if (callAPI("linkcrawler", "isCrawling")) return;
    if (callAPI("linkgrabberv2", "isCollecting")) return;
    if (callAPI("extraction", "getQueue").length > 0) return;
    return true;
}

What exactly is causing the downloads to stall? Does restart fix the issue? If not, the script will keep running in a loop. If you can provide a log Jiaz might be able to check it and fix the underlying issue, or recommend an alternative solution.
Reply With Quote
  #857  
Old 08.08.2019, 18:29
DunDee DunDee is offline
Registered / Inactive
 
Join Date: Aug 2019
Posts: 16
Default

Can someone help me with my list of files. i got backup data my on 1fichier.com hosting. Now they got new rules when someone don't download it in 60 or 80 days they change it to cold storage from hot storage. I used this hosting only for my data backup.
So my question is can someone write a script in JS with short connections with my filelist when i add it in JD2 and i will download simulate only for connect with my files list it can be little download and move to next of files in list.

JD2 got script builded with restart of downloads if below are 50kb then restart. Maybe someone know how to change this script, and dont restard only skip after speed is below 50kb/s then my files move to hot storage and i will rescue them before they delete it from my account.
Sorry for my english im not very good with writing.
this is from JD2 script restard download if the speed is low.

Code:
//check if downloads are running at all
if (isDownloadControllerRunning() && !isDownloadControllerStopping()) {
    var running = getRunningDownloadLinks();
    //loop through all running Downloads
    for (var i = 0; i < running.length; i++) {
        //check if the download has been running at least 30 seconds
        if (running[i].getDownloadDuration() > 30000) {
            //check if the current speed is below 50kb/s
            if (running[i].getSpeed() < 50 * 1024) {
                //reset the download
                //running[i].reset();
                //stop the download and restart it
                running[i].abort();
            }

        }
    }
}

Last edited by DunDee; 08.08.2019 at 19:33.
Reply With Quote
  #858  
Old 18.08.2019, 10:13
djmakinera djmakinera is offline
Banned
 
Join Date: May 2010
Location: Poland
Posts: 8,387
Default

I am looking for a script to download html-pages.
Reply With Quote
  #859  
Old 18.08.2019, 16:32
DunDee DunDee is offline
Registered / Inactive
 
Join Date: Aug 2019
Posts: 16
Default

Nobody knows? how to modify this script used in JD2?
Reply With Quote
  #860  
Old 22.08.2019, 19:39
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

@DunDee: If the data is backup, why is it bad that they move it from hot storage to cold storage. They files aren't lost, just moved?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #861  
Old 28.08.2019, 08:06
ironteeth
Guest
 
Posts: n/a
Default

I have a script request, my apologies if this has already been discussed but I am having an issue where a lot of downloads had extraction errors. I am going through one by one and opening the files with an external extraction software (B1FreeArchiver) and they extract perfectly. It is becoming too tedious to do this one by one for about 200 downloads. Is there a script I can use to speed this process up? The software can batch extract if I open the archives at the same time with the software. As an alternative solution if I could select all of the extraction error files and send them to a single folder, I could then open them outside of JD all at once. Any help would be greatly appreciated. Thanks in advance.

Last edited by ironteeth; 28.08.2019 at 08:10. Reason: additional idea
Reply With Quote
  #862  
Old 28.08.2019, 11:40
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

@ironteeth: the extraction issues are very likely to be caused by unsupported out-of-the-box RAR5
Solution: see https://board.jdownloader.org/showthread.php?t=71069
and download the zip and extract it into the libs folder of your JDownloader installation.
You shouldn't have to take care of extraction by yourself
__________________
JD-Dev & Server-Admin
Reply With Quote
  #863  
Old 29.08.2019, 00:07
ironteeth
Guest
 
Posts: n/a
Default

Thanks for the tip Jiaz, I did see that in my search for a solution and have done the steps to install this. This will be a great addition going forward to prevent the issue, but I don't see a way of dealing with the failed extractions that have already happened before I installed the RAR5 fix. Is there a way to retry all of the extractions instead of going through one by one? I have way too many to manage by manually extracting them one at a time. Like I said there were about 200 or so that downloaded and failed to extract before I installed the RAR5 fix.
Thanks again for the help!
Reply With Quote
  #864  
Old 29.08.2019, 10:50
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

You can rightclick and extract those archives again. You can select all links/packages and do this instead of one by one
__________________
JD-Dev & Server-Admin
Reply With Quote
  #865  
Old 29.08.2019, 22:56
ironteeth
Guest
 
Posts: n/a
Default

What's interesting is that I have tried that and it looks like it is working but when I check the original source folder there is nothing there. I select all of the packages that have extraction errors, right click, select archives, then extract. It looks like its working, there are green check marks and it says finished next to the package and it auto deletes, but like I said when I go to the source folder (where the extractions are usually located) there is nothing there.

Last edited by ironteeth; 29.08.2019 at 22:57. Reason: typo
Reply With Quote
  #866  
Old 30.08.2019, 11:18
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

@ironteeth: extraction finished -> somewhere those files must be. without any custom modification the extraction folder is the same folder where those files are. If you want we can take a look together via teamviewer, just contact me via support@jdownloader.org
__________________
JD-Dev & Server-Admin
Reply With Quote
  #867  
Old 03.09.2019, 11:14
DunDee DunDee is offline
Registered / Inactive
 
Join Date: Aug 2019
Posts: 16
Default

Quote:
Originally Posted by Jiaz View Post
@DunDee: If the data is backup, why is it bad that they move it from hot storage to cold storage. They files aren't lost, just moved?
Data from hot storage to cold are moved after no downloading 80 days when it is they can delete my data in 14 days if nobody download it. That's why i need script to simulate download from other account 1fichier.com. Im doing it once on 2 months. Need this script to do it faster with connections make and don't sit in Jd2 and look all time when connected are delete it. Can u do some script for me or modify exist in JD2.

Quote:
//check if downloads are running at all
if (isDownloadControllerRunning() && !isDownloadControllerStopping()) {
var running = getRunningDownloadLinks();
//loop through all running Downloads
for (var i = 0; i < running.length; i++) {
//check if the download has been running at least 30 seconds
if (running[i].getDownloadDuration() > 30000) {
//check if the current speed is below 50kb/s
if (running[i].getSpeed() < 50 * 1024) {
//reset the download
//running[i].reset();
//stop the download and restart it
running[i].abort();
}

}
}
}
Reply With Quote
  #868  
Old 03.09.2019, 11:25
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

Thanks for the feedback. Didn't know that they're going to delete from cold storage after some time
@mgpai: contact me via mail so we can talk about possible scripts/options for dundee
__________________
JD-Dev & Server-Admin
Reply With Quote
  #869  
Old 06.09.2019, 13:13
lukjod lukjod is offline
JD Alpha
 
Join Date: Sep 2019
Posts: 20
Default reconnect script

is this possible to use event scripter for call bash script on qnap nas to reconnect router.
I have to call bash script

/share/CACHEDEV1_DATA/.qpkg/b715_reboot/reboot_router.sh

which calls python package to restart huawei b715 router

Code:
#!/bin/bash
python3.7 /share/CACHEDEV1_DATA/.qpkg/b715_reboot/reboot_router.py
How to make it right? shoud it contain RECONNECT_BEFORE
Any help needed as all my trials with other approach with
ExternBatchReconnect.json
Code:
{
  "BATCH_COMMAND" : "./reboot.router.sh",
  "TERMINAL" : "/bin/bash",
  "WAIT_FOR_RETURN_SECONDS" : 20,
  "EXECUTE_IN" : "/share/CACHEDEV1_DATA/.qpkg/b715_reboot"
are unsuccessful
Reply With Quote
  #870  
Old 06.09.2019, 14:18
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

No need for eventscripter. You just have to setup that script as external reconnect method
you've got to specify the full path in batch_command, the *execute_in* is just in case you want to specify a different working directory
also best would be to specify the full path to python binary in script
In Settings-Advanced Settings-Reconnect.activepluginid to ExternBatchReconnect
and Reconnect.autoreconnectenabled enable
__________________
JD-Dev & Server-Admin
Reply With Quote
  #871  
Old 06.09.2019, 15:39
lukjod lukjod is offline
JD Alpha
 
Join Date: Sep 2019
Posts: 20
Default

now i have ExternBatchReconnect as
Code:
{
  "BATCH_COMMAND" : "/share/CACHEDEV1_DATA/.qpkg/b715_reboot/reboot_router.sh",
  "TERMINAL" : "/bin/bash",
  "WAIT_FOR_RETURN_SECONDS" : 20,
  "EXECUTE_IN" : ""
}
reboot_router.sh
Code:
#!/bin/bash
/share/CACHEDEV1_DATA/.qpkg/Entware/bin/python3.7 /share/CACHEDEV1_DATA/.qpkg/b715_reboot/reboot_router.py
Reconnect: Active Plugin ID is ExternBatchReconnect
Reconnect: Auto Reconnect is enabled

Here is link for HUawei b715, b618, b525 reboot script
github.com/mkorz/b618reboot

All is working fine
Big TXH Jiaz

Last edited by lukjod; 06.09.2019 at 16:15. Reason: add repository for huawei reconnect python script
Reply With Quote
  #872  
Old 06.09.2019, 15:42
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

@lukjod: yes, that should work. in webinterface there is a reconnect button, you can try it
__________________
JD-Dev & Server-Admin
Reply With Quote
  #873  
Old 06.09.2019, 15:53
lukjod lukjod is offline
JD Alpha
 
Join Date: Sep 2019
Posts: 20
Default

It works ok, thx Jiaz just another problem with unpack?
is my architecture linux-aarch64 supported?
i always get extraction error?
Reply With Quote
  #874  
Old 06.09.2019, 16:06
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

Great !Thanks for the feedback! Yes, here you can find the zip
mega.nz/#!XZ8FgAbD!q2gttNSRhdRFc-3hRo_9obOhMg9fG-W8ZEK2Frp3ih8
download and extract to libs folder(do NOT rename the files)
__________________
JD-Dev & Server-Admin
Reply With Quote
  #875  
Old 06.09.2019, 16:28
lukjod lukjod is offline
JD Alpha
 
Join Date: Sep 2019
Posts: 20
Default

txt but still no go.
Do i need to specify smth in archive extractor? now i have
Extraction: Last Working Lib ID Linux-aarch64
should i have put anything else to call just downloaded files?

edit
uups my rar is 5.0 version

Linux (ARM8, 64Bit)
comming soon... in rar5 sticky topic
so must use windows for now to extract

Last edited by lukjod; 06.09.2019 at 16:32.
Reply With Quote
  #876  
Old 06.09.2019, 16:33
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

you've got to restart JD as well that library supports rar5 and is for correct setup.
I just did not yet update first post
__________________
JD-Dev & Server-Admin
Reply With Quote
  #877  
Old 06.09.2019, 16:50
lukjod lukjod is offline
JD Alpha
 
Join Date: Sep 2019
Posts: 20
Default

Great

it works perfect so far

BIG THX
Reply With Quote
  #878  
Old 06.09.2019, 17:28
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,031
Default

GREAT! Thanks for the feedback
__________________
JD-Dev & Server-Admin
Reply With Quote
  #879  
Old 14.09.2019, 11:01
Bach Bach is offline
Registered / Inactive
 
Join Date: Jul 2017
Posts: 12
Default Automatic update

Hi

Could someone write me a script for an automatic update + restart after all active downloads.
Reply With Quote
  #880  
Old 15.09.2019, 04:50
Demongornot Demongornot is offline
Registered / Inactive
 
Join Date: Sep 2019
Location: Universe, Local group, Milky Way, Solar System, Earth, France
Posts: 50
Default

Hello, does anyone know what code I would need to write to access and control the Youtube Plugin for adding, deleting and changing or selecting subtitles language ".srt" files for Youtube video in the LinkGrabber ?
I code in Javascript since few days so I don't know advanced features yet, the only option I could do would be to feed that video link into a Youtube subtitle's extraction website and get & rename the received file, I haven't done much on HTML elements yet but I think I could get that easily, but I would prefer to directly use the Youtube Plugin in JDownloader.
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 23:03.
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.