mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
feat: title match check aliases system
This commit is contained in:
+4
-5
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user