Skip to content

Bulk asynchronous downloader for multiple file hosts

Change check-for-partial-files-and-empty-dirs flag logic (#511)

Arkadiy Illarionovab0b1677ede5
diff --git a/README.md b/README.md
index 53e90aa1d..2fc8580c2 100644
--- a/README.md
+++ b/README.md
@@ -63,7 +63,7 @@ Read the [Wiki](https://github.com/Jules-WinnfieldX/CyberDropDownloader/wiki/)!
| XBunker | Thread: xbunker.nu/threads/... <br> Continue from (will download this post and after): xbunker.nu/threads/...post-NUMBER |
| XBunkr | Album: xbunkr.com/a/... <br> Direct Links: media.xbunkr.com/... |
-Reminder to leave the link full (include the https://)
+Reminder to leave the link full (include the `https://`)
## Information
@@ -71,18 +71,18 @@ Reminder to leave the link full (include the https://)
You can get Python from here: <https://www.python.org/downloads/>
-Make sure you tick the check box for "Add python to path"
+Make sure you tick the check box for "Add Python to PATH"
![alt text](https://simp2.jpg.church/PATHe426c23371048def.png)
-Mac users will also likely need to open terminal and execute the following command: `xcode-select --install`
+macOS users will also likely need to open terminal and execute the following command: `xcode-select --install`
## Script Method
Go to the [releases page](https://github.com/Jules-WinnfieldX/CyberDropDownloader/releases) and download the Cyberdrop_DL.zip file. Extract it to wherever you want the program to be.
-Put the links in the URLs.txt file then run `Start Windows.bat` (Windows) or `Start Mac.command` (OS X) or `Start Linux.sh` (Linux).
+Put the links in the URLs.txt file then run `Start Windows.bat` (Windows) or `Start Mac.command` (macOS) or `Start Linux.sh` (Linux).
-** Mac users will need to run the command `chmod +x 'Start Mac.command'` to make the file executable.
+**macOS users will need to run the command `chmod +x 'Start Mac.command'` to make the file executable.**
## CLI Method
@@ -90,7 +90,7 @@ Run `pip3 install cyberdrop-dl` in command prompt/terminal
Advanced users may want to use virtual environments (via `pipx`), but it's **NOT** required.
-**pipx is now required for some linux distros.**
+**pipx is now required for some Linux distros.**
1. Run `cyberdrop-dl` once to generate an empty `URLs.txt` file.
2. Copy and paste your links into `URLs.txt`.
@@ -139,29 +139,30 @@ optional arguments:
--skip-coomer-ads enabling this, will remove advertisements for other models pages from scrapes of a profile.
--skip-hosts doesn't allow downloads and scraping from these hosts
---allow-insecure-connections allows insecure connections from content hosts
---attempts number of attempts to download each file
---block-sub-folders block sub folders from being created
---disable-attempt-limit disables the attempt limitation
---filesize-maximum-images maximum filesize for images (in bytes)
---filesize-maximum-videos maximum filesize for videos (in bytes)
---filesize-maximum-other maximum filesize for other files (in bytes)
---filesize-minimum-images minimum filesize for images (in bytes)
---filesize-minimum-videos minimum filesize for videos (in bytes)
---filesize-minimum-other minimum filesize for other files (in bytes)
---include-id include the ID in the download folder name
---max-concurrent-threads number of threads to download simultaneously
---max-concurrent-domains number of domains to download simultaneously
---max-concurrent-albums number of albums to download simultaneously
---max-concurrent-downloads-per-domain number of simultaneous downloads per domain
---max-filename-length maximum filename length
---max-folder-name-length maximum folder name length
---skip-download-mark-completed sets the scraped files as downloaded without downloading
---output-errored-urls sets the failed urls to be output to the errored urls file
---output-unsupported-urls sets the unsupported urls to be output to the unsupported urls file
---proxy HTTP/HTTPS proxy used for downloading, format [protocol]://[ip]:[port]
---remove-bunkr-identifier removes the bunkr added identifier from output filenames
---required-free-space required free space (in gigabytes) for the program to run
+--allow-insecure-connections allows insecure connections from content hosts
+--attempts number of attempts to download each file
+--block-sub-folders block sub folders from being created
+--disable-attempt-limit disables the attempt limitation
+--filesize-maximum-images maximum filesize for images (in bytes)
+--filesize-maximum-videos maximum filesize for videos (in bytes)
+--filesize-maximum-other maximum filesize for other files (in bytes)
+--filesize-minimum-images minimum filesize for images (in bytes)
+--filesize-minimum-videos minimum filesize for videos (in bytes)
+--filesize-minimum-other minimum filesize for other files (in bytes)
+--include-id include the ID in the download folder name
+--max-concurrent-threads number of threads to download simultaneously
+--max-concurrent-domains number of domains to download simultaneously
+--max-concurrent-albums number of albums to download simultaneously
+--max-concurrent-downloads-per-domain number of simultaneous downloads per domain
+--max-filename-length maximum filename length
+--max-folder-name-length maximum folder name length
+--skip-check-for-partial-files-and-empty-dirs skip checks for partial files and empty directories after completing
+--skip-download-mark-completed sets the scraped files as downloaded without downloading
+--output-errored-urls sets the failed urls to be output to the errored urls file
+--output-unsupported-urls sets the unsupported urls to be output to the unsupported urls file
+--proxy HTTP/HTTPS proxy used for downloading, format [protocol]://[ip]:[port]
+--remove-bunkr-identifier removes the bunkr added identifier from output filenames
+--required-free-space required free space (in gigabytes) for the program to run
--sort-downloads sorts downloaded files after downloads have finished
--sort-directory folder to download files to
diff --git a/cyberdrop_dl/base_functions/config_schema.py b/cyberdrop_dl/base_functions/config_schema.py
index 5611eb462..ba832faee 100644
--- a/cyberdrop_dl/base_functions/config_schema.py
+++ b/cyberdrop_dl/base_functions/config_schema.py
@@ -78,7 +78,6 @@ config_default: Dict = {
"allow_insecure_connections": False,
"attempts": 10,
"block_sub_folders": False,
- "check_for_partial_files_and_empty_dirs": True,
"disable_attempt_limit": False,
"filesize_minimum_images": 0,
"filesize_minimum_other": 0,
@@ -98,6 +97,7 @@ config_default: Dict = {
"proxy": "",
"remove_bunkr_identifier": False,
"required_free_space": 5,
+ "skip_check_for_partial_files_and_empty_dirs": False,
"skip_download_mark_completed": False,
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/112.0",
},
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py
index 51aa1bc8d..af3c816cd 100644
--- a/cyberdrop_dl/main.py
+++ b/cyberdrop_dl/main.py
@@ -8,7 +8,7 @@ from pathlib import Path
from typing import Dict, List, Tuple
import aiofiles
-import aiorun as aiorun
+import aiorun
from yarl import URL
from cyberdrop_dl.base_functions.base_functions import (
@@ -75,7 +75,6 @@ def parse_args() -> argparse.Namespace:
runtime_opts.add_argument("--allow-insecure-connections", help="allows insecure connections from content hosts", action="store_true")
runtime_opts.add_argument("--attempts", type=int, help="number of attempts to download each file (default: %(default)s)", default=config_group["attempts"])
runtime_opts.add_argument("--block-sub-folders", help="block sub folders from being created", action="store_true")
- runtime_opts.add_argument("--check-for-partial-files-and-empty-dirs", type=bool, default=config_group["check_for_partial_files_and_empty_dirs"], help="checks for partial files and empty directories after completing (default: %(default)s)")
runtime_opts.add_argument("--disable-attempt-limit", help="disables the attempt limitation", action="store_true")
runtime_opts.add_argument("--filesize-maximum-images", type=int, default=config_group["filesize_maximum_images"], help="maximum filesize for images (in bytes) (default: %(default)s)")
runtime_opts.add_argument("--filesize-maximum-videos", type=int, default=config_group["filesize_maximum_videos"], help="maximum filesize for videos (in bytes) (default: %(default)s)")
@@ -90,6 +89,7 @@ def parse_args() -> argparse.Namespace:
runtime_opts.add_argument("--max-concurrent-downloads-per-domain", type=int, default=config_group["max_concurrent_downloads_per_domain"], help="Number of simultaneous downloads per domain (default: %(default)s)")
runtime_opts.add_argument("--max-filename-length", type=int, default=config_group["max_filename_length"], help="maximum filename length (default: %(default)s)")
runtime_opts.add_argument("--max-folder-name-length", type=int, default=config_group["max_folder_name_length"], help="maximum folder name length (default: %(default)s)")
+ runtime_opts.add_argument("--skip-check-for-partial-files-and-empty-dirs", help="skip checks for partial files and empty directories after completing", action="store_true")
runtime_opts.add_argument("--skip-download-mark-completed", help="sets the scraped files as downloaded without downloading", action="store_true")
runtime_opts.add_argument("--output-errored-urls", help="sets the failed urls to be output to the errored urls file", action="store_true")
runtime_opts.add_argument("--output-unsupported-urls", help="sets the unsupported urls to be output to the unsupported urls file", action="store_true")
@@ -266,14 +266,12 @@ async def scrape_links(scraper: ScrapeMapper, links: List, quiet=False) -> Forum
async def check_outdated(client: Client):
session = ScrapeSession(client)
url = URL('https://pypi.python.org/pypi/cyberdrop-dl/json')
- try:
+ with contextlib.suppress(Exception):
response = await session.get_json(url)
if response['info']['version'] != VERSION:
log(f"\nYour version of Cyberdrop Downloader is outdated. \nYou are running version {VERSION}."
f"\nPlease update to version {response['info']['version']}"
f"\nYou can find out how to do that here: https://github.com/Jules-WinnfieldX/CyberDropDownloader/wiki/Frequently-Asked-Questions#how-to-update", style="red")
- except Exception as e:
- pass
async def director(args: Dict, links: List) -> None:
@@ -321,7 +319,7 @@ async def director(args: Dict, links: List) -> None:
await sorter.sort()
log("")
- if args['Runtime']['check_for_partial_files_and_empty_dirs']:
+ if not args['Runtime']['skip_check_for_partial_files_and_empty_dirs']:
log("Checking for incomplete downloads")
partial_downloads = any(f.is_file() for f in args['Files']['output_folder'].rglob("*.part"))
temp_downloads = any(Path(f).is_file() for f in await SQL_Helper.get_temp_names())