From f5afeff6af73098bb11d08988f368d057764bb4c Mon Sep 17 00:00:00 2001 From: Goldy <153996346+g0ldyy@users.noreply.github.com> Date: Tue, 19 Nov 2024 23:36:11 +0100 Subject: [PATCH] fix: adult content filter --- comet/api/stream.py | 3 ++- comet/utils/general.py | 6 +++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/comet/api/stream.py b/comet/api/stream.py index a81d464..e269568 100644 --- a/comet/api/stream.py +++ b/comet/api/stream.py @@ -356,9 +356,10 @@ async def stream(request: Request, b64config: str, type: str, id: str): for i in range(0, len(indexed_torrents), chunk_size) ] + remove_adult_content = settings.REMOVE_ADULT_CONTENT and config["removeTrash"] tasks = [] for chunk in chunks: - tasks.append(filter(chunk, name, year, year_end, aliases)) + tasks.append(filter(chunk, name, year, year_end, aliases, remove_adult_content)) filtered_torrents = await asyncio.gather(*tasks) index_less = 0 diff --git a/comet/utils/general.py b/comet/utils/general.py index df9828b..52a673b 100644 --- a/comet/utils/general.py +++ b/comet/utils/general.py @@ -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, year_end: int, aliases: dict): +async def filter(torrents: list, name: str, year: int, year_end: int, aliases: dict, remove_adult_content: bool): results = [] for torrent in torrents: index = torrent[0] @@ -478,6 +478,10 @@ async def filter(torrents: list, name: str, year: int, year_end: int, aliases: d parsed = parse(title) + if remove_adult_content and parsed.adult: + results.append((index, False)) + continue + if parsed.parsed_title and not title_match( name, parsed.parsed_title, aliases=aliases ):