Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
tests: add imgshot sites tests (#1204)
NTFSvolumeb9176f36d462
diff --git a/cyberdrop_dl/compat.py b/cyberdrop_dl/compat.pyindex fe55be17a..ca3f4772c 100644--- a/cyberdrop_dl/compat.py+++ b/cyberdrop_dl/compat.py@@ -44,5 +44,8 @@ else:class MayBeUpperStrEnum(StrEnum):@classmethod- def __missing__(cls: type[_EnumMemberT], value: str) -> _EnumMemberT:- return cls[value.upper()]+ def _missing_(cls, value: object):+ try:+ return cls[str(value).upper()]+ except KeyError as e:+ raise ediff --git a/cyberdrop_dl/crawlers/crawler.py b/cyberdrop_dl/crawlers/crawler.pyindex 075747053..744707775 100644--- a/cyberdrop_dl/crawlers/crawler.py+++ b/cyberdrop_dl/crawlers/crawler.py@@ -7,7 +7,6 @@ import inspectimport reimport warningsfrom abc import ABC, abstractmethod-from collections.abc import Iterable, Mappingfrom dataclasses import dataclass, fieldfrom functools import partial, wrapsfrom pathlib import Path@@ -49,7 +48,7 @@ _T_co = TypeVar("_T_co", covariant=True)if TYPE_CHECKING:- from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine, Generator+ from collections.abc import AsyncGenerator, Awaitable, Callable, Coroutine, Generator, Iterablefrom http.cookies import BaseCookiefrom aiohttp_client_cache.response import AnyResponse@@ -61,7 +60,7 @@ if TYPE_CHECKING:OneOrTuple: TypeAlias = T | tuple[T, ...]-SupportedPaths: TypeAlias = Mapping[str, OneOrTuple[str]]+SupportedPaths: TypeAlias = dict[str, OneOrTuple[str]]SupportedDomains: TypeAlias = OneOrTuple[str]@@ -201,6 +200,7 @@ class Crawler(ABC):cls.IS_FALLBACK_GENERIC = cls.NAME == "Generic"cls.IS_REAL_DEBRID = cls.NAME == "RealDebrid"cls.SUPPORTED_PATHS = _sort_supported_paths(cls.SUPPORTED_PATHS)+ cls.IS_ABC = is_abcif cls.IS_GENERIC:cls.GENERIC_NAME = generic_name or cls.NAME@@ -484,7 +484,7 @@ class Crawler(ABC):) -> tuple[str, str]:"""Wrapper around `utils.get_filename_and_ext`.Calls it as is.- If that fails, appedns `assume_ext` and tries again, but only if the user had exclude_files_with_no_extension = `False`+ If that fails, appends `assume_ext` and tries again, but only if the user had exclude_files_with_no_extension = `False`"""try:return get_filename_and_ext(filename, forum)diff --git a/tests/crawlers/test_cases/imagebam.py b/tests/crawlers/test_cases/imagebam.pynew file mode 100644index 000000000..302e3afc8--- /dev/null+++ b/tests/crawlers/test_cases/imagebam.py@@ -0,0 +1,115 @@+DOMAIN = "imagebam"+TEST_CASES = [+ (+ "https://www.imagebam.com/image/9b65e0342494935",+ [+ {+ "url": "https://images3.imagebam.com/eb/21/02/9b65e0342494935.JPG",+ "filename": "0_1456043.jpg",+ "original_filename": "9b65e0342494935.JPG",+ "referer": "https://www.imagebam.com/image/9b65e0342494935",+ "album_id": None,+ },+ ],+ ),+ (+ "https://images3.imagebam.com/eb/21/02/9b65e0342494935.JPG",+ [+ {+ "url": "https://images3.imagebam.com/eb/21/02/9b65e0342494935.JPG",+ "filename": "0_1456043.jpg",+ "original_filename": "9b65e0342494935.JPG",+ "referer": "https://www.imagebam.com/image/9b65e0342494935",+ "album_id": None,+ },+ ],+ ),+ (+ "https://thumbs3.imagebam.com/eb/21/02/9b65e0342494935.JPG",+ [+ {+ "url": "https://images3.imagebam.com/eb/21/02/9b65e0342494935.JPG",+ "filename": "0_1456043.jpg",+ "original_filename": "9b65e0342494935.JPG",+ "referer": "https://www.imagebam.com/image/9b65e0342494935",+ "album_id": None,+ },+ ],+ ),+ (+ "https://www.imagebam.com/gallery/hfqrglgtcf4u143xlnvkpfksofn1et7w",+ [+ {+ "url": "https://images3.imagebam.com/68/8f/e5/84105c342494938.jpg",+ "filename": "main_large.jpg",+ "original_filename": "84105c342494938.jpg",+ "referer": "https://www.imagebam.com/image/84105c342494938",+ "album_id": "hfqrglgtcf4u143xlnvkpfksofn1et7w",+ },+ {+ "url": "https://images3.imagebam.com/eb/21/02/9b65e0342494935.JPG",+ "filename": "0_1456043.jpg",+ "original_filename": "9b65e0342494935.JPG",+ "referer": "https://www.imagebam.com/image/9b65e0342494935",+ "album_id": "hfqrglgtcf4u143xlnvkpfksofn1et7w",+ },+ {+ "url": "https://images3.imagebam.com/5a/bd/a1/764c40342494934.JPG",+ "filename": "0_1456042.jpg",+ "original_filename": "764c40342494934.JPG",+ "referer": "https://www.imagebam.com/image/764c40342494934",+ "album_id": "hfqrglgtcf4u143xlnvkpfksofn1et7w",+ },+ {+ "url": "https://images3.imagebam.com/c0/12/7d/889be4342494931.JPG",+ "filename": "0_1456039.jpg",+ "original_filename": "889be4342494931.JPG",+ "referer": "https://www.imagebam.com/image/889be4342494931",+ "album_id": "hfqrglgtcf4u143xlnvkpfksofn1et7w",+ },+ ],+ ),+ (+ "https://www.imagebam.com/view/ME5IIKF",+ [+ {+ "url": "https://images4.imagebam.com/d0/99/a7/ME5IIKF_o.png",+ "filename": "Logic.png",+ "original_filename": "ME5IIKF_o.png",+ "referer": "https://www.imagebam.com/view/ME5IIKF",+ "album_id": None,+ },+ ],+ ),+ (+ "https://www.imagebam.com/view/GA2LOS",+ [+ {+ "url": "https://images4.imagebam.com/4b/b6/4a/ME5IIKH_o.png",+ "filename": "Pads Logic.png",+ "original_filename": "ME5IIKH_o.png",+ "referer": "https://www.imagebam.com/view/ME5IIKH",+ "album_id": "GA2LOS",+ },+ ],+ 4,+ ),+ (+ "https://thumbs4.imagebam.com/e5/ab/48/ME5IIKD_t.png",+ [+ {+ "url": "https://images4.imagebam.com/e5/ab/48/ME5IIKD_o.png",+ "referer": "https://www.imagebam.com/view/ME5IIKD",+ },+ ],+ ),+ (+ "https://images4.imagebam.com/e5/ab/48/ME5IIKD_o.png",+ [+ {+ "url": "https://images4.imagebam.com/e5/ab/48/ME5IIKD_o.png",+ "referer": "https://www.imagebam.com/view/ME5IIKD",+ },+ ],+ ),+]diff --git a/tests/crawlers/test_cases/imagetwist.py b/tests/crawlers/test_cases/imagetwist.pynew file mode 100644index 000000000..e811faeb5--- /dev/null+++ b/tests/crawlers/test_cases/imagetwist.py@@ -0,0 +1,35 @@+DOMAIN = "imagetwist.com"+TEST_CASES = [+ (+ "https://imagetwist.com/uynrhb4lavce/Latoya14.jpg",+ [+ {+ "url": "https://img115.imagetwist.com/i/20566/uynrhb4lavce.jpg/Latoya14.jpg",+ "filename": "Latoya14.jpg",+ "referer": "https://imagetwist.com/uynrhb4lavce",+ "album_id": None,+ "datetime": None,+ }+ ],+ ),+ (+ "https://img115.imagetwist.com/i/20566/uynrhb4lavce.jpg/Latoya14.jpg",+ [+ {+ "url": "https://img115.imagetwist.com/i/20566/uynrhb4lavce.jpg/Latoya14.jpg",+ "filename": "Latoya14.jpg",+ "referer": "https://imagetwist.com/uynrhb4lavce",+ }+ ],+ ),+ (+ "https://img115.imagetwist.com/th/20566/uynrhb4lavce.jpg",+ [+ {+ "url": "https://img115.imagetwist.com/i/20566/uynrhb4lavce.jpg/Latoya14.jpg",+ "filename": "Latoya14.jpg",+ "referer": "https://imagetwist.com/uynrhb4lavce",+ }+ ],+ ),+]diff --git a/tests/crawlers/test_cases/imagevenue.py b/tests/crawlers/test_cases/imagevenue.pynew file mode 100644index 000000000..ce3455803--- /dev/null+++ b/tests/crawlers/test_cases/imagevenue.py@@ -0,0 +1,38 @@+DOMAIN = "www.imagevenue.com"+TEST_CASES = [+ (+ "https://www.imagevenue.com/ME1BEWWG",+ [+ {+ "url": "https://cdn-images.imagevenue.com/65/8b/4d/ME1BEWWG_o.jpg",+ "filename": "001.jpg",+ "original_filename": "ME1BEWWG_o.jpg",+ "referer": "https://www.imagevenue.com/ME1BEWWG",+ "album_id": None,+ "datetime": None,+ }+ ],+ ),+ (+ "https://cdn-thumbs.imagevenue.com/d2/90/5c/ME1BEWWG_t.jpg",+ [+ {+ "url": "https://cdn-images.imagevenue.com/65/8b/4d/ME1BEWWG_o.jpg",+ "referer": "https://www.imagevenue.com/ME1BEWWG",+ }+ ],+ ),+ (+ "https://cdn-images.imagevenue.com/d2/90/5c/ME1BEWWG_o.jpg",+ [+ {+ "url": "https://cdn-images.imagevenue.com/65/8b/4d/ME1BEWWG_o.jpg",+ "filename": "001.jpg",+ "original_filename": "ME1BEWWG_o.jpg",+ "referer": "https://www.imagevenue.com/ME1BEWWG",+ "album_id": None,+ "datetime": None,+ }+ ],+ ),+]diff --git a/tests/crawlers/test_cases/imgadult.py b/tests/crawlers/test_cases/imgadult.pynew file mode 100644index 000000000..19d5933ea--- /dev/null+++ b/tests/crawlers/test_cases/imgadult.py@@ -0,0 +1,21 @@+DOMAIN = "imgadult.com"+TEST_CASES = [+ (+ "https://imgadult.com/img-685761cc22595.html",+ [+ {+ "url": "https://imgadult.com/upload/big/2025/06/22/685761cc22593.jpg",+ "filename": "1092.jpg",+ "original_filename": "685761cc22593.jpg",+ "referer": "https://imgadult.com/img-685761cc22595.html",+ "album_id": None,+ "datetime": None,+ }+ ],+ ),+ (+ "https://imgadult.com/upload/big/2025/06/22/685761cc22593.jpg",+ # IDs of thumbnails and src images are diferent. CDL should fail+ [],+ ),+]diff --git a/tests/crawlers/test_cases/imx_to.py b/tests/crawlers/test_cases/imx_to.pynew file mode 100644index 000000000..4489e5de3--- /dev/null+++ b/tests/crawlers/test_cases/imx_to.py@@ -0,0 +1,80 @@+DOMAIN = "imx.to"+TEST_CASES = [+ (+ "https://imx.to/i/65axjs",+ [+ {+ "url": "https://imx.to/u/i/2025/06/07/65axjs.jpg",+ "filename": "MetArt_Aperi_Melena-A_high_0014.jpg",+ "referer": "https://imx.to/i/65axjs",+ "album_id": None,+ "datetime": None,+ }+ ],+ ),+ (+ "https://imx.to/u/i/2025/06/07/65axjs.jpg",+ [+ {+ "url": "https://imx.to/u/i/2025/06/07/65axjs.jpg",+ "filename": "MetArt_Aperi_Melena-A_high_0014.jpg",+ "referer": "https://imx.to/i/65axjs",+ "album_id": None,+ "datetime": None,+ }+ ],+ ),+ (+ "https://i006.imx.to/i/2025/06/07/65axjs.jpg",+ [+ {+ "url": "https://imx.to/u/i/2025/06/07/65axjs.jpg",+ "filename": "MetArt_Aperi_Melena-A_high_0014.jpg",+ "referer": "https://imx.to/i/65axjs",+ "album_id": None,+ "datetime": None,+ }+ ],+ ),+ (+ "https://imx.to/g/1g79u",+ [+ {+ "url": "https://imx.to/u/i/2025/08/01/68g6y2.jpg",+ "filename": "525669511_18517410283043270_6195144073773837855_n.jpg",+ "referer": "https://imx.to/i/68g6y2",+ "album_id": "1g79u",+ "datetime": None,+ "download_folder": "re:Krysten Ritter",+ },+ {+ "url": "https://imx.to/u/i/2025/08/01/68g6y1.jpg",+ "filename": "526533280_18517410292043270_6754984459144566137_n.jpg",+ "referer": "https://imx.to/i/68g6y1",+ "album_id": "1g79u",+ "datetime": None,+ },+ {+ "url": "https://imx.to/u/i/2025/08/01/68g6y3.jpg",+ "filename": "526584742_18517410271043270_3904521829833264252_n.jpg",+ "referer": "https://imx.to/i/68g6y3",+ "album_id": "1g79u",+ "datetime": None,+ },+ {+ "url": "https://imx.to/u/i/2025/08/01/68g6y6.jpg",+ "filename": "527219092_18517410241043270_3327959031452792252_n.jpg",+ "referer": "https://imx.to/i/68g6y6",+ "album_id": "1g79u",+ "datetime": None,+ },+ {+ "url": "https://imx.to/u/i/2025/08/01/68g6y4.jpg",+ "filename": "527328982_18517410262043270_2644574510604077618_n.jpg",+ "referer": "https://imx.to/i/68g6y4",+ "album_id": "1g79u",+ "datetime": None,+ },+ ],+ ),+]diff --git a/tests/crawlers/test_cases/picstate.py b/tests/crawlers/test_cases/picstate.pynew file mode 100644index 000000000..1eac6248b--- /dev/null+++ b/tests/crawlers/test_cases/picstate.py@@ -0,0 +1,35 @@+DOMAIN = "picstate.com"+TEST_CASES = [+ (+ "https://picstate.com/view/full/5391859_e3p1g",+ [+ {+ "url": "https://picstate.com/files/5391859_e3p1g/Naked_Diva__2005_.jpg",+ "filename": "Naked_Diva__2005_.jpg",+ "referer": "https://picstate.com/view/full/5391859_e3p1g",+ "album_id": None,+ "datetime": None,+ }+ ],+ ),+ (+ "https://picstate.com/files/5391859_e3p1g/Naked_Diva__2005_.jpg",+ [+ {+ "url": "https://picstate.com/files/5391859_e3p1g/Naked_Diva__2005_.jpg",+ "filename": "Naked_Diva__2005_.jpg",+ "referer": "https://picstate.com/view/full/5391859_e3p1g",+ }+ ],+ ),+ (+ "https://picstate.com/thumbs/small/5391859_e3p1g/Naked_Diva__2005_.jpg",+ [+ {+ "url": "https://picstate.com/files/5391859_e3p1g/Naked_Diva__2005_.jpg",+ "filename": "Naked_Diva__2005_.jpg",+ "referer": "https://picstate.com/view/full/5391859_e3p1g",+ }+ ],+ ),+]diff --git a/tests/crawlers/test_cases/pixhost.py b/tests/crawlers/test_cases/pixhost.pyindex 51b49f185..8dbcf6707 100644--- a/tests/crawlers/test_cases/pixhost.py+++ b/tests/crawlers/test_cases/pixhost.py@@ -7,8 +7,32 @@ TEST_CASES = ["url": "https://img100.pixhost.to/images/491/538303562_035.jpg","filename": "538303562_035.jpg","referer": "https://pixhost.to/show/491/538303562_035.jpg",- "album_id": None, # TODO: get the album id for individual images+ "album_id": None,},],),+ (+ "https://t100.pixhost.to/thumbs/491/538303428_001.jpg",+ [+ {+ "url": "https://img100.pixhost.to/images/491/538303428_001.jpg",+ "filename": "538303428_001.jpg",+ "referer": "https://pixhost.to/show/491/538303428_001.jpg",+ "album_id": None,+ },+ ],+ ),+ (+ "https://pixhost.to/gallery/pgv5s",+ [+ {+ "url": "https://img31.pixhost.to/images/183/107062500_instasave.jpg",+ "filename": "107062500_instasave.jpg",+ "referer": "https://pixhost.to/show/183/107062500_instasave.jpg",+ "album_id": "pgv5s",+ "download_path": "re:Untitled Gallery",+ },+ ],+ 7,+ ),]diff --git a/tests/crawlers/test_cases/vipr_im.py b/tests/crawlers/test_cases/vipr_im.pynew file mode 100644index 000000000..facdfbf23--- /dev/null+++ b/tests/crawlers/test_cases/vipr_im.py@@ -0,0 +1,36 @@+DOMAIN = "vipr.im"+TEST_CASES = [+ (+ "https://vipr.im/t2o2z36omvt6",+ [+ {+ "url": "https://i7.vipr.im/i/12757/t2o2z36omvt6.jpg/luna_rishi-solo1-highres-012.jpg",+ "filename": "luna_rishi-solo1-highres-012.jpg",+ "referer": "https://vipr.im/t2o2z36omvt6",+ "album_id": None,+ },+ ],+ ),+ (+ "https://i7.vipr.im/i/12757/t2o2z36omvt6.jpg/luna_rishi-solo1-highres-012.jpg",+ [+ {+ "url": "https://i7.vipr.im/i/12757/t2o2z36omvt6.jpg/luna_rishi-solo1-highres-012.jpg",+ "filename": "luna_rishi-solo1-highres-012.jpg",+ "referer": "https://vipr.im/t2o2z36omvt6",+ "album_id": None,+ },+ ],+ ),+ (+ "https://i6.vipr.im/th/12757/t2o2z36omvt6.jpg",+ [+ {+ "url": "https://i7.vipr.im/i/12757/t2o2z36omvt6.jpg/luna_rishi-solo1-highres-012.jpg",+ "filename": "luna_rishi-solo1-highres-012.jpg",+ "referer": "https://vipr.im/t2o2z36omvt6",+ "album_id": None,+ },+ ],+ ),+]