Skip to content

Commit

Permalink
feat: ability to enable/disable title match check (TITLE_MATCH_CHECK …
Browse files Browse the repository at this point in the history
…env var)
  • Loading branch information
g0ldyy committed Jul 24, 2024
1 parent 6e3f284 commit 755c4fb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
1 change: 1 addition & 0 deletions .env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ SCRAPE_TORRENTIO=False # scrape Torrentio
CUSTOM_HEADER_HTML=None # only set it if you know what it is
PROXY_DEBRID_STREAM=False # Proxy Debrid Streams (very useful to use your debrid service on multiple IPs at same time)
PROXY_DEBRID_STREAM_PASSWORD=CHANGE_ME # Secret password to enter on configuration page to prevent people from abusing your debrid stream proxy
TITLE_MATCH_CHECK=True # disable if you only use Jackett / Prowlarr / Torrentio and are sure you're only scraping good titles, for example (not at all recommended with Zilean enabled)
41 changes: 21 additions & 20 deletions comet/api/stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,30 +229,31 @@ async def stream(request: Request, b64config: str, type: str, id: str):
if len(torrents) == 0:
return {"streams": []}

indexed_torrents = [(i, torrents[i]["Title"]) for i in range(len(torrents))]
chunk_size = 50
chunks = [
indexed_torrents[i : i + chunk_size]
for i in range(0, len(indexed_torrents), chunk_size)
]
if settings.TITLE_MATCH_CHECK:
indexed_torrents = [(i, torrents[i]["Title"]) for i in range(len(torrents))]
chunk_size = 50
chunks = [
indexed_torrents[i : i + chunk_size]
for i in range(0, len(indexed_torrents), chunk_size)
]

tasks = []
for chunk in chunks:
tasks.append(filter(chunk, name))
tasks = []
for chunk in chunks:
tasks.append(filter(chunk, name))

filtered_torrents = await asyncio.gather(*tasks)
index_less = 0
for result in filtered_torrents:
for filtered in result:
if not filtered[1]:
del torrents[filtered[0] - index_less]
index_less += 1
continue
filtered_torrents = await asyncio.gather(*tasks)
index_less = 0
for result in filtered_torrents:
for filtered in result:
if not filtered[1]:
del torrents[filtered[0] - index_less]
index_less += 1
continue

logger.info(f"{len(torrents)} torrents passed title match check for {log_name}")
logger.info(f"{len(torrents)} torrents passed title match check for {log_name}")

if len(torrents) == 0:
return {"streams": []}
if len(torrents) == 0:
return {"streams": []}

tasks = []
for i in range(len(torrents)):
Expand Down
1 change: 1 addition & 0 deletions comet/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class AppSettings(BaseSettings):
CUSTOM_HEADER_HTML: Optional[str] = None
PROXY_DEBRID_STREAM: Optional[bool] = False
PROXY_DEBRID_STREAM_PASSWORD: Optional[str] = "CHANGE_ME"
TITLE_MATCH_CHECK: Optional[bool] = True


settings = AppSettings()
Expand Down

0 comments on commit 755c4fb

Please sign in to comment.