JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 22.08.2016, 12:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default [Event Scripter] Scripts and requests

EDIT by pspzockerscene:
If you were sent to this thread but you do not know what the EventScripter is, please read THIS support article first.

Convert AAC/M4A/OGG/OPUS files to MP3.
Code:
// Convert aac/m4a/ogg/opus files to mp3.
// Trigger required: "A Download Stopped".
// Requires ffmpeg/ffprobe. Uses JD ffmpeg/ffprobe settings if available.
// Overwrites destination file (mp3) if it already exists.

if (link.isFinished()) {
    var fileName = link.name.replace(/(.+)(\..+$)/, "$1");
    var fileType = link.name.replace(/(.+)(\..+$)/, "$2");
    var sourceFile = link.getDownloadPath();
    var audioFile = /\.(aac|m4a|ogg|opus)$/.test(sourceFile);

    if (audioFile) {
        var downloadFolder = package.getDownloadFolder();
        var destFile = 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");
        var data = JSON.parse(callSync(ffprobe, "-v", "quiet", "-print_format", "json", "-show_streams", "-show_format", sourceFile));
        var streamsBitrate = data.streams[0].bit_rate ? data.streams[0].bit_rate : 0;
        var formatBitrate = data.format.bit_rate ? data.format.bit_rate : 0;
        var bitrate = Math.max(streamsBitrate, formatBitrate) / 1000;
        var deleteSourceFile = false; // Set this to true to delete source file after conversion.

        if (bitrate > 0) {
            callSync(ffmpeg, "-y", "-i", sourceFile, "-b:a", bitrate + "k", destFile);
            if (deleteSourceFile && getPath(destFile).exists()) deleteFile(sourceFile, false);
        }
    }
}

Alternate version (2021.11.04)
Code:
/*
    Convert audio files to mp3 format
    Trigger : A download stopped
*/

if (link.finished) {
    var input = link.downloadPath;
    var output = input.replace(/(aac|m4a|ogg|opus)$/, "mp3");

    if (input != output) {
        try {
            var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
            var bitrate = callSync(ffmpeg, "-i", input).match(/bitrate: (\d+) kb/)[1];

            callAsync(function(error) {
                !error && getPath(input).delete();
            }, ffmpeg, "-y", "-i", input, "-b:a", bitrate + "k", output);
        } catch (e) {};
    }
}

Last edited by Jiaz; 12.08.2022 at 17:49. Reason: Added alternate version
Reply With Quote
  #2  
Old 31.08.2016, 16:20
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Save youtube links and basic information to a html page
Code:
// Save youtube links and basic information to a html page.
// Trigger required: "A Download Stopped"

// Get link property
String.prototype.prop = function() {
    return link.getProperty(this);
};

// Convert duration to hh:mm:ss.ms format
Date.prototype.duration = function() {
    var ms = parseInt((this % 1000) / 100);
    var ss = parseInt((this / 1000) % 60);
    var mm = parseInt((this / (1000 * 60)) % 60);
    var hh = parseInt((this / (1000 * 60 * 60)) % 24);

    hh = (hh < 10) ? "0" + hh : hh;
    mm = (mm < 10) ? "0" + mm : mm;
    ss = (ss < 10) ? "0" + ss : ss;

    return hh + ":" + mm + ":" + ss + "." + ms;
};

// Get media bitrate
Number.prototype.toKbps = function() {
    return ((this / mediaDuration) * 8).toFixed(2);
};

// youtube media check
var youtubeMedia = link.getHost() == "youtube.com" && (/\.(m4a|aac|ogg|mp3|mp4|webm)$/).test(link.getName());

// Get Data
if (youtubeMedia) {
    var output = [];
    var variant = JSON.parse("YT_VARIANT".prop());
    var variantData = JSON.parse(variant.data);
    var youtube = "<a href=\"" + "http"+ "s://youtube.com/";
    var saveFile = link.getDownloadPath() + ".info.html";
    var fileSize = link.getBytesTotal();
    var demux = (/DEMUX/).test(variant.id);
    var audioSize = !demux ? "DASH_AUDIO_SIZE".prop() : fileSize;
    var videoSize = "DASH_VIDEO_SIZE".prop();
    var mediaDuration = "YT_DURATION".prop();
    var data = {
        Video: youtube + "watch?v=" + "YT_ID".prop() + "\">" + "YT_TITLE".prop() + "</a>",
        Playlist: "YT_PLAYLIST_ID".prop() && "YT_PLAYLIST_TITLE".prop() ? youtube + "playlist?list=" + "YT_PLAYLIST_ID".prop() + "\">" + "YT_PLAYLIST_TITLE".prop() + "</a>" : null,
        User: youtube + "user/" + "YT_USER_NAME".prop() + "\">" + "YT_USER_NAME".prop() + "</a>",
        Channel: youtube + "channel/" + "YT_CHANNEL_ID".prop() + "\">" + "YT_CHANNEL".prop() + "</a>" + "\r\n",
        Published: new Date("YT_DATE".prop()).toDateString(),
        Size: (fileSize / 1048576).toFixed(2) + " MiB",
        Duration: new Date(mediaDuration).duration(),
        Width: variantData.width,
        Height: variantData.height,
        FPS: variantData.fps,
        Audio_Bitrate: audioSize.toKbps() + " kbps",
        Video_Bitrate: !demux && fileSize > audioSize ? videoSize.toKbps() + " kbps" : null,
        Overall_Bitrate: !demux && fileSize > audioSize ? fileSize.toKbps() + " kbps" : null,
        Variant_ID: variant.id,
    };
    // Generate output[]
    for (i in data) {
        if (data[i] && data[i] != -1) {
            output.push(i.replace(/_/g, " ") + " : " + data[i]);
        }
    }
    // Format output[] and save to html file
    try {
        deleteFile(saveFile, false); // Delete info file if it already exists on the disk.
        writeFile(saveFile, "<pre>" + output.join("<br>") + "</pre>", false);
    } catch (err) {
        log(err + "");
    }
}
Attached Files
File Type: html Sample_Output.html (717 Bytes, 86 views)

Last edited by Jiaz; 15.07.2019 at 14:33.
Reply With Quote
  #3  
Old 02.09.2016, 13:57
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Extraction Scheduler
Code:
// Schedule Extraction
// Trigger Required: Interval
// Disable Auto Extract in Archive Extractor
// Forum Topic: https://board.jdownloader.org/showthread.php?t=70655

var t = [21, 30]; //Set Starting Time [hours,minutes] e.g. [21,30] is 9:30 PM

if ((new Date().setHours(t[0], t[1], 0, 0) % new Date() < interval)) {
    var links = getAllDownloadLinks();

    for (i = 0; i < links.length; i++) {
        var link = links[i];
        var autoExtract = link.getArchive().getInfo().autoExtract;

        if (link.isFinished() && link.getArchive() && link.getExtractionStatus() == null && autoExtract != "FALSE") {
            callAPI("extraction", "startExtractionNow", [link.getUUID()], []);
        }
    }
}


