Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
How to add Vietnamese Keyboard Layout
#16
(2023-04-08, 19:51)usphil Wrote: I wonder if you can put my first post back in Global Search. Because even though I have created a Vietnamese keyboard, I still want to search without accents.

I took a look at this and I don't see an easy way to do it.  Currently the search is done with database query via JSON-RPC.  I didn't see a way to search without diacriticals except by dumping the database and searching in the addon.  That seems to me to be a big performance problem.

scott s.
.
Reply
#17
There is indeed a performance issue. I added a piece of code that uses the unidecode to filter the returned results. It works OK but it takes about 20-30 seconds.
Can you change the search method according to the SQL query? I have tried directly querying the MyVideos121.db file and the results are returned almost instantly.

import unidecode
import sqlite3

def search_titles(query, titles):
    query = unidecode.unidecode(query).lower()
    matching_titles = [title for title in titles if query in unidecode.unidecode(title).lower()]
    return matching_titles

def get_all_titles(cursor, table_name):
    cursor.execute(f"SELECT c00 FROM {table_name}")
    titles = [row[0] for row in cursor.fetchall()]
    return titles

DB_FILE = r"C:\Users\usphil\AppData\Roaming\Kodi\userdata\Database\MyVideos121.db"

conn = sqlite3.connect(DB_FILE)
cursor = conn.cursor()

movie_titles = get_all_titles(cursor, 'movie')
tvshow_titles = get_all_titles(cursor, 'tvshow')

query = "Em La dinh menh" # Em Là Định Mệnh
matching_movie_titles = search_titles(query, movie_titles)
matching_tvshow_titles = search_titles(query, tvshow_titles)

if matching_movie_titles or matching_tvshow_titles:
    if matching_movie_titles:
        print("Matching movies:")
        for title in matching_movie_titles:
            print(f"- {title}")

    if matching_tvshow_titles:
        print("Matching TV shows:")
        for title in matching_tvshow_titles:
            print(f"- {title}")
else:
    print("No matching titles found.")
Reply

Logout Mark Read Team Forum Stats Members Help
How to add Vietnamese Keyboard Layout0