ukdtom / SRT2UTF-8.bundle

Plex Agent, that'll convert sidecar subtitle files into UTF-8, if not
125 stars 14 forks source link

KeyError: 'xx' #32

Open bakua opened 7 years ago

bakua commented 7 years ago

Hello,

I have PMS running on Ubuntu. Unfortunately, your plug-in doesn't work for me. Could I have an assistance please? Here is the stacktrace. The log file is attached to same issue on Plex Forum https://forums.plex.tv/discussion/comment/1469993/#Comment_1469993

 CRITICAL (agentkit:1078) - Exception in the update function of agent named 'Srt2Utf-8 (Movies)', called with guid 'com.plexapp.agents.imdb://tt2024544?lang=en' (most recent call last):
 #126   File "/usr/lib/plexmediaserver/Resources/Plug-ins-313f93718/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/api/agentkit.py", line 1076, in _update
 #127   agent.update(obj, media, lang, **kwargs)
 #128   File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/SRT2UTF-8.bundle/Contents/Code/__init__.py", line 53, in update
 #129   GetFiles(part)
 #130   File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/SRT2UTF-8.bundle/Contents/Code/__init__.py", line 153, in GetFiles
 #131   FixFile(sTest, sMyLang)
 #132   File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/SRT2UTF-8.bundle/Contents/Code/__init__.py", line 112, in FixFile
 #133   sMyEnc = FindEncBS(sFile, sMyLang)
 #134   File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/SRT2UTF-8.bundle/Contents/Code/__init__.py", line 191, in FindEncBS
 #135   if sCurrentEnc == CP_Windows_ISO.cpWindows[lang]:
 #136   File "/usr/lib/plexmediaserver/Resources/Plug-ins-313f93718/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/code/sandbox.py", line 108, in
 #137   _getitem_ = lambda x, y: x.__getitem__(y),
 #138   KeyError: 'xx'

Thank you :)

ukdtom commented 7 years ago

Answered in Plex forum thread, and awaits feedback from OP

bakua commented 7 years ago

Respondend https://forums.plex.tv/discussion/comment/1470065/#Comment_1470065

bakua commented 7 years ago
2017-06-30 22:31:25,731 (7fac6effd700) : DEBUG (__init__:162) - Converting file: /mnt/virtual/DOWNLOAD/filmy/12 Years a Slave (2013)/12 Years a Slave (2013).en.srt with the encoding of cp1252 into utf-8
#72 2017-06-30 22:31:25,731 (7fac6effd700) : CRITICAL (__init__:124) - Something went wrong converting!!! Check file permissions? (most recent call last):
#73 File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/SRT2UTF-8.bundle/Contents/Code/__init__.py", line 122, in FixFile
#74 ConvertFile(sFile, sMyEnc)
#75 File "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/SRT2UTF-8.bundle/Contents/Code/__init__.py", line 164, in ConvertFile
#76 targetFile.write(sourceFile.read())
#77 File "/usr/lib/plexmediaserver/Resources/Python/lib/python2.7/encodings/cp1252.py", line 23, in decode
#78 return codecs.charmap_decode(input,self.errors,decoding_table)[0]
#79 UnicodeDecodeError: 'charmap' codec can't decode byte 0x9d in position 324: character maps to
#80 
#81 2017-06-30 22:31:25,731 (7fac6effd700) : CRITICAL (__init__:326) - **** Reverting from backup, something went wrong here ****
#82 2017-06-30 22:31:25,737 (7fac6effd700) : DEBUG (__init__:337) - Reverting from backup of /mnt/virtual/DOWNLOAD/filmy/12 Years a Slave (2013)/12 Years a Slave (2013).en.srt.Srt2Utf-8

Subtitles it is happening for: 12 Years a Slave (2013).en.txt I had to rename srt to txt to be able to upload it.

bakua commented 7 years ago

I did a 5 minute digging through the code and that made me realize where we went wrong. My srt file is Czech language one in ISO 8859-2 encoding. Setting the filename to .en.srt for test purposes was incorrect as ISO 8859-2 is unsupported by en locale. I changed the filename to .cs.srt and the above crash does not occur anymore.

However, I would still like to get the bug, that only shows, when running subs without a language identifier, fixed, as none of my subtitle files have the language identifier in it :)

Thank you, bakua

ukdtom commented 7 years ago

Care to try the Tommy-Work branch, found here, and then report back: https://github.com/ukdtom/SRT2UTF-8.bundle/archive/tommy-work.zip

bakua commented 6 years ago

Still doesn't work for me:

/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-ins/SRT2UTF-8.bundle$ git status
On branch tommy-work
Your branch is up-to-date with 'origin/tommy-work'.
nothing to commit, working directory clean

log.zip

ukdtom commented 6 years ago

Sorry, closed by a mistake here....

This one is sadly still an issue

peritissima commented 5 years ago

I have same problem, any suggestion please please please, logs.zip

ukdtom commented 5 years ago

@peritissima Check forum thread for a start