JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1361  
Old 12.05.2020, 12:35
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,103
Default

Quote:
Originally Posted by mgpai View Post
Hello @psp: Sorry for late reply.
No worries
Thanks - I've forwarded this to the user

-psp-
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #1362  
Old 12.05.2020, 16:38
OCHer OCHer is offline
Junior Loader
 
Join Date: Jan 2020
Posts: 12
Default

Quote:
Originally Posted by mgpai View Post
Settings > Advanced Settings > EventScripter.scripts
That is so genius of you @mgpai.
What should the command be if the script only starts after unpacking finished the last download in the queue? Is there also a medicine?

Last edited by OCHer; 12.05.2020 at 16:44.
Reply With Quote
  #1363  
Old 12.05.2020, 20:37
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by martian View Post
Hi all. I'm very new to this and it was recommended to me that I ask the question in this thread. I've used JD2 to download a series of music (.acc and .ogg) files from Youtube playlists so that I can load them into Traktor. The problem is that they won't load because they lack ID3 tags.

I have no real idea what I'm doing here; but might anyone be able to help with a script that could create those tags? A massive thanks for any advice here!
Quote:
Originally Posted by mgpai View Post
It is not possible to add ID3 tags to those formats, since neither of them support that tag type. Also, metadata is not necessary to play media files. It should play just fine without them. Only the song information will not be displayed by the player.

Most likely, the player (or the version of the player) you are using does not have the necessary codecs to play the files...
yep, as mgpai pointed out, possibly codec issue, try this hxxps://codecguide.com/download_kl.htm

if still curious on adding ID3v2 Tags to future downloads give this a try, it's nice to have embed metadata.
Code:
//Add ID3v2 Tags to Youtube Audio Files Includes AAC* & OGG* (w/ffmpeg)
//Trigger: A Download Stopped
//
//IMPORTANT:
//      must config Youtube Plugin with this preset
//      Goto:   [Settings > Plugins > (choose) Youtube > Filename to Audio files > (copy and paste custom audio preset below here)]
//      Preset: [track=`*PLAYLIST_POSITION*`;title=`*TITLE*`;artist=`*USERNAME*`;album=`*PLAYLIST_NAME*`;date=`*DATE*`;.*EXT*] <--without square brackets
//
//      add or remove ID3v2 tags pattern must follow this format:
//      [ffmpegKeyForID3v2Tag=`*YOUTUBE FileNames/PackageNames*`;] <--without square brackets
//
//      ffmpegKeyForID3v2Tags found here > hxxps://gist.github.com/eyecatchup/0757b3d8b989fe433979db2ea7d95a01
//      YOUTUBE FileNames/PackageNames properties are found in [Settings > Plugins > (choose) Youtube > (scroll down toward the bottom)]
//
//NOTE* ffmpeg cant set ID3v2 tags to some audio formats directly e.g aac&ogg but have no problems with container e.g m4a
//      hence this script will wrap aac&ogg file in m4a container then add ID3v2 tags that way
//
//      After finished crawling File Name will be temporary hold Id3v2 metadata retrieved. It'll be messy at first both in DL/LG
//          e.g [track=`0001`;title=`Song Title (Official Video)`;artist=`Uploader Name`;album=`Playlist Name`;date=`Uploaded Date`;.aac]
//      Once finished downloading Id3v2 tags will be applied then custom File Name will be set as [sTrack - sTitle - sArtist - sDate]
//          e.g [0001 - Song Title (Official Video) - Uploader Name - Uploaded Date.acc]           
//

//--------------------------------------------------------
disablePermissionChecks(); //no prompting persmision dialog

var hoster = link.getHost();

