From 33846e46faede2774d248bb79a40e93f9eca595f Mon Sep 17 00:00:00 2001 From: advplyr Date: Fri, 10 Feb 2023 17:07:25 -0600 Subject: [PATCH] Fix:Handle podcast RSS feeds with iso-8859-1 encoding #1489 --- package-lock.json | 2 +- server/utils/podcastUtils.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index df088c02..2f76ab43 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2314,4 +2314,4 @@ "integrity": "sha512-fDlsI/kFEx7gLvbecc0/ohLG50fugQp8ryHzMTuW9vSa1GJ0XYWKnhsUx7oie3G98+r56aTQIUB4kht42R3JvA==" } } -} \ No newline at end of file +} diff --git a/server/utils/podcastUtils.js b/server/utils/podcastUtils.js index 9cb9049f..ef7d54d1 100644 --- a/server/utils/podcastUtils.js +++ b/server/utils/podcastUtils.js @@ -191,7 +191,17 @@ module.exports.parsePodcastRssFeedXml = async (xml, excludeEpisodeMetadata = fal module.exports.getPodcastFeed = (feedUrl, excludeEpisodeMetadata = false) => { Logger.debug(`[podcastUtils] getPodcastFeed for "${feedUrl}"`) - return axios.get(feedUrl, { timeout: 6000 }).then(async (data) => { + return axios.get(feedUrl, { timeout: 6000, responseType: 'arraybuffer' }).then(async (data) => { + + // Adding support for ios-8859-1 encoded RSS feeds. + // See: https://github.com/advplyr/audiobookshelf/issues/1489 + const contentType = data.headers?.['content-type'] || '' // e.g. text/xml; charset=iso-8859-1 + if (contentType.toLowerCase().includes('iso-8859-1')) { + data.data = data.data.toString('latin1') + } else { + data.data = data.data.toString() + } + if (!data || !data.data) { Logger.error(`[podcastUtils] getPodcastFeed: Invalid podcast feed request response (${feedUrl})`) return false