Skip to content

Commit 329bbea

Browse files
committed
Fix:Downloading podcast episode when file extension is mp3 but enclosure type is not mp3 #3711
1 parent e616b53 commit 329bbea

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

server/managers/PodcastManager.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ const LibraryItem = require('../objects/LibraryItem')
2525

2626
class PodcastManager {
2727
constructor() {
28+
/** @type {PodcastEpisodeDownload[]} */
2829
this.downloadQueue = []
30+
/** @type {PodcastEpisodeDownload} */
2931
this.currentDownload = null
3032

3133
this.failedCheckMap = {}
@@ -63,6 +65,11 @@ class PodcastManager {
6365
}
6466
}
6567

68+
/**
69+
*
70+
* @param {PodcastEpisodeDownload} podcastEpisodeDownload
71+
* @returns
72+
*/
6673
async startPodcastEpisodeDownload(podcastEpisodeDownload) {
6774
if (this.currentDownload) {
6875
this.downloadQueue.push(podcastEpisodeDownload)
@@ -106,7 +113,7 @@ class PodcastManager {
106113
}
107114

108115
let success = false
109-
if (this.currentDownload.urlFileExtension === 'mp3') {
116+
if (this.currentDownload.isMp3) {
110117
// Download episode and tag it
111118
success = await ffmpegHelpers.downloadPodcastEpisode(this.currentDownload).catch((error) => {
112119
Logger.error(`[PodcastManager] Podcast Episode download failed`, error)

server/objects/PodcastEpisodeDownload.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ class PodcastEpisodeDownload {
5353
if (globals.SupportedAudioTypes.includes(extname)) return extname
5454
return 'mp3'
5555
}
56+
get enclosureType() {
57+
const enclosureType = this.podcastEpisode?.enclosure?.type
58+
return typeof enclosureType === 'string' ? enclosureType : null
59+
}
60+
/**
61+
* RSS feed may have an episode with file extension of mp3 but the specified enclosure type is not mpeg.
62+
* @see https://github.com/advplyr/audiobookshelf/issues/3711
63+
*
64+
* @returns {boolean}
65+
*/
66+
get isMp3() {
67+
if (this.enclosureType && !this.enclosureType.includes('mpeg')) return false
68+
return this.fileExtension === 'mp3'
69+
}
5670

5771
get targetFilename() {
5872
const appendage = this.appendEpisodeId ? ` (${this.podcastEpisode.id})` : ''

0 commit comments

Comments
 (0)