Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: force album_id for some crawlers

NTFSvolumed8fb1e1171b0
diff --git a/cyberdrop_dl/crawlers/crawler.py b/cyberdrop_dl/crawlers/crawler.py
index 5cdcc2d12..1e5a45dd6 100644
--- a/cyberdrop_dl/crawlers/crawler.py
+++ b/cyberdrop_dl/crawlers/crawler.py
@@ -724,9 +724,18 @@ class Crawler(HTTPMixin, HLSMixin, ABC):
return False
@final
- def create_title(self, title: str, album_id: str | None = None, thread_id: int | None = None) -> str:
+ def create_title(
+ self, title: str, album_id: str | None = None, thread_id: int | None = None, *, force_album_id: bool = False
+ ) -> str:
"""Creates the title for the scrape item."""
- return compose_title(self.config, self.FOLDER_DOMAIN, title, album_id, thread_id)
+ return compose_title(
+ self.config,
+ self.FOLDER_DOMAIN,
+ title,
+ album_id,
+ thread_id,
+ force_album_id=force_album_id,
+ )
@final
def create_separate_post_title(
@@ -1148,16 +1157,18 @@ def _prepare_download_path(item: ScrapeItem, domain: str) -> Path:
return path
-def compose_title(
+def compose_title( # noqa: PLR0913
config: Config,
domain: str,
title: str,
album_id: str | None = None,
thread_id: int | None = None,
+ *,
+ force_album_id: bool = False,
) -> str:
title = (title or "Untitled").strip()
- if album_id and config.subfolders.include.album_id:
+ if album_id and (force_album_id or config.subfolders.include.album_id):
title = f"{title} {album_id}"
if thread_id and config.subfolders.include.thread_id:
diff --git a/cyberdrop_dl/crawlers/pixhost.py b/cyberdrop_dl/crawlers/pixhost.py
index bb25ec24c..27290f1e9 100644
--- a/cyberdrop_dl/crawlers/pixhost.py
+++ b/cyberdrop_dl/crawlers/pixhost.py
@@ -50,9 +50,7 @@ class PixHostCrawler(Crawler):
async def gallery(self, scrape_item: ScrapeItem, album_id: str) -> None:
soup = await self.request_soup(scrape_item.url)
title = css.select_text(soup, Selector.GALLERY_TITLE)
- if title.casefold() == "untitled gallery" and not self.config.subfolders.include.album_id:
- title = f"{title} {album_id}"
- title = self.create_title(title, album_id)
+ title = self.create_title(title, album_id, force_album_id=title.casefold() == "untitled gallery")
scrape_item.setup_as_album(title, album_id=album_id)
should_download = await self.make_album_checker(album_id)
urls = map(_thumbnail_to_src, self.iter_urls(soup, Selector.GALLERY_IMAGES, "src"))