JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1701  
Old 24.04.2021, 07:20
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,342
Default

Quote:
Originally Posted by ThatGuy View Post
... extract to the download directory you set when you enter URLs to the linkgrabber
Code:
/*
    Move extracted files
    Trigger : Archive extraction finished
*/    

archive.extractedFilePaths.forEach(function(filePath) {
    filePath.moveTo(archive.folder);
    filePath.parent.delete();
})
Reply With Quote
  #1702  
Old 01.05.2021, 12:42
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,342
Default

Quote:
Originally Posted by epikk View Post
... how can an mp3 be saved along with its picture (cover picture) from Soundcloud?
Code:
/*
    Add cover art
    Trigger : Package finished
*/    

var links = package.downloadLinks.filter(function(link) {
    return link.host == "soundcloud.com" && getPath(link.downloadPath).extension == "mp3";
})


if (links.length) {
    var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");

    links.forEach(function(link) {
        var cover = getPath(link.downloadPath.replace(/_\d{9}/, "_original_").replace(/mp3$/, "jpg"));

        if (cover.exists()) {
            var input = link.downloadPath;
            var output = input + ".mp3";

            callAsync(function(exitCode) {
                if (exitCode == 0) {
                    getPath(input).delete();
                    getPath(output).renameTo(input);
                }
            }, ffmpeg, "-hide_banner", "-i", input, "-i", cover, "-map", "0:0", "-map", "1:0", "-c", "copy", output);
        }
    })
}
Reply With Quote
  #1703  
Old 04.05.2021, 12:03
namyar namyar is offline
Super Loader
 
Join Date: Apr 2016
Posts: 28
Question

Hi,

I'm trying to replace spaces in filenames with an underscore within the LinkGrabber to enable mirror detection.

However, my current script doesn't work:
Code:
myCrawledLink.setName(myCrawledLink.name.replace(/\s/g, "_"))
It seems "myCrawledLink" has to be defined in some way, but I'm unsure how:confused:
Reply With Quote
  #1704  
Old 04.05.2021, 12:12
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,342
Default

Quote:
Originally Posted by namyar View Post
I'm trying to replace spaces in filenames with an underscore within the LinkGrabber to enable mirror detection.
When do yo want to replace them? Before or after they are added to linkgrabber? You have to use a trigger/link type accordingly.
Reply With Quote
  #1705  
Old 04.05.2021, 12:15
namyar namyar is offline
Super Loader
 
Join Date: Apr 2016
Posts: 28
Default

Quote:
Originally Posted by mgpai View Post
When do yo want to replace them? Before or after they are added to linkgrabber? You have to use a trigger/link type accordingly.
Before they get added to the download tab. Then they will have identical names, enabling mirror detection to work just based on filme names.:)
Reply With Quote
  #1706  
Old 04.05.2021, 12:43
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,342
Default

Quote:
Originally Posted by namyar View Post
Before they get added to the download tab. Then they will have identical names, enabling mirror detection to work just based on filme names.:)
Quote:
Originally Posted by mgpai View Post
When do yo want to replace them? Before or after they are added to linkgrabber? You have to use a trigger/link type accordingly.
This script will replace the characters just before they are added to linkgrabber list. If you want to replace them after they are added to JD, you will have to use a different script with context-menu button pressed trigger.

Code:
/*
    Replace space with underscore in filenames
    Trigger : Packagizer Hook
*/

try {
    if (state == "BEFORE") {
        link.setName(link.name.replace(/\s/g, "_"));
    }
} catch (e) {};
Reply With Quote
  #1707  
Old 04.05.2021, 13:38
namyar namyar is offline
Super Loader
 
Join Date: Apr 2016
Posts: 28
Talking

Quote:
Originally Posted by mgpai View Post
Code:
/*
    Replace space with underscore in filenames
    Trigger : Packagizer Hook
*/

try {
    if (state == "BEFORE") {
        link.setName(link.name.replace(/\s/g, "_"));
    }
} catch (e) {};
Works like a charm, thank you very much!
Reply With Quote
  #1708  
Old 04.05.2021, 13:55
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 72,764
Default

@mgpai: You have a solution for every problem how about a script for world peace?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1709  
Old 11.05.2021, 13:42
qwerti qwerti is offline
Modem User
 
Join Date: May 2021
Posts: 4
Default

Hello everyone

I'm looking for a script for my problem. Maybe someone can help me.

I have a lots of packages with xGB and xfiles.

The script is supposed to extract only one file with all parts and stop the download in order to start again afterwards.
for example:

file_01.part1
file_01.part2
file_01.part3

<download done
<stop download
<start extract
<extract done
<start download

file_02.part1
file_02.part2
...
...

Is that possible? I will be very happy if someone helps me.

Sorry for my english
Reply With Quote
  #1710  
Old 11.05.2021, 14:05
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 72,764
Default

@qwerti: why extract one by one? JDownloader will download the files and extract as possible
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1711  
Old 11.05.2021, 14:14
qwerti qwerti is offline
Modem User
 
Join Date: May 2021
Posts: 4
Default

Quote:
Originally Posted by Jiaz View Post
@qwerti: why extract one by one? JDownloader will download the files and extract as possible
I have a small SSD. The files are downloaded on the SSD and then extracted to cloud storage.
Very large packets quickly get stuck because the SSD is full and cannot be extracted. I can't think of a better solution.

