JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1341  
Old 29.04.2020, 17:58
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,044
Default

@mgpai
Seems like this may have been a misunderstanding with user _comus_:
https://board.jdownloader.org/showthread.php?t=21012

-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
  #1342  
Old 29.04.2020, 18:16
_comus_ _comus_ is offline
Baby Loader
 
Join Date: Apr 2020
Posts: 9
Default

I have lost my history and I want to recover it or one since I installed the jdonloader, it is indifferent to me, I just need, everything that has passed through the downloads tab
Reply With Quote
  #1343  
Old 29.04.2020, 23:22
askin2u askin2u is offline
Fibre Channel User
 
Join Date: Mar 2015
Posts: 128
Default

Is there a way to get this information
Spoiler:


getStatus() only show Finished.
Reply With Quote
  #1344  
Old 30.04.2020, 11:20
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,235
Default

@_cosmus_: There is no such history. What exactly do you mean? Maybe I don't understand correct

@askin2u: At that moment that information is not available. What exactly do you want to achieve? Have in mind?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1345  
Old 30.04.2020, 14:47
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,529
Default

Quote:
Originally Posted by sherif011 View Post
... script to stop downloads when a predefined data limit is reached ...
It is possible to only determine the downloads finished during the day and not the actual bytes downloaded during the day. For this reason the calculated total might be slightly less the actual bytes downloaded, since it might also include bytes from pending downloads which were started during the previous day.

For a more accurate quota management, you may need to use a 3rd party program.

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

if (isDownloadControllerRunning()) {
    var target = 20; // <- Set limit (in GB)
    var actual = 0;
    var t1 = new Date().setHours(0, 0, 0, 0);

    getAllDownloadLinks().filter(function(link) {
        var t2 = new Date(link.getFinishedDate());
        return t2 > t1
    }).forEach(function(link) {
        actual += link.getBytesLoaded();
    })

    if (actual / 1e9 > target) stopDownloads();
}
Reply With Quote
  #1346  
Old 01.05.2020, 02:01
sherif011 sherif011 is offline
Super Loader
 
Join Date: Jul 2018
Posts: 29
Default

Quote:
Originally Posted by mgpai View Post
It is possible to only determine the downloads finished during the day and not the actual bytes downloaded during the day. For this reason the calculated total might be slightly less the actual bytes downloaded, since it might also include bytes from pending downloads which were started during the previous day.

For a more accurate quota management, you may need to use a 3rd party program.

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

if (isDownloadControllerRunning()) {
    var target = 20; // <- Set limit (in GB)
    var actual = 0;
    var t1 = new Date().setHours(0, 0, 0, 0);

    getAllDownloadLinks().filter(function(link) {
        var t2 = new Date(link.getFinishedDate());
        return t2 > t1
    }).forEach(function(link) {
        actual += link.getBytesLoaded();
    })

    if (actual / 1e9 > target) stopDownloads();
}
Thanks a lot for your effort, appreciate it.
Can I set this limit for the current download session with no regards to previous downloads and not for specific time period?

Last edited by sherif011; 01.05.2020 at 02:20.
Reply With Quote
  #1347  
Old 02.05.2020, 09:31
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Open selected files
// Trigger: Downloadlist Contextmenu Button Pressed
// Customize download list context menu > Add a new "Eventscripter Trigger" button > Rename it to "[Script] Open files" (without quotes) > Change Icon (Optional)

if (name == "[Script] Open files") {
    var player = "/videolan/vlc/vlc";

    dlSelection.getLinks().filter(function(link) {
        return link.getBytesLoaded();
    }).forEach(function(link) {
        var file = link.getDownloadPath();
        file = link.isFinished() ? file : file + ".part";
        callAsync(null, player, "--started-from-file", "--playlist-enqueue", file);
    })
}