if (hoster == 'youtube.com') {
    
    var regexAudioExt = /.+\.(aac|ogg|mp3)$/ig; //<-- add/remove audio file extensions
    var isFinished = link.isFinished();
    var fileName = link.getName();
    var fileExt = fileName.replace(regexAudioExt, '$1');

    if (fileExt && isFinished && hoster == 'youtube.com') {

        var sTrack = '';
        var sTitle = '';
        var sArtist = '';
        var sDate = '';
        var metaData = '';
        var fileDir = link.getPackage().getDownloadFolder();
        var filePath = getPath(fileDir + '/' + fileName)

        var regexMetadata = /^(?:^|\s+)?(track|title|artist|album|date|author_url|comment|copyright)(=`.+`)(?:^|\s+)?$/ig; //<--add/remove ffmpeg keys for ID3v2 tags
        var regexYear = /^(date=`).+(\d{4}`)$/ig;

        var regexFile = /^(.*?)\..{2,4}$/ig;
        var string = fileName.replace(regexFile, '$1');

        string.split(';').forEach(function(tag) {
            var tagTmp = tag;
            //if (regexMetadata.test(tagTmp)) { //this fails when string contains utf-8
            if (tag.match(regexMetadata)) {
                if (regexYear.test(tag)) tagTmp = tag.replace(regexYear, '$1$2');
                if (/^track=/.test(tag)) sTrack = tag.replace(/.+\=`(.+)`$/, '$1 - ');
                if (/^title=/.test(tag)) sTitle = tag.replace(/.+\=`(.+)`$/, '$1 - ');
                if (/^artist=/.test(tag)) sArtist = tag.replace(/.+\=`(.+)`$/, '$1 - ');
                if (/^date=/.test(tag)) sDate = tag.replace(/.+\=`(.+)`$/, '$1');

                tagTmp = tagTmp.replace(/`$/g, '"');
                tagTmp = tagTmp.replace(/=`/g, '="');
                if (tagTmp.length) metaData += ' -metadata ' + tagTmp;
            }
        })

        var m4aExt = 'm4a'
        var newFileName = sTrack + sTitle + sArtist + sDate + ' [' + m4aExt + ']' + '.' + fileExt //Custum final file name
        var m4aContainer = sTrack + sTitle + sArtist + sDate + ' [' + m4aExt + ']' + '.' + m4aExt
        var newFileNameWithNoID3Set = sTrack + sTitle + sArtist + sDate + '.' + fileExt //Custum final file name
        var m4aContainerPath = getPath(fileDir + '/' + m4aContainer);
        var newFilePath = getPath(fileDir + '/' + newFileName);

        //var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath"); //download ffmpeg
        var ffmpeg = getPath(JD_HOME + '/tools/Windows/ffmpeg/x64/ffmpeg.exe');
        var ffmpegID3Cmd = getPath(fileDir + '/setID3' + newFileName + '.cmd');

        if (ffmpeg.exists() && filePath.exists()) {

            //Option 1 - will fail with some filename contains none ASCII chars or filename is too long.
            //vbs or ps1 might fix this issue.
            var deleteOrigFile = '\n\r' + 'del "' + filePath + '"'
            var deleteBatchCmd = '\n\r' + 'del "' + ffmpegID3Cmd + '"'
            var renameBacktoOrigExt = '\n\r' + 'ren "' + m4aContainerPath + '" *.' + fileExt //m4aExt > fileExt
            var windowsId3v2dot3comp = ' -id3v2_version 3 -write_id3v1 1 ';

            if (/.+\.(aac|ogg)$/ig.test(fileName)) {
                var ffmpegId3 = '"' + ffmpeg + '" -i "' + filePath + '" ' + metaData + windowsId3v2dot3comp + ' "' + m4aContainerPath + '"' //wrap audio file(s) in m4a container
                var cmd = ffmpegId3 + renameBacktoOrigExt + deleteOrigFile + deleteBatchCmd;
            } else {
                var ffmpegId3 = '"' + ffmpeg + '" -i "' + filePath + '" ' + metaData + windowsId3v2dot3comp + ' "' + newFilePath + '"'
                var cmd = ffmpegId3 + deleteOrigFile + deleteBatchCmd;
            }

            try {
                deleteFile(ffmpegID3Cmd, false);
                writeFile(ffmpegID3Cmd, cmd, false);
                callSync(ffmpegID3Cmd);
                link.setName(newFileName)
            } catch (e) {
                deleteFile(ffmpegID3Cmd, false);
                link.setName(newFileNameWithNoID3Set) //failed wrapping audio file in m4aExt and no Id3v2 tags applied (occurrs on some non ASCII file names/long file names)
            }

            //Option 2 - not working (inputs welcome)
            //callAsync(ffmpeg, '-i', filePath, '-metadata title="Test Set Title"', newFilePath);
            //callAsync(ffmpeg, '-i', filePath, metaData, newFilePath);

        }
    }
}

Last edited by zreenmkr; 13.05.2020 at 03:21. Reason: added host and container check
Reply With Quote
  #1364  
Old 13.05.2020, 10:18
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,539
Default

@zreenmkr: Thanks for your great work and help on scripting!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1365  
Old 15.05.2020, 09:08
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,550
Default

Quote:
Originally Posted by OCHer View Post
What should the command be if the script only starts after unpacking finished the last download in the queue?
Code:
// Call external program
// Trigger: Archive extraction finished

disablePermissionChecks();

if (isDownloadControllerIdle() && !callAPI("extraction", "getQueue").length) callSync("synoindex", "-R", "video");

This should call the external program if no downloads are running and last archive file has been extracted. Install the script in JD with GUI and copy the JSON value from advanced settings.
Reply With Quote
  #1366  
Old 17.05.2020, 16:00
sherif011 sherif011 is offline
Super Loader
 
Join Date: Jul 2018
Posts: 29
Default

Quote:
Originally Posted by zreenmkr View Post
it is possible if you meant starting right now begin count download bytes, once bytes downloaded reach 20GB then stop all downloads.

two scripts needed:
1st one Switch - allow to Reset and Restart loaded bytes session Plus set download limit
2nd one Main - monitor loaded bytes session until limit reached

Code:
//1st
// NOTE: A SWITCH FOR: Stop downloads when target reached
// Get initial loaded bytes state and export initial bytes to txt file
// functional:  To Start AND/OR Reset and Restart Initial Loaded Bytes Count
//              also allow user to set Download Limit in GB for new session
// Trigger: 3 Options: Downloadlist Contextmenu Button Pressed | Toolbar Button Pressed | Main Menu Button Pressed
// ***NOTE: this will always Reset last session and Start a New Session


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

