Skip to content

Bulk asynchronous downloader for multiple file hosts

Reformat code

Jacobcfab2aa9b88d
diff --git a/cyberdrop_dl/scraper/scraper.py b/cyberdrop_dl/scraper/scraper.py
index 9285ce6b5..d1c7561c6 100644
--- a/cyberdrop_dl/scraper/scraper.py
+++ b/cyberdrop_dl/scraper/scraper.py
@@ -384,6 +384,7 @@ class ScrapeMapper:
return False
except NoExtensionFailure:
return False
+
async def map_url(self, scrape_item: ScrapeItem,date:arrow.Arrow=None):
if not isinstance(scrape_item.url, URL):
scrape_item.url = URL(scrape_item.url)
@@ -448,6 +449,7 @@ class ScrapeMapper:
else:
await log(f"Unsupported URL: {scrape_item.url}", 30)
await self.manager.log_manager.write_unsupported_urls_log(scrape_item.url)
+
async def filter_items(self, scrape_item) -> None:
"""Maps URLs to their respective handlers"""
if not scrape_item.url:
diff --git a/cyberdrop_dl/ui/progress/downloads_progress.py b/cyberdrop_dl/ui/progress/downloads_progress.py
index 0772b6c87..a830fd94d 100644
--- a/cyberdrop_dl/ui/progress/downloads_progress.py
+++ b/cyberdrop_dl/ui/progress/downloads_progress.py
@@ -1,4 +1,4 @@
-from typing import Tuple, TYPE_CHECKING
+from typing import TYPE_CHECKING
from rich.console import Group
from rich.panel import Panel
@@ -31,7 +31,8 @@ class DownloadsProgress:
async def get_progress(self) -> Panel:
"""Returns the progress bar"""
- return Panel(self.progress_group, title=f"Config: {self.manager.config_manager.loaded_config}", border_style="green", padding=(1, 1))
+ return Panel(self.progress_group, title=f"Config: {self.manager.config_manager.loaded_config}",
+ border_style="green", padding=(1, 1))
async def update_total(self) -> None:
"""Updates the total number of files to be downloaded"""
diff --git a/cyberdrop_dl/ui/progress/file_progress.py b/cyberdrop_dl/ui/progress/file_progress.py
index 4e8fd8101..dd9a90188 100644
--- a/cyberdrop_dl/ui/progress/file_progress.py
+++ b/cyberdrop_dl/ui/progress/file_progress.py
@@ -16,6 +16,7 @@ async def adjust_title(s: str, length: int = 40, placeholder: str = "...") -> st
class FileProgress:
"""Class that manages the download progress of individual files"""
+
def __init__(self, visible_tasks_limit: int, manager: 'Manager'):
self.manager = manager
@@ -38,8 +39,10 @@ class FileProgress:
self.progress_str = "[{color}]{description}"
self.overflow_str = "[{color}]... And {number} Other {type_str}"
self.queue_str = "[{color}]... And {number} {type_str} In Download Queue"
- self.overflow_task_id = self.overflow.add_task(self.overflow_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
- self.queue_task_id = self.queue.add_task(self.queue_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
+ self.overflow_task_id = self.overflow.add_task(
+ self.overflow_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
+ self.queue_task_id = self.queue.add_task(
+ self.queue_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
self.visible_tasks: List[TaskID] = []
self.invisible_tasks: List[TaskID] = []
@@ -72,16 +75,22 @@ class FileProgress:
self.progress.update(task_id, visible=True)
if len(self.invisible_tasks) > 0:
- self.overflow.update(self.overflow_task_id, description=self.overflow_str.format(color=self.color, number=len(self.invisible_tasks), type_str=self.type_str), visible=True)
+ self.overflow.update(self.overflow_task_id, description=self.overflow_str.format(color=self.color,
+ number=len(
+ self.invisible_tasks),
+ type_str=self.type_str),
+ visible=True)
else:
self.overflow.update(self.overflow_task_id, visible=False)
queue_length = await self.get_queue_length()
if queue_length > 0:
- self.queue.update(self.queue_task_id, description=self.queue_str.format(color=self.color, number=queue_length, type_str=self.type_str), visible=True)
+ self.queue.update(self.queue_task_id,
+ description=self.queue_str.format(color=self.color, number=queue_length,
+ type_str=self.type_str), visible=True)
else:
self.queue.update(self.queue_task_id, visible=False)
-
+
if not passed:
await self.manager.progress_manager.scraping_progress.redraw(True)
@@ -92,10 +101,12 @@ class FileProgress:
description = await adjust_title(description)
if len(self.visible_tasks) >= self.tasks_visibility_limit:
- task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=description), total=expected_size, visible=False)
+ task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=description),
+ total=expected_size, visible=False)
self.invisible_tasks.append(task_id)
else:
- task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=description), total=expected_size)
+ task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=description),
+ total=expected_size)
self.visible_tasks.append(task_id)
await self.redraw()
return task_id
diff --git a/cyberdrop_dl/ui/progress/hash_progress.py b/cyberdrop_dl/ui/progress/hash_progress.py
index 84824a457..b3c171509 100644
--- a/cyberdrop_dl/ui/progress/hash_progress.py
+++ b/cyberdrop_dl/ui/progress/hash_progress.py
@@ -1,36 +1,36 @@
from typing import TYPE_CHECKING
+from humanfriendly import format_size
from rich.console import Group
from rich.panel import Panel
from rich.progress import Progress, BarColumn
-from humanfriendly import format_size
if TYPE_CHECKING:
from cyberdrop_dl.managers.manager import Manager
+
class HashProgress:
"""Class that keeps track of hashed files"""
def __init__(self, manager: 'Manager'):
self.manager = manager
self.hash_progress = Progress("[progress.description]{task.description}",
- BarColumn(bar_width=None),
- "{task.completed} Files")
- self.remove_progress=Progress("[progress.description]{task.description}",
- BarColumn(bar_width=None),
- "{task.completed} Files")
- self.match_progress=Progress("[progress.description]{task.description}",
- BarColumn(bar_width=None),
- "{task.completed} of {task.total} Files")
-
- self.current_hashing_text=Progress("{task.description}")
-
-
+ BarColumn(bar_width=None),
+ "{task.completed} Files")
+ self.remove_progress = Progress("[progress.description]{task.description}",
+ BarColumn(bar_width=None),
+ "{task.completed} Files")
+ self.match_progress = Progress("[progress.description]{task.description}",
+ BarColumn(bar_width=None),
+ "{task.completed} of {task.total} Files")
+
+ self.current_hashing_text = Progress("{task.description}")
+
self.hashed_files = 0
self.prev_hashed_files = 0
- self.hash_progress_group = Group(self.current_hashing_text,self.hash_progress)
-
+ self.hash_progress_group = Group(self.current_hashing_text, self.hash_progress)
+
self.hashed_files_task_id = self.hash_progress.add_task("[green]Hashed", total=None)
self.prev_hashed_files_task_id = self.hash_progress.add_task("[green]Previously Hashed", total=None)
@@ -38,51 +38,45 @@ class HashProgress:
self.currently_hashing_size_task_id = self.current_hashing_text.add_task("")
-
-
-
-
-
- self.removed_files=0
- self.removed_prev_files=0
- self.removed_progress_group = Group(self.match_progress,self.remove_progress)
- self.removed_files_task_id = self.remove_progress.add_task("[green]Removed From Currently Downloaded Files", total=None)
- self.removed_prev_files_task_id = self.remove_progress.add_task("[green]Removed From Previously Downloaded Files", total=None)
-
-
-
+ self.removed_files = 0
+ self.removed_prev_files = 0
+ self.removed_progress_group = Group(self.match_progress, self.remove_progress)
+ self.removed_files_task_id = self.remove_progress.add_task("[green]Removed From Currently Downloaded Files",
+ total=None)
+ self.removed_prev_files_task_id = self.remove_progress.add_task(
+ "[green]Removed From Previously Downloaded Files", total=None)
async def get_hash_progress(self) -> Panel:
"""Returns the progress bar"""
- return Panel(self.hash_progress_group, title=f"Config: {self.manager.config_manager.loaded_config}", border_style="green", padding=(1, 1))
-
+ return Panel(self.hash_progress_group, title=f"Config: {self.manager.config_manager.loaded_config}",
+ border_style="green", padding=(1, 1))
async def get_removed_progress(self) -> Panel:
"""Returns the progress bar"""
return Panel(self.removed_progress_group, border_style="green", padding=(1, 1))
- async def update_currently_hashing(self,file):
- self.current_hashing_text.update(self.currently_hashing_task_id ,description=f"[blue]{file}")
- self.current_hashing_text.update(self.currently_hashing_size_task_id ,description=f"[blue]{format_size(file.stat().st_size)}")
-
+ async def update_currently_hashing(self, file):
+ self.current_hashing_text.update(self.currently_hashing_task_id, description=f"[blue]{file}")
+
+ self.current_hashing_text.update(self.currently_hashing_size_task_id,
+ description=f"[blue]{format_size(file.stat().st_size)}")
async def add_new_completed_hash(self) -> None:
"""Adds a completed file to the progress bar"""
- self.hash_progress.advance(self.hashed_files_task_id , 1)
+ self.hash_progress.advance(self.hashed_files_task_id, 1)
self.hashed_files += 1
async def add_prev_hash(self) -> None:
"""Adds a completed file to the progress bar"""
- self.hash_progress.advance(self.prev_hashed_files_task_id , 1)
+ self.hash_progress.advance(self.prev_hashed_files_task_id, 1)
self.prev_hashed_files += 1
-
async def add_removed_file(self) -> None:
"""Adds a completed file to the progress bar"""
- self.remove_progress.advance(self.removed_files_task_id , 1)
+ self.remove_progress.advance(self.removed_files_task_id, 1)
self.removed_files += 1
async def add_removed_prev_file(self) -> None:
"""Adds a completed file to the progress bar"""
- self.remove_progress.advance(self.removed_prev_files_task_id , 1)
- self.removed_prev_files += 1
\ No newline at end of file
+ self.remove_progress.advance(self.removed_prev_files_task_id, 1)
+ self.removed_prev_files += 1
diff --git a/cyberdrop_dl/ui/progress/scraping_progress.py b/cyberdrop_dl/ui/progress/scraping_progress.py
index 740490cc1..b445eecce 100644
--- a/cyberdrop_dl/ui/progress/scraping_progress.py
+++ b/cyberdrop_dl/ui/progress/scraping_progress.py
@@ -16,6 +16,7 @@ async def adjust_title(s: str, length: int = 40, placeholder: str = "...") -> st
class ScrapingProgress:
"""Class that manages the download progress of individual files"""
+
def __init__(self, visible_tasks_limit: int, manager: 'Manager'):
self.manager = manager
@@ -30,8 +31,10 @@ class ScrapingProgress:
self.progress_str = "[{color}]{description}"
self.overflow_str = "[{color}]... And {number} Other Links"
self.queue_str = "[{color}]... And {number} Links In Scrape Queue"
- self.overflow_task_id = self.overflow.add_task(self.overflow_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
- self.queue_task_id = self.queue.add_task(self.queue_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
+ self.overflow_task_id = self.overflow.add_task(
+ self.overflow_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
+ self.queue_task_id = self.queue.add_task(
+ self.queue_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
self.visible_tasks: List[TaskID] = []
self.invisible_tasks: List[TaskID] = []
@@ -62,23 +65,30 @@ class ScrapingProgress:
self.progress.update(task_id, visible=True)
if len(self.invisible_tasks) > 0:
- self.overflow.update(self.overflow_task_id, description=self.overflow_str.format(color=self.color, number=len(self.invisible_tasks), type_str=self.type_str), visible=True)
+ self.overflow.update(self.overflow_task_id, description=self.overflow_str.format(color=self.color,
+ number=len(
+ self.invisible_tasks),
+ type_str=self.type_str),
+ visible=True)
else:
self.overflow.update(self.overflow_task_id, visible=False)
queue_length = await self.get_queue_length()
if queue_length > 0:
- self.queue.update(self.queue_task_id, description=self.queue_str.format(color=self.color, number=queue_length, type_str=self.type_str), visible=True)
+ self.queue.update(self.queue_task_id,
+ description=self.queue_str.format(color=self.color, number=queue_length,
+ type_str=self.type_str), visible=True)
else:
self.queue.update(self.queue_task_id, visible=False)
-
+
if not passed:
await self.manager.progress_manager.file_progress.redraw(True)
async def add_task(self, url: URL) -> TaskID:
"""Adds a new task to the progress bar"""
if len(self.visible_tasks) >= self.tasks_visibility_limit:
- task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=str(url)), visible=False)
+ task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=str(url)),
+ visible=False)
self.invisible_tasks.append(task_id)
else:
task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=str(url)))
diff --git a/cyberdrop_dl/ui/progress/sort_progress.py b/cyberdrop_dl/ui/progress/sort_progress.py
index ec8133578..5c2c5a222 100644
--- a/cyberdrop_dl/ui/progress/sort_progress.py
+++ b/cyberdrop_dl/ui/progress/sort_progress.py
@@ -12,45 +12,49 @@ async def adjust_title(s: str, length: int = 40, placeholder: str = "...") -> st
"""Collapse and truncate or pad the given string to fit in the given length"""
return f"{s[:length - len(placeholder)]}{placeholder}" if len(s) >= length else s.ljust(length)
+
class SortProgress:
"""Class that keeps track of sorted files"""
def __init__(self, visible_task_limit: 1, manager: 'Manager'):
self.manager = manager
# Sorter to track the progress of folders being sorted, should work similar to the file_progress but for folders, with a percentage and progress bar for the files within the folders
- self.progress = Progress(SpinnerColumn(), "[progress.description]{task.description}",
- BarColumn(bar_width=None), "[progress.percentage]{task.percentage:>3.2f}%",
- "━", "{task.completed}/{task.total} files"
- )
+ self.progress = Progress(SpinnerColumn(), "[progress.description]{task.description}",
+ BarColumn(bar_width=None), "[progress.percentage]{task.percentage:>3.2f}%",
+ "━", "{task.completed}/{task.total} files"
+ )
self.overflow = Progress("[progress.description]{task.description}")
self.queue = Progress("[progress.description]{task.description}")
self.progress_group = Group(self.progress, self.overflow, self.queue)
-
+
self.color = "plum3"
self.type_str = "Folders"
self.progress_str = "[{color}]{description}"
self.overflow_str = "[{color}]... And {number} Other Folders"
self.queue_length = 0
self.queue_str = "[{color}]... And {number} Folders In Sort Queue"
- self.overflow_task_id = self.overflow.add_task(self.overflow_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
- self.queue_task_id = self.queue.add_task(self.queue_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
-
-
+ self.overflow_task_id = self.overflow.add_task(
+ self.overflow_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
+ self.queue_task_id = self.queue.add_task(
+ self.queue_str.format(color=self.color, number=0, type_str=self.type_str), visible=False)
+
self.visible_tasks: List[TaskID] = []
self.invisible_tasks: List[TaskID] = []
self.completed_tasks: List[TaskID] = []
self.uninitiated_tasks: List[TaskID] = []
self.tasks_visibility_limit = visible_task_limit
- #counts
- self.audio_count=0
- self.video_count=0
- self.image_count=0
- self.other_count=0
+ # counts
+ self.audio_count = 0
+ self.video_count = 0
+ self.image_count = 0
+ self.other_count = 0
async def get_progress(self) -> Panel:
"""Returns the progress bar"""
- return Panel(self.progress_group, title=f"Sorting Downloads ━ Config: {self.manager.config_manager.loaded_config}", border_style="green", padding=(1, 1))
+ return Panel(self.progress_group,
+ title=f"Sorting Downloads ━ Config: {self.manager.config_manager.loaded_config}",
+ border_style="green", padding=(1, 1))
async def set_queue_length(self, length: int) -> None:
self.queue_length = length
@@ -67,16 +71,22 @@ class SortProgress:
self.progress.update(task_id, visible=True)
if len(self.invisible_tasks) > 0:
- self.overflow.update(self.overflow_task_id, description=self.overflow_str.format(color=self.color, number=len(self.invisible_tasks), type_str=self.type_str), visible=True)
+ self.overflow.update(self.overflow_task_id, description=self.overflow_str.format(color=self.color,
+ number=len(
+ self.invisible_tasks),
+ type_str=self.type_str),
+ visible=True)
else:
self.overflow.update(self.overflow_task_id, visible=False)
queue_length = self.queue_length
if queue_length > 0:
- self.queue.update(self.queue_task_id, description=self.queue_str.format(color=self.color, number=queue_length, type_str=self.type_str), visible=True)
+ self.queue.update(self.queue_task_id,
+ description=self.queue_str.format(color=self.color, number=queue_length,
+ type_str=self.type_str), visible=True)
else:
self.queue.update(self.queue_task_id, visible=False)
-
+
if not passed:
await self.manager.progress_manager.scraping_progress.redraw(True)
@@ -88,10 +98,12 @@ class SortProgress:
description = await adjust_title(description)
if len(self.visible_tasks) >= self.tasks_visibility_limit:
- task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=description), total=expected_size, visible=False)
+ task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=description),
+ total=expected_size, visible=False)
self.invisible_tasks.append(task_id)
else:
- task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=description), total=expected_size)
+ task_id = self.progress.add_task(self.progress_str.format(color=self.color, description=description),
+ total=expected_size)
self.visible_tasks.append(task_id)
await self.redraw()
return task_id
@@ -122,7 +134,9 @@ class SortProgress:
async def increment_video(self):
self.video_count += 1
+
async def increment_image(self):
self.image_count += 1
+
async def increment_other(self):
- self.other_count += 1
\ No newline at end of file
+ self.other_count += 1
diff --git a/cyberdrop_dl/ui/progress/statistic_progress.py b/cyberdrop_dl/ui/progress/statistic_progress.py
index 6415af49b..bdd3e7a4b 100644
--- a/cyberdrop_dl/ui/progress/statistic_progress.py
+++ b/cyberdrop_dl/ui/progress/statistic_progress.py
@@ -36,7 +36,8 @@ class DownloadStatsProgress:
if failure_type in self.failure_types:
self.progress.advance(self.failure_types[failure_type], 1)
else:
- self.failure_types[failure_type] = self.progress.add_task(failure_type, total=self.failed_files, completed=1)
+ self.failure_types[failure_type] = self.progress.add_task(failure_type, total=self.failed_files,
+ completed=1)
await self.update_total(self.failed_files)
async def return_totals(self) -> Dict:
@@ -78,7 +79,8 @@ class ScrapeStatsProgress:
if failure_type in self.failure_types:
self.progress.advance(self.failure_types[failure_type], 1)
else:
- self.failure_types[failure_type] = self.progress.add_task(failure_type, total=self.failed_files, completed=1)
+ self.failure_types[failure_type] = self.progress.add_task(failure_type, total=self.failed_files,
+ completed=1)
await self.update_total(self.failed_files)
async def return_totals(self) -> Dict:
diff --git a/cyberdrop_dl/ui/prompts/general_prompts.py b/cyberdrop_dl/ui/prompts/general_prompts.py
index 0b7051a0c..a0bf68856 100644
--- a/cyberdrop_dl/ui/prompts/general_prompts.py
+++ b/cyberdrop_dl/ui/prompts/general_prompts.py
@@ -1,8 +1,8 @@
from __future__ import annotations
-import pathlib
-import asyncio
+import asyncio
import os
+import pathlib
from typing import TYPE_CHECKING
from InquirerPy import inquirer
@@ -10,17 +10,16 @@ from InquirerPy.base.control import Choice
from InquirerPy.separator import Separator
from InquirerPy.validator import EmptyInputValidator, PathValidator
from rich.console import Console
-from cyberdrop_dl.utils.utilities import log
from cyberdrop_dl.utils.transfer.transfer_v4_config import transfer_v4_config
from cyberdrop_dl.utils.transfer.transfer_v4_db import transfer_v4_db
+from cyberdrop_dl.utils.utilities import log
if TYPE_CHECKING:
from typing import List
from cyberdrop_dl.managers.manager import Manager
-
console = Console()
@@ -136,14 +135,14 @@ def import_cyberdrop_v4_items_prompt(manager: Manager) -> None:
if import_download_history_path.is_file():
transfer_v4_db(import_download_history_path, manager.path_manager.history_db)
else:
- loop=asyncio.new_event_loop()
+ loop = asyncio.new_event_loop()
for ele in pathlib.Path(import_download_history_path).glob("**/*.sqlite"):
- if str(ele)==str(manager.path_manager.history_db):
+ if str(ele) == str(manager.path_manager.history_db):
continue
try:
transfer_v4_db(ele, manager.path_manager.history_db)
except Exception as e:
- loop.run_until_complete(log(f"Error importing {ele.name}: {str(e)}",20))
+ loop.run_until_complete(log(f"Error importing {ele.name}: {str(e)}", 20))
# Done
elif action == 3:
diff --git a/cyberdrop_dl/ui/prompts/settings_authentication_prompts.py b/cyberdrop_dl/ui/prompts/settings_authentication_prompts.py
index fff8171da..f7064e9d5 100644
--- a/cyberdrop_dl/ui/prompts/settings_authentication_prompts.py
+++ b/cyberdrop_dl/ui/prompts/settings_authentication_prompts.py
@@ -6,8 +6,8 @@ from InquirerPy import inquirer
from InquirerPy.base.control import Choice
from rich.console import Console
-from cyberdrop_dl.utils.args.browser_cookie_extraction import get_forum_cookies
from cyberdrop_dl.managers.manager import Manager
+from cyberdrop_dl.utils.args.browser_cookie_extraction import get_forum_cookies
if TYPE_CHECKING:
from typing import Dict
@@ -224,7 +224,8 @@ def edit_forum_authentication_values_prompt(manager: Manager) -> None:
manager.config_manager.authentication_data["Forums"]["leakedmodels_username"] = leakedmodels_username
manager.config_manager.authentication_data["Forums"]["nudostar_username"] = nudostar_username
manager.config_manager.authentication_data["Forums"]["simpcity_username"] = simpcity_username
- manager.config_manager.authentication_data["Forums"]["socialmediagirls_username"] = socialmediagirls_username
+ manager.config_manager.authentication_data["Forums"][
+ "socialmediagirls_username"] = socialmediagirls_username
manager.config_manager.authentication_data["Forums"]["xbunker_username"] = xbunker_username
manager.config_manager.authentication_data["Forums"]["celebforum_password"] = celebforum_password
@@ -232,7 +233,8 @@ def edit_forum_authentication_values_prompt(manager: Manager) -> None:
manager.config_manager.authentication_data["Forums"]["leakedmodels_password"] = leakedmodels_password
manager.config_manager.authentication_data["Forums"]["nudostar_password"] = nudostar_password
manager.config_manager.authentication_data["Forums"]["simpcity_password"] = simpcity_password
- manager.config_manager.authentication_data["Forums"]["socialmediagirls_password"] = socialmediagirls_password
+ manager.config_manager.authentication_data["Forums"][
+ "socialmediagirls_password"] = socialmediagirls_password
manager.config_manager.authentication_data["Forums"]["xbunker_password"] = xbunker_password
return
elif action == 3:
diff --git a/cyberdrop_dl/ui/prompts/settings_global_prompts.py b/cyberdrop_dl/ui/prompts/settings_global_prompts.py
index cc12b643c..51cb7af63 100644
--- a/cyberdrop_dl/ui/prompts/settings_global_prompts.py
+++ b/cyberdrop_dl/ui/prompts/settings_global_prompts.py
@@ -37,13 +37,13 @@ def edit_global_settings_prompt(manager: Manager) -> None:
# Edit Rate Limiting Settings
elif action == 2:
edit_rate_limiting_settings_prompt(manager)
-
-
- # Edit UI Settings
+
+
+ # Edit UI Settings
elif action == 3:
edit_ui_settings_prompt(manager)
- #Edit Dupe
+ # Edit Dupe
elif action == 4:
edit_dupe_settings_prompt(manager)
@@ -125,7 +125,7 @@ def edit_ui_settings_prompt(manager: Manager) -> None:
float_allowed=False,
vi_mode=manager.vi_mode,
).execute()
-
+
vi_mode = inquirer.confirm(
message="Enable VI/VIM keybindings?",
default=bool(manager.config_manager.global_settings_data['UI_Options']['vi_mode']),
@@ -189,7 +189,8 @@ def edit_rate_limiting_settings_prompt(manager: Manager) -> None:
).execute()
max_simultaneous_downloads_per_domain = inquirer.number(
message="Maximum number of simultaneous downloads per domain:",
- default=int(manager.config_manager.global_settings_data['Rate_Limiting_Options']['max_simultaneous_downloads_per_domain']),
+ default=int(manager.config_manager.global_settings_data['Rate_Limiting_Options'][
+ 'max_simultaneous_downloads_per_domain']),
float_allowed=False,
vi_mode=manager.vi_mode,
).execute()
@@ -198,12 +199,13 @@ def edit_rate_limiting_settings_prompt(manager: Manager) -> None:
manager.config_manager.global_settings_data['Rate_Limiting_Options']['read_timeout'] = int(read_timeout)
manager.config_manager.global_settings_data['Rate_Limiting_Options']['download_attempts'] = int(download_attempts)
manager.config_manager.global_settings_data['Rate_Limiting_Options']['rate_limit'] = int(rate_limit)
- manager.config_manager.global_settings_data['Rate_Limiting_Options']['download_speed_limit'] = int(download_speed_limit)
+ manager.config_manager.global_settings_data['Rate_Limiting_Options']['download_speed_limit'] = int(
+ download_speed_limit)
manager.config_manager.global_settings_data['Rate_Limiting_Options']['download_delay'] = float(throttle)
- manager.config_manager.global_settings_data['Rate_Limiting_Options']['max_simultaneous_downloads'] = int(max_simultaneous_downloads)
- manager.config_manager.global_settings_data['Rate_Limiting_Options']['max_simultaneous_downloads_per_domain'] = int(max_simultaneous_downloads_per_domain)
-
-
+ manager.config_manager.global_settings_data['Rate_Limiting_Options']['max_simultaneous_downloads'] = int(
+ max_simultaneous_downloads)
+ manager.config_manager.global_settings_data['Rate_Limiting_Options']['max_simultaneous_downloads_per_domain'] = int(
+ max_simultaneous_downloads_per_domain)
def edit_dupe_settings_prompt(manager: Manager) -> None:
@@ -214,35 +216,34 @@ def edit_dupe_settings_prompt(manager: Manager) -> None:
delete_after = inquirer.select(
message="Toggle duplicate files deletion using hashes:",
default=manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['delete_after_download'],
- choices=[Choice(True,"True"),Choice(False,"False")],
+ choices=[Choice(True, "True"), Choice(False, "False")],
vi_mode=manager.vi_mode,
).execute()
hash_while_downloading = inquirer.select(
message="Hash Files during downloading:",
long_instruction=
-
-"""
-Generate file hashes after each download, instead of batched
-together during deduplication process
-""",
+
+ """
+ Generate file hashes after each download, instead of batched
+ together during deduplication process
+ """,
default=manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['hash_while_downloading'],
- choices=[Choice(True,"True"),Choice(False,"False")],
+ choices=[Choice(True, "True"), Choice(False, "False")],
vi_mode=manager.vi_mode,
).execute()
dedupe_already_downloaded = inquirer.select(
message="How to handle files already on system: ",
default=manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['dedupe_already_downloaded'],
- choices=[Choice(True,"Mark Existing Files as 'new'"),Choice(False,"Skip Existing Files")],
+ choices=[Choice(True, "Mark Existing Files as 'new'"), Choice(False, "Skip Existing Files")],
vi_mode=manager.vi_mode,
).execute()
-
keep_current = inquirer.select(
message="What to do with new file when deduping: ",
long_instruction="Keep a curent file. Current files are files that were either downloaded or a file was skipped for already existing when dedupe_already_downloaded is true",
default=manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['keep_new_download'],
- choices=[Choice(True,"Keep a newfile"),Choice(False,"Delete all new files")],
+ choices=[Choice(True, "Keep a newfile"), Choice(False, "Delete all new files")],
vi_mode=manager.vi_mode,
).execute()
@@ -250,25 +251,24 @@ together during deduplication process
message="What to do with previous file(s) when deduping:",
default=manager.config_manager.global_settings_data['Dupe_Cleanup_Options'],
long_instruction="Any file that is not in the list of current files with a matching hash",
- choices=[Choice(True,"Keep a previous file "),Choice(False,"Delete all previous files")],
+ choices=[Choice(True, "Keep a previous file "), Choice(False, "Delete all previous files")],
vi_mode=manager.vi_mode,
).execute()
delete_off_disk = inquirer.select(
message="How to handle removal of files: ",
default=manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['delete_off_disk'],
- choices=[Choice(True,"Permanently Delete File"),Choice(False,"Send to Trash")],
+ choices=[Choice(True, "Permanently Delete File"), Choice(False, "Send to Trash")],
vi_mode=manager.vi_mode,
).execute()
-
-
-
- manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['delete_after_download'] = delete_after
- manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['hash_while_downloading'] = hash_while_downloading
+ manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['delete_after_download'] = delete_after
+ manager.config_manager.global_settings_data['Dupe_Cleanup_Options'][
+ 'hash_while_downloading'] = hash_while_downloading
manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['keep_prev_download'] = keep_prev
manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['keep_new_download'] = keep_current
- manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['dedupe_already_downloaded'] = dedupe_already_downloaded
+ manager.config_manager.global_settings_data['Dupe_Cleanup_Options'][
+ 'dedupe_already_downloaded'] = dedupe_already_downloaded
- manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['delete_off_disk'] = delete_off_disk
\ No newline at end of file
+ manager.config_manager.global_settings_data['Dupe_Cleanup_Options']['delete_off_disk'] = delete_off_disk
diff --git a/cyberdrop_dl/ui/prompts/settings_hash_prompts.py b/cyberdrop_dl/ui/prompts/settings_hash_prompts.py
index 6182c0ec9..96431e96d 100644
--- a/cyberdrop_dl/ui/prompts/settings_hash_prompts.py
+++ b/cyberdrop_dl/ui/prompts/settings_hash_prompts.py
@@ -10,7 +10,6 @@ if TYPE_CHECKING:
from cyberdrop_dl.managers.manager import Manager
-
def path_prompt(manager: Manager):
home_path = "~/" if os.name == "posix" else "C:\\"
hash_path = inquirer.filepath(
@@ -18,4 +17,4 @@ def path_prompt(manager: Manager):
default=home_path,
validate=PathValidator(is_dir=True, message="Input is not a directory"),
).execute()
- return hash_path
\ No newline at end of file
+ return hash_path
diff --git a/cyberdrop_dl/ui/prompts/settings_user_prompts.py b/cyberdrop_dl/ui/prompts/settings_user_prompts.py
index 47d1e7514..e0138bd42 100644
--- a/cyberdrop_dl/ui/prompts/settings_user_prompts.py
+++ b/cyberdrop_dl/ui/prompts/settings_user_prompts.py
@@ -366,7 +366,6 @@ def edit_runtime_options_prompt(manager: Manager, config: Dict) -> None:
vi_mode=manager.vi_mode,
).execute()
-
console_log_level = inquirer.number(
message="Enter the log level for console output:",
default=int(config['Runtime_Options']['console_log_level']),
@@ -385,13 +384,13 @@ def edit_runtime_options_prompt(manager: Manager, config: Dict) -> None:
config['Runtime_Options']['console_log_level'] = int(console_log_level)
-
def edit_sort_options_prompt(manager: Manager, config: Dict) -> None:
"""Edit the sort options"""
console.clear()
console.print("Editing Sort Options")
config["Sorting"]["sort_downloads"] = False
- sort_downloads = inquirer.confirm(message="Do you want Cyberdrop-DL to sort files for you?", vi_mode=manager.vi_mode).execute()
+ sort_downloads = inquirer.confirm(message="Do you want Cyberdrop-DL to sort files for you?",
+ vi_mode=manager.vi_mode).execute()
if sort_downloads:
config["Sorting"]["sort_downloads"] = True
sort_folder = inquirer.filepath(
diff --git a/cyberdrop_dl/ui/prompts/url_file_prompts.py b/cyberdrop_dl/ui/prompts/url_file_prompts.py
index 3f3a74bc5..221dda49e 100644
--- a/cyberdrop_dl/ui/prompts/url_file_prompts.py
+++ b/cyberdrop_dl/ui/prompts/url_file_prompts.py
@@ -4,7 +4,8 @@ from pathlib import Path
from InquirerPy import inquirer
from rich.console import Console
-console = Console()
+console = Console()
+
def edit_urls_prompt(URLs_File: Path, vi_mode: bool, fix_strings=True) -> None:
"""Edit the URLs file"""
diff --git a/cyberdrop_dl/ui/ui.py b/cyberdrop_dl/ui/ui.py
index 11d43ac2c..a31a7519f 100644
--- a/cyberdrop_dl/ui/ui.py
+++ b/cyberdrop_dl/ui/ui.py
@@ -1,25 +1,23 @@
from __future__ import annotations
from pathlib import Path
+from pydoc import pager
from typing import TYPE_CHECKING
from InquirerPy import inquirer
from InquirerPy.validator import PathValidator
from rich.console import Console
-from pydoc import pager
+import cyberdrop_dl.utils.changelog as Changelog
from cyberdrop_dl import __version__
-from cyberdrop_dl.ui.prompts.settings_authentication_prompts import edit_authentication_values_prompt
+from cyberdrop_dl.clients.hash_client import hash_directory_scanner
from cyberdrop_dl.ui.prompts.general_prompts import (
- main_prompt, select_config_prompt, donations_prompt,
- import_cyberdrop_v4_items_prompt, manage_configs_prompt)
+ main_prompt, select_config_prompt, import_cyberdrop_v4_items_prompt, manage_configs_prompt)
+from cyberdrop_dl.ui.prompts.settings_authentication_prompts import edit_authentication_values_prompt
from cyberdrop_dl.ui.prompts.settings_global_prompts import edit_global_settings_prompt
-from cyberdrop_dl.ui.prompts.url_file_prompts import edit_urls_prompt
-from cyberdrop_dl.ui.prompts.settings_user_prompts import create_new_config_prompt, edit_config_values_prompt
from cyberdrop_dl.ui.prompts.settings_hash_prompts import path_prompt
-from cyberdrop_dl.clients.hash_client import hash_directory_scanner
-import cyberdrop_dl.utils.changelog as Changelog
-
+from cyberdrop_dl.ui.prompts.settings_user_prompts import create_new_config_prompt, edit_config_values_prompt
+from cyberdrop_dl.ui.prompts.url_file_prompts import edit_urls_prompt
console = Console()
@@ -49,12 +47,12 @@ def program_ui(manager: Manager):
elif action == 3:
manager.args_manager.retry_failed = True
break
-
+
# Scanning folder to create hashes
elif action == 4:
- path=path_prompt(manager)
- hash_directory_scanner(manager,path)
-
+ path = path_prompt(manager)
+ hash_directory_scanner(manager, path)
+
# Sort All Configs
elif action == 5:
manager.args_manager.sort_all_configs = True
@@ -63,7 +61,8 @@ def program_ui(manager: Manager):
# Edit URLs
elif action == 6:
- input_file = manager.config_manager.settings_data['Files']['input_file'] if not manager.args_manager.input_file else manager.args_manager.input_file
+ input_file = manager.config_manager.settings_data['Files'][
+ 'input_file'] if not manager.args_manager.input_file else manager.args_manager.input_file
edit_urls_prompt(input_file, manager.vi_mode)
# Select Config
diff --git a/cyberdrop_dl/utils/args/args.py b/cyberdrop_dl/utils/args/args.py
index 717f25100..8e1795130 100644
--- a/cyberdrop_dl/utils/args/args.py
+++ b/cyberdrop_dl/utils/args/args.py
@@ -1,5 +1,6 @@
import argparse
-import arrow
+
+import arrow
from cyberdrop_dl import __version__ as VERSION
from cyberdrop_dl.utils.dataclasses.supported_domains import SupportedDomains
@@ -14,86 +15,138 @@ def parse_args() -> argparse.Namespace:
general.add_argument("--proxy", type=str, help="manually specify proxy string", default="")
general.add_argument("--flaresolverr", type=str, help="IP:PORT for flaresolverr", default="")
general.add_argument("--no-ui", action="store_true", help="Disables the UI/Progress view entirely", default=False)
- general.add_argument("--download", action="store_true", help="Skip the UI and go straight to downloading", default=False)
- general.add_argument("--download-all-configs", action="store_true", help="Skip the UI and go straight to downloading (runs all configs sequentially)", default=False)
+ general.add_argument("--download", action="store_true", help="Skip the UI and go straight to downloading",
+ default=False)
+ general.add_argument("--download-all-configs", action="store_true",
+ help="Skip the UI and go straight to downloading (runs all configs sequentially)",
+ default=False)
general.add_argument("--sort-all-configs", action="store_true", help="Sort all configs sequentially", default=False)
general.add_argument("--retry-failed", action="store_true", help="retry failed downloads", default=False)
general.add_argument("--retry-all", action="store_true", help="retry all downloads", default=False)
- general.add_argument("--retry-maintenance", action="store_true", help="retry all failed downloads due to maintenance, only supports bunkr and requires files to be hashed", default=False)
- general.add_argument("--completed-after", help="only download completed downloads at or after this date", default=None,type=lambda x:None if not x else arrow.get(x))
- general.add_argument("--completed-before", help="only download completed downloads at or before this date", default=None,type=lambda x:None if not x else arrow.get(x))
- general.add_argument("--max-items-retry", help="max number of links to retry",type=int)
-
+ general.add_argument("--retry-maintenance", action="store_true",
+ help="retry all failed downloads due to maintenance, only supports bunkr and requires files to be hashed",
+ default=False)
+ general.add_argument("--completed-after", help="only download completed downloads at or after this date",
+ default=None, type=lambda x: None if not x else arrow.get(x))
+ general.add_argument("--completed-before", help="only download completed downloads at or before this date",
+ default=None, type=lambda x: None if not x else arrow.get(x))
+ general.add_argument("--max-items-retry", help="max number of links to retry", type=int)
# File Paths
file_paths = parser.add_argument_group("File_Paths")
- file_paths.add_argument("-i", "--input-file", type=str, help="path to txt file containing urls to download", default="")
+ file_paths.add_argument("-i", "--input-file", type=str, help="path to txt file containing urls to download",
+ default="")
file_paths.add_argument("-d", "--output-folder", type=str, help="path to download folder", default="")
file_paths.add_argument("--config-file", type=str, help="path to the CDL settings.yaml file to load", default="")
- file_paths.add_argument("--appdata-folder", type=str, help="path to where you want CDL to store it's AppData folder", default="")
- file_paths.add_argument("--log-folder", type=str, help="path to where you want CDL to store it's log files", default="")
+ file_paths.add_argument("--appdata-folder", type=str,
+ help="path to where you want CDL to store it's AppData folder", default="")
+ file_paths.add_argument("--log-folder", type=str, help="path to where you want CDL to store it's log files",
+ default="")
file_paths.add_argument("--main-log-filename", type=str, help="filename for the main log file", default="")
- file_paths.add_argument("--last-forum-post-filename", type=str, help="filename for the last forum post log file", default="")
- file_paths.add_argument("--unsupported-urls-filename", type=str, help="filename for the unsupported urls log file", default="")
- file_paths.add_argument("--download-error-urls-filename", type=str, help="filename for the download error urls log file", default="")
- file_paths.add_argument("--scrape-error-urls-filename", type=str, help="filename for the scrape error urls log file", default="")
+ file_paths.add_argument("--last-forum-post-filename", type=str, help="filename for the last forum post log file",
+ default="")
+ file_paths.add_argument("--unsupported-urls-filename", type=str, help="filename for the unsupported urls log file",
+ default="")
+ file_paths.add_argument("--download-error-urls-filename", type=str,
+ help="filename for the download error urls log file", default="")
+ file_paths.add_argument("--scrape-error-urls-filename", type=str,
+ help="filename for the scrape error urls log file", default="")
file_paths.add_argument("--webhook_url", help="Discord webhook url to send download recap to", default="")
# Settings
download_options = parser.add_argument_group("Download_Options")
- download_options.add_argument("--block-download-sub-folders", action="store_true", help="block sub folder creation", default=False)
- download_options.add_argument("--disable-download-attempt-limit", action="store_true", help="disable download attempt limit", default=False)
- download_options.add_argument("--disable-file-timestamps", action="store_true", help="disable file timestamps", default=False)
- download_options.add_argument("--include-album-id-in-folder-name", action="store_true", help="include album id in folder name", default=False)
- download_options.add_argument("--include-thread-id-in-folder-name", action="store_true", help="include thread id in folder name", default=False)
- download_options.add_argument("--remove-domains-from-folder-names", action="store_true", help="remove website domains from folder names", default=False)
- download_options.add_argument("--remove-generated-id-from-filenames", action="store_true", help="remove site generated id from filenames", default=False)
- download_options.add_argument("--scrape-single-forum-post", action="store_true", help="scrape single forum post", default=False)
- download_options.add_argument("--separate-posts", action="store_true", help="separate posts into folders", default=False)
- download_options.add_argument("--skip-download-mark-completed", action="store_true", help="skip download and mark as completed in history", default=False)
+ download_options.add_argument("--block-download-sub-folders", action="store_true", help="block sub folder creation",
+ default=False)
+ download_options.add_argument("--disable-download-attempt-limit", action="store_true",
+ help="disable download attempt limit", default=False)
+ download_options.add_argument("--disable-file-timestamps", action="store_true", help="disable file timestamps",
+ default=False)
+ download_options.add_argument("--include-album-id-in-folder-name", action="store_true",
+ help="include album id in folder name", default=False)
+ download_options.add_argument("--include-thread-id-in-folder-name", action="store_true",
+ help="include thread id in folder name", default=False)
+ download_options.add_argument("--remove-domains-from-folder-names", action="store_true",
+ help="remove website domains from folder names", default=False)
+ download_options.add_argument("--remove-generated-id-from-filenames", action="store_true",
+ help="remove site generated id from filenames", default=False)
+ download_options.add_argument("--scrape-single-forum-post", action="store_true", help="scrape single forum post",
+ default=False)
+ download_options.add_argument("--separate-posts", action="store_true", help="separate posts into folders",
+ default=False)
+ download_options.add_argument("--skip-download-mark-completed", action="store_true",
+ help="skip download and mark as completed in history", default=False)
file_size_limits = parser.add_argument_group("File_Size_Limits")
- file_size_limits.add_argument("--maximum-image-size", type=int, help="maximum image size in bytes (default: %(default)s)", default=0)
- file_size_limits.add_argument("--maximum-video-size", type=int, help="maximum video size in bytes (default: %(default)s)", default=0)
- file_size_limits.add_argument("--maximum-other-size", type=int, help="maximum other size in bytes (default: %(default)s)", default=0)
- file_size_limits.add_argument("--minimum-image-size", type=int, help="minimum image size in bytes (default: %(default)s)", default=0)
- file_size_limits.add_argument("--minimum-video-size", type=int, help="minimum video size in bytes (default: %(default)s)", default=0)
- file_size_limits.add_argument("--minimum-other-size", type=int, help="minimum other size in bytes (default: %(default)s)", default=0)
+ file_size_limits.add_argument("--maximum-image-size", type=int,
+ help="maximum image size in bytes (default: %(default)s)", default=0)
+ file_size_limits.add_argument("--maximum-video-size", type=int,
+ help="maximum video size in bytes (default: %(default)s)", default=0)
+ file_size_limits.add_argument("--maximum-other-size", type=int,
+ help="maximum other size in bytes (default: %(default)s)", default=0)
+ file_size_limits.add_argument("--minimum-image-size", type=int,
+ help="minimum image size in bytes (default: %(default)s)", default=0)
+ file_size_limits.add_argument("--minimum-video-size", type=int,
+ help="minimum video size in bytes (default: %(default)s)", default=0)
+ file_size_limits.add_argument("--minimum-other-size", type=int,
+ help="minimum other size in bytes (default: %(default)s)", default=0)
ignore_options = parser.add_argument_group("Ignore_Options")
- ignore_options.add_argument("--exclude-videos", action="store_true", help="exclude videos from downloading", default=False)
- ignore_options.add_argument("--exclude-images", action="store_true", help="exclude images from downloading", default=False)
- ignore_options.add_argument("--exclude-audio", action="store_true", help="exclude images from downloading", default=False)
- ignore_options.add_argument("--exclude-other", action="store_true", help="exclude other files from downloading", default=False)
- ignore_options.add_argument("--ignore-coomer-ads", action="store_true", help="ignore coomer ads when scraping", default=False)
- ignore_options.add_argument("--skip-hosts", choices=SupportedDomains.supported_hosts, action="append", help="skip these domains when scraping", default=[])
- ignore_options.add_argument("--only-hosts", choices=SupportedDomains.supported_hosts, action="append", help="only scrape these domains", default=[])
+ ignore_options.add_argument("--exclude-videos", action="store_true", help="exclude videos from downloading",
+ default=False)
+ ignore_options.add_argument("--exclude-images", action="store_true", help="exclude images from downloading",
+ default=False)
+ ignore_options.add_argument("--exclude-audio", action="store_true", help="exclude images from downloading",
+ default=False)
+ ignore_options.add_argument("--exclude-other", action="store_true", help="exclude other files from downloading",
+ default=False)
+ ignore_options.add_argument("--ignore-coomer-ads", action="store_true", help="ignore coomer ads when scraping",
+ default=False)
+ ignore_options.add_argument("--skip-hosts", choices=SupportedDomains.supported_hosts, action="append",
+ help="skip these domains when scraping", default=[])
+ ignore_options.add_argument("--only-hosts", choices=SupportedDomains.supported_hosts, action="append",
+ help="only scrape these domains", default=[])
runtime_options = parser.add_argument_group("Runtime_Options")
- runtime_options.add_argument("--ignore-history", action="store_true", help="ignore history when scraping", default=False)
+ runtime_options.add_argument("--ignore-history", action="store_true", help="ignore history when scraping",
+ default=False)
runtime_options.add_argument("--log-level", type=int, help="set the log level (default: %(default)s)", default=10)
- runtime_options.add_argument("--skip-check-for-partial-files", action="store_true", help="skip check for partial downloads", default=False)
- runtime_options.add_argument("--skip-check-for-empty-folders", action="store_true", help="skip check (and removal) for empty folders", default=False)
- runtime_options.add_argument("--delete-partial-files", action="store_true", help="delete partial downloads", default=False)
- runtime_options.add_argument("--send-unsupported-to-jdownloader", action="store_true", help="send unsupported urls to jdownloader", default=False)
- runtime_options.add_argument("--update-last-forum-post", action="store_true", help="update the last forum post", default=False)
+ runtime_options.add_argument("--skip-check-for-partial-files", action="store_true",
+ help="skip check for partial downloads", default=False)
+ runtime_options.add_argument("--skip-check-for-empty-folders", action="store_true",
+ help="skip check (and removal) for empty folders", default=False)
+ runtime_options.add_argument("--delete-partial-files", action="store_true", help="delete partial downloads",
+ default=False)
+ runtime_options.add_argument("--send-unsupported-to-jdownloader", action="store_true",
+ help="send unsupported urls to jdownloader", default=False)
+ runtime_options.add_argument("--update-last-forum-post", action="store_true", help="update the last forum post",
+ default=False)
sorting_options = parser.add_argument_group("Sorting")
- sorting_options.add_argument("--sort-downloads", action="store_true", help="sort downloads into folders", default=False)
- sorting_options.add_argument("--sort-all-downloads", action="store_true", help="sort all downloads, not just those downloader by Cyberdrop-DL", default=False)
- sorting_options.add_argument("--sort-folder", type=str, help="path to where you want CDL to store it's log files", default="")
- sorting_options.add_argument("--scan-folder", type=str, help="path to scan for files, if not set then the download_dir is used", default="")
-
+ sorting_options.add_argument("--sort-downloads", action="store_true", help="sort downloads into folders",
+ default=False)
+ sorting_options.add_argument("--sort-all-downloads", action="store_true",
+ help="sort all downloads, not just those downloader by Cyberdrop-DL", default=False)
+ sorting_options.add_argument("--sort-folder", type=str, help="path to where you want CDL to store it's log files",
+ default="")
+ sorting_options.add_argument("--scan-folder", type=str,
+ help="path to scan for files, if not set then the download_dir is used", default="")
+
ui_options = parser.add_argument_group("UI_Options")
ui_options.add_argument("--vi-mode", action="store_true", help="enable VIM keybindings for UI", default=None)
- ui_options.add_argument("--refresh-rate", type=int, help="refresh rate for the UI (default: %(default)s)", default=10)
- ui_options.add_argument("--scraping-item-limit", type=int, help="number of lines to allow for scraping items before overflow (default: %(default)s)", default=5)
- ui_options.add_argument("--downloading-item-limit", type=int, help="number of lines to allow for downloading items before overflow (default: %(default)s)", default=5)
-
+ ui_options.add_argument("--refresh-rate", type=int, help="refresh rate for the UI (default: %(default)s)",
+ default=10)
+ ui_options.add_argument("--scraping-item-limit", type=int,
+ help="number of lines to allow for scraping items before overflow (default: %(default)s)",
+ default=5)
+ ui_options.add_argument("--downloading-item-limit", type=int,
+ help="number of lines to allow for downloading items before overflow (default: %(default)s)",
+ default=5)
+
# Links
- parser.add_argument("links", metavar="link", nargs="*", help="link to content to download (passing multiple links is supported)", default=[])
- args= parser.parse_args()
- #set ignore history on retry_all
+ parser.add_argument("links", metavar="link", nargs="*",
+ help="link to content to download (passing multiple links is supported)", default=[])
+ args = parser.parse_args()
+ # set ignore history on retry_all
if args.retry_all or args.retry_maintenance:
args.ignore_history = True
return args
diff --git a/cyberdrop_dl/utils/args/browser_cookie_extraction.py b/cyberdrop_dl/utils/args/browser_cookie_extraction.py
index cf64c616c..645c58566 100644
--- a/cyberdrop_dl/utils/args/browser_cookie_extraction.py
+++ b/cyberdrop_dl/utils/args/browser_cookie_extraction.py
@@ -17,6 +17,7 @@ if TYPE_CHECKING:
def cookie_wrapper(func):
"""Wrapper handles errors for url scraping"""
+
@wraps(func)
def wrapper(self, *args, **kwargs):
try:
@@ -24,11 +25,15 @@ def cookie_wrapper(func):
except PermissionError:
console = Console()
console.clear()
- console.print("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("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
@@ -40,11 +45,13 @@ def get_forum_cookies(manager: Manager, browser: str) -> None:
for forum in SupportedDomains.supported_forums:
try:
cookie = get_cookie(browser, forum)
- auth_args['Forums'][f'{SupportedDomains.supported_forums_map[forum]}_xf_user_cookie'] = cookie._cookies[forum]['/']['xf_user'].value
+ auth_args['Forums'][f'{SupportedDomains.supported_forums_map[forum]}_xf_user_cookie'] = \
+ cookie._cookies[forum]['/']['xf_user'].value
except KeyError:
try:
cookie = get_cookie(browser, "www." + forum)
- auth_args['Forums'][f'{SupportedDomains.supported_forums_map[forum]}_xf_user_cookie'] = cookie._cookies["www." + forum]['/']['xf_user'].value
+ auth_args['Forums'][f'{SupportedDomains.supported_forums_map[forum]}_xf_user_cookie'] = \
+ cookie._cookies["www." + forum]['/']['xf_user'].value
except KeyError:
pass
diff --git a/cyberdrop_dl/utils/database/tables/hash_table.py b/cyberdrop_dl/utils/database/tables/hash_table.py
index 54a794f67..4fecbd337 100644
--- a/cyberdrop_dl/utils/database/tables/hash_table.py
+++ b/cyberdrop_dl/utils/database/tables/hash_table.py
@@ -1,13 +1,16 @@
from __future__ import annotations
+
import pathlib
from sqlite3 import IntegrityError
import aiosqlite
+from rich.console import Console
from cyberdrop_dl.utils.database.table_definitions import create_hash
-from rich.console import Console
-console=Console()
+console = Console()
+
+
class HashTable:
def __init__(self, db_conn: aiosqlite.Connection):
self.db_conn: aiosqlite.Connection = db_conn
@@ -23,7 +26,7 @@ class HashTable:
result = await cursor.execute("""pragma table_info(hash)""")
result = await result.fetchall()
current_cols = [col[1] for col in result]
-
+
if "download_filename" not in current_cols:
await self.db_conn.execute("""ALTER TABLE hash RENAME COLUMN filename TO download_filename;""")
await self.db_conn.commit()
@@ -39,6 +42,7 @@ class HashTable:
if "referer" not in current_cols:
await self.db_conn.execute("""ALTER TABLE hash ADD COLUMN referer TEXT""")
await self.db_conn.commit()
+
async def get_file_hash_exists(self, full_path):
"""
Checks if a file exists in the database based on its folder, filename, and size.
@@ -61,7 +65,8 @@ class HashTable:
cursor = await self.db_conn.cursor()
# Check if the file exists with matching folder, filename, and size
- await cursor.execute("SELECT hash FROM hash WHERE folder=? AND download_filename=? AND file_size=?", (folder, filename, size))
+ await cursor.execute("SELECT hash FROM hash WHERE folder=? AND download_filename=? AND file_size=?",
+ (folder, filename, size))
result = await cursor.fetchone()
if result and result[0]:
return result[0]
@@ -70,7 +75,7 @@ class HashTable:
console.print(f"Error checking file: {e}")
return False
- async def get_files_with_hash_matches(self,hash_value,size):
+ async def get_files_with_hash_matches(self, hash_value, size):
"""
Retrieves a list of (folder, filename) tuples based on a given hash.
@@ -84,15 +89,15 @@ class HashTable:
cursor = await self.db_conn.cursor()
try:
- await cursor.execute("SELECT folder, download_filename FROM hash WHERE hash = ? and file_size=?", (hash_value,size))
+ await cursor.execute("SELECT folder, download_filename FROM hash WHERE hash = ? and file_size=?",
+ (hash_value, size))
results = await cursor.fetchall()
return results
except Exception as e:
console.print(f"Error retrieving folder and filename: {e}")
return []
-
-
- async def insert_or_update_hash_db(self, hash_value, file,original_filename,referer):
+
+ async def insert_or_update_hash_db(self, hash_value, file, original_filename, referer):
"""
Inserts or updates a record in the specified SQLite database.
@@ -107,16 +112,17 @@ class HashTable:
"""
cursor = await self.db_conn.cursor()
- full_path=pathlib.Path(file).absolute()
- file_size=full_path.stat().st_size
-
- download_filename=full_path.name
- folder=str(full_path.parent)
+ full_path = pathlib.Path(file).absolute()
+ file_size = full_path.stat().st_size
+
+ download_filename = full_path.name
+ folder = str(full_path.parent)
# Assuming a table named 'file_info' with columns: id (primary key), hash, size, filename, folder
try:
- await cursor.execute("INSERT INTO hash (hash, file_size, download_filename, folder,original_filename,referer) VALUES (?, ?, ?, ?,?,?)",
- (hash_value, file_size, download_filename, folder,original_filename,referer))
+ await cursor.execute(
+ "INSERT INTO hash (hash, file_size, download_filename, folder,original_filename,referer) VALUES (?, ?, ?, ?,?,?)",
+ (hash_value, file_size, download_filename, folder, original_filename, referer))
await self.db_conn.commit()
return True
except IntegrityError:
@@ -127,14 +133,14 @@ class HashTable:
referer= CASE WHEN ? IS NOT NULL THEN ? ELSE referer END,
original_filename = CASE WHEN ? IS NOT NULL THEN ? ELSE original_filename END
WHERE download_filename = ? AND folder = ?;""",
- (file_size,hash_value,referer,referer,original_filename,original_filename,download_filename,folder))
+ (file_size, hash_value, referer, referer, original_filename, original_filename,
+ download_filename, folder))
await self.db_conn.commit()
return True
except Exception as e:
console.print(f"Error inserting/updating record: {e}")
return False
-
async def get_all_unique_hashes(self):
"""
Retrieves a list of (folder, filename) tuples based on a given hash.
@@ -155,6 +161,3 @@ WHERE download_filename = ? AND folder = ?;""",
except Exception as e:
console.print(f"Error retrieving folder and filename: {e}")
return []
-
-
-
diff --git a/cyberdrop_dl/utils/transfer/first_time_setup.py b/cyberdrop_dl/utils/transfer/first_time_setup.py
index 26aad2287..82da4382a 100644
--- a/cyberdrop_dl/utils/transfer/first_time_setup.py
+++ b/cyberdrop_dl/utils/transfer/first_time_setup.py
@@ -149,9 +149,11 @@ class TransitionManager:
# User data transfer
new_user_data['Download_Options']['block_download_sub_folders'] = old_data['Runtime']['block_sub_folders']
- new_user_data['Download_Options']['disable_download_attempt_limit'] = old_data['Runtime']['disable_attempt_limit']
+ new_user_data['Download_Options']['disable_download_attempt_limit'] = old_data['Runtime'][
+ 'disable_attempt_limit']
new_user_data['Download_Options']['include_album_id_in_folder_name'] = old_data['Runtime']['include_id']
- new_user_data['Download_Options']['remove_generated_id_from_filenames'] = old_data['Runtime']['remove_bunkr_identifier']
+ new_user_data['Download_Options']['remove_generated_id_from_filenames'] = old_data['Runtime'][
+ 'remove_bunkr_identifier']
new_user_data['Download_Options']['separate_posts'] = old_data['Forum_Options']['separate_posts']
new_user_data['Download_Options']['skip_download_mark_completed'] = False
@@ -171,9 +173,12 @@ class TransitionManager:
new_user_data['Ignore_Options']['only_hosts'] = old_data['Ignore']['only_hosts']
new_user_data['Runtime_Options']['ignore_history'] = old_data['Ignore']['ignore_history']
- new_user_data['Runtime_Options']['skip_check_for_partial_files'] = old_data['Runtime']['skip_check_for_partial_files_and_empty_dirs']
- new_user_data['Runtime_Options']['skip_check_for_empty_folders'] = old_data['Runtime']['skip_check_for_partial_files_and_empty_dirs']
- new_user_data['Runtime_Options']['send_unsupported_to_jdownloader'] = old_data['JDownloader']['apply_jdownloader']
+ new_user_data['Runtime_Options']['skip_check_for_partial_files'] = old_data['Runtime'][
+ 'skip_check_for_partial_files_and_empty_dirs']
+ new_user_data['Runtime_Options']['skip_check_for_empty_folders'] = old_data['Runtime'][
+ 'skip_check_for_partial_files_and_empty_dirs']
+ new_user_data['Runtime_Options']['send_unsupported_to_jdownloader'] = old_data['JDownloader'][
+ 'apply_jdownloader']
new_user_data['Sorting']['sort_downloads'] = old_data['Sorting']['sort_downloads']
@@ -181,19 +186,22 @@ class TransitionManager:
new_user_data['Files']['input_file'] = "./URLs.txt"
# Global data transfer
- new_global_settings_data['General']['allow_insecure_connections'] = old_data['Runtime']['allow_insecure_connections']
+ new_global_settings_data['General']['allow_insecure_connections'] = old_data['Runtime'][
+ 'allow_insecure_connections']
new_global_settings_data['General']['user_agent'] = old_data['Runtime']['user_agent']
new_global_settings_data['General']['proxy'] = old_data['Runtime']['proxy']
new_global_settings_data['General']['max_file_name_length'] = old_data['Runtime']['max_filename_length']
new_global_settings_data['General']['max_folder_name_length'] = old_data['Runtime']['max_folder_name_length']
new_global_settings_data['General']['required_free_space'] = old_data['Runtime']['required_free_space']
- new_global_settings_data['Rate_Limiting_Options']['connection_timeout'] = old_data['Ratelimiting']['connection_timeout']
+ new_global_settings_data['Rate_Limiting_Options']['connection_timeout'] = old_data['Ratelimiting'][
+ 'connection_timeout']
new_global_settings_data['Rate_Limiting_Options']['download_attempts'] = old_data['Runtime']['attempts']
new_global_settings_data['Rate_Limiting_Options']['download_delay'] = old_data['Ratelimiting']['throttle']
new_global_settings_data['Rate_Limiting_Options']['read_timeout'] = old_data['Ratelimiting']['read_timeout']
new_global_settings_data['Rate_Limiting_Options']['rate_limit'] = old_data['Ratelimiting']['ratelimit']
- new_global_settings_data['Rate_Limiting_Options']['max_simultaneous_downloads_per_domain'] = old_data['Runtime']['max_concurrent_downloads_per_domain']
+ new_global_settings_data['Rate_Limiting_Options']['max_simultaneous_downloads_per_domain'] = \
+ old_data['Runtime']['max_concurrent_downloads_per_domain']
new_user_data['Files']['input_file'] = str(new_user_data['Files']['input_file'])
new_user_data['Files']['download_folder'] = str(new_user_data['Files']['download_folder'])
diff --git a/cyberdrop_dl/utils/transfer/transfer_v4_db.py b/cyberdrop_dl/utils/transfer/transfer_v4_db.py
index 884e4d8d2..2a2c23a42 100644
--- a/cyberdrop_dl/utils/transfer/transfer_v4_db.py
+++ b/cyberdrop_dl/utils/transfer/transfer_v4_db.py
@@ -24,7 +24,9 @@ def transfer_v4_db(db_path: Path, new_db_path: Path) -> None:
row[3] = str(Path(row[3]).parent)
old_data_revised.append(tuple(row))
- new_db_connection.executemany("insert or ignore into media (domain, url_path, referer, download_path, download_filename, original_filename, completed) values (?, ?, ?, ?, ?, ?, ?)", old_data_revised)
+ new_db_connection.executemany(
+ "insert or ignore into media (domain, url_path, referer, download_path, download_filename, original_filename, completed) values (?, ?, ?, ?, ?, ?, ?)",
+ old_data_revised)
del old_data_history
new_db_connection.commit()