diff --git a/server/managers/PodcastManager.js b/server/managers/PodcastManager.js index 0a32e3ca..456927c8 100644 --- a/server/managers/PodcastManager.js +++ b/server/managers/PodcastManager.js @@ -25,7 +25,9 @@ const LibraryItem = require('../objects/LibraryItem') class PodcastManager { constructor() { + /** @type {PodcastEpisodeDownload[]} */ this.downloadQueue = [] + /** @type {PodcastEpisodeDownload} */ this.currentDownload = null this.failedCheckMap = {} @@ -63,6 +65,11 @@ class PodcastManager { } } + /** + * + * @param {PodcastEpisodeDownload} podcastEpisodeDownload + * @returns + */ async startPodcastEpisodeDownload(podcastEpisodeDownload) { if (this.currentDownload) { this.downloadQueue.push(podcastEpisodeDownload) @@ -106,7 +113,7 @@ class PodcastManager { } let success = false - if (this.currentDownload.urlFileExtension === 'mp3') { + if (this.currentDownload.isMp3) { // Download episode and tag it success = await ffmpegHelpers.downloadPodcastEpisode(this.currentDownload).catch((error) => { Logger.error(`[PodcastManager] Podcast Episode download failed`, error) diff --git a/server/objects/PodcastEpisodeDownload.js b/server/objects/PodcastEpisodeDownload.js index 86a85801..eb9f059a 100644 --- a/server/objects/PodcastEpisodeDownload.js +++ b/server/objects/PodcastEpisodeDownload.js @@ -53,6 +53,20 @@ class PodcastEpisodeDownload { if (globals.SupportedAudioTypes.includes(extname)) return extname return 'mp3' } + get enclosureType() { + const enclosureType = this.podcastEpisode?.enclosure?.type + return typeof enclosureType === 'string' ? enclosureType : null + } + /** + * RSS feed may have an episode with file extension of mp3 but the specified enclosure type is not mpeg. + * @see https://github.com/advplyr/audiobookshelf/issues/3711 + * + * @returns {boolean} + */ + get isMp3() { + if (this.enclosureType && !this.enclosureType.includes('mpeg')) return false + return this.fileExtension === 'mp3' + } get targetFilename() { const appendage = this.appendEpisodeId ? ` (${this.podcastEpisode.id})` : ''