//--------------------------------------------------------
//setDisableOnException(true); // enable/disable script on error exceptions
//setNotifyOnException(true); // true enable/false disable error notification on exceptions

//--------------------------------------------------------
//setAdvancedAlert(true);


beginLoadedBytesState = getPath(JD_HOME + '/tmp/_init_loaded_bytes_state.txt');
bytesTarget = getPath(JD_HOME + '/tmp/_set_download_limit_per_session.txt');

if (name == 'Start Monitor Loaded Bytes') {
    if (isDownloadControllerRunning()) {

        var loadedBytesInit = 0;

        if (beginLoadedBytesState.exists()) {
            deleteFile(beginLoadedBytesState, false);

            loadedBytesInit = _getCurrentLoadedBytesState();
            writeFile(beginLoadedBytesState, loadedBytesInit, false);

            var bytesLimit = _setDownloadBytesSessionLimit()
            var bytesLimit = bytesLimit.replace(/^\[(.*?)\]/, '$1');
            var bytesLimit = parseInt(bytesLimit.replace(/\[^0-9.]/g, ''));

            alert('New Session with Limit of: ' + bytesLimit + ' GB');
        } else {
            loadedBytesInit = _getCurrentLoadedBytesState();
            writeFile(beginLoadedBytesState, loadedBytesInit, false);
        }
    }
}

//--------------------------------------------------------
function _getCurrentLoadedBytesState() {
    var loadedBytesCount = 0;
    getAllDownloadLinks().filter(function(link) {
        return link.getBytesLoaded();
    }).forEach(function(link) {
        loadedBytesCount += link.getBytesLoaded();
    })
    return loadedBytesCount
}

//--------------------------------------------------------
function _setDownloadBytesSessionLimit() {
    var inputBox = 'notepad.exe';
    if (!bytesTarget.exists()) {
        writeFile(bytesTarget, "[20] <-- Enter New download limit (unit in GB) inside Square Brackets or Leave as it. ***NOTE: Will Reset/Restart New Session!", true);
    }
    callSync(inputBox, bytesTarget);
    return readFile(bytesTarget);
}

Code:
//2nd
// Stop downloads when target reached
// Trigger: Interval (Recommended 60000 or more)


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

//--------------------------------------------------------
//setDisableOnException(true); // enable/disable script on error exceptions
//setNotifyOnException(true); // true enable/false disable error notification on exceptions

//--------------------------------------------------------
//setAdvancedAlert(true);



beginLoadedBytesState = getPath(JD_HOME + '/tmp/_init_loaded_bytes_state.txt');
bytesTarget = getPath(JD_HOME + '/tmp/_set_download_limit_per_session.txt');

if (isDownloadControllerRunning()) {

    // get
    if (beginLoadedBytesState.exists()) {

        var target = _getTargetBytes();
        var loadedBytesInit = readFile(beginLoadedBytesState);
        var loadedBytesCurr = _getCurrentLoadedBytesState();

        // condition
        if ((loadedBytesCurr - parseInt(loadedBytesInit)) / 1e9 > target) {
            deleteFile(beginLoadedBytesState, false);
            stopDownloads();
        }

        // debug - make sure to set interval to at least 10secs otherwise you are not going to like this alert
        //var loadedBytes = ((loadedBytesCurr - parseInt(loadedBytesInit)) / 1e9);
        //alert('init:\t' + loadedBytesInit + '\ncurr:\t' + loadedBytesCurr + '\n\r' + 'progress:\t' + loadedBytes + ' GB\ntarget:\t' + target + ' GB');
    } else {
        //Need to run 1st script to set beginLoadedBytesState & bytesTarget
        //otherwise this script does not execute anything on first run or after target met
    }
}


//--------------------------------------------------------
function _getTargetBytes() {
    if (bytesTarget.exists()) {
        var target = readFile(bytesTarget); // <- get limit set by user (in GB)
        var target = target.replace(/^\[(.*?)\]/, '$1');
        var target = parseInt(target.replace(/[^0-9.]/g, ''));
    } else {
        var target = 20; // <- Set limit (in GB) note: user input will overwrite 
    }
    return target
}


//--------------------------------------------------------
function _getCurrentLoadedBytesState() {
    var loadedBytesCount = 0;
    getAllDownloadLinks().filter(function(link) {
        return link.getBytesLoaded();
    }).forEach(function(link) {
        loadedBytesCount += link.getBytesLoaded();
    })
    return loadedBytesCount
}
Thank you, but I'm not sure what trigger I should be using for the 1st script, do I have to add and configure a new button? And what if I need to change the limit, do I have to change it in both scripts?

Last edited by sherif011; 17.05.2020 at 16:09.
Reply With Quote
  #1367  
Old 17.05.2020, 16:03
sherif011 sherif011 is offline
Super Loader
 
Join Date: Jul 2018
Posts: 29
Default

