From 45f8b06d569df68a6cf7b14ae4db72e1fff34ac9 Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 15 Nov 2024 08:30:54 -0600 Subject: [PATCH] Fix:CBC Radio podcast RSS feeds not accepting our user-agent string #3322 --- server/utils/podcastUtils.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/utils/podcastUtils.js b/server/utils/podcastUtils.js index 92679903..ac96c8d0 100644 --- a/server/utils/podcastUtils.js +++ b/server/utils/podcastUtils.js @@ -228,6 +228,13 @@ module.exports.parsePodcastRssFeedXml = async (xml, excludeEpisodeMetadata = fal module.exports.getPodcastFeed = (feedUrl, excludeEpisodeMetadata = false) => { Logger.debug(`[podcastUtils] getPodcastFeed for "${feedUrl}"`) + let userAgent = 'audiobookshelf (+https://audiobookshelf.org; like iTMS)' + // Workaround for CBC RSS feeds rejecting our user agent string + // See: https://github.com/advplyr/audiobookshelf/issues/3322 + if (feedUrl.startsWith('https://www.cbc.ca')) { + userAgent = 'audiobookshelf (+https://audiobookshelf.org; like iTMS) - CBC' + } + return axios({ url: feedUrl, method: 'GET', @@ -235,7 +242,7 @@ module.exports.getPodcastFeed = (feedUrl, excludeEpisodeMetadata = false) => { responseType: 'arraybuffer', headers: { Accept: 'application/rss+xml, application/xhtml+xml, application/xml, */*;q=0.8', - 'User-Agent': 'audiobookshelf (+https://audiobookshelf.org; like iTMS)' + 'User-Agent': userAgent }, httpAgent: global.DisableSsrfRequestFilter ? null : ssrfFilter(feedUrl), httpsAgent: global.DisableSsrfRequestFilter ? null : ssrfFilter(feedUrl)