bromix/plugin.video.bromix.youtube — pull request #78 by olexiyt (2014-12-13 19:25:28+00:00)
Title: Allow to perfrom search of words entered with Cyrillic letters(probably ...

...will work with other national alphabets too).

Checked with Kodi 2:14.0~git20141208.0500-c489922-0trusty/plugin.video.bromix.youtube.alpha28

The Cyrillic string passed to plugin as str containing utf-8 and stored in search history as unicode utf-8. Added branching to process str/unicode differently and avoid exception on ascii conversion of str containing utf-8.

Disclaimer: i have almost 0 expertise in python programming and xbmc/xbmc addons code and realize
that proposed fix might be an example of cargo cult coding

Original exceptions after entering Cyrillic string and fixing exceptions places one by one.
1.

0:02:09 T:140396373964544 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type:
Error Contents: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
Traceback (most recent call last):
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/default.py", line 7, in
runner.run(__provider__)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/runner.py", line 16, in run
__RUNNER__.run(provider, context)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/impl/xbmc/xbmc_runner.py", line 21, in run
results = provider.navigate(context)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/abstract_provider.py", line 59, in navigate
result = method(context, re_match)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/abstract_provider.py", line 215, in _internal_search
search_history.update(text)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/utils/search_history.py", line 42, in update
self._set(self._make_id(search_text), search_text)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/utils/search_history.py", line 34, in _make_id
m.update(search_text.encode('utf-8'))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
-->End of Python script error report<--
2.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

01:03:59 T:140397192378112 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type:
Error Contents: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
Traceback (most recent call last):
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/default.py", line 7, in
runner.run(__provider__)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/runner.py", line 16, in run
__RUNNER__.run(provider, context)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/impl/xbmc/xbmc_runner.py", line 21, in run
results = provider.navigate(context)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/abstract_provider.py", line 59, in navigate
result = method(context, re_match)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/abstract_provider.py", line 222, in _internal_search
new_context = context.clone(new_path=new_path, new_params=new_params)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/impl/xbmc/xbmc_context.py", line 130, in clone
plugin_id=self._plugin_id, override=False)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/impl/xbmc/xbmc_context.py", line 18, in __init__
AbstractContext.__init__(self, path, params, plugin_name, plugin_id)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/impl/abstract_context.py", line 30, in __init__
self._uri = self.create_uri(self._path, self._params)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/impl/abstract_context.py", line 102, in create_uri
uri_params[param] = unicode(params[param]).encode('utf-8')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
-->End of Python script error report<--
3.<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

01:13:44 T:140396424320768 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type:
Error Contents: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
Traceback (most recent call last):
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/default.py", line 7, in
runner.run(__provider__)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/runner.py", line 16, in run
__RUNNER__.run(provider, context)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/impl/xbmc/xbmc_runner.py", line 21, in run
results = provider.navigate(context)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/abstract_provider.py", line 59, in navigate
result = method(context, re_match)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/abstract_provider.py", line 249, in _internal_search
search_history_item = items.create_search_history_item(context, search)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/items/utils.py", line 15, in create_search_history_item
image=context.create_resource_path('media/search.png'))
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/items/directory_item.py", line 6, in __init__
BaseItem.__init__(self, name, uri, image, fanart)
File "/home/xbmc/.kodi/addons/plugin.video.bromix.youtube/resources/lib/kodion/items/base_item.py", line 11, in __init__
self._name = unicode(name)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)
-->End of Python script error report<--