pymedusa / Medusa

Automatic Video Library Manager for TV Shows. It watches for new episodes of your favorite shows, and when they are posted it does its magic.
https://pymedusa.com
GNU General Public License v3.0
1.76k stars 274 forks source link

[APP SUBMITTED]: UnicodeEncodeError: 'charmap' codec can't encode character '\u30fb' in position 9030: character maps to <undefined> #10749

Open Theonepudding opened 2 years ago

Theonepudding commented 2 years ago

INFO

Python Version: 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)] Operating System: Windows-10-10.0.19041-SP0 Locale: cp1252 Branch: master Database: 44.19 Commit: pymedusa/Medusa@ad2c7adcde31a423ecd3195c1c76f39f67800451 Link to Log: No Log available

ERROR

2022-06-10 04:54:59 ERROR    SHOWQUEUE-REFRESH :: [ad2c7ad] 321285: Error while refreshing show Boruto: Naruto Next Generations. Error: 'charmap' codec can't encode character '\u30fb' in position 9030: character maps to 
Traceback (most recent call last):
  File "C:\Medusa\Medusa\medusa\queues\show_queue.py", line 758, in run
    self.show.refresh_dir()
  File "C:\Medusa\Medusa\medusa\tv\series.py", line 2111, in refresh_dir
    self.load_episodes_from_dir()
  File "C:\Medusa\Medusa\medusa\tv\series.py", line 1115, in load_episodes_from_dir
    cur_episode = self.make_ep_from_file(os.path.join(self.location, media_file))
  File "C:\Medusa\Medusa\medusa\tv\series.py", line 1488, in make_ep_from_file
    root_ep.create_meta_files()
  File "C:\Medusa\Medusa\medusa\tv\episode.py", line 1157, in create_meta_files
    self.__create_nfo(metadata_provider)
  File "C:\Medusa\Medusa\medusa\tv\episode.py", line 1170, in __create_nfo
    result = metadata_provider.create_episode_metadata(self) or result
  File "C:\Medusa\Medusa\medusa\metadata\plex.py", line 248, in create_episode_metadata
    return self.write_ep_file(ep_obj)
  File "C:\Medusa\Medusa\medusa\metadata\plex.py", line 220, in write_ep_file
    outfile.write('\n'.join(data))
  File "C:\Medusa\tools\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 '\u30fb' in position 9030: character maps to 

STAFF NOTIFIED: @pymedusa/support @pymedusa/moderators

reconman commented 2 years ago

Try setting the environment variable PYTHONUTF8=1 on your Windows machine.

The error is caused by some Japanese・characters in the Japanese episode names and Medusa tries to write them into files. The default encoding on Windows is cp1252. The environment variable changes it to UTF-8 by default.

BenjV commented 2 years ago

Or as alternative you could add this switch to the python command.

-Xutf8

Theonepudding commented 2 years ago

Where would i do that?

reconman commented 2 years ago

For my solution, see https://docs.oracle.com/en/database/oracle/machine-learning/oml4r/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0