From 99ca16c45d27650efdd2e64344056cad5b45f26f Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Thu, 5 Mar 2026 11:44:38 +0100 Subject: [PATCH] Improve logging message --- changedetectionio/content_fetchers/requests.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/changedetectionio/content_fetchers/requests.py b/changedetectionio/content_fetchers/requests.py index f9d5de083..6300e3770 100644 --- a/changedetectionio/content_fetchers/requests.py +++ b/changedetectionio/content_fetchers/requests.py @@ -154,11 +154,14 @@ class fetcher(Fetcher): # See: https://github.com/dgtlmoon/changedetection.io/issues/3952 try: r.content.decode('utf-8') # try to decode, validation only + original_encoding = r.encoding r.encoding = 'utf-8' # If it got this far, set it to utf-8 + if original_encoding != r.encoding: + logger.info(f"URL: {url} content was re-encoded successfully from '{original_encoding}' to '{r.encoding}'") except UnicodeDecodeError: - # Not valid UTF-8, fall back to chardet + # Not valid UTF-8, fall back to chardetr encoding = chardet.detect(r.content)['encoding'] - logger.warning(f"URL: {url} Did not decode as UTF-8, got UnicodeDecodeError, guessed new encoding as '{encoding}' via chardet") + logger.warning(f"URL: {url} Did not decode as utf-8, got UnicodeDecodeError, guessed new encoding as '{encoding}' via chardet") if encoding: r.encoding = encoding