Skip to content

Commit 1c3ab13

Browse files
committed
Fix py2compat
1 parent ec8cd87 commit 1c3ab13

1 file changed

Lines changed: 18 additions & 14 deletions

File tree

resources/lib/plugin.py

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ def show_genres():
207207
items = []
208208
for genre in genres:
209209
items.append({
210-
'label': genre["systemEnglish"],
210+
'label': __encode(genre["systemEnglish"]),
211211
'icon': plugin.icon,
212212
'fanart': __get_plugin_fanart(),
213213
'path': plugin.url_for(
214214
'show_popular_and_az',
215215
category='genres',
216-
value=genre["systemEnglish"]
216+
value=__encode(genre["systemEnglish"])
217217
),
218218
})
219219
return plugin.finish(items)
@@ -224,13 +224,13 @@ def show_topics():
224224
items = []
225225
for topic in topics:
226226
items.append({
227-
'label': topic["systemEnglish"],
227+
'label': __encode(topic["systemEnglish"]),
228228
'icon': plugin.icon,
229229
'fanart': __get_plugin_fanart(),
230230
'path': plugin.url_for(
231231
'show_popular_and_az',
232232
category='topics',
233-
value=topic["systemEnglish"]
233+
value=__encode(topic["systemEnglish"])
234234
),
235235
})
236236
return plugin.finish(items)
@@ -241,13 +241,13 @@ def show_countries():
241241
items = []
242242
for country in countries:
243243
items.append({
244-
'label': country["systemEnglish"],
244+
'label': __encode(country["systemEnglish"]),
245245
'icon': plugin.icon,
246246
'fanart': __get_plugin_fanart(),
247247
'path': plugin.url_for(
248248
'show_popular_and_az',
249249
category='countries',
250-
value=country["systemEnglish"]
250+
value=__encode(country["systemEnglish"])
251251
),
252252
})
253253
return plugin.finish(items)
@@ -258,13 +258,13 @@ def show_languages():
258258
items = []
259259
for lang in languages:
260260
items.append({
261-
'label': lang["systemEnglish"],
261+
'label': __encode(lang["systemEnglish"]),
262262
'icon': plugin.icon,
263263
'fanart': __get_plugin_fanart(),
264264
'path': plugin.url_for(
265265
'show_popular_and_az',
266266
category='languages',
267-
value=lang["systemEnglish"]
267+
value=__encode(lang["systemEnglish"])
268268
),
269269
})
270270
return plugin.finish(items)
@@ -292,25 +292,25 @@ def show_cities_list(option):
292292
countries = radio_api.get_countries()
293293
for country in countries:
294294
items.append({
295-
'label': country["systemEnglish"],
295+
'label': __encode(country["systemEnglish"]),
296296
'icon': plugin.icon,
297297
'fanart': __get_plugin_fanart(),
298298
'path': plugin.url_for(
299299
'show_cities_by_country',
300-
country = country["systemEnglish"],
300+
country = __encode(country["systemEnglish"]),
301301
),
302302
})
303303
else:
304304
cities = radio_api.get_cities()
305305
for city in cities:
306306
items.append({
307-
'label': city["systemEnglish"],
307+
'label': __encode(city["systemEnglish"]),
308308
'icon': plugin.icon,
309309
'fanart': __get_plugin_fanart(),
310310
'path': plugin.url_for(
311311
'show_popular_and_az',
312312
category = 'cities',
313-
value = city["systemEnglish"],
313+
value = __encode(city["systemEnglish"]),
314314
),
315315
})
316316
return plugin.finish(items)
@@ -321,13 +321,13 @@ def show_cities_by_country(country):
321321
cities = radio_api.get_cities(country=country)
322322
for city in cities:
323323
items.append({
324-
'label': city["systemEnglish"],
324+
'label': __encode(city["systemEnglish"]),
325325
'icon': plugin.icon,
326326
'fanart': __get_plugin_fanart(),
327327
'path': plugin.url_for(
328328
'show_popular_and_az',
329329
category = 'cities',
330-
value = city["systemEnglish"],
330+
value = __encode(city["systemEnglish"]),
331331
)
332332
})
333333
return plugin.finish(items)
@@ -546,6 +546,10 @@ def __log(text):
546546
def __get_plugin_fanart():
547547
return plugin.fanart if not plugin.get_setting('hide-fanart', bool) else ''
548548

549+
def __encode(string):
550+
if PY3:
551+
return string
552+
return string.encode('utf-8')
549553

550554
def _(string_id):
551555
if string_id in STRINGS:

0 commit comments

Comments
 (0)