Rewritten:
Code:
github.com/mgpai/resources/blob/master/jdownloader/eventscripter/scripts/Taobaibai.js

Last edited by mgpai; 22.02.2018 at 18:00. Reason: Added link to rewritten script
Reply With Quote
  #4  
Old 06.09.2016, 15:22
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Update JD when idle.
Code:
// Restart and Update JD when idle
// Trigger Required: "Interval"

var newInterval = 600000;

if (interval == newInterval) {
    if (isDownloadControllerIdle()) {
        if (isUpdateAvailable() && !isExtracting() && !isCrawling()) {
            restartAndUpdate();
        } else {
            if (!isAutoUpdateCheckEnabled()) {
                runUpdateCheck();
            }
        }
    }
} else {
    interval = newInterval;
}

//Functions

function isUpdateAvailable() {
    return callAPI("update", "isUpdateAvailable");
}

function isExtracting() {
    return callAPI("extraction", "getQueue").length > 0;
}

function isCrawling() {
    return callAPI("linkcrawler", "isCrawling");
}

function restartAndUpdate() {
    callAPI("update", "restartAndUpdate");
}

function isAutoUpdateCheckEnabled() {
    return callAPI("config", "get", "org.jdownloader.updatev2.UpdateSettings", null, "autoupdatecheckenabled");
}

function runUpdateCheck() {
    callAPI("update", "runUpdateCheck");
}

Updated version of the script can be found in Post# 881 of this thread.

Last edited by mgpai; 15.09.2019 at 10:52. Reason: Link to new version of the script.
Reply With Quote
  #5  
Old 10.09.2016, 12:51
DoctorD90
Guest
 
Posts: n/a
Default md5sum

Generate md5 hash file in download folder
Code:
// Generate md5 hash file in download folder
// Trigger: "A Download Stopped"
// Latest updates: **External links are only visible to Support Staff**// Credits: mgpai

if (link.isFinished()) {
	var filename = link.getName()
	var file = link.getDownloadPath()
	var folder = link.package.getDownloadFolder()
	var hashfile = folder + "/" + filename + "\.md5"
	if (getPath(hashfile).exists()) getPath(hashfile).delete()
	var MD5text = getChecksum("md5", file).toLowerCase() + "\t" + filename + "\n"
	writeFile(hashfile, MD5text, true)
}

Last edited by DoctorD90; 10.09.2016 at 13:29.
Reply With Quote
  #6  
Old 30.01.2019, 20:32
plaintext plaintext is offline
BugMeNot Account
 
Join Date: Sep 2016
Posts: 241
Default

Quote:
Originally Posted by mgpai View Post
Update JD when idle.
I would like to trigger updates after a reconnect, can you tell me how to modify the script for this?
Why dont't you need to check isDonwloading() ?

thank you.
Reply With Quote
  #7  
Old 31.01.2019, 06:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by plaintext View Post
I would like to trigger updates after a reconnect...
It might better to restart and update "Before a Reconnect". Running it "After a Reconnect", may interrupt downloads or any other activities which have started immediately after the reconnect, in which case updating while idle is a better option.

This script can also be used with "After a Reconnect" trigger.

Code:
// Restart and update, if updates are available
// Trigger: Before a Reconnect

if (callAPI("update", "isUpdateAvailable")) callAPI("update", "restartAndUpdate");

Quote:
Originally Posted by plaintext View Post
Why dont't you need to check isDonwloading() ?
It does check if downloads are running (isDownloadControllerIdle()).
Reply With Quote
  #8  
Old 22.02.2018, 00:31
Taobaibai
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by mgpai View Post
Extraction Scheduler
Code:
// Schedule Extraction
// Trigger Required: Interval
// Disable Auto Extract in Archive Extractor
// Forum Topic: https://board.jdownloader.org/showthread.php?t=70655

var t = [21, 30]; //Set Starting Time [hours,minutes] e.g. [21,30] is 9:30 PM

if ((new Date().setHours(t[0], t[1], 0, 0) % new Date() < interval)) {
    var links = getAllDownloadLinks();

    for (i = 0; i < links.length; i++) {
        var link = links[i];
        var autoExtract = link.getArchive().getInfo().autoExtract;

        if (link.isFinished() && link.getArchive() && link.getExtractionStatus() == null && autoExtract != "FALSE") {
            callAPI("extraction", "startExtractionNow", [link.getUUID()], []);
        }
    }
}



Doesn't work for me? Is there an update?
Reply With Quote
  #9  
Old 18.05.2019, 23:14
JDFan
Guest
 
Posts: n/a
Default

Hello,

