#2521
|
|||
|
|||
![]()
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. |
#2522
|
||||
|
||||
![]()
@Rhamlock: have you tested the command line outside of JDownloader first, to make sure it's correct and working?
Quote:
you should rewrite/change it so script waits for audio+cover to be finished and then do the conversion at once
__________________
JD-Dev & Server-Admin Last edited by Jiaz; 12.12.2022 at 15:52. |
#2523
|
|||
|
|||
![]() Quote:
Should I convert the M4A to mp3 first, and then add the art to the MP3? I tried adding the jpg as art cover directly to the M4A, and it didn't work Code:
/* Add cover art Trigger : Package finished */ var links = package.downloadLinks.filter(function(link) { return link.host == "youtube.com" && getPath(link.downloadPath).extension == "m4a"; }) 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(/m4a$/, "jpg")); if (cover.exists()) { var input = link.downloadPath; var output = input + ".m4a"; 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); } }) } checking reddit I found that m4a doesn't support art cover, that's why this doesn't work |
#2524
|
||||
|
||||
![]()
@Rhamlock: The idea was to move the m4a->mp3 conversion before the embedding of cover art. so package finished trigger, then every m4a file, then for each file with cover, first convert to mp3 and then add the cover. try to just add the mp3 stuff before the var cover... stuff
__________________
JD-Dev & Server-Admin |
#2525
|
|||
|
|||
![]()
what am i messing up with the notation here?
Quote:
Quote:
Quote:
|
#2526
|
|||
|
|||
![]() Quote:
I divided the script into two different events The result is the same, I can convert to mp3 no problem. But I can't add the jpg as cover art on the mp3. ![]() Here a couple pictures **External links are only visible to Support Staff****External links are only visible to Support Staff** **External links are only visible to Support Staff****External links are only visible to Support Staff** I found this thread where there is a different script for the mp3 cover https://board.jdownloader.org/showth...=mp3+cover+art but it seems it only works with soundcloud files. Code:
// Add album art (if available) to mp3 audiofiles from soundcloud.com // Trigger : "Package Finished" // Uses "original thumbnail" from soundcloud for album art // Can also be used to add title, url and other metadata to the audio file var links = package.getDownloadLinks(); for (i = 0; i < links.length; i++) { var link = links[i]; var host = link.getHost(); var fileType = getPath(link.getDownloadPath()).getExtension(); if (host == "soundcloud.com" && fileType == "mp3") { var downloadFolder = link.getPackage().getDownloadFolder(); var plainFileName = link.getProperty("plainfilename"); var linkID = link.getProperty("linkid"); var channel = link.getProperty("channel"); var coverFileName = plainFileName + "_original_" + linkID + " - " + channel + ".jpg"; var coverFile = getPath(downloadFolder + "/" + coverFileName); if (coverFile.exists()) { var tagger = "ffmpeg"; var audioFile = link.getDownloadPath(); callSync(tagger, "-i", audioFile, "-i", coverFile, "-c copy -map 0 -map 1", plainFileName, ".mp3"); //coverFile.delete(); // Delete cover file } } } Last edited by Rhamlock; 14.12.2022 at 04:38. |
#2527
|
||||
|
||||
![]()
@markifi: callasync calls an external application/binary/script but you can't place bash commands in there! I would recommend to place that all in a ready bash script and use the callsync method to execute it. for example
Code:
#!/bin/bash if [ ! $(pgrep xdotool) ]; then xdotool getactivewindow sleep 10 windowactivate; else echo "it's running"; fi;
__________________
JD-Dev & Server-Admin |
#2528
|
||||
|
||||
![]()
@Rhamlock: Can you please send me an email to support@jdownloader.org and then I will take a look at it myself. Currently just very busy. I don't see any reason why it should not work when both scripts are placed in one. most likely just a simple misstake. can you please send me a reminder and link to your post?
__________________
JD-Dev & Server-Admin |
#2529
|
|||
|
|||
![]() Quote:
|
#2530
|
|||
|
|||
![]()
Hi! I'm trying to add an additional download from a script whose Trigger is "Packagizer Hook". I try:
Code:
myObject = callAPI("linkgrabberv2", "addLinks", { "links": link, "packageName": packageName, "destinationFolder": destinationFolder }); How can I influence the packageName OR destinationFolder? Maybe the aforementioned myObject somehow allows finding the links in the LinkGrabber and changing the package name? alert(myObject); yields just a number, I don't know what I can do with that number. A separate Event Scripter script that catches the links added by the mega co nz plugin wouldn't know what package name the original script wanted. |
#2531
|
||||
|
||||
![]()
@SMS: You have to enable overwritePackagizerRules , else the destination folder/package name set by Plugin and/or Packagizer Rules will be applied.
with overwritePackagizerRules true, you tell JDownloader that you custom package name and/or directory should be used see https://my.jdownloader.org/developers/#tag_244 for the fields of addLinks
__________________
JD-Dev & Server-Admin |
#2532
|
|||
|
|||
![]()
Hi everyone.
Is there a function that allows me to save the number of packages in my Download list in a variable? Basically I'm using this script to merge packages with the same name: Code:
if (name == "Merge Packages") { alert("Merging..."); var count=0; //used to count merged packages getAllFilePackages().forEach(function(package) { if (package) { var packages = []; getAllFilePackages().forEach(function(package2) { if (package2.name + package2.downloadFolder == package.name + package.downloadFolder) { packages.push(package2); } }) if (packages.length > 1) { var linkIds = []; packages.forEach(function(package3) { package3.downloadLinks.forEach(function(link) { linkIds.push(link.UUID); }) }) linkIds.sort().forEach(function(linkId) { callAPI("downloadsV2", "moveLinks", [linkId], -1, package.UUID); }) count++; } } }) alert("Merged: "+count); } 25%, 50%, 75 and 90% using the percentage formula: tot*0.25, tot*0.50.... in pseudo code Code:
tot=countFunction() //or similar .... .... if(actualPackage==tot*0.25) alert("progress 25%") ...... ....... |
#2533
|
||||
|
||||
![]() Quote:
Quote:
__________________
JD-Dev & Server-Admin |
#2534
|
|||
|
|||
![]()
Perfect. This works!
Thanks |
#2535
|
|||
|
|||
![]() Quote:
I still want to do that thing with conversion then cover addition. But I haven't find a way |
#2536
|
|||
|
|||
![]()
Is there a way to automatically deactivate the "Silent Mode" after a certain time after switching it on? E.g. different timer settings: after 2, 3, 4, 5 hours after activating the "Silent Mode" etc. should the "Silent Mode" switch off again automatically?
I often forget to turn it back on myself after I've turned it on for a while. https://board.jdownloader.org/showth...279#post515279
__________________
Aktuelles Windows |
#2537
|
||||
|
||||
![]()
@Rhamlock: Yes, but I did not yet find time for it, sorry.
__________________
JD-Dev & Server-Admin |
#2538
|
|||
|
|||
![]() Quote:
Good day! Happy New Year! Help needed again please. I have expanded the above script to suit my needs which would get certain links matching names enabled and rest disabled. My issue now is that when the links get updated, I do not see the active ones under 'Downloads' tab. I have to go any other tab and come back to see the latest links. Is there anyway to refresh the UI to see the latest links please? |
#2539
|
|||
|
|||
![]()
Good Gentlemen, I would like to know if there is any way that Jdownloader 2 can read the links saved in an X link history folder and that when the file is previously downloaded it marks it as if it were downloading in red or if it can be another color Whatever, if there is a script for that or if something occurs to you, please tell me the code. Thank you very much. In the same way, I thank you for paying attention to me and I currently have a script from here that It creates a text file per day, I wish it was just one and they simply added more links, but it creates 1 text file per day with date. If there is a way for a script to filter those links where it is generated in the auto folder I would appreciate it very much. i use this
Code:
// Simple history // Trigger Required : A Download Stopped if (link.isFinished()) { var a /*date*/ = new Date().toString().substring(4, 16); var b /*history folder*/ = JD_HOME + "/auto/history/"; var c /*history file Name */ = a + ".txt"; var d /*download url*/ = link.getContentURL(); var e /*download file name*/ = link.getName(); if (!getPath(b).exists()) getPath(b).mkdirs(); writeFile(b + c, [d, e].join(",") + "\r\n", true); } Last edited by Alexpark24; 10.01.2023 at 17:52. |
#2540
|
|||
|
|||
![]()
can someone make me a script that download 1% of the file then stops and disable that file (gray it out) then move to the next file and do the same , not required the downloaded size is 1% it just need to download some data from that file whether 1% or download for 10 second then gray it out then move to the next one.
|
![]() |
Thread Tools | |
Display Modes | |
|
|