desbma/r128gain

Unicode error

Closed this issue · 1 comments

Don't know why (probably weird file names?) but -s switch can give this error:

Traceback (most recent call last):                                                                                                                                            
  File "/home/user/.local/bin/r128gain", line 8, in <module>
    sys.exit(cl_main())
  File "/home/user/.local/lib/python3.8/site-packages/r128gain/__init__.py", line 784, in cl_main
    err_count = process_recursive(args.path,
  File "/home/user/.local/lib/python3.8/site-packages/r128gain/__init__.py", line 583, in process_recursive
    dir_futures = scan(album_filepaths,
  File "/home/user/.local/lib/python3.8/site-packages/r128gain/__init__.py", line 234, in scan
    logger().info("File '%s' already has a track gain tag, skipping track gain scan" % (audio_filepath))
  File "/usr/lib/python3.8/logging/__init__.py", line 1434, in info
    self._log(INFO, msg, args, **kwargs)
  File "/usr/lib/python3.8/logging/__init__.py", line 1577, in _log
    self.handle(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1587, in handle
    self.callHandlers(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 1649, in callHandlers
    hdlr.handle(record)
  File "/usr/lib/python3.8/logging/__init__.py", line 950, in handle
    self.emit(record)
  File "/home/user/.local/lib/python3.8/site-packages/r128gain/tqdm_logging.py", line 21, in emit
    self.tqdm.write(msg)
  File "/home/user/.local/lib/python3.8/site-packages/tqdm/std.py", line 585, in write
    fp.write(s)
UnicodeEncodeError: 'utf-8' codec can't encode character '\udca0' in position 156: surrogates not allowed

It should be somewhat improved by 6294e67

The file will still generate an error, but will not take the whole program with it.

Unfortunately, I can't do much more for files with non unicode filenames, because I use ffmpeg-python, which excepts all filenames to be Python string, which have to be unicode.