feat: title match check aliases system

This commit is contained in:
Goldy
2024-11-19 15:42:28 +01:00
parent 720723788b
commit 36323ac028
2 changed files with 17 additions and 12 deletions
+4 -5
View File
@@ -342,10 +342,9 @@ async def stream(request: Request, b64config: str, type: str, id: str):
return {"streams": []}
if settings.TITLE_MATCH_CHECK:
# aliases = await get_aliases(
# session, "movies" if type == "movie" else "series", id
# )
# print(aliases)
aliases = await get_aliases(
session, "movies" if type == "movie" else "shows", id
)
indexed_torrents = [(i, torrents[i]["Title"]) for i in range(len(torrents))]
chunk_size = 50
@@ -356,7 +355,7 @@ async def stream(request: Request, b64config: str, type: str, id: str):
tasks = []
for chunk in chunks:
tasks.append(filter(chunk, name, year, {}))
tasks.append(filter(chunk, name, year, aliases))
filtered_torrents = await asyncio.gather(*tasks)
index_less = 0
+13 -7
View File
@@ -673,11 +673,17 @@ def get_client_ip(request: Request):
async def get_aliases(session: aiohttp.ClientSession, media_type: str, media_id: str):
response = await session.get(
f"https://api.trakt.tv/{media_type}/{media_id}/aliases"
)
aliases = {}
try:
response = await session.get(f"https://api.trakt.tv/{media_type}/{media_id}/aliases")
for aliase in await response.json():
country = aliase["country"]
if not country in aliases:
aliases[country] = []
aliases[country].append(aliase["title"])
except:
pass
if not response.ok:
return set()
return {item["title"] for item in response.json()}
return aliases