From f0b410415dd82ae46bb038b4f9d0a557fb0d50d2 Mon Sep 17 00:00:00 2001 From: sbyrx Date: Wed, 1 Jan 2025 16:01:26 +0000 Subject: [PATCH] Adds a configuration for podcast feed and episode download timeout --- server/Server.js | 6 ++++++ server/utils/ffmpegHelpers.js | 2 +- server/utils/podcastUtils.js | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/server/Server.js b/server/Server.js index 46850cbb7b..c5cad0a14e 100644 --- a/server/Server.js +++ b/server/Server.js @@ -65,6 +65,12 @@ class Server { } } + if (process.env.FILE_DOWNLOAD_TIMEOUT) { + global.FileDownloadTimeout = process.env.FILE_DOWNLOAD_TIMEOUT + } else { + global.FileDownloadTimeout = 30000 + } + if (!fs.pathExistsSync(global.ConfigPath)) { fs.mkdirSync(global.ConfigPath) } diff --git a/server/utils/ffmpegHelpers.js b/server/utils/ffmpegHelpers.js index c70242252c..60c1c0bcfc 100644 --- a/server/utils/ffmpegHelpers.js +++ b/server/utils/ffmpegHelpers.js @@ -106,7 +106,7 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => { headers: { 'User-Agent': 'audiobookshelf (+https://audiobookshelf.org)' }, - timeout: 30000 + timeout: global.FileDownloadTimeout }).catch((error) => { Logger.error(`[ffmpegHelpers] Failed to download podcast episode with url "${podcastEpisodeDownload.url}"`, error) return null diff --git a/server/utils/podcastUtils.js b/server/utils/podcastUtils.js index 26bd173398..fd504d7194 100644 --- a/server/utils/podcastUtils.js +++ b/server/utils/podcastUtils.js @@ -238,7 +238,7 @@ module.exports.getPodcastFeed = (feedUrl, excludeEpisodeMetadata = false) => { return axios({ url: feedUrl, method: 'GET', - timeout: 12000, + timeout: global.FileDownloadTimeout, responseType: 'arraybuffer', headers: { Accept: 'application/rss+xml, application/xhtml+xml, application/xml, */*;q=0.8',