diff --git a/bin/bin.js b/bin/bin.js index 890aa6c..11b7307 100644 --- a/bin/bin.js +++ b/bin/bin.js @@ -312,18 +312,14 @@ const main = async () => { }, onAfterDownload: () => { if (addMp3MetadataFlag || bitrate || mono) { - try { - runFfmpeg({ - feed, - item, - bitrate, - mono, - itemIndex: item._originalIndex, - outputPath: outputPodcastPath, - }); - } catch (error) { - logError("Error running ffmpeg", error); - } + runFfmpeg({ + feed, + item, + bitrate, + mono, + itemIndex: item._originalIndex, + outputPath: outputPodcastPath, + }); } if (exec) { diff --git a/bin/util.js b/bin/util.js index 6d10be2..a058c14 100644 --- a/bin/util.js +++ b/bin/util.js @@ -560,7 +560,19 @@ const runFfmpeg = ({ command += ` "${tmpMp3Path}"`; logMessage("Running ffmpeg..."); - execSync(command); + + try { + execSync(command); + } catch (error) { + logError("Error running ffmpeg", error); + + if (fs.existsSync(tmpMp3Path)) { + logMessage("Cleaning up temporary file..."); + fs.unlinkSync(tmpMp3Path); + } + + return; + } fs.unlinkSync(outputPath); fs.renameSync(tmpMp3Path, outputPath);