desbma / r128gain

Fast audio loudness scanner & tagger (ReplayGain v2 / R128)
GNU Lesser General Public License v2.1
172 stars 9 forks source link

Unicode error #18

Closed Oreolek closed 4 years ago

Oreolek commented 4 years ago

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
desbma commented 4 years ago

It should be somewhat improved by https://github.com/desbma/r128gain/commit/6294e67fc353ce0f6d7f637bd439aa6c1da223fd

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.