diff --git a/Contents/Code/__init__.py b/Contents/Code/__init__.py index 6cb43a4..407b190 100644 --- a/Contents/Code/__init__.py +++ b/Contents/Code/__init__.py @@ -113,7 +113,7 @@ def ListGroups(page = 1): use_groups = False for group in groups_list: - if group['title'] not in [unicode(L('All')), unicode(L('No category'))]: + if group['title'] not in [unicode('All'), unicode('No category')]: use_groups = True break @@ -126,12 +126,12 @@ def ListGroups(page = 1): oc = ObjectContainer(title1 = unicode(L('View playlist'))) oc.add( DirectoryObject( - key = Callback(ListItems, group = unicode(L('All'))), + key = Callback(ListItems, group = unicode('All')), title = unicode(L('All')) ) ) for group in groups_list: - if group['title'] not in [unicode(L('All')), unicode(L('No category'))]: + if group['title'] not in [unicode('All'), unicode('No category')]: thumb = GetImage(group['thumb'], default = 'icon-folder.png', title = group['title']) art = GetImage(group['art'], default = 'art-default.png') oc.add( @@ -142,10 +142,10 @@ def ListGroups(page = 1): art = art ) ) - if unicode(L('No category')) in groups.keys(): + if unicode('No category') in groups.keys(): oc.add( DirectoryObject( - key = Callback(ListItems, group = unicode(L('No category'))), + key = Callback(ListItems, group = unicode('No category')), title = unicode(L('No category')) ) ) @@ -155,7 +155,7 @@ def ListGroups(page = 1): #################################################################################################### @route(PREFIX + '/listitems', page = int) -def ListItems(group = unicode(L('All')), query = '', page = 1): +def ListItems(group = unicode('All'), query = '', page = 1): if not Dict['streams']: LoadPlaylist() @@ -220,6 +220,7 @@ def ListItems(group = unicode(L('All')), query = '', page = 1): return oc else: return ObjectContainer( + title1 = unicode(L('Search')), header = unicode(L('Search')), message = unicode(L('No items were found')) ) @@ -281,7 +282,11 @@ def PlayVideo(url): def ReloadPlaylist(): if Dict['playlist_loading_in_progress']: - return ObjectContainer(header = unicode(L('Warning')), message = unicode(L('Playlist is reloading in the background, please wait'))) + return ObjectContainer( + title1 = unicode(L('Warning')), + header = unicode(L('Warning')), + message = unicode(L('Playlist is reloading in the background, please wait')) + ) LoadPlaylist() @@ -303,7 +308,11 @@ def ReloadPlaylist(): def ReloadGuide(): if Dict['guide_loading_in_progress']: - return ObjectContainer(header = unicode(L('Warning')), message = unicode(L('Program guide is reloading in the background, please wait'))) + return ObjectContainer( + title1 = unicode(L('Warning')), + header = unicode(L('Warning')), + message = unicode(L('Program guide is reloading in the background, please wait')) + ) LoadGuide() diff --git a/Contents/Code/m3u_parser.py b/Contents/Code/m3u_parser.py index 1d72dc9..502ad8c 100644 --- a/Contents/Code/m3u_parser.py +++ b/Contents/Code/m3u_parser.py @@ -62,7 +62,7 @@ def LoadM3UFile(m3u_file, groups = {}, streams = {}, cust_m3u_name = None): for i in range(line_count - 1): line_1 = lines[i].strip() if line_1.startswith('#EXTINF'): - title = unicode(line_1[line_1.rfind(',') + 1:len(line_1)].strip()) + title = unicode(line_1[line_1.rfind(',') + 1:len(line_1)].strip(), errors = 'replace') id = GetAttribute(line_1, 'tvg-id') name = GetAttribute(line_1, 'tvg-name') thumb = GetAttribute(line_1, 'tvg-logo') @@ -102,12 +102,12 @@ def LoadM3UFile(m3u_file, groups = {}, streams = {}, cust_m3u_name = None): 'order': stream_count } if not streams: - streams.setdefault(unicode(L('All')), {})[stream_count] = stream + streams.setdefault(unicode('All'), {})[stream_count] = stream if streams: - if not any(item['url'] == stream['url'] for item in streams[unicode(L('All'))].values()): - streams.setdefault(unicode(L('All')), {})[stream_count] = stream + if not any(item['url'] == stream['url'] for item in streams[unicode('All')].values()): + streams.setdefault(unicode('All'), {})[stream_count] = stream if not group_title: - group_title = unicode(L('No category') if not m3u_name else m3u_name) + group_title = unicode('No category' if not m3u_name else m3u_name) if group_title not in groups.keys(): group_thumb = GetAttribute(line_1, 'group-logo') group_art = GetAttribute(line_1, 'group-art') @@ -124,7 +124,7 @@ def LoadM3UFile(m3u_file, groups = {}, streams = {}, cust_m3u_name = None): else: streams.setdefault(group_title, {})[stream_count] = stream elif line_1.startswith('#EXTIMPORT'): - group_title = unicode(line_1[line_1.rfind(',') + 1:len(line_1)].strip()) if line_1.rfind(',') > -1 else None + group_title = unicode(line_1[line_1.rfind(',') + 1:len(line_1)].strip(), errors = 'replace') if line_1.rfind(',') > -1 else None url = None for j in range(i + 1, line_count): line_2 = lines[j].strip() @@ -151,21 +151,15 @@ def DecodeURIComponent(uri): #################################################################################################### def GetAttribute(text, attribute, delimiter1 = '=', delimiter2 = '"', default = ''): - try: - value = unicode(default) - except: - value = unicode(L('Unicode decode error')) x = text.lower().find(attribute.lower() + delimiter1 + delimiter2) if x > -1: y = x + len(attribute) + len(delimiter1) + len(delimiter2) z = text.lower().find(delimiter2.lower(), y) if delimiter2 else len(text) if z == -1: z = len(text) - try: - value = unicode(text[y:z].strip()) - except: - value = unicode(L('Unicode decode error')) - return value + return unicode(text[y:z].strip(), errors = 'replace') + else: + return unicode(default, errors = 'replace') #################################################################################################### def PlaylistReloader(): diff --git a/Contents/Code/xmltv_parser.py b/Contents/Code/xmltv_parser.py index 4a19a86..692f60f 100644 --- a/Contents/Code/xmltv_parser.py +++ b/Contents/Code/xmltv_parser.py @@ -56,20 +56,20 @@ def LoadGuide(): id = channel.get('id') if id: for name in channel.findall('display-name'): - key = unicode(name.text) + key = unicode(name.text, errors = 'replace') if key: channels[key] = id count = 0 current_datetime = Datetime.Now() for programme in root.findall('./programme'): - channel = unicode(programme.get('channel')) + channel = unicode(programme.get('channel'), errors = 'replace') start = StringToLocalDatetime(programme.get('start')) stop = StringToLocalDatetime(programme.get('stop')) if stop >= current_datetime: title = programme.find('title').text desc_node = programme.find('desc') try: - desc = unicode(programme.find('desc').text) + desc = unicode(programme.find('desc').text, errors = 'replace') except: desc = None count = count + 1 diff --git a/Contents/Strings/en.json b/Contents/Strings/en.json index b876006..e0e126c 100644 --- a/Contents/Strings/en.json +++ b/Contents/Strings/en.json @@ -15,7 +15,6 @@ "Reload program guide": "Reload program guide", "Search": "Search", "Success": "Success", - "Unicode decode error": "Unicode decode error", "View playlist": "View playlist", "Warning": "Warning" } \ No newline at end of file diff --git a/Contents/Strings/fr.json b/Contents/Strings/fr.json index 96dd003..4fd5e90 100644 --- a/Contents/Strings/fr.json +++ b/Contents/Strings/fr.json @@ -15,7 +15,6 @@ "Reload program guide": "Recharger le guide des programmes", "Search": "Rechercher", "Success": "Succès", - "Unicode decode error": "Unicode decode error", "View playlist": "Visualiser la playlist", "Warning": "Attention" } diff --git a/Contents/Strings/ru.json b/Contents/Strings/ru.json index 3fbdc9d..40b8ee1 100644 --- a/Contents/Strings/ru.json +++ b/Contents/Strings/ru.json @@ -15,7 +15,6 @@ "Reload program guide": "Обновить программу передач", "Search": "Поиск", "Success": "Готово", - "Unicode decode error": "Unicode decode error", "View playlist": "Показать плейлист", "Warning": "Внимание" } \ No newline at end of file