Quote:
Originally Posted by mgpai View Post
It is possible to set session based limit instead of daily limit. But I could not quite understand what you meant by "with no regards to previous downloads".
I mean, I just need to set the limit for the current session, just after I click start, without counting previous downloads.
Reply With Quote
  #1368  
Old 17.05.2020, 17:10
MrBojangles_ MrBojangles_ is offline
Junior Loader
 
Join Date: May 2020
Posts: 13
Default

Hi I've got a couple things I'm trying to sort out in this script. One thing I've pretty much done but I haven't got a clue how to do the second thing.

1: This script works fine, until after it runs test.exe, when that task completes the downloads don't start again...I don't understand why.

2: I want to be able to measure the interval between occurrences of the script. For example take the system time, save as a global variable, then compare that with system time the next time a download goes offline.

Hope someone can help!

Code:
// Script to stop, reset links, run captcha macro, restart downloads
// Trigger: "A Download Stopped"
var finalStatus = link.getFinalLinkStatus();
disablePermissionChecks();
if (finalStatus == "OFFLINE") {
    stopDownloads();
    link.reset();
    callSync("c:\\test.exe");
    startDownloads();
}
Reply With Quote
  #1369  
Old 17.05.2020, 20:48
ElCho ElCho is offline
Tornado
 
Join Date: May 2014
Posts: 247
Default

@mgpai

Hi, regarding the script that deals with Zippyshare's and general links reset, is there a way that it doesn't trigger the sleeping process if there are still pending downloads? I mean, the other day I left a bunch of files downloading and since after a while the system went to sleep, I thought all of them were downloaded, but it wasn't like that. Back when I checked, I noticed the system was put to sleep, but there were many files still not downloaded/interrupted.

Thanks.

Last edited by ElCho; 18.05.2020 at 13:39. Reason: typo
Reply With Quote
  #1370  
Old 18.05.2020, 02:59
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by sherif011 View Post
Thank you, but I'm not sure what trigger I should be using for the 1st script, do I have to add and configure a new button? And what if I need to change the limit, do I have to change it in both scripts?

leave the 2nd script alone, dont change anything there. because trigger is interval, it runs silently in the background every x number of mili-seconds (change that at top right corner of eventscript editor, 1000 = 1second) to check if x GB limit is met that is set by the 1st script.

1st script is a controller, allows your to enter x GB limit and also start a new session everytime you select/click on it. to activate the controller, create a button or a menu selector for it. there are 3 options for trigger described but there are also other options to do that.

the 3 commonly used are Toolbar Button at the top, or add menu selector when you Right-Mouse-Click or in the Main menu.

here is the tutorial, But the easiest way is after you set trigger to e.g 'Toolbar Button Pressed', go back into eventscripter editor, there is now a button at the top call 'Main Toolbar', click on that, follow the tutorial above to create a button. rename 'Event Scripter' to 'Start Monitor Loaded Bytes'

Last edited by zreenmkr; 18.05.2020 at 03:04.
Reply With Quote
  #1371  
Old 18.05.2020, 04:40
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by MrBojangles_ View Post
1: This script works fine, until after it runs test.exe, when that task completes the downloads don't start again...I don't understand why.
use this to get the actual link status, you might also want to look into isSkipped();. instead of reset(); try resume();
Code:
//Trigger: Downloadlist ContextMenu Button Pressed
if (name == 'CheckLink Status') {
    try {
        link = lgSelection.getContextLink();
    } catch (e) {}
    try {
        link = dlSelection.getContextLink();
    } catch (e) {}

    var lnkStatus1 = link.getStatus();
    var lnkStatus2 = link.getFinalLinkStatus();
    alert('status1: ' + lnkStatus1 + '\nstatus2: ' + lnkStatus2);
}

Quote:
2: I want to be able to measure the interval between occurrences of the script. For example take the system time, save as a global variable, then compare that with system time the next time a download goes offline.
not sure what you want to do with the time interval check. afaik jd eventscriptr is single instance script. every global variables are reset after script exited/completed. there is a workaround by save it out to txt file then read back at later time. scroll back to a few post sjust above for example. make sure text file name is unique by using the file name e.g link.getName(); again dont know what callSync("c:\\test.exe"); will give you but getStatus(); isSkipped(); & resume(); are all you might need

alternatively if you know why your files skip downloading or go offline frequently, you can also use trigger Interval and check every links every x minutes. Adapt this script to your own needs

Last edited by zreenmkr; 18.05.2020 at 06:11.
Reply With Quote
  #1372  
Old 18.05.2020, 05:01
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by ElCho View Post
@mgpai

Hi, regarding the script that deals with Zippyshare's and general links reset, is there a way that it doesn't trigger the sleeping process if there is still pending downloads? I mean, the other day I left a bunch of files downloading and since after a while the system went to sleep, I thought all of them were downloaded, but it wasn't like that. Back when I checked, I noticed the system was put to sleep, but there were many files still not downloaded/interrupted.

Thanks.
Settings > Bye-bye, Standby! > prevent standby/sleep when > JDownload is running

Also, your issue might be the same with @MrBojangles_ see above for solutions
Reply With Quote
  #1373  
