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

Encoding error in file names ? #611

Closed SeeDborg closed 7 years ago

SeeDborg commented 8 years ago

I have trouble updating the database, having this king of error :

Traceback (most recent call last):
  File "/usr/lib/python3.4/logging/__init__.py", line 980, in emit
    stream.write(msg)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 287-288: ordinal not in range(128)
Call stack:
  File "/usr/lib/python3.4/threading.py", line 888, in _bootstrap
    self._bootstrap_inner()
  File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.4/threading.py", line 868, in run
    self._target(*self._args, **self._kwargs)
  File "/opt/cherrymusic/cherrymusicserver/util.py", line 49, in wrapper
    result = func(*args, **kwargs)
  File "/opt/cherrymusic/cherrymusicserver/sqlitecache.py", line 471, in full_update
    self.update_db_recursive(cherry.config['media.basedir'], skipfirst=True)
  File "/opt/cherrymusic/cherrymusicserver/sqlitecache.py", line 540, in update_db_recursive
    self.register_file_with_db(item.infs)
  File "/opt/cherrymusic/cherrymusicserver/sqlitecache.py", line 312, in register_file_with_db
    log.e(_("wrong encoding for filename '%s' (%s)"), fileobj.relpath, e.__class__.__name__)
  File "/opt/cherrymusic/cherrymusicserver/log.py", line 126, in error
    _get_logger().error(msg, *args, **kwargs)
Message: "wrong encoding for filename '%s' (%s)"
Arguments: ('Les paradis disponibles/7 - Mon P\udcc3\udca8re Ce H\udcc3\udca9ros.mp3', 'UnicodeEncodeError')

I think it's related to the caracters in my files' names. How can I fix this ?

EDIT: Formatted code properly. Please use Markdown next time. -- 6arms1leg

gbrito commented 8 years ago

I had a similar problem with Cherrymusic, the problem is the locales not being passed correctly to python. Although the locales in my environment were set to en_US.UTF-8 the Cherrymusic wasn't getting the proper ones.

In my system i has starting Cherrymusic with the command:

python cherrymusic &

The command python was bind to python2.7. Since i have python 2.7 and python 3.2 i tried with both of them and python 3.2 was getting the necessary locales. You can test the commands in your system through the python console and see what happens in the different python versions.

goncalo@fr19286:~$ python3.2
Python 3.2.3 (default, Feb 20 2013, 14:44:27)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale()
('en_US', 'UTF-8')

goncalo@fr19286:~$ python
Python 2.7.3 (default, Mar 13 2014, 11:03:55)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import locale
>>> locale.getlocale()
(None, None)

Now i start the Cherrymusic with the command python3.2 cherrymusic & and have no problems.

mobiuszero1 commented 8 years ago

Thanks @gbrito I was having the same issue and this appears to have fixed it for me.

6arms1leg commented 8 years ago

@SeeDborg , did this fix the issue for you, too (so I can close this one)?

EDIT: See post below. -- 6arms1leg

6arms1leg commented 8 years ago

