Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Fix download of text files (#514)
mullertremolod2a2e4b73f4b
diff --git a/cyberdrop_dl/base_functions/base_functions.py b/cyberdrop_dl/base_functions/base_functions.pyindex 18b48e6c3..dcfa10e6d 100644--- a/cyberdrop_dl/base_functions/base_functions.py+++ b/cyberdrop_dl/base_functions/base_functions.py@@ -39,6 +39,10 @@ FILE_FORMATS = {},'Audio': {'.mp3', '.flac', '.wav', '.m4a',+ },+ 'Text': {+ '.htm', '.html', '.md', '.nfo',+ '.txt',}}diff --git a/cyberdrop_dl/client/client.py b/cyberdrop_dl/client/client.pyindex 46ec6627d..b7b3a2346 100644--- a/cyberdrop_dl/client/client.py+++ b/cyberdrop_dl/client/client.py@@ -15,17 +15,16 @@ import certififrom aiolimiter import AsyncLimiterfrom bs4 import BeautifulSoupfrom multidict import CIMultiDictProxy+from pathlib import Pathfrom tqdm import tqdmfrom yarl import URL-from ..base_functions.base_functions import logger+from ..base_functions.base_functions import logger, FILE_FORMATSfrom ..base_functions.error_classes import DownloadFailure, InvalidContentTypeFailurefrom ..downloader.downloader_utils import CustomHTTPStatusfrom ..downloader.progress_definitions import ProgressMaster, adjust_titleif TYPE_CHECKING:- from pathlib import Path-from rich.progress import TaskIDfrom ..base_functions.data_classes import MediaItem@@ -170,7 +169,9 @@ class DownloadSession:raise DownloadFailure(code=CustomHTTPStatus.IM_A_TEAPOT, message="No content-type in response header")if resp.url in self.bunkr_maintenance:raise DownloadFailure(code=HTTPStatus.SERVICE_UNAVAILABLE, message="Bunkr under maintenance")- if any(s in content_type.lower() for s in ('html', 'text')):++ extname = Path(media.filename).suffix.lower()+ if any(s in content_type.lower() for s in ('html', 'text')) and extname not in FILE_FORMATS['Text']:logger.debug("Server for %s is experiencing issues, you are being ratelimited, or cookies have expired", media.url)raise DownloadFailure(code=CustomHTTPStatus.IM_A_TEAPOT, message="Unexpectedly got text as response")