the code example
Save youtube links and basic information to a html page
contains the following invalid line:
Code:
if (youtubeMedia) {
    var output = [];
    var variant = JSON.parse("YT_VARIANT".prop());
    var variantData = JSON.parse(variant.data);
    var youtube = "<a href=\"External links are only visible to Support Staff;
Can someone be so kind and correct that?


Many thanks and greetings
JDFan
Reply With Quote
  #10  
Old 19.05.2019, 08:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by JDFan View Post
... the code example Save youtube links and basic information to a html page contains the following invalid line: ...
Code:
 var youtube = "<a href=\"External links are only visible to Support Staff;

Script:
Code:
gist.github.com/mgpai/defe23044e32d7cec7756053997295e1/download
Reply With Quote
  #11  
Old 29.09.2016, 15:01
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Split packages and create sub-folders

Adding custom command to context menu
  1. Add script to event scripter
  2. Go to Linkgrabber Tab > Context Menu > Open Menu Manager
  3. Add Submenu > Name it "Scripts" (can specify any name)
  4. Select "Scripts" Submenu > Add Action > EventScripter Trigger
  5. In the right-side panel change the name from "EventScripter Trigger" to "Split Packages" (Exact name specified in the script, case-sensitive)
  6. Save
Code:
// Split Packages and create sub-folder based on package length
// Trigger : Linkgrabber Contextmenu Button Pressed
// Forum Topic: https://board.jdownloader.org/showthread.php?t=70979

if (name == "Split Packages") {
    var package = lgSelection.getContextPackage();
    var links = package.getDownloadLinks();
    var newSize = 100; // Specify max number of links per package
    var UUIDS = [];
    var count = 1;

    if (links.length > newSize) {
        for (i = 0; i < links.length; i++) {
            var link = links[i];
            UUIDS.push(link.getUUID());
        }

        while (UUIDS.length) {
            var oldFolder = package.getDownloadFolder();
            var packageName = package.getName();
            var splitUUIDS = UUIDS.splice(0, newSize);
            var newFolder = oldFolder + "/" + pad(count);
            setNewFolder();
            count++;
        }
    }
}

// Add sub folder
function setNewFolder() {
    callAPI("linkgrabberv2", "movetoNewPackage", splitUUIDS, [], packageName, newFolder);
}

// Pad number with leading zeros
function pad(num) {
    var a = num + "";
    var b = (links.length / newSize).toFixed(0);
    while (a.length < b.length) a = "0" + a;
    return a;
}
Reply With Quote
  #12  
Old 07.10.2016, 14:52
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Simple history of downloaded links in text format.
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\history")
  • Default file name: "<current date>.txt" (e.g. "Oct 07 2016.txt")
Code:
// Simple history
// Trigger Required : A Download Stopped

if (link.isFinished()) {
    var a /*date*/ = new Date().toString().substring(4, 16);
    var b /*history folder*/ = JD_HOME + "/auto/history/";
    var c /*history file Name */ = a + ".txt";
    var d /*download url*/ = link.getContentURL();
    var e /*download file name*/ = link.getName();

    if (!getPath(b).exists()) getPath(b).mkdirs();
    writeFile(b + c, [d, e].join(",") + "\r\n", true);
}
Reply With Quote
  #13  
Old 17.10.2016, 13:59
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Hide/Unhide Infobar Window

Adding custom command to Tray menu
  • Add script to event scripter
  • Tray Menu > Open Menu Manager > Add Action > EventScripter Trigger
  • In the right-side panel, change the name from "EventScripter Trigger" to "Infobar" (Exact name - without quotes - as specified in the script, case-sensitive)
  • Change Icon (Optional)
  • Save
Code:
// Hide/Unhide Infobar Window
// Trigger: Traymenu Button Pressed
// Can also use other 'button pressed' triggers if you want to specify/use 'keyboard shortcut'
// Requirements: Install and enable infobar extension
// Forum Topic: https://board.jdownloader.org/showthread.php?t=70617

if (name = "Infobar") {
    var infobar = "org.jdownloader.extensions.infobar.InfoBarConfig";
    var storage = "cfg/org.jdownloader.extensions.infobar.InfoBarExtension";
    var windowVisible = callAPI("config", "get", infobar, storage, "windowvisible");

    if (windowVisible) {
        callAPI("config", "set", infobar, storage, "windowvisible", false);
    } else {
        callAPI("config", "set", infobar, storage, "windowvisible", true);
    }
}

Last edited by mgpai; 18.10.2016 at 11:56. Reason: Modified scrtipt to Hide/Unhide Infobar Window instead of Enable/Disable Infobar Extension
Reply With Quote
  #14  
Old 11.11.2016, 01:03
Spongshga's Avatar
Spongshga Spongshga is offline
JD Legend
 
Join Date: Apr 2009
Location: web
Posts: 1,159
Default

Quote:
Originally Posted by mgpai View Post
Simple history of downloaded links in text format.
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\history")
  • Default file name: "<current date>.txt" (e.g. "Oct 07 2016.txt")
Code:
// Simple history
// Trigger Required : A Download Stopped

if (link.isFinished()) {
    var a /*date*/ = new Date().toString().substring(4, 16);
    var b /*history folder*/ = JD_HOME + "/auto/history/";
    var c /*history file Name */ = a + ".txt";
    var d /*download url*/ = link.getContentURL();
    var e /*download file name*/ = link.getName();

    if (!getPath(b).exists()) getPath(b).mkdirs();
    writeFile(b + c, [d, e].join(",") + "\r\n", true);
}
Was muss ich ändern um einen Außerhalb des JD-Verzeichniss liegenden Speicher-Pfad anzugeben?
Falls im Beitrag ergrenzt kann dieser Post gelöscht werden :-)


@Administratoren:
Wäre es nicht schlecht für kommende Scripts ein extra Foren-bereich einzurichten und für jeden Script ein Thema zu erstellen. Dann noch ein Verweis via URL im JD in der Script-Erweiterung auf den Foren bereich... Scheint künftig übersichtlicher und Interessanter oder?

Klasse wärs, wenn genannte Scripte bei "Beispielen im JD auftauchen würden und ggf. die außenstehenden Infos im Script dokumentiert werden sodass sie funktionstüchtig laufen. Beispielsweise wie [...] Default folder: "< [...] Oder eben der Hinweis via URL.
__________________
sorry about my gramma (dyslexia).
———————————————————————————————————
SuFu/Google: Inoffizielle JDownloader Plugins, Erweiterungen, Addons & Tools

Last edited by Spongshga; 11.11.2016 at 01:09.
Reply With Quote
  #15  
Old 11.11.2016, 02:54
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Spongshga View Post
Was muss ich ändern um einen Außerhalb des JD-Verzeichniss liegenden Speicher-Pfad anzugeben?
Falls im Beitrag ergrenzt kann dieser Post gelöscht werden :-)
Example:

Code:
var b /*history folder*/ = "c:/myFolder/history/";

Note: Path should always include "/" at the end.
Reply With Quote
  #16  
Old 11.11.2016, 03:22
Informativ Informativ is offline
JD Adviser
 
Join Date: Nov 2016
Posts: 106
Default

Hello mgpai,
i have crawljob white description inside. Is it possible to write this in txt file and do in downloadfolder? I have no idea how to implement this.
regards

https://board.jdownloader.org/showthread.php?t=71524
Reply With Quote
  #17  
Old 29.09.2020, 01:52
metozeton metozeton is offline
Modem User
 
Join Date: Sep 2020
Posts: 1
Default

Quote:
Originally Posted by mgpai View Post
Export download URLs (Linkgrabber List)
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\export")
  • Default file name: "<timestamp> - LG Selection.txt" (e.g. "Nov 25 2016 17.26.44 - LG Selection.txt")
Code:
// Export download URLs
// Trigger : "Linkgrabber Contextmenu Button Pressed"

if (name == "Export URLs") {
    var exportFolder = JD_HOME + "/auto/export/"; // <- Folder for exporting the text files
    var now = new Date().toString().substring(4, 24).replace(/:/g, "."); // <- Timestamp used in file name
    var exportFile = now + " - LG Selection.txt"; // <- Filename for exporting the URLs
    var links = lgSelection.getLinks();
    var urls = [];

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

    if (!getPath(exportFolder).exists()) getPath(exportFolder).mkdirs();
    writeFile(exportFolder + exportFile, urls.join("\r\n"), true);
}

Export Download URLs (Download List)
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\export")
  • Default file name: "<timestamp> - DL Selection.txt" (e.g. "Nov 25 2016 17.26.44 - DL Selection.txt")
Code:
// Export download URLs
// Trigger : "DownloadList Contextmenu Button Pressed"

if (name == "Export URLs") {
    var exportFolder = JD_HOME + "/auto/export/"; // <- Folder for exporting the text files
    var now = new Date().toString().substring(4, 24).replace(/:/g, "."); // <- Timestamp used in file name
    var exportFile = now + " - DL Selection.txt"; // <- Filename for exporting the URLs
    var links = dlSelection.getDownloadLinks();
    var urls = [];

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

    if (!getPath(exportFolder).exists()) getPath(exportFolder).mkdirs();
    writeFile(exportFolder + exportFile, urls.join("\r\n"), true);
}

Hello,

