From 92fcdaf5df48f5b344a438bba3a10d5f9e04a0e3 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Sat, 1 Sep 2018 01:50:02 +0200 Subject: [PATCH] Change decode html entities returned from tvdb api. --- lib/tvdb_api/tvdb_api.py | 4 ++++ lib/tvdb_api_v1/tvdb_api.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/lib/tvdb_api/tvdb_api.py b/lib/tvdb_api/tvdb_api.py index 91d8bd20..1e5f31d4 100644 --- a/lib/tvdb_api/tvdb_api.py +++ b/lib/tvdb_api/tvdb_api.py @@ -25,6 +25,8 @@ import re from sickbeard.helpers import getURL, tryInt import sickbeard +from lib.six.moves.html_parser import HTMLParser + from lib.dateutil.parser import parse from lib.cachecontrol import CacheControl, caches @@ -737,6 +739,8 @@ class Tvdb: return [self._clean_data(d) for d in data] if isinstance(data, dict): return {k: self._clean_data(v) for k, v in data.iteritems()} + if isinstance(data, basestring): + return HTMLParser().unescape(data).strip() return data if not isinstance(data, (str, unicode)) else data.strip().replace(u'&', u'&') def search(self, series): diff --git a/lib/tvdb_api_v1/tvdb_api.py b/lib/tvdb_api_v1/tvdb_api.py index 7e70c89a..5057a769 100644 --- a/lib/tvdb_api_v1/tvdb_api.py +++ b/lib/tvdb_api_v1/tvdb_api.py @@ -29,6 +29,7 @@ except ImportError: from lib.dateutil.parser import parse from lib.cachecontrol import CacheControl, caches +from lib.six.moves.html_parser import HTMLParser from lib.etreetodict import ConvertXmlToDict from tvdb_ui import BaseUI, ConsoleUI @@ -637,6 +638,8 @@ class TvdbV1: - Replaces & with & - Trailing whitespace """ + if isinstance(data, basestring): + return HTMLParser().unescape(data).strip() return data if not isinstance(data, basestring) else data.strip().replace(u'&', u'&') def _get_url_artwork(self, image):