Skip to content

Commit

Permalink
Limited search speed without FlareSolverr
Browse files Browse the repository at this point in the history
If FlareSolverr is not added, reduce search speed of GetComics, as it triggered the CF block to easily for new users.
  • Loading branch information
Casvt committed Jan 14, 2025
1 parent 11ebbb8 commit 89794b3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
8 changes: 8 additions & 0 deletions backend/implementations/flaresolverr.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ def disable_flaresolverr(self) -> None:
self.session_id = None
return

def is_enabled(self) -> bool:
"""Check if FlareSolverr is enabled.
Returns:
bool: Whether FlareSolverr is enabled.
"""
return bool(self.session_id and self.base_url)

def get_ua_cookies(self, url: str) -> Tuple[str, Dict[str, str]]:
"""Get the user agent and cookies for a certain URL. The UA and cookies
can be cleared by CF, so use them to avoid challenges. In case the URL
Expand Down
13 changes: 12 additions & 1 deletion backend/implementations/getcomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
TorrentDownload,
WeTransferDownload)
from backend.implementations.external_clients import ExternalClients
from backend.implementations.flaresolverr import FlareSolverr
from backend.implementations.matching import gc_group_filter
from backend.implementations.naming import generate_issue_name
from backend.implementations.volumes import Volume
Expand Down Expand Up @@ -765,7 +766,17 @@ async def search_getcomics(
)
for page in range(2, max_page + 1)
]
other_htmls = await gather(*other_tasks)

if FlareSolverr().is_enabled():
# FlareSolverr available, run at full speed
other_htmls = await gather(*other_tasks)
else:
# FlareSolverr not available, run at sequencial speed
other_htmls = [
await task
for task in other_tasks
]

other_soups = [
BeautifulSoup(html, "html.parser")
for html in other_htmls
Expand Down

0 comments on commit 89794b3

Please sign in to comment.