JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1361  
Old 12.05.2020, 13:35
pspzockerscene's Avatar
pspzockerscene pspzockerscene is online now
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,143
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, 17: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 17:44.
Reply With Quote
  #1363  
Old 12.05.2020, 21: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 04:21. Reason: added host and container check
Reply With Quote
  #1364  
Old 13.05.2020, 11:18
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,343
Default

@zreenmkr: Thanks for your great work and help on scripting!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1365  
Old 15.05.2020, 10:08
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 17: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 17:09.
Reply With Quote
  #1367  
Old 17.05.2020, 17: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, 18: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, 21:48
ElCho ElCho is offline
Tornado
 
Join Date: May 2014
Posts: 245
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 14:39. Reason: typo
Reply With Quote
  #1370  
Old 18.05.2020, 03: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 04:04.
Reply With Quote
  #1371  
Old 18.05.2020, 05: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 07:11.
Reply With Quote
  #1372  
Old 18.05.2020, 06: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, 09:32
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 09:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 14: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 14:22. Reason: Answered one of my own questions...
Reply With Quote
  #1376  
Old 18.05.2020, 15:14
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 16: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 16:31. Reason: More testing.
Reply With Quote
  #1378  
Old 18.05.2020, 16:57
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
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, 15: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, 22: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
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 13:53.
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.