just a little mod
Code:
// Open selected files or files in packagename
if (name == "VLC Player") {
    //if (name == "VLC Player - Add To Playlist") {

    newVlcIntance = true; //1-open new intance of vlc player | 0-add to existing intance of vlc player
    playSelectedFilesNow = true; //1-overwrite existence vlc player and start playing selected files | 0-add selected files to playlist
    var player = "C:/Program Files (x86)/VideoLAN/VLC/vlc.exe"; // <- Set path to media player
    var regex = /\.(part|mp4|mov|mkv|mpg|avi|flv|m4a|m4b|m4c|m4d|mp3|acc)$/ig; //only open file with these extensions

    dlSelection.getLinks().sort().filter(function(link) {
        return link.getBytesLoaded();
    }).forEach(function(link) {
        var file = link.getDownloadPath();
        var fileExt = link.getName().match(regex);
        var isExist = getPath(file).exists();
        if (fileExt && isExist) {
            file = link.isFinished() ? file : file + fileExt; //!!!this might no longer be required
            if (!playSelectedFilesNow ) {
                callAsync(null, player, "--one-instance", "--playlist-enqueue", file); //add selected files to existance of vlc playlist
                //callAsync(null, player, "--started-from-file", "--playlist-enqueue", file); //add selected files to existance of vlc playlist
            } else {
                callAsync(null, player, "--one-instance", "--no-playlist-enqueue", file); //add and start selected files
                //callAsync(null, player, "--started-from-file", "--no-playlist-enqueue", file); //add and start selected files
                playSelectedFilesNow = false;
            }
            sleep(10); //ensure each file is added to playlist in its intended order (increase if required)

            //**External links are only visible to Support Staff**
            //??? can't figure out how to start a new instance of vlc then add the remaining selected files to playlist'
            //callAsync(null, player, "--no-started-from-file", "-playlist-enqueue", file); //WARNING: start each intance of vlc player for each selected file
            //callAsync(null, player, "--no-one-instance", "-playlist-enqueue", file); //WARNING: start each intance of vlc player for each selected file
        }

    })
}
Reply With Quote
  #1348  
Old 03.05.2020, 21:46
markifi markifi is offline
Baby Loader
 
Join Date: May 2020
Posts: 8
Default

I'm currently trying to write a script that simply executes the following:
vlc --playlist-enqueue --fullscreen --one-instance --qt-continue=2 <filepath>

so far I have this on a trigger of Package finished:
var player = "vlc";
var file = getPath(link.getDownloadPath());
callAsync(null, player, file);

this works, but doesn't pass the command line switches. how can I pass the command line switches?
Reply With Quote
  #1349  
Old 04.05.2020, 05:19
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,659
Default

@markifi
believe each switch has to be wrapped between "", just how java ProcessBuilderFactory requires inputs. the javascript call is just wrapped into a Java command.

there are some working examples above.
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #1350  
Old 07.05.2020, 09:54
martian martian is offline
Modem User
 
Join Date: May 2020
Posts: 4
Default ID3 tags on MP3s from Youtube downloads

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!
Reply With Quote
  #1351  
Old 07.05.2020, 11:27
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,044
Default

hi mgpai

I have a question regarding THIS thread.

To sum it up, this is what the user wants:
- The ability to make JD NOT recognize same files (same name & size) as mirror
- Maybe e.g. modify the filename of possible mirrors (e.g. add random numbers to end), maybe change it back to original once user e.g. removes all items except one from that package

Any ideas?
Do you maybe already have a similar script for something like this?
This user wants to download mirrors at the same time so he can manually check which has the best downloadspeed --> Then download this

-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
  #1352  
Old 08.05.2020, 00:09
humor4fun humor4fun is offline
I will play nice!
 
Join Date: May 2020
Posts: 1
Default

I use this ES script to make sure that everything from gog-games.com gets put into commonly formatted folders based on the game name.

Code:
// Set Package Name for gog-games.com downloads
// Tigger Required: "Packagizer Hook"
// Forum Topic: https://board.jdownloader.org/showthread.php?t=74182

