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,142
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,142
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: 27
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,142
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: 27
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,142
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: 27
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: 70,039
Default

@mgpai: You have a solution for every problem how about a script for world peace?
__________________
JD-Dev & Server-Admin
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 09:24.
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.