From dca8b6ed5f3027c39cac9977431667476163638a Mon Sep 17 00:00:00 2001 From: Cigaras Date: Mon, 26 Jun 2017 08:52:26 +0300 Subject: [PATCH] Version 2.1.5 * Empty programme description fix (#134) --- Contents/Code/__init__.py | 2 +- Contents/Code/xmltv_parser.py | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 66affd0..8c118c4 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -12,7 +12,7 @@ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# Version 2.1.4 +# Version 2.1.5 from m3u_parser import LoadPlaylist, PlaylistReloader from xmltv_parser import LoadGuide, GuideReloader diff --git a/Contents/Code/xmltv_parser.py b/Contents/Code/xmltv_parser.py index 95c6cea..9c4f034 100644 --- a/Contents/Code/xmltv_parser.py +++ b/Contents/Code/xmltv_parser.py @@ -79,13 +79,21 @@ def LoadGuide(): start = StringToLocalDatetime(programme_elem.get('start')) stop = StringToLocalDatetime(programme_elem.get('stop')) if stop >= current_datetime: - title = programme_elem.find('title').text - desc_attr = programme_elem.find('desc') - try: - desc = unicode(desc_attr.text, errors = 'replace') - except TypeError: - desc = desc_attr.text.decode('utf-8') - except AttributeError: + title_text = programme_elem.find('title').text + if title_text: + try: + title = unicode(title_text, errors = 'replace') + except TypeError: + title = title_text.decode('utf-8') + else: + title = None + desc_text = programme_elem.find('desc').text + if desc_text: + try: + desc = unicode(desc_text, errors = 'replace') + except TypeError: + desc = desc_text.decode('utf-8') + else: desc = None count = count + 1 item = {