Old 18.05.2020, 08:32
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,550
Default

Quote:
Originally Posted by sherif011 View Post
I mean, I just need to set the limit for the current session, just after I click start, without counting previous downloads.
NOTE: Do not delete partiallly/completely downloaded links from the list, when the downloads are running.

Code:
// Limit per download session
// Trigger: Download Controller Started

var limit = 20; // <- Session limit (GB)
var interval = 30; // <- Interval between checks (seconds)

var getLoadedBytes = function() {
    return callAPI("polling", "poll", {
        "aggregatedNumbers": true
    })[0].eventData.data.loadedBytes;
}

var loadedBytes = getLoadedBytes();

while (isDownloadControllerRunning() || isDownloadControllerPaused()) {
    sleep(interval * 1000);
    if ((getLoadedBytes() - loadedBytes) / 1e9 > limit) stopDownloads();
}
Reply With Quote
  #1374  
Old 18.05.2020, 08:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,550
Default

Quote:
Originally Posted by MrBojangles_ View Post
1: This script works fine, until after it runs test.exe, when that task completes the downloads don't start again...I don't understand why.
What is the status of the link after you have the script has finished running? Is it "OFFLINE" or "UNKNOWN"? You can try resetting the link after running the external program.

Quote:
Originally Posted by MrBojangles_ View Post
2: I want to be able to measure the interval between occurrences of the script. For example take the system time, save as a global variable, then compare that with system time the next time a download goes offline.
Code:
var myObject = setProperty(myString/*"key"*/, myObject/*anyValue*/, myBoolean/*global(boolean)*/);/*Set a Property. This property will be available until JD-exit or a script overwrites it. if global is true, the property will be available for al scripts*/
/* Example: */var oldValue=setProperty("myobject", { "name": true}, false);

var myObject = getProperty(myString/*"key"*/, myBoolean/*global(boolean)*/);/*Get a Property. Set global to true if you want to access a global property*/
/* Example: */var value=getProperty("myobject", false);
Reply With Quote
  #1375  
Old 18.05.2020, 13:19
MrBojangles_ MrBojangles_ is offline
Junior Loader
 
Join Date: May 2020
Posts: 13
Default

Quote:
What is the status of the link after you have the script has finished running? Is it "OFFLINE" or "UNKNOWN"? You can try resetting the link after running the external program.
So all the links start as UNKNOWN because checking the links counts against the download limit (approx 75 between captchas).

Before the script runs, the download that failed (/triggered the captcha) is OFFLINE. After the link resets then it goes back to UNKNOWN. Putting it after running the external program doesn't seem to change anything, except resetting the link later. The downloads still don't restart

Does startDownloads() not do anything if the links are UNKNOWN?

Quote:
Code:
var myObject = setProperty(myString/*"key"*/, myObject/*anyValue*/, myBoolean/*global(boolean)*/);/*Set a Property. This property will be available until JD-exit or a script overwrites it. if global is true, the property will be available for al scripts*/
/* Example: */var oldValue=setProperty("myobject", { "name": true}, false);

var myObject = getProperty(myString/*"key"*/, myBoolean/*global(boolean)*/);/*Get a Property. Set global to true if you want to access a global property*/
/* Example: */var value=getProperty("myobject", false);
Great that's exactly what I was looking for, thank you!

Quote:
use this to get the actual link status, you might also want to look into isSkipped();. instead of reset(); try resume();
The way I'm extracting link status seems to be working ok, and resetting it works too. But it's just restarting downloads within the script that I'm having trouble with.

Quote:
not sure what you want to do with the time interval check. afaik jd eventscriptr is single instance script. every global variables are reset after script exited/completed. there is a workaround by save it out to txt file then read back at later time. scroll back to a few post sjust above for example. make sure text file name is unique by using the file name e.g link.getName(); again dont know what callSync("c:\\test.exe"); will give you but getStatus(); isSkipped(); & resume(); are all you might need
Mgpai's method seems to indicate I can save variables that I can retrieve in later instances. BUT if there's no way to read system time from within the script I can use Snaz to output time to a text file and then read from that, so that's a great backup plan - thanks!

Last edited by MrBojangles_; 18.05.2020 at 13:22. Reason: Answered one of my own questions...
Reply With Quote
  #1376  
Old 18.05.2020, 14:14
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,550
Default

Quote:
Originally Posted by MrBojangles_ View Post
Does startDownloads() not do anything if the links are UNKNOWN?
It will attempt to download UNKNOWN links. If they are still OFFLINE, they will be again marked as such.

If you post the log ID of that session and also provide the urls of the links which fail to start, the developers might be able to check it and provide more information.
Reply With Quote
  #1377  
Old 18.05.2020, 15:18
MrBojangles_ MrBojangles_ is offline
Junior Loader
 
Join Date: May 2020
Posts: 13
Default

Quote:
Originally Posted by mgpai View Post
It will attempt to download UNKNOWN links. If they are still OFFLINE, they will be again marked as such.