It works. But how can I add information about the source? (the webpage where found the link)

Last edited by metozeton; 29.09.2020 at 02:35.
Reply With Quote
  #18  
Old 29.09.2020, 12:14
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by metozeton View Post
... how can I add information about the source? (the webpage where found the link)
If available, JD may save the webpage URL as 'origin', 'referrer' or 'container' URL depending on the plugin and/or how it was copied. The following script will export all the available URLs related to a link. It can be used with DL or LG context menu trigger.

Code:
// Export related URLs
// Trigger : Linkgrabber Contextmenu Button Pressed OR DownloadList Contextmenu Button Pressed

if (name == "Export URLs") {
    var lgSelection, dlSelection,
        selection = lgSelection || dlSelection;

    if (selection) {
        var folder = JD_HOME + "/auto/export/", // <- Folder for exporting the text files
            date = new Date().toString().substring(4, 24).replace(/:/g, "."), // <- Timestamp used in file name
            name = lgSelection ? " - LG Selection.txt" : " - DL Selection.txt",
            file = date + name,
            content = [],
            links = selection.links,
            addContent = function(arr, data) {
                if (data && arr.indexOf(data) == -1) {
                    arr.push(data);
                }
            };

        links.forEach(function(link) {
            var arr = [];
            addContent(arr, link.name);
            addContent(arr, link.contentURL);
            addContent(arr, link.pluginURL);
            addContent(arr, link.containerURL);
            addContent(arr, link.referrerURL);
            addContent(arr, link.originURL);
            content.push(arr.join(","));
        })

        if (!getPath(folder).exists()) {
            getPath(folder).mkdirs();
        }
        
        writeFile(folder + file, content.join("\r\n"), true);
    }
}
Reply With Quote
  #19  
Old 02.07.2022, 04:42
TomNguyen TomNguyen is offline
DSL Light User
 
Join Date: Jul 2017
Posts: 33
Default

Quote:
Originally Posted by mgpai View Post
Simple history of downloaded links in text format.
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\history")
  • Default file name: "<current date>.txt" (e.g. "Oct 07 2016.txt")
Code:
// Simple history
// Trigger Required : A Download Stopped

if (link.isFinished()) {
    var a /*date*/ = new Date().toString().substring(4, 16);
    var b /*history folder*/ = JD_HOME + "/auto/history/";
    var c /*history file Name */ = a + ".txt";
    var d /*download url*/ = link.getContentURL();
    var e /*download file name*/ = link.getName();

    if (!getPath(b).exists()) getPath(b).mkdirs();
    writeFile(b + c, [d, e].join(",") + "\r\n", true);
}
Dear mgpai,
Could you please help modify this script to save status of all links currently in Jdownloader (not just downloaded links but also links that are currently downloading, links are waiting to download and error links).
My intention is to run this script once per day to get status of all links.
I am currently running Jdownloader on a small Raspberry Pi that doesn't have a screen, it would be very convenient to get status of all links in a text file every day.
Thank you!

Last edited by TomNguyen; 02.07.2022 at 05:10.
Reply With Quote
  #20  
Old 10.11.2016, 20:19
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

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:
Attached Files
File Type: txt links.txt (74 Bytes, 56 views)

Last edited by pspzockerscene; 11.11.2016 at 03:36.
Reply With Quote
  #21  
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
  #22  
Old 07.03.2020, 06:58
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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
  #23  
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
  #24  
Old 07.03.2020, 11:17
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by AlphaSlayer View Post
... 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 /, \. ... "destinationFolder": "C:\Users\Admin\Desktop\New folder\<jd:packagename>"
You have to use either "\\" or "/" as path separators.

Try:

Code:
"C:\\Users\\Admin\\Desktop\\New folder\\<jd:packagename>"

OR

"C:/Users/Admin/Desktop/New folder/<jd:packagename>"
Reply With Quote
  #25  
Old 14.11.2016, 13:19
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

You cannot use multiple comment lines!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #26  
Old 16.11.2016, 14:48
Trialer03
Guest
 
Posts: n/a
Default sorry, failed to set new value

I become the message:

sorry, failed to set new value

what is here wrong?
Reply With Quote
  #27  
Old 16.11.2016, 15:46
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

Can you please provide screenshots/example what you want to set?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #28  
Old 17.11.2016, 17:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Replace 128kbit audio with 192kbit audio in 1080p youtube videos
  • The 1080p video file and 192kbit audio file must be placed in the same package and the package must contain only those two files.
  • Sometimes the actual bitrate of the downloaded audio file can be less than the bitrate stated in the variant. In "Advanced Settings", enable "Youtube.doextendedaudiobitratelookupenabled", to detect the actual audio bitrate before the file is downloaded.
Code:
// Replace 128kbit audio with 192kbit audio in 1080p youtube videos
// Trigger Required: "Package Finished"
// Forum Topic: https://board.jdownloader.org/showthread.php?t=69971

var links = package.getDownloadLinks();

if (links.length == 2) {
    var video = false;
    var audio = false;

    for (i = 0; i < links.length; i++) {
        var link = links[i];
        if (link.getHost() == "youtube.com") {
            var file = link.getDownloadPath();
            var variant = JSON.parse(link.getProperty("YT_VARIANT")).id;
            if ((/DEMUX.+192KBIT/i).test(variant)) {
                audio = file;
                var audioURL = link.getContainerURL();
            }
            if ((/1080P.+128KBIT/i).test(variant)) {
                video = file;
                var videoURL = link.getContainerURL();
                var out = (/128/).test(file) ? file.replace(/128/, "192") : file.replace(/(.+)(\..+)/, "$1 (192kbit Audio)$2");
            }
        }
    }

    if (video && audio && videoURL == audioURL) {
        var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
        callSync(ffmpeg, "-i", video, "-i", audio, "-c", "copy", "-map", "0:v:0", "-map", "1:a:0", out);
    }
}

Last edited by mgpai; 17.11.2016 at 18:21. Reason: Added fallback method for 'output' file name
Reply With Quote
  #29  
Old 25.11.2016, 14:04
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Export download URLs (Linkgrabber List)
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\export")
  • Default file name: "<timestamp> - LG Selection.txt" (e.g. "Nov 25 2016 17.26.44 - LG Selection.txt")
Code:
// Export download URLs
// Trigger : "Linkgrabber Contextmenu Button Pressed"

if (name == "Export URLs") {
    var exportFolder = JD_HOME + "/auto/export/"; // <- Folder for exporting the text files
    var now = new Date().toString().substring(4, 24).replace(/:/g, "."); // <- Timestamp used in file name
    var exportFile = now + " - LG Selection.txt"; // <- Filename for exporting the URLs
    var links = lgSelection.getLinks();
    var urls = [];

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

    if (!getPath(exportFolder).exists()) getPath(exportFolder).mkdirs();
    writeFile(exportFolder + exportFile, urls.join("\r\n"), true);
}

