Skip to content

Commit

Permalink
fix: adult content filter
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy committed Nov 19, 2024
1 parent 9495f1e commit f5afeff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion comet/api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion comet/utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
):
Expand Down

0 comments on commit f5afeff

Please sign in to comment.