Skip to content

Commit

Permalink
Merge pull request #2 from tstrul1/patch-1
Browse files Browse the repository at this point in the history
Fix support for RTL
  • Loading branch information
vlmaksime authored Nov 21, 2020
2 parents 8183f1b + 8f2b26c commit 69f2508
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion plugin.video.united.search/resources/lib/unitedsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -113,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()

Expand Down

0 comments on commit 69f2508

Please sign in to comment.