OK, I tried same thing on my server which gave the same result. Also, I remembered we had similar issues in the past (see https://github.com/devsnd/cherrymusic/issues/368#issuecomment-28640120), even one that is still open (#315). @devsnd , is the latter one related (or even a duplicate) or did we lost Python >= 2.6 support completely somewhere along the way? :scream:

devsnd commented 8 years ago

@6arms1leg The python2 support seems to be as broken as it always was: It requires the system to ber set up perfectly, whereas python 3 just works.

I have however still one change in mind that might fix a lot of those issues. Some time ago I read about the option for python to encode characters that include invalid byte-sequences using a so-called replacement character. (see here for the documentation). This might take care of many of those problems (mostly hiding them, but who cares, as long as it works ;)

IvanBayan commented 8 years ago

I think i faced with same bug, Mozilla/5.0 (X11; Linux i686; rv:45.0) Gecko/20100101 Firefox/45.0 stops playing, Chromium 53.0.2785.143 stops and resumes every few minutes. Chromium console looks like that:

preloaded template mediabrowser-directory
cherrymusic.dist.js:1516 preloaded template mediabrowser-playlist
cherrymusic.dist.js:1516 preloaded template flash-message
cherrymusic.dist.js:1376 refreshTabs
cherrymusic.dist.js:1383 refreshPlaylists
cherrymusic.dist.js:1384 Array[1]
3cherrymusic.dist.js:1376 refreshTabs
cherrymusic.dist.js:1383 refreshPlaylists
cherrymusic.dist.js:1384 Array[1]
cherrymusic.dist.js:1376 refreshTabs
cherrymusic.dist.js:1416 remembering playlists periodically
cherrymusic.dist.js:1516 preloaded template mediabrowser-file
cherrymusic.dist.js:1516 preloaded template mediabrowser-message
cherrymusic.dist.js:1516 preloaded template mediabrowser-compact
46cherrymusic.dist.js:1453 load_unloaded_meta_data
cherrymusic.dist.js:1450 fetch_meta_data
cherrymusic.dist.js:1446 renderMetaData
cherrymusic.dist.js:1453 load_unloaded_meta_data
2cherrymusic.dist.js:1376 refreshTabs
cherrymusic.dist.js:1394 Trying available transcoders.
cherrymusic.dist.js:1395 added live transcoding flac --> ogg @ trans/ogg/cyclope/music/%D0%97%D0%B2%D0%B5%D0%B7%D0%B4%D0%B0%20%D0%B8%20%D0%A1%D0%BC%D0%B5%D1%80%D1%82%D1%8C%20%D0%A5%D0%BE%D0%B0%D0%BA%D0%B8%D0%BD%D0%B0%20%D0%9C%D1%83%D1%80%D1%8C%D0%B5%D1%82%D1%8B/%D0%90%D0%BB%D0%B5%D0%BA%D1%81%D0%B5%D0%B9%20%D0%A0%D1%8B%D0%B1%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2%20-%20%D0%97%D0%B2%D0%B5%D0%B7%D0%B4%D0%B0%20%D0%B8%20%D0%A1%D0%BC%D0%B5%D1%80%D1%82%D1%8C%20%D0%A5%D0%BE%D0%B0%D0%BA%D0%B8%D0%BD%D0%B0%20%D0%9C%D1%83%D1%80%D1%8C%D0%B5%D1%82%D1%8B.flac?bitrate=0
cherrymusic.dist.js:1395 added live transcoding flac --> mp3 @ trans/mp3/cyclope/music/%D0%97%D0%B2%D0%B5%D0%B7%D0%B4%D0%B0%20%D0%B8%20%D0%A1%D0%BC%D0%B5%D1%80%D1%82%D1%8C%20%D0%A5%D0%BE%D0%B0%D0%BA%D0%B8%D0%BD%D0%B0%20%D0%9C%D1%83%D1%80%D1%8C%D0%B5%D1%82%D1%8B/%D0%90%D0%BB%D0%B5%D0%BA%D1%81%D0%B5%D0%B9%20%D0%A0%D1%8B%D0%B1%D0%BD%D0%B8%D0%BA%D0%BE%D0%B2%20-%20%D0%97%D0%B2%D0%B5%D0%B7%D0%B4%D0%B0%20%D0%B8%20%D0%A1%D0%BC%D0%B5%D1%80%D1%82%D1%8C%20%D0%A5%D0%BE%D0%B0%D0%BA%D0%B8%D0%BD%D0%B0%20%D0%9C%D1%83%D1%80%D1%8C%D0%B5%D1%82%D1%8B.flac?bitrate=0
http://192.168.108.246:8080/trans/mp3/cyclope/music/%D0%97%D0%B2%D0%B5%D0%B…B8%D0%BD%D0%B0%20%D0%9C%D1%83%D1%80%D1%8C%D0%B5%D1%82%D1%8B.flac?bitrate=0 Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
cherrymusic.dist.js:1367 Playback failed! trying to resume from the point it failed.
http://192.168.108.246:8080/trans/mp3/cyclope/music/%D0%97%D0%B2%D0%B5%D0%B…B8%D0%BD%D0%B0%20%D0%9C%D1%83%D1%80%D1%8C%D0%B5%D1%82%D1%8B.flac?bitrate=0 Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
cherrymusic.dist.js:1367 Playback failed! trying to resume from the point it failed.
http://192.168.108.246:8080/trans/mp3/cyclope/music/%D0%97%D0%B2%D0%B5%D0%B…B8%D0%BD%D0%B0%20%D0%9C%D1%83%D1%80%D1%8C%D0%B5%D1%82%D1%8B.flac?bitrate=0 Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
cherrymusic.dist.js:1367 Playback failed! trying to resume from the point it failed.
http://192.168.108.246:8080/trans/mp3/cyclope/music/%D0%97%D0%B2%D0%B5%D0%B…B8%D0%BD%D0%B0%20%D0%9C%D1%83%D1%80%D1%8C%D0%B5%D1%82%D1%8B.flac?bitrate=0 Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
cherrymusic.dist.js:1367 Playback failed! trying to resume from the point it failed.

PS Thanks for cherrymusic

tilboerner commented 7 years ago

Sorry, I'm late to the party! :dancer: @SeeDborg (the OP) has a Python 3 bug, and it's a duplicate of #595: See the obstinate \xdc byte there in that mangled unicode? I'm closing this ticket in favor of the older one. Please take all related discussion there.

@IvanBayan: If CherryMusic stops playing in the middle of your tracks, you have a different problem. An audio transcoding one, if I had to guess. Decoding your output with UTF-8 leads to some text Google translates as Serbian, so I think your filename is fine. If your issue persists, could you please open a new ticket? Just copy and paste your comment; if you have any output from the server console to add, that would be great. ^^