If you post the log ID of that session and also provide the urls of the links which fail to start, the developers might be able to check it and provide more information.
I think I see what the problem is: the start button stays greyed out until after the script completes (or maybe just the if statement? Needs testing), so maybe you can't stop and start downloads in the same script? A hacky solution for now is to save a text file (or global variable if I can get that working) with start=yes and then run a separate interval script that tests if start=yes then startDownloads().


I'm moving onto problem two now, I have tried to set a global variable that I can recall later, using the commands you showed:

Code:
   
   FirstTime = typeof(FirstTime) == 'undefined' ? 0 : FirstTime;
   setProperty(FirstTime, {"stamp":Date.now()}, true);

   var RetrievedTimeStamp = getProperty(FirstTime, true);
   alert(RetrievedTimeStamp.stamp);
Test running this script works fine, and I get expected result. If I try to getProperty in a different script (or comment out first two lines in original script) though it tells me FirstTime is undefined. But I thought it should stay defined asa global variable until JD exits?

Last edited by MrBojangles_; 18.05.2020 at 15:31. Reason: More testing.
Reply With Quote
  #1378  
Old 18.05.2020, 15:57
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,550
Default

Quote:
Originally Posted by MrBojangles_ View Post
... maybe you can't stop and start downloads in the same script?
You can. You have to make sure the download controller has stopped, before you start it again. In your script, try adding the following after stopDownloads():

Code:
while (!isDownloadControllerIdle()) sleep(1000);

Should work, assuming some other link/script will not try to start the download in the meanwhile.

Quote:
Originally Posted by MrBojangles_ View Post
If I try to getProperty in a different script (or comment out first two lines in original script) though it tells me FirstTime is undefined. But I thought it should stay defined asa global variable until JD exits?
var myObject = setProperty(myString*"key"*//, myObject/*anyValue*/, myBoolean/*global(boolean)*/);

"key" should be "String"

Code:
if (getProperty("FirstTime", true) === null) {
    setProperty("FirstTime", {
        "stamp": Date.now()
    }, true);
}

var RetrievedTimeStamp = getProperty("FirstTime", true);
alert(RetrievedTimeStamp.stamp);
Reply With Quote
  #1379  
Old 19.05.2020, 14:08
MrBojangles_ MrBojangles_ is offline
Junior Loader
 
Join Date: May 2020
Posts: 13
Default

Quote:
Originally Posted by mgpai View Post
You can. You have to make sure the download controller has stopped, before you start it again. In your script, try adding the following after stopDownloads():

Code:
while (!isDownloadControllerIdle()) sleep(1000);

Should work, assuming some other link/script will not try to start the download in the meanwhile.
Ahhh the issue was that the script was set to synchronous. As soon as I switched that off everything worked as expected.

It did create a new problem with the script being triggered repeatedly before the first iteration stopped downloads but I figured a way round that.

Quote:
Originally Posted by mgpai View Post

var myObject = setProperty(myString*"key"*//, myObject/*anyValue*/, myBoolean/*global(boolean)*/);

"key" should be "String"

Code:
if (getProperty("FirstTime", true) === null) {
    setProperty("FirstTime", {
        "stamp": Date.now()
    }, true);
}

var RetrievedTimeStamp = getProperty("FirstTime", true);
alert(RetrievedTimeStamp.stamp);
That fixed it!

Everything is now working beautifully, thank you so much for your help!
Reply With Quote
  #1380  
Old 19.05.2020, 21:57
sherif011 sherif011 is offline
Super Loader
 
Join Date: Jul 2018
Posts: 29
Default

Quote:
Originally Posted by zreenmkr View Post
leave the 2nd script alone, dont change anything there. because trigger is interval, it runs silently in the background every x number of mili-seconds (change that at top right corner of eventscript editor, 1000 = 1second) to check if x GB limit is met that is set by the 1st script.

1st script is a controller, allows your to enter x GB limit and also start a new session everytime you select/click on it. to activate the controller, create a button or a menu selector for it. there are 3 options for trigger described but there are also other options to do that.

the 3 commonly used are Toolbar Button at the top, or add menu selector when you Right-Mouse-Click or in the Main menu.

here is the **External links are only visible to Support Staff**..., But the easiest way is after you set trigger to e.g 'Toolbar Button Pressed', go back into eventscripter editor, there is now a button at the top call 'Main Toolbar', click on that, follow the tutorial above to create a button. rename 'Event Scripter' to 'Start Monitor Loaded Bytes'
Quote:
Originally Posted by mgpai View Post
NOTE: Do not delete partiallly/completely downloaded links from the list, when the downloads are running.

Code:
// Limit per download session
// Trigger: Download Controller Started

var limit = 20; // <- Session limit (GB)
var interval = 30; // <- Interval between checks (seconds)

var getLoadedBytes = function() {
    return callAPI("polling", "poll", {
        "aggregatedNumbers": true
    })[0].eventData.data.loadedBytes;
}

var loadedBytes = getLoadedBytes();

while (isDownloadControllerRunning() || isDownloadControllerPaused()) {
    sleep(interval * 1000);
    if ((getLoadedBytes() - loadedBytes) / 1e9 > limit) stopDownloads();
}
Thanks guys, appreciate your help
Reply With Quote
  #1381  
Old 19.05.2020, 23:40
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by MrBojangles_ View Post
gpai's method seems to indicate I can save variables that I can retrieve in later instances...
i didn't know that, i'm new to object and method in general
Reply With Quote
  #1382  
Old 20.05.2020, 07:55
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,614
Default

@MrBojangles_
adding links to JD interface
will result in linkchecking via website or api

account based downloads
downloading method for web includes linkchecking part of the download step or not. If websites have direct download option we typically do not do this logged in as it will send data over html. If they always return html we use logged in as its one less request (faster). If its api based two calls, one to check online status, second to start download.

free downloads
will online check as part of the download routine.

which site penalises you ? Maybe best approach is for us to add plugin specific code to just always return links online. Filename/size/onlinestatus will only be available on download

adding work around like this is kinda pointless. right? Have you thought about turning linkchecking off (advanced setting)?
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]

Last edited by raztoki; 20.05.2020 at 09:34.
Reply With Quote
  #1383  
Old 20.05.2020, 11:15
MrBojangles_ MrBojangles_ is offline
Junior Loader
 
Join Date: May 2020
Posts: 13
Default

Quote:
i didn't know that, i'm new to object and method in general
You're one step ahead of me; I haven't got a clue about any of this stuff! Appreciate the help though.

Quote:
which site penalises you ? Maybe best approach is for us to add plugin specific code to just always return links online. Filename/size/onlinestatus will only be available on download

adding work around like this is kinda pointless. right? Have you thought about turning linkchecking off (advanced setting)?
The site is **External links are only visible to Support Staff**www.soundsnap.com You can download about 75 things before you get hit with a captcha. Linkchecking gets counted in that. Fortunately pspzockerscene very kindly made a crawler rule for me, and I turned link checking off.

If you felt like making a plugin that handled this that would be amazing (I have 300k files to download!) - because my very hacky solution to getting round the recaptcha with mouse macros works until it starts asking you to match pictures instead of just ticking a box. In my testing I've found that you can complete the captcha on a completely different computer and it'll still reset the download limit - so I'm guessing that it would be possible to automate everything and send the captchas to a farm via a plugin. I'd love to make this myself but I think it's beyond my capabilities
Reply With Quote
  #1384  
Old 20.05.2020, 12:15
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,103
Default

@MrBojangles_
What you want would still require a plugin - everything else is just a workaround/hack.
Also keep in mind that there will NEVER be any "general" solution for scenarios like yours - a script always needs to recognize the moment in which that captcha starts to appear and needs to know what to do then.
... not saying it is impossible via LinkCrawler rules though as I did send you here.

-psp-
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #1385  
Old 20.05.2020, 12:25
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,614
Default

if your using crawler rules, probably also means you're downloading wiht directhttp plugin which means no in plugin support for captcha for that service. so yes what psp said is that you do need dedicated hoster plugin which could at least provide you with means to answer respective captcha.

alternatively if its all based on IP session, one could reset ip address to avoid said limits. At least on the download side you implied its only requirement once limit is met, resetting ip (if you have dynamic) would be a better solution than answering 1 captcha per download thereon after.
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]

