Bug 205696 - multimedia/plexmediaserver localmedia agent fails when reading subtitles containing UTF-8 characters
Summary: multimedia/plexmediaserver localmedia agent fails when reading subtitles cont...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Many People
Assignee: Mark Felder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-29 14:25 UTC by Dan Barowy
Modified: 2015-12-31 15:21 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (feld)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dan Barowy 2015-12-29 14:25:27 UTC
The out-of-the-box configuration of Plex on FreeBSD causes the localmedia agent to barf when trying to read subtitles containing Unicode characters.  In "/usr/local/plexdata/Plex Media Server/Library/Logs/PMS Plugin Logs/com.plexapp.agents.localmedia.log" you get something like:

CRITICAL (agentkit:1057) - Exception in the update function of agent named 'Local Media Assets (Movies)', called with guid 'com.plexapp.agents.imdb://tt1617661?lang=en' (most recent call last):
  File "bundles-release/Framework.bundle-dist/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1055, in _update
  File "/usr/local/share/plexmediaserver/Resources/Plug-ins-f38ac80/LocalMedia.bundle/Contents/Code/__init__.py", line 56, in update
    localmedia.findSubtitles(part)
  File "/usr/local/share/plexmediaserver/Resources/Plug-ins-f38ac80/LocalMedia.bundle/Contents/Code/localmedia.py", line 260, in findSubtitles
    if os.path.isfile(os.path.join(path, file_path_listing)):
  File "/usr/local/share/plexmediaserver/Resources/Python/lib/python2.7/genericpath.py", line 29, in isfile
    st = os.stat(path)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 43-44: ordinal not in range(128)

This can be fixed by editing the startup script "/usr/local/etc/rc.d/plexmediaserver", changing the lines:

export LC_ALL="C"
export LANG="C"

to

export LC_ALL="en_US.UTF-8"
export LANG="en_US.UTF-8"

This fix is described in the Plex forums here: https://forums.plex.tv/discussion/comment/780533/#Comment_780533
Comment 1 Mark Felder freebsd_committer freebsd_triage 2015-12-31 15:00:21 UTC
Hi, Thanks!

I modled the rc script after the shell script that ships with Plex and at the time it was using the C locale. I am not sure if they changed it; haven't looked. Either way, this is a smart change.
Comment 2 commit-hook freebsd_committer freebsd_triage 2015-12-31 15:20:00 UTC
A commit references this bug:

Author: feld
Date: Thu Dec 31 15:19:39 UTC 2015
New revision: 404948
URL: https://svnweb.freebsd.org/changeset/ports/404948

Log:
  multimedia/plexmediaserver(-plexpass): Fix scanner crash

  The Plex processes were running under the C locale. This was to
  replicate the behavior of the start.sh shell script shipped with Plex and
  used by Linux distributions. The scanner process was crashing when it
  encountered unicode filenames due to this locale.
  Upstream Plex fixed this, but we were left affected.

  This resolves the scanner process crash on FreeBSD.

  PR:		205696

Changes:
  head/multimedia/plexmediaserver/Makefile
  head/multimedia/plexmediaserver/files/plexmediaserver.in
  head/multimedia/plexmediaserver-plexpass/Makefile
  head/multimedia/plexmediaserver-plexpass/files/plexmediaserver_plexpass.in