View Single Post
  #843  
Old 12.07.2019, 03: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 07:13.
Reply With Quote