Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: password protected albums (chevereto) (#1235)

NTFSvolume3f3d8a1d5261
diff --git a/cyberdrop_dl/crawlers/_chevereto.py b/cyberdrop_dl/crawlers/_chevereto.py
index 3b8c483dc..5ca7a0a45 100644
--- a/cyberdrop_dl/crawlers/_chevereto.py
+++ b/cyberdrop_dl/crawlers/_chevereto.py
@@ -121,7 +121,9 @@ class CheveretoCrawler(Crawler, is_generic=True):
async for soup in self.web_pager(_sort_by_new(scrape_item.url), trim=False):
if not title:
if _is_password_protected(soup):
- soup = await self._get_soup_w_password(scrape_item)
+ await self._unlock_password_protected_album(scrape_item)
+ return await self.album(scrape_item, album_id)
+
title = self.create_title(open_graph.title(soup), album_id)
scrape_item.setup_as_album(title, album_id=album_id)
self._process_page(scrape_item, soup, results)
@@ -149,17 +151,17 @@ class CheveretoCrawler(Crawler, is_generic=True):
self.create_task(self.run(new_scrape_item))
- async def _get_soup_w_password(self, scrape_item: ScrapeItem) -> BeautifulSoup:
+ async def _unlock_password_protected_album(self, scrape_item: ScrapeItem) -> None:
password = scrape_item.pop_query("password")
if not password:
raise PasswordProtectedError
+
async with self.request_limiter:
soup = await self.client.post_data_get_soup(
- self.DOMAIN, _sort_by_new(scrape_item.url), data={"content-password": password}
+ self.DOMAIN, _sort_by_new(scrape_item.url / ""), data={"content-password": password}
)
if _is_password_protected(soup):
raise PasswordProtectedError(message="Wrong password")
- return soup
@error_handling_wrapper
async def direct_file(
diff --git a/tests/crawlers/test_cases/jpg5.py b/tests/crawlers/test_cases/jpg5.py
index fbcdb3438..ca6ea2a1f 100644
--- a/tests/crawlers/test_cases/jpg5.py
+++ b/tests/crawlers/test_cases/jpg5.py
@@ -76,4 +76,29 @@ TEST_CASES = [
],
285,
),
+ (
+ # Password protected, no password supplied
+ "https://jpg6.su/a/alyrosez.Y2Pmn",
+ [],
+ ),
+ (
+ # Password protected, incorrect password supplied
+ "https://jpg6.su/a/alyrosez.Y2Pmn?password=1234",
+ [],
+ ),
+ (
+ # Password protected, valid password supplied
+ "https://jpg6.su/a/alyrosez.Y2Pmn?password=aly",
+ [
+ {
+ "url": "https://simp2.jpg5.su/0afcc905cd6c64e52.jpg",
+ "filename": "0afcc905cd6c64e52.jpg",
+ "referer": "https://jpg6.su/img/ahfHow",
+ "datetime": None,
+ "download_folder": r"re:alyrosez \(JPG5\)",
+ "album_id": "Y2Pmn",
+ },
+ ],
+ 1065,
+ ),
]