Skip to content

Commit

Permalink
[Screenshot] more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
japandotorg committed Sep 25, 2024
1 parent aeb6d99 commit e3e3262
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 14 deletions.
6 changes: 3 additions & 3 deletions screenshot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@

async def setup(bot: Red) -> None:
urllib_logger.setLevel(logging.WARNING)
logging.getLogger("PIL").setLevel(logging.WARNING)
logging.getLogger("h5py").setLevel(logging.WARNING)
logging.getLogger("selenium").setLevel(logging.WARNING)
logging.getLogger("PIL").setLevel(logging.DEBUG)
logging.getLogger("h5py").setLevel(logging.DEBUG)
logging.getLogger("selenium").setLevel(logging.DEBUG)
if platform.system().lower() not in ["windows", "linux"]:
raise CogLoadError("This cog is only available for linux and windows devices right now.")
cog: Screenshot = Screenshot(bot)
Expand Down
8 changes: 1 addition & 7 deletions screenshot/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ def take_screenshot_with_url(
raise commands.UserFeedbackCheckFailure("Timed out opening the website.")
except WebDriverException as error:
if re.search(pattern="about:neterror", string=str(error.msg), flags=re.IGNORECASE):
log.exception("Something went wrong connecting to the internet.", exc_info=error)
raise ProxyConnectFailedError()
raise commands.UserFeedbackCheckFailure(
"Could not get a screenshot of that website, try again later."
Expand Down Expand Up @@ -166,12 +165,7 @@ async def driver(self) -> AsyncGenerator[Firefox, None]:
now: datetime = datetime.now(timezone.utc)
try:
driver: Firefox = await self.launcher()
(
driver.install_addon(os.fspath(location), temporary=True)
if (location := self.cog.manager.get_extension_location("cookies"))
else None
)
driver.set_page_load_timeout(time_to_wait=230.0)
driver.set_page_load_timeout(time_to_wait=30.0)
driver.fullscreen_window()
try:
yield driver
Expand Down
3 changes: 1 addition & 2 deletions screenshot/common/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ class DriverManager:
)
FIREFOX_ADDONS = {
"dark": "https://addons.mozilla.org/firefox/downloads/file/4351387/darkreader-4.9.92.xpi",
"cookies": "https://addons.mozilla.org/firefox/downloads/file/3625855/ninja_cookie-0.2.7.xpi",
}

def __init__(self, session: Optional[aiohttp.ClientSession] = None) -> None:
Expand Down Expand Up @@ -193,7 +192,7 @@ async def wait_until_driver_downloaded(self) -> None:
await self.__event.wait()

async def execute_tor_binary(self) -> Optional[asyncio.subprocess.Process]:
if self.tor_location and self._tor_process is discord.utils.MISSING:
if self.tor_location:
process: asyncio.subprocess.Process = await asyncio.subprocess.create_subprocess_shell(
(
"{0}/tor/tor -f {0}/torrc"
Expand Down
4 changes: 2 additions & 2 deletions screenshot/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ async def screenshot(self, ctx: commands.Context, url: URLConverter, *, flags: s
**Arguments**:
- ``<url> ``: a well formatted url.
- ``<flags>``:
- ``--full`` for a full screenshot of the page.
- ``--mode <mode>`` either ``light`` or ``dark``.
- ``--full`` for a full screenshot of the page.
- ``--mode <mode>`` either ``light`` or ``dark``.
**Examples**:
- ``[p]screenshot https://seina-cogs.readthedocs.io``
Expand Down

0 comments on commit e3e3262

Please sign in to comment.