From 0c0197f26564bccfd30adcd893919ee6288607b8 Mon Sep 17 00:00:00 2001 From: Jules-WinnfieldX Date: Sat, 15 Jun 2024 11:16:06 -0600 Subject: [PATCH] Add explicit error for no download button on cyberfile --- cyberdrop_dl/__init__.py | 2 +- cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py | 14 +++++++++----- pyproject.toml | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py index a51c28dcd..a7c419667 100644 --- a/cyberdrop_dl/__init__.py +++ b/cyberdrop_dl/__init__.py @@ -1 +1 @@ -__version__ = "5.3.26" +__version__ = "5.3.27" diff --git a/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py b/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py index 2204b30b4..7b0ec9178 100644 --- a/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py +++ b/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py @@ -8,7 +8,7 @@ from bs4 import BeautifulSoup from yarl import URL -from cyberdrop_dl.clients.errors import PasswordProtected +from cyberdrop_dl.clients.errors import PasswordProtected, ScrapeFailure from cyberdrop_dl.scraper.crawler import Crawler from cyberdrop_dl.utils.dataclasses.url_objects import ScrapeItem from cyberdrop_dl.utils.utilities import error_handling_wrapper, log, get_filename_and_ext @@ -152,10 +152,14 @@ async def handle_content_id(self, scrape_item: ScrapeItem, contentId: int) -> No file_menu = ajax_soup.select_one('ul[class="dropdown-menu dropdown-info account-dropdown-resize-menu"] li a') file_button = ajax_soup.select_one('div[class="btn-group responsiveMobileMargin"] button') - if file_menu: - html_download_text = file_menu.get("onclick") - else: - html_download_text = file_button.get("onclick") + try: + if file_menu: + html_download_text = file_menu.get("onclick") + else: + html_download_text = file_button.get("onclick") + except AttributeError: + await log(f"Couldn't find download button for {scrape_item.url}", 30) + raise ScrapeFailure(422, "Couldn't find download button") link = URL(html_download_text.split("'")[1]) file_detail_table = ajax_soup.select('table[class="table table-bordered table-striped"]')[-1] diff --git a/pyproject.toml b/pyproject.toml index d65fbd05e..b09a03f78 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cyberdrop-dl" -version = "5.3.26" +version = "5.3.27" description = "Bulk downloader for multiple file hosts" authors = ["Jules Winnfield "] readme = "README.md"