Export Download URLs (Download List)
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\export")
  • Default file name: "<timestamp> - DL Selection.txt" (e.g. "Nov 25 2016 17.26.44 - DL Selection.txt")
Code:
// Export download URLs
// Trigger : "DownloadList Contextmenu Button Pressed"

if (name == "Export URLs") {
    var exportFolder = JD_HOME + "/auto/export/"; // <- Folder for exporting the text files
    var now = new Date().toString().substring(4, 24).replace(/:/g, "."); // <- Timestamp used in file name
    var exportFile = now + " - DL Selection.txt"; // <- Filename for exporting the URLs
    var links = dlSelection.getDownloadLinks();
    var urls = [];

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

    if (!getPath(exportFolder).exists()) getPath(exportFolder).mkdirs();
    writeFile(exportFolder + exportFile, urls.join("\r\n"), true);
}
Reply With Quote
  #30  
Old 13.03.2018, 21:09
patriks's Avatar
patriks patriks is offline
Super Loader
 
Join Date: Aug 2017
Location: Brasil
Posts: 29
Default

Quote:
Originally Posted by mgpai View Post
Export download URLs (Linkgrabber List)

Export Download URLs (Download List)
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\export")
  • Default file name: "<timestamp> - DL Selection.txt" (e.g. "Nov 25 2016 17.26.44 - DL Selection.txt")
Code:
// Export download URLs
// Trigger : "DownloadList Contextmenu Button Pressed"

if (name == "Export URLs") {
    var exportFolder = JD_HOME + "/auto/export/"; // <- Folder for exporting the text files
    var now = new Date().toString().substring(4, 24).replace(/:/g, "."); // <- Timestamp used in file name
    var exportFile = now + " - DL Selection.txt"; // <- Filename for exporting the URLs
    var links = dlSelection.getDownloadLinks();
    var urls = [];

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

    if (!getPath(exportFolder).exists()) getPath(exportFolder).mkdirs();
    writeFile(exportFolder + exportFile, urls.join("\r\n"), true);
}
mgpai, I'm testing this script, but not work, no error message. Did I do something wrong?


I tested the linkgrabber version too, and it did not work.
Reply With Quote
  #31  
Old 14.03.2018, 11:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by patriks View Post
... is it possible to make the script ignore and delete the duplicate links?
Script Updated:
Code:
github.com/mgpai/resources/blob/master/jdownloader/eventscripter/scripts/patriks.js

Quote:
Originally Posted by patriks View Post
I'm testing this script, but not work, no error message. Did I do something wrong?
Have you renamed "EventScripter Trigger" to "Export URLs"? The button name in context menu should be the same as the one used in script.
Reply With Quote
  #32  
Old 07.03.2019, 22:11
Bach Bach is offline
Junior Loader
 
Join Date: Jul 2017
Posts: 12
Default

Quote:
Originally Posted by mgpai View Post
Export download URLs (Linkgrabber List)
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\export")
  • Default file name: "<timestamp> - LG Selection.txt" (e.g. "Nov 25 2016 17.26.44 - LG Selection.txt")
Code:
// Export download URLs
// Trigger : "Linkgrabber Contextmenu Button Pressed"

if (name == "Export URLs") {
    var exportFolder = JD_HOME + "/auto/export/"; // <- Folder for exporting the text files
    var now = new Date().toString().substring(4, 24).replace(/:/g, "."); // <- Timestamp used in file name
    var exportFile = now + " - LG Selection.txt"; // <- Filename for exporting the URLs
    var links = lgSelection.getLinks();
    var urls = [];

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

    if (!getPath(exportFolder).exists()) getPath(exportFolder).mkdirs();
    writeFile(exportFolder + exportFile, urls.join("\r\n"), true);
}

Export Download URLs (Download List)
  • Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\export")
  • Default file name: "<timestamp> - DL Selection.txt" (e.g. "Nov 25 2016 17.26.44 - DL Selection.txt")
Code:
// Export download URLs
// Trigger : "DownloadList Contextmenu Button Pressed"

if (name == "Export URLs") {
    var exportFolder = JD_HOME + "/auto/export/"; // <- Folder for exporting the text files
    var now = new Date().toString().substring(4, 24).replace(/:/g, "."); // <- Timestamp used in file name
    var exportFile = now + " - DL Selection.txt"; // <- Filename for exporting the URLs
    var links = dlSelection.getDownloadLinks();
    var urls = [];

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

    if (!getPath(exportFolder).exists()) getPath(exportFolder).mkdirs();
    writeFile(exportFolder + exportFile, urls.join("\r\n"), true);
}

Hi mgpai

What and how do I have to enter exactly at name == Export Urls.
Reply With Quote
  #33  
Old 21.06.2019, 01:20
thecoder2012's Avatar
thecoder2012 thecoder2012 is offline
Official 9kw.eu Support
 
Join Date: Feb 2013
Location: Internet
Posts: 1,324
Post

Code:
// Export download URLs (original by mgpai)
// Trigger : "DownloadList Contextmenu Button Pressed"

if (name == "Export URLs") {
    var links = dlSelection.getDownloadLinks();
    var urls = [];

    for (i = 0; i < links.length; i++) {
        var link = links[i];
        var fileName = link.getName();
        //var downloadURL = link.getContentURL();//original
        var downloadURL = link.getContentURL() + "," + link.getContainerURL() + "," + link.getOriginURL() + "," + link.getUrl();
        urls.push(downloadURL + "," + fileName);
    }
    alert(urls.join("\r\n"));
}
It works with directlinks (zippyshare, filecrypt) but NOT with container like filecrypt (cnl/dlc container with zippyshare links). I got only "null" or "filecrypt.cc" but nothing else (e.g. zippyshare links).

Directlink:
**External links are only visible to Support Staff****External links are only visible to Support Staff** (www44.zippyshare.com/v/PAJnvyv2/file.html)

Filecrypt test with cnl/dlc container (without captcha):
**External links are only visible to Support Staff****External links are only visible to Support Staff** (filecrypt.cc/Container/BF0DB46AB8.html)

Zippyshare directlink:


Linkgrabber with filecryptlink as directlink and without CNL/DLC:


Filecrypt CNL/DLC (with my browser):


I can grab it with trigger "A new link has been added" (with cnl/dlc) with all tries:
Code:
// See new links
// Trigger: A new link has been added
var myPLink = link;
alert(myPLink.getURL() + "\n");

But I hate workarounds. The option "Synchronous execution of script" is better off with alert function.

Bug? Security reasons?

My old workaround for filecrypt and cnl:
Spoiler:
Code:
//Filecrypt CNL-Test in JS
//disablePermissionChecks();
//setNotifyOnException(false);
require("https" + "://gist.githubusercontent.com/gabrysiak/3dedf160fd2ee719c2b6/raw/1052dfbc0989b8e444df6098ce253d42fa1e6bb7");//base64 en- and decode in js

