ZeroQI / YouTube-Agent.bundle

Plex Metadata Agent for Movies and TV Series libraries
452 stars 43 forks source link

All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters #14

Closed ghost closed 5 years ago

ghost commented 5 years ago

Seems that the scraper fails if it has non-standard characters within the channel name.

Example: SIVΛ [UCCgUcOtOjz6p7XbrsRb8-tQ]

File "/*****/******/******/plex/usr/lib/plexmediaserver/Resources/Plug-ins-115f087d6/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/modelling/model.py", line 190, in _write self._serialize(os.path.join(self._storage_path, subdir)) File "/*****/******/******/plex/usr/lib/plexmediaserver/Resources/Plug-ins-115f087d6/Framework.bundle/Contents/Resources/Versions/2/Python/Framework/modelling/model.py", line 215, in _serialize el.set('id', self._id) File "lxml.etree.pyx", line 699, in lxml.etree._Element.set (src/lxml/lxml.etree.c:34531) File "apihelpers.pxi", line 563, in lxml.etree._setAttributeValue (src/lxml/lxml.etree.c:15781) File "apihelpers.pxi", line 1366, in lxml.etree._utf8 (src/lxml/lxml.etree.c:22211) ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

Logfile: https://hastebin.com/ikinesecam.log

ZeroQI commented 5 years ago

@ewan2395 The error comes after the end of the scanner so a ~Plex issue. I can remove special xml non-compatible chars from every field updated but that will mean changing loads of code. Here is the function to apply to every string

#Based on an answer by John Machin on Stack Overflow http://stackoverflow.com/questions/8733233/filtering-out-certain-bytes-in-python
def filterInvalidXMLChars(string):
  def isValidXMLChar(char):  c = ord(char);  return 0x20 <= c <= 0xD7FF or 0xE000 <= c <= 0xFFFD or 0x10000 <= c <= 0x10FFFF or c in (0x9, 0xA, 0xD)
  return filter(isValidXMLChar, string)

Have to finish Lambda code beforehands. Will update this bug report when i start working on the code to change every instance of metadata updating...

ZeroQI commented 5 years ago

You need to remove specials characters from the folder name, it is a Plex limitation i added 'Λ' to a previously working folder, same issue, despite no 'Λ' from folder name being reused.

2018-09-30 19:34:03,046 (1e7c) : CRITICAL (core:574) - Exception serializing TV_Show with guid 'com.plexapp.agents.youtube://youtube|UUboMX_UNgaPBsUOIgasn3-Q|FunHΛus [UUboMX_UNgaPBsUOIgasn3-Q]?lang=xn' (most recent call last): File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-10d48da0d\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\modelling\model.py", line 190, in _write self._serialize(os.path.join(self._storage_path, subdir)) File "C:\Program Files (x86)\Plex\Plex Media Server\Resources\Plug-ins-10d48da0d\Framework.bundle\Contents\Resources\Versions\2\Python\Framework\modelling\model.py", line 215, in _serialize el.set('id', self._id) File "lxml.etree.pyx", line 699, in lxml.etree._Element.set (..\src\lxml\lxml.etree.c:34531) File "apihelpers.pxi", line 563, in lxml.etree._setAttributeValue (..\src\lxml\lxml.etree.c:15781) File "apihelpers.pxi", line 1366, in lxml.etree._utf8 (..\src\lxml\lxml.etree.c:22211) ValueError: All strings must be XML compatible: Unicode or ASCII, no NULL bytes or control characters

This needs raising to Plex, is not agent related, will close this bug report

JPH71 commented 4 years ago

I was getting the above error - I found that I had an em dash in my defaultprefs,jason file. Once removed the error disappeared.