Skip to content

Commit

Permalink
Cookie Extraction Prompt menu (#277)
Browse files Browse the repository at this point in the history
* add prompts for cookie extraction

* add prompts for cookie extraction

* change browser to browsers

* change browser to browsers

* change browser prompts to checkbox

* fix repeat word

* fix prompt

* ran  ruff

* fixes for prompt

* remove default other checkboxes don't have it, and it complicates things

* change global settings from field default

* remove re

---------

Co-authored-by: datawhores <[email protected]>
  • Loading branch information
datawhores and datawhores authored Nov 14, 2024
1 parent dbac16c commit cf2f5af
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 15 deletions.
3 changes: 1 addition & 2 deletions cyberdrop_dl/managers/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@ def _verify_global_settings_config(self) -> None:
"""Verifies the global settings config file and creates it if it doesn't exist."""
default_global_settings_data = copy.deepcopy(global_settings)
existing_global_settings_data = _load_yaml(self.global_settings)
self.global_settings_data = _match_config_dicts(default_global_settings_data, existing_global_settings_data)

if get_keys(default_global_settings_data) == get_keys(existing_global_settings_data):
self.global_settings_data = existing_global_settings_data
Expand All @@ -200,8 +201,6 @@ def _verify_global_settings_config(self) -> None:
for subkey, subvalue in value.items():
self.global_settings_data[key][subkey] = self.return_verified(subvalue)

self.global_settings_data = _match_config_dicts(default_global_settings_data, existing_global_settings_data)

_save_yaml(self.global_settings, self.global_settings_data)

"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""
Expand Down
113 changes: 111 additions & 2 deletions cyberdrop_dl/ui/prompts/settings_user_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def edit_config_values_prompt(manager: Manager) -> None:
Choice(5, "Edit Ignore Options"),
Choice(6, "Edit Runtime Options"),
Choice(7, "Edit Sorting Options"),
Choice(8, "Done"),
Choice(8, "Edit Cookie Extraction Options"),
Choice(9, "Done"),
],
long_instruction="ARROW KEYS: Navigate | ENTER: Select",
vi_mode=manager.vi_mode,
Expand Down Expand Up @@ -84,8 +85,12 @@ def edit_config_values_prompt(manager: Manager) -> None:
elif action == 7:
edit_sort_options_prompt(manager, config)

# Done
# Edit Cookie extraction Options
elif action == 8:
edit_cookies_options_prompt(manager, config)

# Done
elif action == 9:
manager.config_manager.settings_data = config
manager.config_manager.write_updated_settings_config()
return
Expand Down Expand Up @@ -489,3 +494,107 @@ def edit_sort_options_prompt(manager: Manager, config: dict) -> None:
config["Sorting"]["sorted_video"] = sorted_video
config["Sorting"]["sorted_image"] = sorted_image
config["Sorting"]["sorted_other"] = sorted_other