Edit: I've experimented with download limits. However, it does not always work properly and not at full speed.

Last edited by qwerti; 11.05.2021 at 14:18.
Reply With Quote
  #1712  
Old 11.05.2021, 15:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,342
Default

@qwerti: Try this. It is a pretty complex workaround, but should fairly achieve your objective.

It will ensure that only one package is active (download order/sequence of packages may differ) at any give time (by skipping others). Will start the next package only after the current package is finished and any running extractions have stopped.

Code:
/*
    Limit running packages
    Trigger : A Download Started
*/

var first = getRunningDownloadPackages()[0];

getAllFilePackages().forEach(function(package) {

    if (!package.finished && package.UUID != first.UUID) {
        package.downloadLinks.forEach(function(link) {
            link.skipped = true;
        })
    }
})

Code:
/*
    Start pending downloads after extraction is finished
    Trigger : Download Controller Stopped
*/    

while (callAPI("extraction", "getQueue").length) {
    sleep(1000);
}

getAllFilePackages().some(function(package) {
    return !package.finished;
}) && startDownloads();

If you have alternative solutions in mind or need any modifications to the current scripts, you can find me in JD Chat.

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
Reply With Quote
  #1713  
Old 11.05.2021, 16:34
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 72,764
Default

@mgpai: an alternative idea, interval checks for ongoing extraction and in case of yes, it stops the downloads and then starts downloads again. or *pause* new downloads
for example trigger is startdownload -> check for ongoing extraction, loop and wait till extraction is finished. I think this might even be better/easier solution
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1714  
Old 11.05.2021, 16:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,342
Default

Quote:
Originally Posted by qwerti View Post
Very large packets quickly get stuck because the SSD is full and cannot be extracted.
Quote:
Originally Posted by Jiaz View Post
@mgpai: an alternative idea, interval checks for ongoing extraction and in case of yes, it stops the downloads and then starts downloads again. or *pause* new downloads
Had already considered it, but if the number of running packages are not limited it can result in multiple packages running simultaneously and filling up the SSD. While the proposed solution does not eliminate that possibility completely, it should be fairly successful in limiting the SSD usage most of the time.
Reply With Quote
  #1715  
Old 11.05.2021, 16:56
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 72,764
Default

@mgpai: just an idea but you are right, didn't think about the packages
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1716  
Old 11.05.2021, 17:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,342
Default

Quote:
Originally Posted by Jiaz View Post
@mgpai: just an idea
It can always be something which has not occurred to me. So keep them coming.
Reply With Quote
  #1717  
Old 12.05.2021, 14:29
qwerti qwerti is offline
Modem User
 
Join Date: May 2021
Posts: 4
Default

Hello mgpai,

I am very grateful for the quick help. Thanks for the script.
It works great in the following cases.

Package one --> 11,37 GB
Package tow --> 7,86 GB
Package x --> x GB

Is it possible to modify it like this?

Package one --> 342,23 GB
Package one.1 (11 rar-parts) --> 10,31 GB
Package one.2 (12 rar-parts) --> 11,96 GB
Package one.x (x rar-parts) --> x GB
I don't know how to explain it better. I'm sorry
Reply With Quote
  #1718  
Old 12.05.2021, 14:38
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 72,764
Default

@qwerti: In case you are talking about sub-packages, those are not supported.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1719  
Old 12.05.2021, 14:51
qwerti qwerti is offline
Modem User
 
Join Date: May 2021
Posts: 4
Default

Quote:
Originally Posted by Jiaz View Post
@qwerti: In case you are talking about sub-packages, those are not supported.
Vielleicht kurz auf Deutsch, mein Englisch ist echt mies.
Das der JDownloader keine sub-packages unterstützt weiß ich.
Ich hab halt sehr oft das Problem das ich in einem package mehrere Dateien habe und die Pakete dadurch locker über mehrere hundert GB groß sind.
Mein Speicherplatz auf der SSD ist aber nur knapp 60 GB groß ich kann also bei sehr großen Paketen nicht erst das ganze Paket laden, um es dann zu entpacken.

Tut mir leid, wenn ich etwas falsch verstehe und für das deutsch :/
Reply With Quote
  #1720  
Old 12.05.2021, 16:12
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,342
Default

Quote:
Originally Posted by qwerti View Post
Is it possible to modify it like this?
Replace "Limit running packages" script with this one. Please note, the script uses a different trigger. Also remember to disable "Synchronous execution of script" checkbox in the top panel of the script editor.

Code:
/*
    Limit running links/archives
    Trigger : Download Controller Started
    Important: Disable Synchronous execution of script checkbox in the top panel
*/

while (!getRunningDownloadLinks().length) {
    sleep(1000);
}

var first = getName(getRunningDownloadLinks()[0]);

getAllDownloadLinks().forEach(function(link) {
    if (!link.finished && getName(link) != first) {
        link.skipped = true;
    }
})

function getName(link) {
    try {
        return link.archive.name;
    } catch (e) {
        return link.name;
    }
}
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 14:28.
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 - 2021, Jelsoft Enterprises Ltd.