View Single Post
  #1702  
Old 01.05.2021, 13:42
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,484
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