def edit_cookies_options_prompt(manager: Manager, config: dict) -> None:
"""Edit the file size limits."""
console.clear()
console.print("Editing Automatic Cookie Extraction Settings")
auto_import = inquirer.select(
message="Toggles auto cookie extraction",
default=config["Browser_Cookies"]["auto_import"],
vi_mode=manager.vi_mode,
choices=[
Choice(
value=False,
name="Disable auto cookie extraction",
),
Choice(
value=True,
name="Enable auto cookie extraction",
),
],
).execute()
browser_select = inquirer.checkbox(
message="Select the browser(s) for cookie extraction",
vi_mode=manager.vi_mode,
choices=[
Choice(value="chrome", name="Chrome"),
Choice(value="firefox", name="Firefox"),
Choice(value="edge", name="Edge"),
Choice(value="safari", name="Safari"),
Choice(value="opera", name="Opera"),
Choice(value="brave", name="Brave"),
Choice(value="librewolf", name="LibreWolf"),
Choice(value="opera_gx", name="Opera GX"),
Choice(value="vivaldi", name="Vivaldi"),
Choice(value="chromium", name="Chromium"),
],
long_instruction="ARROW KEYS: Navigate | TAB: Select | ENTER: Confirm",
).execute()
sites_select = inquirer.checkbox(
message="Select the site for cookie extraction",
vi_mode=manager.vi_mode,
choices=[
Choice(value="bunkr", name="bunkr"),
Choice(value="bunkrr", name="bunkrr"),
Choice(value="celebforum", name="celebforum"),
Choice(value="coomer", name="coomer"),
Choice(value="cyberdrop", name="cyberdrop"),
Choice(value="cyberfile", name="cyberfile"),
Choice(value="e-hentai", name="e-hentai"),
Choice(value="erome", name="erome"),
Choice(value="f95zone", name="f95zone"),
Choice(value="fapello", name="fapello"),
Choice(value="gofile", name="gofile"),
Choice(value="host.church", name="host.church"),
Choice(value="hotpic", name="hotpic"),
Choice(value="ibb.co", name="ibb.co"),
Choice(value="imageban", name="imageban"),
Choice(value="imagepond.net", name="imagepond.net"),
Choice(value="img.kiwi", name="img.kiwi"),
Choice(value="imgbox", name="imgbox"),
Choice(value="imgur", name="imgur"),
Choice(value="jpeg.pet", name="jpeg.pet"),
Choice(value="jpg.church", name="jpg.church"),
Choice(value="jpg.fish", name="jpg.fish"),
Choice(value="jpg.fishing", name="jpg.fishing"),
Choice(value="jpg.homes", name="jpg.homes"),
Choice(value="jpg.pet", name="jpg.pet"),
Choice(value="jpg1.su", name="jpg1.su"),
Choice(value="jpg2.su", name="jpg2.su"),
Choice(value="jpg3.su", name="jpg3.su"),
Choice(value="jpg4.su", name="jpg4.su"),
Choice(value="jpg5.su", name="jpg5.su"),
Choice(value="kemono", name="kemono"),
Choice(value="leakedmodels", name="leakedmodels"),
Choice(value="mediafire", name="mediafire"),
Choice(value="nudostar.com", name="nudostar.com"),
Choice(value="nudostar.tv", name="nudostar.tv"),
Choice(value="omegascans", name="omegascans"),
Choice(value="pimpandhost", name="pimpandhost"),
Choice(value="pixeldrain", name="pixeldrain"),
Choice(value="postimg", name="postimg"),
Choice(value="realbooru", name="realbooru"),
Choice(value="real-debrid", name="real-debrid"),
Choice(value="redd.it", name="redd.it"),
Choice(value="reddit", name="reddit"),
Choice(value="redgifs", name="redgifs"),
Choice(value="rule34.xxx", name="rule34.xxx"),
Choice(value="rule34.xyz", name="rule34.xyz"),
Choice(value="rule34vault", name="rule34vault"),
Choice(value="saint", name="saint"),
Choice(value="scrolller", name="scrolller"),
Choice(value="socialmediagirls", name="socialmediagirls"),
Choice(value="toonily", name="toonily"),
Choice(value="tokyomotion.net", name="tokyomotion.net"),
Choice(value="xbunker", name="xbunker"),
Choice(value="xbunkr", name="xbunkr"),
Choice(value="xxxbunker", name="xxxbunker"),
],
long_instruction="ARROW KEYS: Navigate | TAB: Select | ENTER: Confirm",
).execute()

config["Browser_Cookies"]["auto_import"] = auto_import
config["Browser_Cookies"]["browsers"] = browser_select
config["Browser_Cookies"]["sites"] = sites_select
15 changes: 7 additions & 8 deletions cyberdrop_dl/utils/args/browser_cookie_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,13 @@ def wrapper(*args, **kwargs) -> CookieJar:
def get_cookies_from_browser(manager: Manager, browsers: str = None) -> None:
"""Get the cookies for the supported sites"""
manager.path_manager.cookies_dir.mkdir(exist_ok=True)
browsers = browsers or manager.config_manager.settings_data["Browser_Cookies"]["browser"]
if isinstance(browsers, str):
browsers = re.split(r"[ ,]+", browsers)
all_sites = set(SupportedDomains.supported_hosts)
user_sites = manager.config_manager.settings_data["Browser_Cookies"]["sites"] or SupportedDomains.supported_hosts
if isinstance(user_sites, str):
user_sites = re.split(r"[ ,]+", user_sites)

browsers = browsers or manager.config_manager.settings_data["Browser_Cookies"]["browsers"]
if isinstance(browsers,str):
browsers=re.split(r'[ ,]+', browsers)
all_sites=set(SupportedDomains.supported_forums)
user_sites= manager.config_manager.settings_data["Browser_Cookies"]["sites"] or SupportedDomains.supported_hosts
if isinstance(user_sites,str):
user_sites=re.split(r'[ ,]+', user_sites)
for domain in user_sites:
domain = domain.lower() if domain else None
if domain not in all_sites:
Expand Down
2 changes: 1 addition & 1 deletion cyberdrop_dl/utils/args/config_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
"sorted_video": "{sort_dir}/{base_dir}/Videos/{filename}{ext}",
},
"Browser_Cookies": {
"browser": "Chrome",
"browsers": "Chrome",
"auto_import": False,
"sites": None,
},
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/configuration-options/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,9 @@ toggles automatic import of cookies at the start of each run

***

* **browser**
* **browsers**

The browser to extract cookies from
The browser(s) to extract cookies from

<div style="border: 1px solid #ccc; padding: 10px; border-radius: 5px; background-color: #f9f9f9;"> <strong>Hint:</strong> If the value entered is null then no browser will be extracted from </div>

Expand Down

0 comments on commit cf2f5af

Please sign in to comment.