Skip to content

Commit

Permalink
feat: title match check aliases system
Browse files Browse the repository at this point in the history
g0ldyy committed Nov 19, 2024
1 parent 7207237 commit 36323ac
Showing 2 changed files with 17 additions and 12 deletions.
9 changes: 4 additions & 5 deletions comet/api/stream.py
Original file line number Diff line number Diff line change
@@ -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
20 changes: 13 additions & 7 deletions comet/utils/general.py
Original file line number Diff line number Diff line change
@@ -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"
)

if not response.ok:
return set()
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

return {item["title"] for item in response.json()}
return aliases

0 comments on commit 36323ac

Please sign in to comment.