Skip to content

Commit 5f046d1

Browse files
committed
feat: uses search by file with full file name for better accuracy
1 parent d83aba0 commit 5f046d1

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

functions/torboxFunctions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ def getUserDownloads(type: DownloadType):
6060
"extension": os.path.splitext(file.get("short_name"))[-1],
6161
}
6262
title_data = PTN.parse(file.get("short_name"))
63-
metadata, _, _ = searchMetadata(title_data.get("title"), title_data, file.get("short_name"))
63+
metadata, _, _ = searchMetadata(title_data.get("title"), title_data, file.get("short_name"), f"{item.get('name')} {file.get('short_name')}")
6464
data.update(metadata)
6565
files.append(data)
6666
logging.debug(data)
6767
insertData(data, type.value)
6868

6969
return files, True, f"{type.value.capitalize()} fetched successfully."
7070

71-
def searchMetadata(query: str, title_data: dict, file_name: str):
71+
def searchMetadata(query: str, title_data: dict, file_name: str, full_title: str):
7272
base_metadata = {
7373
"metadata_title": cleanTitle(query),
7474
"metadata_link": None,
@@ -82,7 +82,7 @@ def searchMetadata(query: str, title_data: dict, file_name: str):
8282
"metadata_rootfoldername": title_data.get("title", None),
8383
}
8484
extension = os.path.splitext(file_name)[-1]
85-
response = search_api_http_client.get(f"/meta/search/{query}")
85+
response = search_api_http_client.get(f"/meta/search/{full_title}", params={"type": "file"})
8686
if response.status_code != 200:
8787
return base_metadata, False, f"Error searching metadata. {response.status_code}"
8888
try:

0 commit comments

Comments
 (0)