diff --git a/server/controllers/MeController.js b/server/controllers/MeController.js index 8fa5c6bc..b5147fb7 100644 --- a/server/controllers/MeController.js +++ b/server/controllers/MeController.js @@ -336,7 +336,7 @@ class MeController { } /** - * GET: /api/stats/year/:year + * GET: /api/me/stats/year/:year * * @param {import('express').Request} req * @param {import('express').Response} res diff --git a/server/utils/ffmpegHelpers.js b/server/utils/ffmpegHelpers.js index 3e4848f3..aa0b4805 100644 --- a/server/utils/ffmpegHelpers.js +++ b/server/utils/ffmpegHelpers.js @@ -101,8 +101,8 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => { }) if (!response) return resolve(false) - const ffmpeg = Ffmpeg(response.data) + ffmpeg.addOption('-loglevel debug') // Debug logs printed on error ffmpeg.outputOptions( '-c', 'copy', '-metadata', 'podcast=1' @@ -110,6 +110,7 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => { const podcastMetadata = podcastEpisodeDownload.libraryItem.media.metadata const podcastEpisode = podcastEpisodeDownload.podcastEpisode + const finalSizeInBytes = Number(podcastEpisode.enclosure?.length || 0) const taggings = { 'album': podcastMetadata.title, @@ -147,13 +148,30 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => { ffmpeg.addOutput(podcastEpisodeDownload.targetPath) + const stderrLines = [] + ffmpeg.on('stderr', (stderrLine) => { + if (typeof stderrLine === 'string') { + stderrLines.push(stderrLine) + } + }) ffmpeg.on('start', (cmd) => { Logger.debug(`[FfmpegHelpers] downloadPodcastEpisode: Cmd: ${cmd}`) }) - ffmpeg.on('error', (err, stdout, stderr) => { - Logger.error(`[FfmpegHelpers] downloadPodcastEpisode: Error ${err} ${stdout} ${stderr}`) + ffmpeg.on('error', (err) => { + Logger.error(`[FfmpegHelpers] downloadPodcastEpisode: Error ${err}`) + if (stderrLines.length) { + Logger.error(`Full stderr dump for episode url "${podcastEpisodeDownload.url}": ${stderrLines.join('\n')}`) + } resolve(false) }) + ffmpeg.on('progress', (progress) => { + let progressPercent = 0 + if (finalSizeInBytes && progress.targetSize && !isNaN(progress.targetSize)) { + const finalSizeInKb = Math.floor(finalSizeInBytes / 1000) + progressPercent = Math.min(1, progress.targetSize / finalSizeInKb) * 100 + } + Logger.debug(`[FfmpegHelpers] downloadPodcastEpisode: Progress estimate ${progressPercent.toFixed(0)}% (${progress?.targetSize || 'N/A'} KB) for "${podcastEpisodeDownload.url}"`) + }) ffmpeg.on('end', () => { Logger.debug(`[FfmpegHelpers] downloadPodcastEpisode: Complete`) resolve(podcastEpisodeDownload.targetPath) diff --git a/server/utils/probeWorker.js b/server/utils/probeWorker.js deleted file mode 100644 index 2a93fce9..00000000 --- a/server/utils/probeWorker.js +++ /dev/null @@ -1,9 +0,0 @@ -const { parentPort } = require("worker_threads") -const prober = require('./prober') - -parentPort.on("message", async ({ mediaPath }) => { - const results = await prober.probe(mediaPath) - parentPort.postMessage({ - data: results, - }) -}) \ No newline at end of file