var ln = link.getName(); //get the filename from the link
//alert("ln", ln); // for debugging
var newln = ln.replace(/^Plugin Defect\!/, ""); //remove 'Plugin Defect!' error
//alert("newln", newln); // for debugging
link.setName(newln); // update the filename

// these lines strip prefixes off of the filename to be used in the package name
var pkg = newln.replace(/^game-/, ""); //remove prefix
pkg = pkg.replace(/^extras-/, ""); //remove prefix
pkg = pkg.replace(/^patch-/, ""); //remove prefix
pkg = pkg.replace(/^fix-/, ""); //remove prefix
pkg = pkg.replace(/^other-/, ""); //remove prefix

// these lines remove file extensions
pkg = pkg.replace(/.rar$/, ""); //remove file extension
pkg = pkg.replace(/.zip$/, ""); //remove file extension
pkg = pkg.replace(/.7zip$/, ""); //remove file extension
pkg = pkg.replace(/.7z$/, ""); //remove file extension

// these lines do some additional cleanup
pkg = pkg.replace(/\.part(\d+)/, "") //remove part#
pkg = pkg.replace(/\./g, "_"); //replace . with _

//alert("pkg", pkg); //for debugging

link.setPackageName(pkg); //set the package name to the cleaned up string
Reply With Quote
  #1353  
Old 08.05.2020, 11:55
OCHer OCHer is offline
Junior Loader
 
Join Date: Jan 2020
Posts: 12
Default

Hello dear JDownloader Community,
I'm looking for a solution to run a simple script on Synology after each download is completed and unzipped (ON_ARCHIVE_EXTRACTED).
Code:
synoindex -R video
This will start media indexing for the shared video folder.

Synchronous execution would also be an advantage.

Here I found something similar I don't know how such a script for my Synology (Linux) should look like.

Does anyone know advice?
Reply With Quote
  #1354  
Old 10.05.2020, 18:28
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Code:
// Set Package Name for gog-games.com downloads
// Tigger Required: "Packagizer Hook"
// Forum Topic: https://board.jdownloader.org/showthread.php?t=74182

var ln = link.getName(); //get the filename from the link
//alert("ln", ln); // for debugging
var newln = ln.replace(/^Plugin Defect\!/, ""); //remove 'Plugin Defect!' error
//alert("newln", newln); // for debugging
link.setName(newln); // update the filename
.
...
are all file names start with 'Plugin Defect!'? or is it mistaken for an error message? There is a conflict as layout below which clearly show all file names either start with 'extra' or 'patch' or 'fix' or 'other'


Quote:
Code:
...
.
// these lines strip prefixes off of the filename to be used in the package name
var pkg = newln.replace(/^game-/, ""); //remove prefix
pkg = pkg.replace(/^extras-/, ""); //remove prefix
pkg = pkg.replace(/^patch-/, ""); //remove prefix
pkg = pkg.replace(/^fix-/, ""); //remove prefix
pkg = pkg.replace(/^other-/, ""); //remove prefix

// these lines remove file extensions
pkg = pkg.replace(/.rar$/, ""); //remove file extension
pkg = pkg.replace(/.zip$/, ""); //remove file extension
pkg = pkg.replace(/.7zip$/, ""); //remove file extension
pkg = pkg.replace(/.7z$/, ""); //remove file extension

// these lines do some additional cleanup
pkg = pkg.replace(/\.part(\d+)/, "") //remove part#
pkg = pkg.replace(/\./g, "_"); //replace . with _

//alert("pkg", pkg); //for debugging

link.setPackageName(pkg); //set the package name to the cleaned up string
the above could be reduced to
Code:
    var regex = /(?:^|game|extra|patch|fix|other)-(.*?)\.(?:^|.{2,4}|part\d{1,2}\..{2,4})$/ig;
    var pkgName = fileName.replace(regex, '$1');
    var pkgName = pkgName.replace(/\./g, "_");
    link.setPackageName(pkgName);
Reply With Quote
  #1355  
