Fix:Download podcast episodes that are not mp3 #1513

This commit is contained in:
advplyr 2023-03-15 18:04:31 -05:00
parent ebad304aa9
commit 387a37e4da

View File

@ -1,6 +1,7 @@
const Path = require('path')
const { getId } = require('../utils/index')
const { sanitizeFilename } = require('../utils/fileUtils')
const globals = require('../utils/globals')
class PodcastEpisodeDownload {
constructor() {
@ -40,8 +41,14 @@ class PodcastEpisodeDownload {
}
}
get fileExtension() {
const extname = Path.extname(this.url).substring(1).toLowerCase()
if (globals.SupportedAudioTypes.includes(extname)) return extname
return 'mp3'
}
get targetFilename() {
return sanitizeFilename(`${this.podcastEpisode.title}.mp3`)
return sanitizeFilename(`${this.podcastEpisode.title}.${this.fileExtension}`)
}
get targetPath() {
return Path.join(this.libraryItem.path, this.targetFilename)