radusuciu / traktor_nowplaying

A cross-platform library and command-line tool that extracts the currently playing track in Traktor and optionally outputs to a file with configurable formatting.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issue with some Unicode characters

succinct opened this issue · comments

I'm getting exceptions when track data includes non-latin characters - see the example below.

Listening on port 8000.
Outputting to f:\DJ Stuff\nowplaying.txt
Mr.Kitty - Puzzle Heart (feat. 初音ミク)
----------------------------------------
Exception happened during processing of request from ('192.168.1.133', 61855)
Traceback (most recent call last):
  File "c:\users\nick\appdata\local\programs\python\python38\lib\socketserver.py", line 316, in _handle_request_noblock
    self.process_request(request, client_address)
  File "c:\users\nick\appdata\local\programs\python\python38\lib\socketserver.py", line 347, in process_request
    self.finish_request(request, client_address)
  File "c:\users\nick\appdata\local\programs\python\python38\lib\socketserver.py", line 360, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "c:\users\nick\appdata\local\programs\python\python38\lib\socketserver.py", line 720, in __init__
    self.handle()
  File "c:\users\nick\appdata\local\programs\python\python38\lib\http\server.py", line 427, in handle
    self.handle_one_request()
  File "c:\users\nick\appdata\local\programs\python\python38\lib\http\server.py", line 415, in handle_one_request
    method()
  File "c:\users\nick\appdata\local\programs\python\python38\lib\site-packages\traktor_nowplaying\core.py", line 36, in do_SOURCE
    callback(metadata)
  File "c:\users\nick\appdata\local\programs\python\python38\lib\site-packages\traktor_nowplaying\core.py", line 60, in _output_to_file
    f.write(f'{_get_track_string(data)}\n')
  File "c:\users\nick\appdata\local\programs\python\python38\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 31-34: character maps to <undefined>
----------------------------------------

I'll take a look, thanks for the report!

Thanks for looking, this library has been super helpful for me!

Thanks again for report, fixed. Sorry for delay, I haven't had much time to spend on code outside of work and wanted to be able to reproduce first before deploying a fix.

Thanks so much for the update, it works great!