Jump to content

Suggestions for searching media libraries in other lang


opvecn

Recommended Posts

对于使用英文搜索媒体库,已经能够很好的返回搜索结果
For searching media libraries in English, it is already possible to return search results very well

 


但是使用其他语言搜索还是很糟糕
But searching in other languages is still terrible


如果想要好的改进,对于开发人员而言可能需要了解多门语言
If you want good improvements, developers may need to understand multiple languages


所以 我有一个好的建议如下:
So I have a good suggestion as follows:


1. 本地进行一次搜索获取结果后
1. After conducting a local search to obtain results


2. 再进行一次网络API搜索(api.themoviedb.org)
2. Conduct another web API search (api.themoviedb. org)


3. 获取TMBD API返回结果中的imdbid或者tmdbid
3. Obtain the imdbid or tmdbid in the TMBD API return result


4. 利用获取的ID再进行一次本地搜索
4. Perform another local search using the obtained ID


5. 将两次结果对比, 去掉重复结果返回
5. Compare the two results, remove duplicate results, and return


通过上述办法,可以有效解决其他语言搜索匹配的能力
By using the above methods, the ability to search for matches in other languages can be effectively addressed

 

Link to comment
Share on other sites

2 hours ago, Luke said:

Hi there, can you please provide a specific example of a problem? Thanks.

我并不熟悉C#,只能用python给你一个简单的示例
I am not familiar with C #, so I can only use Python to give you a simple example

 

#!/usr/bin/python3

import sqlite3  # Import the sqlite3 library to work with SQLite databases.
import requests  # Import the requests library for making HTTP requests.
import json  # Import the json library to work with JSON data.

# Connect to the SQLite database named "library.db".
connection = sqlite3.connect("library.db")

# Create a cursor object to interact with the database.
cursor = connection.cursor()

# Define the URL for the Movie Database (TMDb) API to search for media content with the query "砂糖" in Chinese (Simplified).
url = "https://api.themoviedb.org/3/search/multi?query=砂糖&include_adult=false&language=zh-CN&page=1"

# Define HTTP headers, including an authorization token for TMDb API.
headers = {
    "accept": "application/json",
    "Authorization": "xxxxxxxxxxxxxxxxxx",
}

# Send an HTTP GET request to the TMDb API and store the response in the 'response' variable.
response = requests.get(url, headers=headers)

# Parse the JSON response from the API and extract the "results" field.
result = json.loads(response.text)["results"]

# Loop through the retrieved results.
for item in result:
    # Execute an SQL query to select the "Name" from the "MediaItems" table where "ProviderIds" contain the TMDb ID.
    cursor.execute(
        "SELECT Name FROM MediaItems WHERE ProviderIds LIKE '%%Tmdb=%d%%';" % item["id"]
    )

    # Fetch the first result of the SQL query.
    results = cursor.fetchone()

    # Print the TMDb ID, name, and results from the database.
    print(item["id"], item.get("name", "None"), results)

# Close the cursor and database connection.
cursor.close()
connection.close()

执行结果:
results of execution:

TmdbId      TmdbName      Local Database Results

135335 银砂糖师与黑色妖精 None
127775 白砂糖战士 None
762698 None None
1007930 None None
389089 None None
80826 幸福甜蜜生活 ('幸福甜蜜生活',)
125042 Nyan~ Neko Sugar Girls None
305091 None None
379171 None None
102851 None None
Link to comment
Share on other sites

Hi.  Can  you please provide a specific example of the actual problem as opposed to your suggested solution?

Thanks.

Link to comment
Share on other sites

11 hours ago, ebr said:

Hi.  Can  you please provide a specific example of the actual problem as opposed to your suggested solution?

Thanks.

比如《Hello World》,搜索"hello"或者"world"都能查到,但是如果是中文《你好,世界》,只有搜索''你好"才能返回查到,搜索"世界"却不行
For example, 《Hello World》 can be found by searching for "hello" or "world", but if it is Chinese "《你好,世界》", only by searching for "你好(hello)" can one return to the search, but not by searching for "世界(world)"

The specific example is like this

The cause may be as described by this person:

Link to comment
Share on other sites

在 10/9/2023 在 9:13 PM 上,ebr 说:

Hi.  Can  you please provide a specific example of the actual problem as opposed to your suggested solution?

Thanks.

  

 QQ20231011101810.thumb.gif.8b225dd9aa153cd8a8c8fce4b8f06b5b.gif

 

 

 

  • Thanks 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...