cvarelaruiz / owi2plex

Exporter of EPG from OpenWebif to XMLTV to use with Plex
Mozilla Public License 2.0
26 stars 6 forks source link

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

Closed MrNick4B closed 5 years ago

MrNick4B commented 5 years ago

Today, when executing the script, I got the following error:

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

It seems that there can be control characters in the title, subtitle and descriptions of a program.

I fixed this for myself by replacing some lines in def addEvents2XML:

Old:

...
programme_desc.text = unescape(event['shortdesc'])
...
programme_desc.text = unescape(event['longdesc'])
...
programme_subtitle.text = unescape(subtitle)
...
programme_title.text = title
...

New:

...
programme_desc.text = re.sub(u'[^\u0020-\uD7FF\u0009\u000A\u000D\uE000-\uFFFD\U00010000-\U0010FFFF]+', '', unescape(event['shortdesc']))
...
programme_desc.text = re.sub(u'[^\u0020-\uD7FF\u0009\u000A\u000D\uE000-\uFFFD\U00010000-\U0010FFFF]+', '', unescape(event['longdesc']))
...
programme_subtitle.text = re.sub(u'[^\u0020-\uD7FF\u0009\u000A\u000D\uE000-\uFFFD\U00010000-\U0010FFFF]+', '', unescape(subtitle))
...
programme_title.text = re.sub(u'[^\u0020-\uD7FF\u0009\u000A\u000D\uE000-\uFFFD\U00010000-\U0010FFFF]+', '', title)
MrNick4B commented 5 years ago

Looks like this is a duplicate issue, sorry! #5

Dosepower commented 4 years ago

thanks