mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-09-29 17:51:19 +02:00
Fix issue with episode downloads without streams, fallback to regular dl on ffprobe fail
This commit is contained in:
parent
85d5531bc1
commit
a456865ec0
@ -127,10 +127,20 @@ class PodcastManager {
|
|||||||
})
|
})
|
||||||
let success = !!ffmpegDownloadResponse?.success
|
let success = !!ffmpegDownloadResponse?.success
|
||||||
|
|
||||||
// If failed due to ffmpeg error, retry without tagging
|
if (success) {
|
||||||
|
// Attempt to ffprobe and add podcast episode audio file
|
||||||
|
success = await this.scanAddPodcastEpisodeAudioFile()
|
||||||
|
if (!success) {
|
||||||
|
Logger.error(`[PodcastManager] Failed to scan and add podcast episode audio file - removing file`)
|
||||||
|
await fs.remove(this.currentDownload.targetPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If failed due to ffmpeg or ffprobe error, retry without tagging
|
||||||
// e.g. RSS feed may have incorrect file extension and file type
|
// e.g. RSS feed may have incorrect file extension and file type
|
||||||
// See https://github.com/advplyr/audiobookshelf/issues/3837
|
// See https://github.com/advplyr/audiobookshelf/issues/3837
|
||||||
if (!success && ffmpegDownloadResponse?.isFfmpegError) {
|
// e.g. Ffmpeg may be download the file without streams causing the ffprobe to fail
|
||||||
|
if (!success && !ffmpegDownloadResponse?.isRequestError) {
|
||||||
Logger.info(`[PodcastManager] Retrying episode download without tagging`)
|
Logger.info(`[PodcastManager] Retrying episode download without tagging`)
|
||||||
// Download episode only
|
// Download episode only
|
||||||
success = await downloadFile(this.currentDownload.url, this.currentDownload.targetPath)
|
success = await downloadFile(this.currentDownload.url, this.currentDownload.targetPath)
|
||||||
@ -139,23 +149,20 @@ class PodcastManager {
|
|||||||
Logger.error(`[PodcastManager] Podcast Episode download failed`, error)
|
Logger.error(`[PodcastManager] Podcast Episode download failed`, error)
|
||||||
return false
|
return false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
success = await this.scanAddPodcastEpisodeAudioFile()
|
||||||
|
if (!success) {
|
||||||
|
Logger.error(`[PodcastManager] Failed to scan and add podcast episode audio file - removing file`)
|
||||||
|
await fs.remove(this.currentDownload.targetPath)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
success = await this.scanAddPodcastEpisodeAudioFile()
|
Logger.info(`[PodcastManager] Successfully downloaded podcast episode "${this.currentDownload.episodeTitle}"`)
|
||||||
if (!success) {
|
this.currentDownload.setFinished(true)
|
||||||
await fs.remove(this.currentDownload.targetPath)
|
task.setFinished()
|
||||||
this.currentDownload.setFinished(false)
|
|
||||||
const taskFailedString = {
|
|
||||||
text: 'Failed',
|
|
||||||
key: 'MessageTaskFailed'
|
|
||||||
}
|
|
||||||
task.setFailed(taskFailedString)
|
|
||||||
} else {
|
|
||||||
Logger.info(`[PodcastManager] Successfully downloaded podcast episode "${this.currentDownload.episodeTitle}"`)
|
|
||||||
this.currentDownload.setFinished(true)
|
|
||||||
task.setFinished()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const taskFailedString = {
|
const taskFailedString = {
|
||||||
text: 'Failed',
|
text: 'Failed',
|
||||||
|
@ -99,7 +99,7 @@ module.exports.resizeImage = resizeImage
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {import('../objects/PodcastEpisodeDownload')} podcastEpisodeDownload
|
* @param {import('../objects/PodcastEpisodeDownload')} podcastEpisodeDownload
|
||||||
* @returns {Promise<{success: boolean, isFfmpegError?: boolean}>}
|
* @returns {Promise<{success: boolean, isRequestError?: boolean}>}
|
||||||
*/
|
*/
|
||||||
module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => {
|
module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => {
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
@ -118,7 +118,7 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
responseType: 'stream',
|
responseType: 'stream',
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': '*/*',
|
Accept: '*/*',
|
||||||
'User-Agent': userAgent
|
'User-Agent': userAgent
|
||||||
},
|
},
|
||||||
timeout: global.PodcastDownloadTimeout
|
timeout: global.PodcastDownloadTimeout
|
||||||
@ -139,7 +139,8 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => {
|
|||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
return resolve({
|
return resolve({
|
||||||
success: false
|
success: false,
|
||||||
|
isRequestError: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,8 +205,7 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => {
|
|||||||
Logger.error(`Full stderr dump for episode url "${podcastEpisodeDownload.url}": ${stderrLines.join('\n')}`)
|
Logger.error(`Full stderr dump for episode url "${podcastEpisodeDownload.url}": ${stderrLines.join('\n')}`)
|
||||||
}
|
}
|
||||||
resolve({
|
resolve({
|
||||||
success: false,
|
success: false
|
||||||
isFfmpegError: true
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
ffmpeg.on('progress', (progress) => {
|
ffmpeg.on('progress', (progress) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user