extrobe/plex_and_media_utilities

Character encoding in output.txt

Opened this issue · 0 comments

I encountered the following error when trying to run sonarr_episode_changes.py:

Traceback (most recent call last): File "D:\sonarr_episode_changes.py", line 137, in <module> main() File "D:\sonarr_episode_changes.py", line 129, in main z += process_season(series_id, series_name) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "D:\sonarr_episode_changes.py", line 109, in process_season text_file.write("Mismatch Found: %s" % title + " | " + file + "\n") File "C:\Program Files\Python311\Lib\encodings\cp1252.py", line 19, in encode return codecs.charmap_encode(input,self.errors,encoding_table)[0] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ UnicodeEncodeError: 'charmap' codec can't encode character '\u2665' in position 78: character maps to <undefined>

I was able to fix the issue by updating
with open("Output.txt", "a") as text_file:
to
with open("Output.txt", "a", encoding='utf-8') as text_file:
in lines 102 and 106