#1
|
|||
|
|||
![]()
i am trying to use exiftool to change the metadata of an audio file from youtube but i am misunderstaning how to use callSync.
Using the command line: Code:
"C:/ExifTool/exiftool.exe" -artist="New Artist" -albumartist="New Participating Artist" -title="NewTtitle" -overwrite_original "SomeAudio.mp3" Code:
var program = ["C:\ExifTool\exiftool.exe"]; var parameters = ["paremeter1", "parameter2", "paremeter..."].join(","); var file = getPath(link.downloadPath); callSync(program, parameters, file); |
#2
|
||||
|
||||
![]()
@SirJohnny: See example here
https://board.jdownloader.org/showpo...72&postcount=2 callsync method siganture is (String...) meaning that you just put the individual parts as Strings Quote:
Quote:
Just give it a try and of course, just ask if you need help or got questions
__________________
JD-Dev & Server-Admin |
#3
|
|||
|
|||
![]()
I have moved on from exiftool to ffmpeg. What I am trying to do is use ffmpeg to create a temporary file with the metadata I want, delete the original file and then rename the temporary file as the original.
I realize the error is in the callSync but I can't figure it out. Code:
var file = getPath(link.downloadPath); var fileName = link.getName(); var fileExtension = "." + fileName.slice((fileName.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase(); var downloadFolder = package.getDownloadFolder(); var tempFilename = downloadFolder + "/" + "temp" + fileExtension; alert(callSync("ffmpeg","-i", file, "-metadata", "title=" + title, "-metadata", "artist=" + artist, "-metadata", "album_artist=" + artist, "-c", "copy", tempFilename, "&&", "del", file, "&&", "rename", tempFilename, file)); |
#4
|
|||
|
|||
![]()
This is my full working script:
Code:
var linkIsFinished = link.finished; var packageName = link.getPackage().getName(); var isPackageNameDiscography = packageName.includes("Discography"); var isHostYoutube = link.getHost() === "youtube.com"; var fileName = link.getName(); var isAudioFile = /\.(aac|m4a|ogg|opus|mp3)$/.test(fileName); if (linkIsFinished && isPackageNameDiscography && isHostYoutube && isAudioFile) { // Get metadata values var artist = packageName.replace("[Discography] " , ""); var title = fileName.split('.').slice(0, -1).join('.'); alert("title:" + title); var file = getPath(link.downloadPath); // Temp file for ffmpeg var filenameNoExtension = fileName.split('.').slice(0, -1).join('.'); var fileExtension = "." + fileName.slice((fileName.lastIndexOf(".") - 1 >>> 0) + 2).toLowerCase(); var downloadFolder = package.getDownloadFolder(); var tempFilename = downloadFolder + "\\" + "temp" + fileExtension; alert("filename:" + fileName); // Create temp file with provided meta data values with ffmpeg callSync("ffmpeg","-i", file, "-metadata", "title=" + title, "-metadata", "artist=" + artist, "-metadata", "album_artist=" + artist, tempFilename); // Delete original file callSync("cmd", "/c", "del", file); // Rename temp file with original name callSync("cmd", "/c", "rename", tempFilename, fileName); } |
#5
|
||||
|
||||
![]()
callSync is no cmd/bash/batch, you cannot make use of &&
![]() You have to call those commands separately. I would also recommend to not use cmd for delete and rename and make use of FilePath, see the list of available Objects/methods Quote:
__________________
JD-Dev & Server-Admin |
#6
|
|||
|
|||
![]()
Your script currently will (try to) delete and rename the file without checking if the ffmpeg command was successful. Better to use callAsync and check the exitCode OR redirect the errOut to stdOut in callsync OR use "&&" as in the example below.
Code:
callSync("cmd", "/c", "notepad", "&&", "dir") |
![]() |
Thread Tools | |
Display Modes | |
|
|