Old 11.05.2020, 01:24
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by humor4fun View Post
I use this ES script to make sure that everything from gog-games.com gets put into commonly formatted folders based on the game name.
Code:
// Set Package Name for gog-games.com downloads
// Tigger Required: "Packagizer Hook"
// Forum Topic: https://board.jdownloader.org/showthread.php?t=74182

var hoster = link.getHost();
if (state == 'BEFORE') {

    // only file souce download from 'gog-games.com' 
    if (hoster == 'gog-games.com') {                    //<--edit download sources as desired

        var newFileName = link.getName();

        // only file names with these extensions
        var fileWithExt = /\.(rar|zip|7zip|7z)$/i;
        if (fileWithExt.test(newFileName)) {

            // AND only file names begin with
            var fileNameBegins = /(game|extra|patch|fix|other)-/i;
            if (fileNameBegins.test(newFileName)) {

                var regex = /(?:^|game|extra|patch|fix|other)-(.*?)\.(?:^|(?:part\d{1,2}\.)?.{2,4})$/i;
                var pkgName = newFileName.replace(regex, '$1');
                var pkgName = pkgName.replace(/\./g, "_");
                link.setPackageName(pkgName);
            }
        }
    }
}
Code:
// also available
if (state == 'AFTER') {
}
Reply With Quote
  #1356  
Old 11.05.2020, 04:12
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Originally Posted by sherif011 View Post
Can I set this limit for the current download session with no regards to previous downloads and not for specific time period?
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
}

Last edited by zreenmkr; 11.05.2020 at 05:48. Reason: avoid unlimited sessions
Reply With Quote
  #1357  
Old 12.05.2020, 11:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,529
Default

Quote:
Originally Posted by sherif011 View Post
... Can I set this limit for the current download session with no regards to previous downloads and not for specific time period?
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".
Reply With Quote
  #1358  
Old 12.05.2020, 11:44
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,529
Default

Quote:
Originally Posted by martian View Post
... 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.

... but might anyone be able to help with a script that could create those tags?
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. Check the manual or the support forums of that player to verify if it in facts supports these formats. Some players will require you to install additional codecs to play files which are not supported by default.

Another option would be transcode the files to a format supported by your player, but I would strongly advice against it since transcoding files from one lossy format to another will result in loss of quality.
Reply With Quote
  #1359  
Old 12.05.2020, 12:32
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,529
Default

Hello @psp: Sorry for late reply.

Quote:
Originally Posted by pspzockerscene View Post
... modify the filename of possible mirrors ...
Code:
// Add prefix to filename
// Tirgger: A Download Started

link.getPackage().getDownloadLinks().forEach(function(link, index) {
    if (link.status == "Mirror http links is loading") {
        var prefix = "[" + link.getDownloadHost() + "] ";

        link.setName(prefix + link.getName());
        link.setSkipped(true);
        sleep(1000);
        link.setSkipped(false);
    }
})

Quote:
Originally Posted by pspzockerscene View Post
... change it back to original once user e.g. removes all items except one from that package
Code:
// Remove prefix from filename
// Trigger: A Download Stopped

if (link.isFinished()) {
    var prefix = "[" + link.getDownloadHost() + "] ";
    var file = link.getDownloadPath().replace(prefix, "");

    if (!getPath(file).exists()) {
        var n1 = link.getName();
        var n2 = n1.replace(prefix, "");

        if (n1 != n2) link.setName(n2);
    }
}
Reply With Quote
  #1360  
Old 12.05.2020, 12:55
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,529
Default

Quote:
Originally Posted by OCHer View Post
... run a simple script on Synology after each download is completed and unzipped ... Synchronous execution would also be an advantage.
Settings > Advanced Settings > EventScripter.scripts

Code:
[{
	"eventTrigger": "ON_ARCHIVE_EXTRACTED",
	"enabled": true,
	"name": "2020.05.12 ",
	"script": "disablePermissionChecks();\ncallSync(\"synoindex\", \"-R\", \"video\");",
	"eventTriggerSettings": {
		"isSynchronous": true
	},
	"id": 1589276857812
}]
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 11:18.
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.