Last edited by raztoki; 20.05.2020 at 12:29.
Reply With Quote
  #1386  
Old 20.05.2020, 12:29
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,103
Default

@raztoki
I did help him to make that Link Crawler rule and it will work fine, especially in combination with deactivating the linkcheck but once he runs in this limit, all following URLs will get displayed as offline.
He then has to solve the captcha after which everything will continue to work with the existing session cookies.

-psp-
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #1387  
Old 20.05.2020, 13:04
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,614
Default

arh so its cookie based. so ip resetting most likely wont be a workable solution then
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #1388  
Old 20.05.2020, 13:08
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,103
Default

I haven't tried it but don't think it would though I have seen providers which would e.g. reset account limits on reconnect (keep2share) but it's rare.

-psp-
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #1389  
Old 20.05.2020, 14:57
MrBojangles_ MrBojangles_ is offline
Junior Loader
 
Join Date: May 2020
Posts: 13
Default

@raztoki
Sorry I haven't really been clear about how their site works:
You get around 75 downloads (varies) between captcha requests
The captchas start as just clicks (hence mouse macro), but then turn into the picture ones after (presumably) too many captcha requests have been done in a set amount of time.

Something I haven't mentioned which actually seems quite relevant is that the captcha page is generic: (**External links are only visible to Support Staff****External links are only visible to Support Staff**)
and resets the download limit even if you browse to it directly without being redirected there (which is why my mouse macro works because it just browses to that page and clicks the box automatically).

Presumably then a plugin could pass that link plus the embedded session cookie out to a captcha farm automatically whenever a download fails? It feels like that would be more straightforward than most plugins, but obviously I speak from a position of complete ignorance. Is there a similar plugin already in JD that I could study?
Reply With Quote
  #1390  
Old 20.05.2020, 16:17
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,103
Default

