From 91b9a70eb5c85338681bbdc5c168b3bc23388f8f Mon Sep 17 00:00:00 2001 From: Tzachi Strul Date: Fri, 20 Nov 2020 23:00:10 +0200 Subject: [PATCH 1/2] Fix support for RTL This is a workaround, looks lie RTL is passed mirrored in this code: https://github.com/vlmaksime/plugin.video.united.search/blob/master/plugin.video.united.search/resources/lib/unitedsearch.py#L327-L331 clouldnt find a way to fix it so I created a function to reverse RTL input (hebrew, arabic etc) in advance --- .../resources/lib/unitedsearch.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/plugin.video.united.search/resources/lib/unitedsearch.py b/plugin.video.united.search/resources/lib/unitedsearch.py index 41aef57..cd3dcc1 100644 --- a/plugin.video.united.search/resources/lib/unitedsearch.py +++ b/plugin.video.united.search/resources/lib/unitedsearch.py @@ -21,7 +21,15 @@ def _get_directory_threaded( us, directory ): us.result = [] for item in us.get_directory(directory): us.result.append(item) - + +def is_rtl(string): + if any([(ord(char) >= 1424 and ord(char) <= 1514) for char in string]) or \ + any([(ord(char) >= 64285 and ord(char) <= 64335) for char in string]) or \ + any([(ord(char) >= 64336 and ord(char) <= 65023) for char in string]) or \ + any([(ord(char) >= 1536 and ord(char) <= 1791) for char in string]) or \ + any([(ord(char) >= 65136 and ord(char) <= 65279) for char in string]): + return True + class UnitedSearch(object): def __init__( self ): self.__load_supported_addons() @@ -37,7 +45,11 @@ def search( self, params ): kbd.setHeading(_('Search')) kbd.doModal() if kbd.isConfirmed(): - keyword = kbd.getText() + text = kbd.getText() + if is_rtl(text.decode('utf-8')): + keyword = text.decode('utf-8')[::-1] + else: + keyword = text if keyword: succeeded = True From 8f2b26c3bad179be0a73c35b0abe3766d7babcaa Mon Sep 17 00:00:00 2001 From: Tzachi Strul Date: Sat, 21 Nov 2020 02:35:27 +0200 Subject: [PATCH 2/2] Update unitedsearch.py --- plugin.video.united.search/resources/lib/unitedsearch.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugin.video.united.search/resources/lib/unitedsearch.py b/plugin.video.united.search/resources/lib/unitedsearch.py index cd3dcc1..ceda4ea 100644 --- a/plugin.video.united.search/resources/lib/unitedsearch.py +++ b/plugin.video.united.search/resources/lib/unitedsearch.py @@ -45,11 +45,7 @@ def search( self, params ): kbd.setHeading(_('Search')) kbd.doModal() if kbd.isConfirmed(): - text = kbd.getText() - if is_rtl(text.decode('utf-8')): - keyword = text.decode('utf-8')[::-1] - else: - keyword = text + keyword = kbd.getText() if keyword: succeeded = True @@ -125,6 +121,8 @@ def get_directory( self, directory ): yield file def __get_learned_directory( self, directory, keyword ): + if is_rtl(keyword.decode('utf-8')): + keyword = keyword.decode('utf-8')[::-1] t = threading.Thread(target=_get_directory_threaded, args = (self, directory)) t.start()