devsnd / cherrymusic

Stream your own music collection to all your devices! The easy to use free and open-source music streaming server.
http://www.fomori.org/cherrymusic
GNU General Public License v3.0
1.03k stars 187 forks source link

Transcoding should work with files with multibyte UTF-8-encoded characters in their path #296

Closed undu closed 11 years ago

undu commented 11 years ago

Right now, the transcoding module doesn't deal well with multibyte characters in the fails and generates and error when trying to transcode it.

[130320-19:58] 10.0.2.2 - - [20/Mar/2013:19:58:56] "GET /trans/Violadores del Verso/Vivir para contarlo/01. Filosof\xc3\x83\xc2\xada y letras.flac/get.mp3 HTTP/1.1" 200 - "http://undu.no-ip.org:8081/res/js/Jplayer.swf" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0"
[130320-19:58] ERROR   : [20/Mar/2013:19:58:56]  Traceback (most recent call last):
 File "/usr/lib/python3.3/site-packages/cherrypy/_cpwsgi.py", line 169, in trap
return func(*args, **kwargs)
  File "/usr/lib/python3.3/site-packages/cherrypy/_cpwsgi.py", line 258, in __next__
return next(self.iter_response)
  File "/home/pau/cherrymusic/audiotranscode/__init__.py", line 178, in transcodeStream
    raise e
  File "/home/pau/cherrymusic/audiotranscode/__init__.py", line 168, in transcodeStream
    decoder_process = self._decode(filepath, decoder)
  File "/home/pau/cherrymusic/audiotranscode/__init__.py", line 127, in _decode
    raise DecodeError('File not Found! Cannot decode "file" %s'%filepath)
audiotranscode.DecodeError: 'File not Found! Cannot decode "file" /home/pau/music/Violadores del Verso/Vivir para contarlo/01. FilosofÃ\xada y letras.flac'

I'm using the master branch, notice how in the GET command, the string shows utf-8 codes, but in the exception at the end the name of the file is written in plain ASCII.

I've checked the code, the issue seems to be the code in the server that handles the filepath and calls HTTPHandler.trans() at httphandler.py, as the string is already malformed there and the webclient seems to generate correctly the string.

Maybe it's related to how Cherrypy handles the string?

devsnd commented 11 years ago

Hello undu, thank you for your detailed report and investigations!

But it seems that this is a duplicate of #273, which really was a problem with the way cherrypy handles unicode characters, just like you diagnosed.

A workaround was applied to the devel branch af8ad67709b7befeb6ddf53646dd02d6fe756a31. Please check out the devel branch and see if this resolves your problem. If it doesn't, just reopen this issue and we'll see what's going wrong.

undu commented 11 years ago

Woops, that's what I get for not cheking throughtly first.

It works great in the devel branch, thanks!