mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
feat: improve year check
This commit is contained in:
+6
-1
@@ -105,6 +105,10 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
|
||||
name = element["l"]
|
||||
year = element.get("y")
|
||||
|
||||
year_end = None
|
||||
if "yr" in element:
|
||||
year_end = int(element["yr"].split("-")[1])
|
||||
except Exception as e:
|
||||
logger.warning(f"Exception while getting metadata for {id}: {e}")
|
||||
|
||||
@@ -345,6 +349,7 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
aliases = await get_aliases(
|
||||
session, "movies" if type == "movie" else "shows", id
|
||||
)
|
||||
# print(aliases)
|
||||
|
||||
indexed_torrents = [(i, torrents[i]["Title"]) for i in range(len(torrents))]
|
||||
chunk_size = 50
|
||||
@@ -355,7 +360,7 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
|
||||
tasks = []
|
||||
for chunk in chunks:
|
||||
tasks.append(filter(chunk, name, year, aliases))
|
||||
tasks.append(filter(chunk, name, year, year_end, aliases))
|
||||
|
||||
filtered_torrents = await asyncio.gather(*tasks)
|
||||
index_less = 0
|
||||
|
||||
+13
-4
@@ -467,7 +467,7 @@ async def get_mediafusion(log_name: str, type: str, full_id: str):
|
||||
return results
|
||||
|
||||
|
||||
async def filter(torrents: list, name: str, year: int, aliases: dict):
|
||||
async def filter(torrents: list, name: str, year: int, year_end: int, aliases: dict):
|
||||
results = []
|
||||
for torrent in torrents:
|
||||
index = torrent[0]
|
||||
@@ -482,11 +482,20 @@ async def filter(torrents: list, name: str, year: int, aliases: dict):
|
||||
name, parsed.parsed_title, aliases=aliases
|
||||
):
|
||||
results.append((index, False))
|
||||
# print(title, "|", parsed.parsed_title, "| title mismatch")
|
||||
continue
|
||||
|
||||
if year and parsed.year and year != parsed.year:
|
||||
results.append((index, False))
|
||||
continue
|
||||
if year and parsed.year:
|
||||
if year_end is not None:
|
||||
if not (year <= parsed.year <= year_end):
|
||||
# print(title, "|", year, "to", year_end, "!=", parsed.year, "| year mismatch")
|
||||
results.append((index, False))
|
||||
continue
|
||||
else:
|
||||
if year < (parsed.year - 1) or year > (parsed.year + 1):
|
||||
# print(title, "|", year, "!=", parsed.year, "| year mismatch")
|
||||
results.append((index, False))
|
||||
continue
|
||||
|
||||
results.append((index, True))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user