var myBr = getBrowser();
var html = myBr.getPage("**External links are only visible to Support Staff**);//testlink with CNL and without captcha
var res = html.match(/CNLPOP\('([^']+)', '([^']+)', '([^']+)'/i);
var jk = res[2];
var crypted = res[3];
var crypted_nobase64 = base64_decode(crypted);

var jk_decoded = "";
for (var i = 0; i < jk.length; i += 2) {
    var tmp = jk.substr(i, 2);
    jk_decoded += String.fromCharCode(parseInt(tmp, 16));
}

function bin2string(array) {
    var result = "";
    for (var i = 0; i < array.length; ++i) {
        result += (String.fromCharCode(array[i]));
    }
    return result;
}

//source github.com/kraynel/js-rijndael
//mcrypt/cbc/rijndael-128
var mcrypt = mcrypt ? mcrypt : new function() {
    var ciphers = {
        "rijndael-128": [16, 32]
    }

    var blockCipherCalls = {};
    blockCipherCalls['rijndael-128'] = function(cipher, block, key, encrypt) {
        if (encrypt)
            Rijndael.Encrypt(block, key);
        else
            Rijndael.Decrypt(block, key);
        return block;
    };

    var pub = {};

    pub.Encrypt = function(message, IV, key, cipher, mode) {
        return pub.Crypt(true, message, IV, key, cipher, mode);
    };

    pub.Decrypt = function(ctext, IV, key, cipher, mode) {
        return pub.Crypt(false, ctext, IV, key, cipher, mode);
    };

    pub.Crypt = function(encrypt, text, IV, key, cipher, mode) {
        if (key) cKey = key;
        else key = cKey;
        if (cipher) cCipher = cipher;
        else cipher = cCipher;
        if (mode) cMode = mode;
        else mode = cMode;
        if (!text)
            return true;
        if (blockCipherCalls[cipher].init)
            blockCipherCalls[cipher].init(cipher, key, encrypt);
        var blockS = ciphers[cipher][0];
        var chunkS = blockS;
        var iv = new Array(blockS);
        switch (mode) {
            case 'cfb':
                chunkS = 1;
            case 'cbc':
            case 'ncfb':
            case 'nofb':
            case 'ctr':
                if (!IV)
                    throw "mcrypt.Crypt: IV Required for mode " + mode;
                if (IV.length != blockS)
                    throw "mcrypt.Crypt: IV must be " + blockS + " characters long for " + cipher;
                for (var i = blockS - 1; i >= 0; i--)
                    iv[i] = IV.charCodeAt(i);
                break;
            case 'ecb':
                break;
            default:
                throw "mcrypt.Crypt: Unsupported mode of opperation" + cMode;
        }
        var chunks = Math.ceil(text.length / chunkS);
        var orig = text.length;
        text += Array(chunks * chunkS - orig + 1).join(String.fromCharCode(0));
        var out = '';
        switch (mode) {
            case 'ecb':
                for (var i = 0; i < chunks; i++) {
                    for (var j = 0; j < chunkS; j++)
                        iv[j] = text.charCodeAt((i * chunkS) + j);
                    blockCipherCalls[cipher](cipher, iv, cKey, encrypt);
                    for (var j = 0; j < chunkS; j++)
                        out += String.fromCharCode(iv[j]);
                }
                break;
            case 'cbc':
                if (encrypt) {
                    for (var i = 0; i < chunks; i++) {
                        for (var j = 0; j < chunkS; j++)
                            iv[j] = text.charCodeAt((i * chunkS) + j) ^ iv[j];
                        blockCipherCalls[cipher](cipher, iv, cKey, true);
                        for (var j = 0; j < chunkS; j++)
                            out += String.fromCharCode(iv[j]);
                    }
                } else {
                    for (var i = 0; i < chunks; i++) {
                        var temp = iv;
                        iv = new Array(chunkS);
                        for (var j = 0; j < chunkS; j++)
                            iv[j] = text.charCodeAt((i * chunkS) + j);
                        var decr = iv.slice(0);
                        blockCipherCalls[cipher](cipher, decr, cKey, false);
                        for (var j = 0; j < chunkS; j++)
                            out += String.fromCharCode(temp[j] ^ decr[j]);
                    }
                }
                break;
            case 'cfb':
                for (var i = 0; i < chunks; i++) {
                    var temp = iv.slice(0);
                    blockCipherCalls[cipher](cipher, temp, cKey, true);
                    temp = temp[0] ^ text.charCodeAt(i);
                    iv.push(encrypt ? temp : text.charCodeAt(i));
                    iv.shift();
                    out += String.fromCharCode(temp);
                }
                out = out.substr(0, orig);
                break;
            case 'ncfb':
                for (var i = 0; i < chunks; i++) {
                    blockCipherCalls[cipher](cipher, iv, cKey, true);
                    for (var j = 0; j < chunkS; j++) {
                        var temp = text.charCodeAt((i * chunkS) + j);
                        iv[j] = temp ^ iv[j];
                        out += String.fromCharCode(iv[j]);
                        if (!encrypt)
                            iv[j] = temp;
                    }
                }
                out = out.substr(0, orig);
                break;
            case 'nofb':
                for (var i = 0; i < chunks; i++) {
                    blockCipherCalls[cipher](cipher, iv, cKey, true);
                    for (var j = 0; j < chunkS; j++)
                        out += String.fromCharCode(text.charCodeAt((i * chunkS) + j) ^ iv[j]);
                }
                out = out.substr(0, orig);
                break;
            case 'ctr':
                for (var i = 0; i < chunks; i++) {
                    temp = iv.slice(0);
                    blockCipherCalls[cipher](cipher, temp, cKey, true);
                    for (var j = 0; j < chunkS; j++)
                        out += String.fromCharCode(text.charCodeAt((i * chunkS) + j) ^ temp[j]);
                    var carry = 1;
                    var index = chunkS;
                    do {
                        index--;
                        iv[index] += 1;
                        carry = iv[index] >> 8;
                        iv[index] &= 255;
                    } while (carry)
                }
                out = out.substr(0, orig);
                break;
        }
        if (blockCipherCalls[cipher].deinit)
            blockCipherCalls[cipher].deinit(cipher, key, encrypt);
        return out;
    };

    pub.get_block_size = function(cipher, mode) {
        if (!cipher) cipher = cCipher;
        if (!ciphers[cipher])
            return false;
        return ciphers[cipher][0];
    }

    pub.get_cipher_name = function(cipher) {
        if (!cipher) cipher = cCipher;
        if (!ciphers[cipher])
            return false;
        return cipher;
    }

    pub.get_iv_size = function(cipher, mode) {
        if (!cipher) cipher = cCipher;
        if (!ciphers[cipher])
            return false;
        return ciphers[cipher][0];
    }

    pub.get_key_size = function(cipher, mode) {
        if (!cipher) cipher = cCipher;
        if (!ciphers[cipher])
            return false;
        return ciphers[cipher][1];
    }

    pub.list_algorithms = function() {
        var ret = [];
        for (var i in ciphers)
            ret.push(i);
        return ret;
    }

    pub.list_modes = function() {
        return ['ecb', 'cbc', 'cfb', 'ncfb', 'nofb', 'ctr'];
    }

    var cMode = 'cbc';
    var cCipher = 'rijndael-128';
    var cKey = '12345678911234567892123456789312';

    return pub;
};

var Rijndael = Rijndael ? Rijndael : new function() {
    var pub = {};

    pub.Encrypt = function(block, key) {
        crypt(block, key, true);
    }
    pub.Decrypt = function(block, key) {
        crypt(block, key, false);
    }

    var sizes = [16, 24, 32];

    var rounds = [
        [10, 12, 14], //	16
        [12, 12, 14], //	24
        [14, 14, 14]
    ]; //	32
    var expandedKeys = {};

    var ExpandKey = function(key) {
        if (!expandedKeys[key]) {
            var kl = key.length,
                ks, Rcon = 1;
            ks = 15 << 5;
            keyA = new Array(ks);
            for (var i = 0; i < kl; i++)
                keyA[i] = key.charCodeAt(i);
            for (var i = kl; i < ks; i += 4) {
                var temp = keyA.slice(i - 4, i);
                if (i % kl == 0) {
                    temp = [Sbox[temp[1]] ^ Rcon, Sbox[temp[2]],
                        Sbox[temp[3]], Sbox[temp[0]]
                    ];
                    if ((Rcon <<= 1) >= 256)
                        Rcon ^= 0x11b;
                } else if ((kl > 24) && (i % kl == 16))
                    temp = [Sbox[temp[0]], Sbox[temp[1]],
                        Sbox[temp[2]], Sbox[temp[3]]
                    ];
                for (var j = 0; j < 4; j++)
                    keyA[i + j] = keyA[i + j - kl] ^ temp[j];
            }
            expandedKeys[key] = keyA;
        }
        return expandedKeys[key];
    }

    var crypt = function(block, key, encrypt) {
        var bB = block.length;
        var kB = key.length;
        var bBi = 0;
        var kBi = 0;
        switch (bB) {
            case 32:
                bBi++;
            case 24:
                bBi++;
            case 16:
                break;
            default:
                throw 'rijndael: Unsupported block size: ' + block.length;
        }
        switch (kB) {
            case 32:
                kBi++;
            case 24:
                kBi++;
            case 16:
                break;
            default:
                throw 'rijndael: Unsupported key size: ' + key.length;
        }
        var r = rounds[bBi][kBi];
        key = ExpandKey(key);
        var end = r * bB;
        if (encrypt) {
            AddRoundKey(block, key.slice(0, bB));
            var SRT = ShiftRowTab[bBi];
            for (var i = bB; i < end; i += bB) {
                SubBytes(block, Sbox);
                ShiftRows(block, SRT);
                MixColumns(block);
                AddRoundKey(block, key.slice(i, i + bB));
            }
            SubBytes(block, Sbox);
            ShiftRows(block, SRT);
            AddRoundKey(block, key.slice(i, i + bB));
        } else {
            AddRoundKey(block, key.slice(end, end + bB));
            var SRT = ShiftRowTab_Inv[bBi];
            ShiftRows(block, SRT);
            SubBytes(block, Sbox_Inv);
            for (var i = end - bB; i >= bB; i -= bB) {
                AddRoundKey(block, key.slice(i, i + bB));
                MixColumns_Inv(block);
                ShiftRows(block, SRT);
                SubBytes(block, Sbox_Inv);
            }
            AddRoundKey(block, key.slice(0, bB));
        }
    }

    var Sbox = new Array(99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171,
        118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253,
        147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154,
        7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227,
        47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170,
        251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245,
        188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61,
        100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224,
        50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213,
        78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221,
        116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29,
        158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161,
        137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22);
    //row	0	1	2	3		block Bytes
    var rowshifts = [
        [0, 1, 2, 3], //16
        [0, 1, 2, 3], //24
        [0, 1, 3, 4]
    ]; //32

    var ShiftRowTab = Array(3);
    for (var i = 0; i < 3; i++) {
        ShiftRowTab[i] = Array(sizes[i]);
        for (var j = sizes[i]; j >= 0; j--)
            ShiftRowTab[i][j] = (j + (rowshifts[i][j & 3] << 2)) % sizes[i];
    }
    var Sbox_Inv = new Array(256);
    for (var i = 0; i < 256; i++)
        Sbox_Inv[Sbox[i]] = i;
    var ShiftRowTab_Inv = Array(3);
    for (var i = 0; i < 3; i++) {
        ShiftRowTab_Inv[i] = Array(sizes[i]);
        for (var j = sizes[i]; j >= 0; j--)
            ShiftRowTab_Inv[i][ShiftRowTab[i][j]] = j;
    }
    var xtime = new Array(256);
    for (var i = 0; i < 128; i++) {
        xtime[i] = i << 1;
        xtime[128 + i] = (i << 1) ^ 0x1b;
    }

    var SubBytes = function(state, sbox) {
        for (var i = state.length - 1; i >= 0; i--)
            state[i] = sbox[state[i]];
    }

    var AddRoundKey = function(state, rkey) {
        for (var i = state.length - 1; i >= 0; i--)
            state[i] ^= rkey[i];
    }

    var ShiftRows = function(state, shifttab) {
        var h = state.slice(0);
        for (var i = state.length - 1; i >= 0; i--)
            state[i] = h[shifttab[i]];
    }

    var MixColumns = function(state) {
        for (var i = state.length - 4; i >= 0; i -= 4) {
            var s0 = state[i + 0],
                s1 = state[i + 1];
            var s2 = state[i + 2],
                s3 = state[i + 3];
            var h = s0 ^ s1 ^ s2 ^ s3;
            state[i + 0] ^= h ^ xtime[s0 ^ s1];
            state[i + 1] ^= h ^ xtime[s1 ^ s2];
            state[i + 2] ^= h ^ xtime[s2 ^ s3];
            state[i + 3] ^= h ^ xtime[s3 ^ s0];
        }
    }

    var MixColumns_Inv = function(state) {
        for (var i = state.length - 4; i >= 0; i -= 4) {
            var s0 = state[i + 0],
                s1 = state[i + 1];
            var s2 = state[i + 2],
                s3 = state[i + 3];
            var h = s0 ^ s1 ^ s2 ^ s3;
            var xh = xtime[h];
            var h1 = xtime[xtime[xh ^ s0 ^ s2]] ^ h;
            var h2 = xtime[xtime[xh ^ s1 ^ s3]] ^ h;
            state[i + 0] ^= h1 ^ xtime[s0 ^ s1];
            state[i + 1] ^= h2 ^ xtime[s1 ^ s2];
            state[i + 2] ^= h1 ^ xtime[s2 ^ s3];
            state[i + 3] ^= h2 ^ xtime[s3 ^ s0];
        }
    }
    return pub;
};

alert(mcrypt.Decrypt(crypted_nobase64, jk_decoded, jk_decoded, 'rijndael-128', 'cbc').replace(/\x00+$/g, '') + "\n\n");
__________________
Join 9kw.eu Captcha Service now and let your JD continue downloads while you sleep.

Last edited by thecoder2012; 26.06.2019 at 11:29.
Reply With Quote
  #34  
Old 21.06.2019, 10:50
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,286
Default

Quote:
Originally Posted by thecoder2012 View Post
Bug? Security reasons?
We don't want to provide access to the internal url as this can be abused or the internal url is something purely internal but I've added getPluginURL method with next core update
__________________
JD-Dev & Server-Admin
Reply With Quote
  #35  
Old 03.01.2017, 16:26
Tyler Tyler is offline
JD Legend
 
Join Date: Jul 2010
Posts: 581
Default

Do you take requests?

I need a script that will stop downloads if my download speed drops below say 100kb\s for x amount of minutes and then restart after that time has passed.
Reply With Quote
  #36  
Old 06.01.2017, 14:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by Tyler View Post
I need a script that will stop downloads if my download speed drops below say 100kb\s for x amount of minutes and then restart after that time has passed.
Code:
// Auto stop/restart downloads if the current average speed is below limit.
// Trigger Required: "Interval"

var minSpeed = 128; // (KiB/s) <- minimum average download Speed.
var minDuration = 1; // (minutes) <- minimum download duration per link.
var waitTime = 1; // (minutes) <- wait time before restart.

if (running() && getAverageSpeed() < minSpeed * 1024) {
    stopDownloads();
    sleep(waitTime * 60 * 1000);
    startDownloads();
}

// Check if all downloads have been running for atleast the minimum duration.
function running() {
    var links = getRunningDownloadLinks();
    if (links.length > 0) {
        for (i = 0; i < links.length; i++) {
            var link = links[i];
            if (link.getDownloadDuration() < minDuration * 60 * 1000) {
                return false;
            }
        }
        return true;
    } else {
        return false;
    }
}
Reply With Quote
  #37  
Old 04.02.2017, 12:49
jdorg
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Auto stop/restart downloads if the current average speed is below limit.
// Trigger Required: "Interval"

var minSpeed = 128; // (KiB/s) <- minimum average download Speed.
var minDuration = 1; // (minutes) <- minimum download duration per link.
var waitTime = 1; // (minutes) <- wait time before restart.

if (running() && getAverageSpeed() < minSpeed * 1024) {
    stopDownloads();
    sleep(waitTime * 60 * 1000);
    startDownloads();
}

// Check if all downloads have been running for atleast the minimum duration.
function running() {
    var links = getRunningDownloadLinks();
    if (links.length > 0) {
        for (i = 0; i < links.length; i++) {
            var link = links[i];
            if (link.getDownloadDuration() < minDuration * 60 * 1000) {
                return false;
            }
        }
        return true;
    } else {
        return false;
    }
}
Hi,

is it possible to also reconnect and not just stop and restart?

while testing, i realized that if i activate the speed limit in jdownloader and the speed is below the limit in your script, than it also activates the script.
could you maybe add an "suspend the script code" if "speed limit" in jdownloader is active?

and is there a way to make buttons for the toolbar, that actives/deactivates an specific script from the event scripter list?

i tried the "activate/deactivate Event Scripter Button", but it doesn't seem to work.
even if i deactivate the Event Scripter the activated scripts still run.
and i have to deactivate them in the Event Scripter List in the settings tab.
i think to get the "activate/deactivate Event Scripter Button" to work it needs a restart and thats not practical.

thank you for your work/help
:)

