Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
add error wrapper for cookie extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
Jules-WinnfieldX committed Dec 6, 2023
1 parent b8e018a commit 7aa78c8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cyberdrop_dl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "5.0.47"
__version__ = "5.0.48"
22 changes: 22 additions & 0 deletions cyberdrop_dl/utils/args/browser_cookie_extraction.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from __future__ import annotations

from functools import wraps
from typing import TYPE_CHECKING

import browser_cookie3
from InquirerPy import inquirer
from rich.console import Console

from cyberdrop_dl.utils.dataclasses.supported_domains import SupportedDomains

Expand All @@ -12,7 +15,25 @@
from cyberdrop_dl.managers.manager import Manager


def cookie_wrapper(func):
"""Wrapper handles errors for url scraping"""
@wraps(func)
def wrapper(self, *args, **kwargs):
try:
return func(self, *args, **kwargs)
except PermissionError:
console = Console()
console.clear()
console.print(f"We've encountered a Permissions Error. Please close all browsers and try again.", style="bold red")
console.print("If you are still having issues, make sure all browsers processes are closed in a Task Manager.", style="bold red")
console.print("Nothing has been saved.", style="bold red")
inquirer.confirm(message="Press enter to return menu.").execute()
return
return wrapper


# noinspection PyProtectedMember
@cookie_wrapper
def get_forum_cookies(manager: Manager, browser: str) -> None:
"""Get the cookies for the forums"""
auth_args: Dict = manager.config_manager.authentication_data
Expand All @@ -31,6 +52,7 @@ def get_forum_cookies(manager: Manager, browser: str) -> None:


# noinspection PyProtectedMember
@cookie_wrapper
def get_ddos_guard_cookies(manager: Manager, browser: str) -> None:
"""Get the cookies for DDOS-Guard"""
auth_args: Dict = manager.config_manager.authentication_data
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyberdrop-dl"
version = "5.0.47"
version = "5.0.48"
description = "Bulk downloader for multiple file hosts"
authors = ["Jules Winnfield <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 7aa78c8

Please sign in to comment.