Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: make sure the input file is the first group

NTFSvolumefe636d75bfb9
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 52412bb68..5a4e8260b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -26,8 +26,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
-- New `--input-folder` option that scans all `.txt` within a folder for URLs (non recursive). URLs within the same file will be a group;
- A subfolder within the downloads folder will be created for each group. See: <https://script-ware.gitbook.io/cyberdrop-dl/reference/config/sorting#group-urls>
+- New `--input-folder` option that scans all `.txt` within a folder for URLs (non recursive). URLs within the same file will create a group. The name of the group is the filename;
+ Each group will be downloaded to their own subfolder within the downloads folder. See: <https://script-ware.gitbook.io/cyberdrop-dl/reference/config/sorting#group-urls>
- New `--source` option that accepts either a file or a folder
### Changed
diff --git a/cyberdrop_dl/scrape_source.py b/cyberdrop_dl/scrape_source.py
index 4c0fb5e2f..54b63502b 100644
--- a/cyberdrop_dl/scrape_source.py
+++ b/cyberdrop_dl/scrape_source.py
@@ -68,11 +68,15 @@ async def load_items_from_folder(path: Path) -> AsyncGenerator[ScrapeItem]:
[f async for f in aio.glob(path, "*.txt") if not f.name.startswith(".")], key=lambda x: str(x).casefold()
)
for file in files:
- async with contextlib.aclosing(load_items_from_file(file)) as items:
- async for item in items:
- item.append_folders(file.stem)
- item.part_of_album = True
- yield item
+ async with contextlib.aclosing(_parse_input_file_groups(file)) as lines:
+ async for group_name, urls in lines:
+ for url in urls:
+ item = ScrapeItem.from_url(url)
+ item.append_folders(file.stem)
+ item.part_of_album = True
+ if group_name:
+ item.append_folders(group_name)
+ yield item
async def load_items_from_file(file: Path) -> AsyncGenerator[ScrapeItem]: