JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1321  
Old 20.04.2020, 18:44
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

Quote:
Originally Posted by drjs5x View Post
if skip link wait 1 seconds after next link check etc..
resume.
Sorry, but I am not able to understand what you are trying to achieve with the script.
Reply With Quote
  #1322  
Old 21.04.2020, 11:27
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Dear mgpai,

for quite a while now I am using the script you generously wrote for my use-case. It allows me to play finished AND also partially downloaded files via the context menu.

It works really great! I would not want to miss it anymore. :-)

Now there is one little thing, which would make it even more convenient in my eyes. If this script would not just work on the file itself ... but already on its folder. (So the folder would not have to be opened before playing the file.)

Say dear mgpai ... could you extend the original script and add this feature? Or is this too much of a hassle?

This is the original script:

Code:
// Open finished or partially download file for the selected download link
// Trigger: Downloadlist Contextmenu Button Pressed
// Customize download list context menu > Add a new "Eventscripter Trigger" button > Rename it to "[Script] Open file" (without quotes) > Change Icon (Optional)

if (name == "[Script] Open file") {
    var link = dlSelection.getContextLink();

    if (link) {
        var player = "/videolan/vlc/vlc"; // <- Set path to media player
        var file = getPath(link.getDownloadPath());

        if (file.exists()) {
            callAsync(null, player, file);
        } else {
            var partFile = getPath(file + ".part");

            if (partFile.exists()) {
                callAsync(null, player, partFile);
            }
        }
    }
}
Reply With Quote
  #1323  
Old 21.04.2020, 14:22
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

Quote:
Originally Posted by Sokub View Post
... could you extend the original script ...
Code:
// Open selected folder in media player
// Trigger: Downloadlist Contextmenu Button Pressed
// Customize download list context menu > Add a new "Eventscripter Trigger" button > Rename it to "[Script] Open folder" (without quotes) > Change Icon (Optional)

if (name == "[Script] Open folder") {
    var package = dlSelection.getContextPackage();

    if (package) {
        var player = "/videolan/vlc/vlc"; // <- Set path to media player
        var folder = getPath(package.getDownloadFolder());
        
        callAsync(null, player, folder);
    }
}
Reply With Quote
  #1324  
Old 22.04.2020, 16:50
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Dear mgpai, ... thank you for your work!

I'm sorry ... I guess, I expressed myself misleading. (I'm German.) Now the new script is playing the whole download-folder. But I was looking for it to just play the files from the "package-folder" (If that is the right name for the folders in the JD-download-list containing one or more "links/files".)

And also, I was looking for it to keep the old functionality too, so that it works/plays in all cases: 1. complete file or 2. incomplete file or 3. package-folder (with complete and incomplete files).

If this is too complicated, please just say so! ... it is not all that important, would just be really nice ... ;-)
Reply With Quote
  #1325  
Old 24.04.2020, 12:23
Mnk3y Mnk3y is offline
I will play nice!
 
Join Date: Apr 2020
Posts: 2
Default

Quote:
Originally Posted by mgpai View Post
Can use packagizer rules to move/rename files after extraction.
Hello, thanks for the answer. Unfortunately I couldn't make it work with packagizer. But I am currently working on a bash script which I want to run with JDownloader.

I am using a function for the event scripter from you.
**External links are only visible to Support Staff****External links are only visible to Support Staff**
But my bash script will be executed twice. I can see that by simply echoing something in the bash script.

How can I prevent this? Many thanks in advance.
Reply With Quote
  #1326  
Old 24.04.2020, 14:31
gerijani gerijani is offline
Baby Loader
 
Join Date: Apr 2020
Posts: 5
Default

Hi mgapi,

I was redirected to here to ask if is there sany script which can help to prevent this?

"We have blocked your account because our security systems have flagged your Pluralsight account for an unusual amount of activity. This means a high volume of requests have occurred every 10-30 seconds for a prolonged period of time. Please note that this high volume of activity is in violation of our terms of service"

After I put about 10 link of learning paths and shortly after the linkgrabber started to extract the video links, it happened.
Anything that can slow down the process?
Many thanks in advance.

Last edited by gerijani; 24.04.2020 at 14:34.
Reply With Quote
  #1327  
Old 24.04.2020, 14:33
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

Quote:
Originally Posted by Mnk3y View Post
... I couldn't make it work with packagizer ...
I would still recommend using packagizer. You can find me in JD Chat if you need help with it.

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader

Quote:
... my bash script will be executed twice.
Not sure what is causing it. Since you want to run it after extraction, better to use archive extraction trigger. Does the bash script process the folder or individual files?
Reply With Quote
  #1328  
Old 24.04.2020, 14:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

Quote:
Originally Posted by gerijani View Post
After I put about 10 link of learning paths and shortly after the linkgrabber started to extract the video links, it happened.
Anything that can slow down the process?
If you are adding the links from a script, you can use MYJD API methods to wait till the crawler job is finished and then add the next link.

You can also try reducing the max. threads used by checker and crawler. Try setting both to 1.

Advanced settings:
Code:
LinkChecker.maxthreads
LinkCrawler.maxthreads
Reply With Quote
  #1329  
Old 27.04.2020, 11:51
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

Quote:
Originally Posted by Sokub View Post
... the new script is playing the whole download-folder.
The script does not send the contents of the 'package', It only sends the download destination used by it. It is then up to the external program to load files from it. Hence, ff you are using the same download destination with other packages, they will be loaded too. As will be will any other files from that package, even if they are not currently on JD list.

Code:
// Open selected package
// Trigger: Downloadlist Contextmenu Button Pressed
// Customize download list context menu > Add a new "Eventscripter Trigger" button > Rename it to "[Script] Open package" (without quotes) > Change Icon (Optional)

if (name == "[Script] Open package") {
    var package = dlSelection.getContextPackage();

    if (package) {
        var player = "/videolan/vlc/vlc"; // <- Set path to media player
        var files = [];

        package.getDownloadLinks().filter(function(link) {
            return link.getBytesLoaded();
        }).forEach(function(link) {
            var file = link.getDownloadPath();
            file = link.isFinished() ? file : file + ".part";
            files.push("\"" + file + "\"");
        })

        if (files.length) callAsync(null, player, files.join(" "));
    }
}
Reply With Quote
  #1330  
Old 28.04.2020, 09:56
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Dear mgpai,

thank you very much for your effort!

Unfortunately I did not get your script to work. The player opens only if the script is triggered from a package ... but not if triggered from a single file. But the opened player does not play the file for unknown (to me) reasons.

I managed to combine two of your earlier scripts for me (originally for separate purposes) ... and this comes pretty close: the player plays when triggered from a package and also when triggered from a single file. The only drawback: If the package contains more than one file, it opens many players (instead of putting them in a single playlist.)

As a workaround: Can you give me a hint, how to exit the loop, when the first file to play has been found? (So the playlist won't be filled, but at least I don't have a ton of open players.)


Code:
if (name == "Play") {
    var links = dlSelection.getLinks();

    if (links.length) {
        links.forEach(function(link) {
            var player = "/usr/bin/smplayer"; // <- Set path to media player
            var file = getPath(link.getDownloadPath());

            if (file.exists()) {
                callAsync(null, player, file);
            } else {
                var partFile = getPath(file + ".part");

                if (partFile.exists()) {
                    callAsync(null, player, partFile);
                }
            }
        })
    }
}
Reply With Quote
  #1331  
Old 28.04.2020, 10:11
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

Quote:
Originally Posted by Sokub View Post
Unfortunately I did not get your script to work. The player opens only if the script is triggered from a package ... but not if triggered from a single file.
As the button name suggests, it only opens a package content. It is not supposed to work on file selection. For that you you will have to use the old script. I have also tested it before posting, and made sure the files were correctly being played.
Reply With Quote
  #1332  
Old 28.04.2020, 11:57
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Ok, mgpai, thank you very much!
Reply With Quote
  #1333  
Old 28.04.2020, 12:18
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

Quote:
Originally Posted by Sokub View Post
Ok
If it still does't work, find me in JD Chat.

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
Reply With Quote
  #1334  
Old 28.04.2020, 13:05
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

I need the script to work for both packages and files ... so I stick with my latest version (combined out of 2 of yours). Thank you, mgpai, very much!
Reply With Quote
  #1335  
Old 28.04.2020, 14:47
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
Default

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);
    })
}
Reply With Quote
  #1336  
Old 28.04.2020, 16:35
Sokub Sokub is offline
JD Adviser
 
Join Date: Feb 2018
Posts: 107
Default

Thanks again for your help!
Reply With Quote
  #1337  
Old 28.04.2020, 16:39
sherif011 sherif011 is offline
Super Loader
 
Join Date: Jul 2018
Posts: 29
Default Data usage limit

Hi,
Can you make an event script to stop downloads when a predefined data limit is reached?
E.g: I want downloading to stop when a limit of 20 GB is reached.
I need it for all hosts with or without account, just an overall data limit for all sites.
Thank you..

Last edited by sherif011; 28.04.2020 at 17:39. Reason: clarification
Reply With Quote
  #1338  
Old 28.04.2020, 16:47
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,121
Default

@sherif011
Your post is missing information e.g.:
- Do you mean a quota of an account or do you download without account?
- For all hosts or only for a specified host?

-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
  #1339  
Old 28.04.2020, 17:40
sherif011 sherif011 is offline
Super Loader
 
Join Date: Jul 2018
Posts: 29
Default

Quote:
Originally Posted by pspzockerscene View Post
@sherif011
Your post is missing information e.g.:
- Do you mean a quota of an account or do you download without account?
- For all hosts or only for a specified host?

-psp-
Updated
Reply With Quote
  #1340  
Old 29.04.2020, 16:39
_comus_ _comus_ is offline
Baby Loader
 
Join Date: Apr 2020
Posts: 9
Default

Someone could tell me a scrip, to know the history or all the folders or links, of the download list, I accidentally deleted it, in cleaning disabled and it is urgent for me to recover them
Reply With Quote
  #1341  
Old 29.04.2020, 16:58
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,121
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, 17: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, 22: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, 10:20
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,594
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, 13:47
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
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, 01: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 01:20.
Reply With Quote
  #1347  
Old 02.05.2020, 08: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, 20: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, 04:19
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,615
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, 08: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, 10:27
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,121
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 07.05.2020, 23: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, 10: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, 17: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, 00: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, 03: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 04:48. Reason: avoid unlimited sessions
Reply With Quote
  #1357  
Old 12.05.2020, 10:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
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, 10:44
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
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, 11:32
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
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, 11:55
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,553
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 00:02.
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.