Last edited by jdorg; 04.02.2017 at 12:51.
Reply With Quote
  #38  
Old 04.02.2017, 19:40
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by jdorg View Post
is it possible to also reconnect and not just stop and restart?
Code:
// Request reconnect if the current average speed is below limit.
// Trigger Required: "Interval"

var minSpeed = 128; // (KiB/s) <- minimum average download Speed.
var minDuration = 1; // (minutes) <- minimum download duration per link.

if (running() && !limitEnabled() && getAverageSpeed() < minSpeed * 1024) {
    requestReconnect();
}

// Check if all downloads are resumeable and have been running for atleast the minimum duration.
function running() {
    var links = getRunningDownloadLinks();
    if (links.length > 0) {
        for (i = 0; i < links.length; i++) {
            var link = links[i];
            if (!link.isResumeable() || link.getDownloadDuration() < minDuration * 60 * 1000) {
                return false;
            }
        }
        return true;
    }
    return false;
}

// Check if Speed limit or pause is currently enabled
function limitEnabled() {
    if (callAPI("config", "get", "org.jdownloader.settings.GeneralSettings", null, "downloadspeedlimitenabled") || isDownloadControllerPaused()) {
        return true;
    }
    return false;
}
Quote:
Originally Posted by jdorg View Post
...is there a way to make buttons for the toolbar, that actives/deactivates an specific script from the event scripter list?
Not that I know of. And yes, just disabling the event scripter does not seem to terminate running scripts. Seems it needs to be disabled in the list.