Quote:
Originally Posted by MrBojangles_ View Post
Presumably then a plugin could pass that link plus the embedded session cookie out to a captcha farm automatically whenever a download fails? It feels like that would be more straightforward than most plugins, but obviously I speak from a position of complete ignorance.
Basically, yes.

Quote:
Originally Posted by MrBojangles_ View Post
Is there a similar plugin already in JD that I could study?
Sure - I'm unable to remember a "clean" written one atm but there are good examples.

You're especially looking for some containing reCaptchaV2 solver code aka "CaptchaHelperHostPluginRecaptchaV2" nd also ones that support account login --> text "enablePremium".

-psp-"
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #1391  
Old 05.06.2020, 17:47
BillyCool BillyCool is offline
Super Loader
 
Join Date: Sep 2016
Location: Australia
Posts: 28
Default

There's a number newer Javascript features that don't seem to be supported in the event scripter, things like default parameter values or arrow expressions.

I suspect is due to using HtmlUnit 2.15, which was released 6 years ago. Is it possible to update HtmlUnit to a newer version to support modern Javascript features?
Reply With Quote
  #1392  
Old 05.06.2020, 19:50
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,539
Default

@BillyCool: Has nothing to do with HtmlUnit but with used JS Engine Rhino and limited JS feature set and old JS support version. It was never goal to fully support JS nor modern language features because lack of JS engine support.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1393  
Old 05.06.2020, 20:22
BillyCool BillyCool is offline
Super Loader
 
Join Date: Sep 2016
Location: Australia
Posts: 28
Default

Quote:
Originally Posted by Jiaz View Post
@BillyCool: Has nothing to do with HtmlUnit but with used JS Engine Rhino and limited JS feature set and old JS support version. It was never goal to fully support JS nor modern language features because lack of JS engine support.
I see, is there any way to maybe import modern JS features using require(), maybe JQuery potentially? I remember trying in the past with no luck. Has anyone attempted and succeeded?
Reply With Quote
  #1394  
Old 06.06.2020, 04:20
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,614
Default

Not sure they will make support possible as it would require more modern Java and then moves JD away from older Java support. Currently JD supports 1.6 =< *

using 3rd party libraries could be a solution though, see what Jiaz says on his return =]
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #1395  
Old 07.06.2020, 10:22
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
Here is a new script, but if you need help to troubleshoot/fix yours, contact me in JD Chat.

Code:
// Move archive files after extraction
// Trigger: Archive Extraction Finished

var links = archive.getDownloadLinks() || [];
var destinationFolder = "C:/sherbee/check";

links.forEach(function(link) {
    var filePath = getPath(link.getDownloadPath());
    var i = 0;

    while (getPath(destinationFolder + "/" + filePath.getName()).exists()) {
        i++;
        newPath = getPath(link.getDownloadPath().toString().replace(/(.+)(\..+)/, "$1" + i + "$2"));
        getPath(filePath).renameTo(newPath);
        filePath = newPath;
    }

    filePath.moveTo(destinationFolder);
});
The script is very good. But problem now:

When menu-tools-extract files then archive.getDownloadLinks() not there.
How get path(s) from manual open?
I need path for case single file (abc.rar or abc.zip etc) but too for multi file like (abc.001, abc.002) so move can work for manual open too.
Reply With Quote
  #1396  
Old 07.06.2020, 11:24
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,550
Default

Quote:
Originally Posted by sherbee View Post
... When menu-tools-extract files then archive.getDownloadLinks() not there. How get path(s) from manual open? ...
Loop through extracted file paths (array):

Code:
var myFilePath[] = myArchive.getExtractedFilePaths();
Reply With Quote
  #1397  
Old 08.06.2020, 06:47
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
Loop through extracted file paths (array):

Code:
var myFilePath[] = myArchive.getExtractedFilePaths();
Thank! Will try soon! Hope it works.
Reply With Quote
  #1398  
Old 08.06.2020, 19:28
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,539
Default

@BillyCool
I'm afraid that's not possible because the JS engine itself must support the language elements/features.
Optional github.com/graalvm/graaljs might be possible
I see that modern language features are a nice to have but I think that the the purpose to create simple scripts can also be achieved with current language feature set

@mgpai: I think best would be to add generic support for all internal archive file type
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1399  
Old 10.06.2020, 16:49
Fragmata Fragmata is offline
Modem User
 
Join Date: Jan 2020
Posts: 2
Default

Hello, I know something similar has already been asked several times, but no where can I find a solution that works to my liking.

I would like a script for a custom button, that when pressed, will check my Files and Folders if they exist, then compare them with the Files in my Linkgrabber and then either mark them as already existing or move them to a different package or simply delete them from the Linkgrabber list.
I do not want it to only disable the Links when attempting to Download, because when I switch to an empty Hard Drive later on, it will no longer be able to check if the Files already exist.
Reply With Quote
  #1400  
Old 10.06.2020, 16:59
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,539
Default

@Fragmata: such a script rings my bell but I couldn't find it right now. Maybe other community users can find it or similiar one or can help with creation of such a script.
__________________
JD-Dev & Server-Admin
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 12: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.