JDownloader Community - Appwork GmbH
 

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #11  
Old 10.12.2022, 04:54
Rhamlock Rhamlock is offline
Baby Loader
 
Join Date: Dec 2022
Posts: 5
Cool I'm trying to first convert M4A to MP3 and then add the PNG as art cover

Hello everyone!
I'm currently trying to download a song from YT
the song downloads as M4A, then using the power of the Event Script it gets converted to Mp3 using the second script on this thread
https://board.jdownloader.org/showthread.php?t=70525

And because I'm downloading the JPG together with the M4A, I try to use another script to set the cover art on the resulting Mp3
using the script at the very end of this thread
https://board.jdownloader.org/showthread.php?t=87059

Mixing both scripts, I get this.

Code:
/*
    Convert audio files to mp3 format
    Trigger : A download stopped
*/

if (link.finished) {
    var input = link.downloadPath;
    var output = input.replace(/(aac|m4a|ogg|opus)$/, "mp3");

    if (input != output) {
        try {
            var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
            var bitrate = callSync(ffmpeg, "-i", input).match(/bitrate: (\d+) kb/)[1];

            callAsync(function(error) {
                !error && getPath(input).delete();
            }, ffmpeg, "-y", "-i", input, "-b:a", bitrate + "k", output);
        } catch (e) {};
    }
}
   
/*
    Add cover art
    Trigger : Package finished
*/ 

var links = package.downloadLinks.filter(function(link) {
    return link.host == "youtube.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);
        }
    })
}

Now the problem is I seem to be able to download the song on M4A and then convert it to MP3, however, I can't get the jpg to be set as the art for the MP3.

Any ideas how to solve this?
thanks in advance!

Last edited by Rhamlock; 10.12.2022 at 05:10.
Reply With Quote
 

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 19:00.
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.