Quote:
Originally Posted by jdorg View Post
thank you for your work/help
:)
You are welcome

Last edited by mgpai; 06.02.2017 at 14:13. Reason: Added check for non-resumeable downloads before reconnect
Reply With Quote
  #39  
Old 05.02.2017, 11:58
jdorg
Guest
 
Posts: n/a
Default

thank you for the script, but i forgot to ask if its possible to check if one or more (active/downloading) files in the download list are NOT resumable.

when there are some of them, than suspend the script and/or give a warning alert/popup that there are NOT resumable links in the list.

EDIT:
i just had a case that my download limit on mega filehoster was reached and the download speed was 0/nothing but there was no reconnect.
what could be the reason?

Last edited by jdorg; 05.02.2017 at 13:40.
Reply With Quote
  #40  
Old 28.03.2017, 01:08
Tyler Tyler is offline
JD Legend
 
Join Date: Jul 2010
Posts: 581
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Auto stop/restart downloads if the current average speed is below limit.
// Trigger Required: "Interval"

var minSpeed = 128; // (KiB/s) <- minimum average download Speed.
var minDuration = 1; // (minutes) <- minimum download duration per link.
var waitTime = 1; // (minutes) <- wait time before restart.

if (running() && getAverageSpeed() < minSpeed * 1024) {
    stopDownloads();
    sleep(waitTime * 60 * 1000);
    startDownloads();
}

// Check if all downloads have been running for atleast the minimum duration.
function running() {
    var links = getRunningDownloadLinks();
    if (links.length > 0) {
        for (i = 0; i < links.length; i++) {
            var link = links[i];
            if (link.getDownloadDuration() < minDuration * 60 * 1000) {
                return false;
            }
        }
        return true;
    } else {
        return false;
    }
}
mgpai could you modify that script for individual links?

like say one link is downloading at 128kb\s leave that alone, but if another is downloading at 50kb/s have it stopped and then started.
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 15:23.
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.