UnicodeDecodeError: 'utf8' codec can't decode byte 0xe0 in position 0: invalid continuat

I recently developed a plugin for plex, and now one user can not use it, and I can not figure out why he gets following error:

2013-12-10 19:52:37,072 (4810) :  DEBUG (runtime:717) - Handling request GET /:/plugins/com.plexapp.plugins.iptvlite/resources/icon-default.png?t=1386697505
2013-12-10 19:52:37,138 (4810) :  DEBUG (runtime:814) - Found route matching /:/plugins/com.plexapp.plugins.iptvlite/resources/icon-default.png
2013-12-10 19:52:37,211 (4810) :  CRITICAL (core:561) - Exception (most recent call last):
  File "C:\Users\mdenisov\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\components\runtime.py", line 840, in handle_request
    result = f(**d)
  File "C:\Users\mdenisov\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\handlers\resources.py", line 69, in resource
    return Framework.objects.DataObject(self._core, resource, Framework.utils.guess_mime_type(resource_name))
  File "C:\Users\mdenisov\AppData\Local\Plex Media Server\Plug-ins\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\utils.py", line 40, in guess_mime_type
    mtype = mimetypes.guess_type(filename)[0]
  File "C:\Program Files (x86)\Plex\Plex Media Server\python27.zip\mimetypes.py", line 294, in guess_type
    init()
  File "C:\Program Files (x86)\Plex\Plex Media Server\python27.zip\mimetypes.py", line 355, in init
    db.read_windows_registry()
  File "C:\Program Files (x86)\Plex\Plex Media Server\python27.zip\mimetypes.py", line 259, in read_windows_registry
    for ctype in enum_types(mimedb):
  File "C:\Program Files (x86)\Plex\Plex Media Server\python27.zip\mimetypes.py", line 249, in enum_types
    ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'utf8' codec can't decode byte 0xe0 in position 0: invalid continuation byte

Any ideas?

From what I can find about the subject, this is an issue with python on certain Windows installs. I think that you may be able to work around it by manually assigning the mimetype in your code. Just guessing here but, I would try adding the following line to your Start() function.

Resource.AddMimeType('image/png','png')

I've never used the Resource.AddMimeType() function so, I'm not really sure how it works but I think it should bypass the bug that's causing that error.

After further discussion with Sander, the issue is likely simpler to fix. When returning the default-icon, you should use a Redirect(), like so:

return Redirect(R('icon-default.png'))

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.