Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
tests: delete tmp cwd after each successful test
NTFSvolume11d94b9485ae
diff --git a/pyproject.toml b/pyproject.tomlindex 091c53d27..036af454a 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -1,6 +1,6 @@[project]name = "cyberdrop-dl-patched"-version = "10.12.1"+version = "10.13.0dev0"authors = [{name = "Jacob B", email = "[email protected]"}]classifiers = ["Development Status :: 5 - Production/Stable",@@ -86,7 +86,7 @@ requires = ["uv_build>=0.13.0,<0.14.0"][dependency-groups]dev = [- "prek>=0.5.5",+ "prek>=0.5.7","pytest-asyncio>=1.4.0","pytest>=9.1.1","ruff>=0.17.1,<0.18.0"@@ -135,6 +135,8 @@ markers = [minversion = "9.1.1"strict_config = truestrict_markers = true+tmp_path_retention_count = "0"+tmp_path_retention_policy = "failed"[tool.ruff]line-length = 120diff --git a/tests/conftest.py b/tests/conftest.pyindex bd589e807..76fa7b2e1 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -10,7 +10,6 @@ from cyberdrop_dl.manager import Managerif TYPE_CHECKING:from collections.abc import AsyncGenerator, Generator- from pathlib import Pathif TYPE_CHECKING:@@ -53,6 +52,19 @@ def pytest_collection_modifyitems(config: PyTestConfig, items: list[pytest.Item]items[:] = selected_tests+def pytest_sessionstart(session: object) -> None: # noqa: ARG001+ import shutil+ import tempfile++ tmp_root = Path(tempfile.gettempdir())+ free = shutil.disk_usage(tmp_root).free++ required = 1e9+ if tmp_root == Path("/tmp") and free < required: # noqa: S108+ print(f"\n Warning: Only {free // required}MB free in {tmp_root}")+ print("Consider running with: TMPDIR=/var/tmp/pytest\n")++@pytest.fixture(autouse=True)def tmp_cwd(tmp_path: Path) -> Generator[Path]:with pytest.MonkeyPatch.context() as m:diff --git a/tests/crawlers/test_pawchive.py b/tests/crawlers/test_pawchive.pydeleted file mode 100644index 80a28153b..000000000--- a/tests/crawlers/test_pawchive.py+++ /dev/null@@ -1,148 +0,0 @@-import asyncio-import datetime as dt-from typing import Any--import aiohttp-import pytest--from cyberdrop_dl import env-from cyberdrop_dl.crawlers.kemono.kemono import _extract_urls, _has_ads-from cyberdrop_dl.crawlers.kemono.models import Embed, File, UserPostModel, _parse_tags--pytestmark = pytest.mark.http-pytestmark = pytest.mark.skipif(env.CI, reason="Skip requests")---def request_json(url: str) -> Any:- async def fetch():- async with aiohttp.request("GET", url) as resp:- return await resp.json(encoding="utf8", content_type=None)-- return asyncio.run(fetch())--[email protected](scope="session")-def post_resp() -> dict[str, Any]:- resp = request_json("https://pawchive.pw/api/v1/patreon/user/3295915/post/129540190/revisions")- return next(p for p in resp if p["revision_id"] == 59409)--[email protected](scope="session")-def post_resp_w_embeds() -> dict[str, Any]:- return request_json("https://pawchive.pw/api/v1/patreon/user/47101380/post/128071303")---def post(post_resp: dict[str, Any]) -> UserPostModel:- return UserPostModel.model_validate(post_resp)---def test_post_validation(post_resp: dict[str, Any]) -> None:- post = UserPostModel.model_validate(post_resp)- assert post.id == "129540190"- assert post.content- assert (- "<p>Hey everyone! Its been a long time in the making. I'm really proud of this one and I hope you all like is as much as I do!"- in post.content- )- assert post.file == File(- path="/4f/3a/4f3a65f8e123dfc1fb0a91ae7f001b598c96135695e977701daf55d528145d74.png",- name="Timeline 1_0242.00_08_06_14.Still002.png",- server=None,- deferred=False,- )- assert post.attachments == (- File(- path="/4f/3a/4f3a65f8e123dfc1fb0a91ae7f001b598c96135695e977701daf55d528145d74.png",- name="Timeline 1_0242.00_08_06_14.Still002.png",- server=None,- ),- )- assert post.published == dt.datetime(2025, 5, 21, 18, 11, 4, tzinfo=dt.UTC)- assert post.added- assert post.added.date() >= dt.date(2026, 6, 11)- assert post.edited- assert post.edited > dt.datetime(2026, 7, 8, 3, 11, 18, tzinfo=dt.UTC)- assert post.timestamp == 1747851064- assert post.tags == ("Animation", "Announcement")- assert post.embed is None- assert post.has_full is True- assert post.service == "patreon"- assert post.user_id == "3295915"- assert post.title == "DANDADAN FULL ANIMATION!!"- assert post.web_path_qs == "patreon/user/3295915/post/129540190"- assert _has_ads(post) is False--- ("content", "expected"),- [- (- "<p>Who would have through that good guys had a 'no killing' rule?...</p><p><a href=\"https://www.dropbox.com/scl/fi/wsgws25ma0hyqggfwkwcd/Harley-Quinn-4x01-4x02.mp4?rlkey=lqf7wqu7mj6uwjlysoewqg0fw&st=00z4mrmq&dl=0\">https://www.dropbox.com/scl/fi/wsgws25ma0hyqggfwkwcd/Harley-Quinn-4x01-4x02.mp4?rlkey=lqf7wqu7mj6uwjlysoewqg0fw&st=00z4mrmq&dl=0</a></p>",- [- "https://www.dropbox.com/scl/fi/wsgws25ma0hyqggfwkwcd/Harley-Quinn-4x01-4x02.mp4?rlkey=lqf7wqu7mj6uwjlysoewqg0fw&st=00z4mrmq&dl=0"- ],- ),- (- "<p>Hey everyone! Its been a long time in the making. I'm really proud of this one and I hope you all like is as much as I do! I really tried my</p><p>Hey everyone!</p><p>Its been a long time in the making. I'm really proud of this one and I hope you all like is as much as I do! I really tried my best to do the characters justice and add a bit more comedy in this one!</p><p>In the next week I'll be doing an update on the other projects and when they're projected to finish! Right now I just have Alya and Sono Bisque Doll in the making but I'll probably be planning another in the next month or so using a poll!</p><h3><strong>Here is the </strong><a href=\"https://www.dropbox.com/scl/fi/ze2v1bih3lwvdjqn9syde/DDN-PATRON-ONLY.mp4?rlkey=oidlzqufodhr0nra3jfrgguxx&st=urfuvf73&dl=0\">LINK </a><strong>to the full animation!</strong></h3><p>Thanks for your patience and everything!</p>",- [- "https://www.dropbox.com/scl/fi/ze2v1bih3lwvdjqn9syde/DDN-PATRON-ONLY.mp4?rlkey=oidlzqufodhr0nra3jfrgguxx&st=urfuvf73&dl=0"- ],- ),- ],-)-def test_extract_urls_from_content(content: str, expected: list[str]) -> None:- found = list(_extract_urls(content))- assert found- assert found == expected---def test_validation_of_post_not_archived_yet(post_resp_w_embeds: dict[str, Any]) -> None:- post = UserPostModel.model_validate(post_resp_w_embeds)- assert post.id == "128071303"- assert post.content == ""- assert post.file == File(- path="/83/66/8366796e0d9fadd5e22ae8f8ea32d1b539d54e25e9da19f906fa36d1cf973cc2.jpg",- name="461372899.jpg",- server=None,- )- assert post.attachments == ()- assert post.published == dt.datetime(2025, 5, 3, 17, 12, 47, tzinfo=dt.UTC)- assert post.added- assert post.added.date() == dt.date(2026, 6, 10)- assert post.edited is None- assert post.timestamp == 1746292367- assert post.tags == ("Naughty ASMR",)- assert post.embed == Embed(- url="https://u.pcloud.link/publink/show?code=XZDlYb5ZlyjdRy0vl0bJWMbT2L2cp5RbUCFX",- subject="ASMR ~ Girl Next Door ~ Patreon EXCLUSIVE.mp4 - Shared with pCloud",- description="Store videos in pCloud. Share them with just the right people. Access them on any device. Create a free account now!",- )- assert post.has_full is False- assert post.service == "patreon"- assert post.user_id == "47101380"- assert post.title == "ASMR ~ Girl Next Door ~ Patreon EXCLUSIVE"--- ("tags", "expected"),- [- (- '{animation,"animation 2d",anime,"fan animation",fanart,fedorartt,"genshin impact"}',- ["animation", "animation 2d", "anime", "fan animation", "fanart", "fedorartt", "genshin impact"],- ),- (- 'animation,"animation 2d",anime,"fan animation",fanart,fedorartt,"genshin impact"',- ["animation", "animation 2d", "anime", "fan animation", "fanart", "fedorartt", "genshin impact"],- ),- (- ["animation", "animation 2d", "anime", "fan animation", "fanart", "fedorartt", "genshin impact"],- ["animation", "animation 2d", "anime", "fan animation", "fanart", "fedorartt", "genshin impact"],- ),- ("null", ()),- (None, ()),- ],-)-def test_tags_validation(tags: object, expected: list[str]) -> None:- result = _parse_tags(tags)- assert result == expecteddiff --git a/tests/test_prune.py b/tests/test_prune.pyindex 82dd138d3..63e0b1ea4 100644--- a/tests/test_prune.py+++ b/tests/test_prune.py@@ -199,7 +199,7 @@ class TestPruneCommand:return aio.run(read())- def test_removes_rows_of_deleted_files(self, capsys: pytest.CaptureFixture[str], tmp_cwd: Path) -> None:+ def test_removes_rows_of_deleted_files(self, logs: pytest.LogCaptureFixture, tmp_cwd: Path) -> None:db_file, kept, gone = tmp_cwd / "test.db", tmp_cwd / "kept.txt", tmp_cwd / "gone.txt"self._seed(db_file, kept, gone)gone.unlink()@@ -207,7 +207,7 @@ class TestPruneCommand:exit_code = run_cdl(["database", "prune", "hashes", "--database-file", str(db_file)])assert exit_code == 0- assert "Deleted: 1 hash entries" in capsys.readouterr().out+ assert "Deleted: 1 hash entries" in set(map(str.strip, logs.messages))assert self._read(db_file, "files") == {"kept.txt"}assert self._read(db_file, "hash") == {"kept.txt"}diff --git a/uv.lock b/uv.lockindex c30df0cd3..ceeccf90c 100644--- a/uv.lock+++ b/uv.lock@@ -621,7 +621,7 @@ wheels = [[[package]]name = "cyberdrop-dl-patched"-version = "10.12.1"+version = "10.13.0.dev0"source = { editable = "." }default-groups = "all"dependencies = [@@ -730,7 +730,7 @@ provides-extras = ["apprise", "lxml", "wreq"][package.metadata.requires-dev]dev = [- { name = "prek", specifier = ">=0.5.5" },+ { name = "prek", specifier = ">=0.5.7" },{ name = "pytest", specifier = ">=9.1.1" },{ name = "pytest-asyncio", specifier = ">=1.4.0" },{ name = "ruff", specifier = ">=0.17.1,<0.18.0" },@@ -1192,19 +1192,19 @@ wheels = [[[package]]name = "prek"-version = "0.5.5"+version = "0.5.7"source = { registry = "https://pypi.org/simple" }-sdist = { url = "https://files.pythonhosted.org/packages/9b/7b/11538b8e6cd7e269261feae62a2d08818fdcf8f43c3b1a253cec01a5488d/prek-0.5.5.tar.gz", hash = "sha256:16bf596768bb754779c7d42317e9ca16ac609c0cce7d13bae0829944ab40a26a", size = 570428, upload-time = "2026-10-05T06:08:59.165Z" }+sdist = { url = "https://files.pythonhosted.org/packages/e0/0c/985c6f0fe1671e639fb97bf5a60f3945369f26d4ccf5a8a1b063d357e6da/prek-0.5.7.tar.gz", hash = "sha256:91049700f0f13b4575deb44045dd6dd51f7c4a70c53ec5d452b09925962e3b35", size = 580753, upload-time = "2026-10-21T00:46:48.231Z" }wheels = [- { url = "https://files.pythonhosted.org/packages/2e/77/189e554ea92baf6c1d33733b3e9d1ed819ab7d77e57eb2e3ead0bb1d8060/prek-0.5.5-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:50fbceb0f728b504023f6e6c9037ac0656436949d94f7a85bac5542e6c1a4a75", size = 6038669, upload-time = "2026-10-05T06:08:39.368Z" },- { url = "https://files.pythonhosted.org/packages/63/ea/fc857c6b3f1e3fdb4d81bdca2051076de82e986cb1455a01b351ac7a5cd1/prek-0.5.5-py3-none-macosx_11_0_arm64.whl", hash = "sha256:2f610927b95e84b28173a4c810892a7b5d5bb55bee792ddf97178fa97654633e", size = 5548955, upload-time = "2026-10-05T06:08:41.428Z" },- { url = "https://files.pythonhosted.org/packages/47/c3/2bab54f6393fb9f247225681d476086e24fa6242f329e9ca1e5bd638ec50/prek-0.5.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:120ef7d4b6bb58155e74827743c266e48501efb0e4c37ff726b14fe6e86a126b", size = 5848228, upload-time = "2026-10-05T06:08:44.051Z" },- { url = "https://files.pythonhosted.org/packages/aa/f9/1279e1c83819de5904db1a09f4afc589932a2e62c7063713b1fe3a54ee46/prek-0.5.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:2f6c453a12c21757b23bbbc97415aef78527841ad3f9e61f52cb35cf012f93e5", size = 6371296, upload-time = "2026-10-05T06:08:46.278Z" },- { url = "https://files.pythonhosted.org/packages/93/fc/e566be5919eaffef4cc22488f16e4bbfd08961734bd67c06f85d405e4cbc/prek-0.5.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:73d509c0d9556171de2502bada4962be7a25871e7b23e782549074e1416dc850", size = 6269922, upload-time = "2026-10-05T06:08:48.645Z" },- { url = "https://files.pythonhosted.org/packages/d2/39/a48d8e6203055bff7bb734b1f2f9aede4a4539bee6ab4c9273dbc01fa546/prek-0.5.5-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:76c867fdbd4e4f19e6b6b2988bd1e1407d1324170ebcf1428e4e34f8f0751a99", size = 5861518, upload-time = "2026-10-05T06:08:50.808Z" },- { url = "https://files.pythonhosted.org/packages/b7/03/690fba9543033e25ea2e7b2ae1cca1ae8d8c2e32295f0d66f4b50934b8c7/prek-0.5.5-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:c69f60c2b3b4d481e38d0eab3b97ac05ec05d7648ae690925ae95ca9d22c7643", size = 6383685, upload-time = "2026-10-05T06:08:52.868Z" },- { url = "https://files.pythonhosted.org/packages/8c/04/1e9ccf3a61a3bfd4107b83973f7afde9177b6ff8f2d5d4b00125e77c2100/prek-0.5.5-py3-none-win_amd64.whl", hash = "sha256:15bff9039349466ea9bf6b0c173b822ff08f8ae4cfbfdea782492e519c06d874", size = 5784759, upload-time = "2026-10-05T06:08:55.056Z" },- { url = "https://files.pythonhosted.org/packages/41/d9/bb6811e438d3c74d26cb5d72e6343606e0a7a6283fee87521189f4ba1191/prek-0.5.5-py3-none-win_arm64.whl", hash = "sha256:3db3191d2509830c75438e20956a47c2259867d18a4106064ed75088b968a0c6", size = 5517355, upload-time = "2026-10-05T06:08:57.193Z" },+ { url = "https://files.pythonhosted.org/packages/0c/36/56c107d100cabfb7e7c7f2e62d363052c77c3fcf664707b66ef9e3b865a4/prek-0.5.7-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:621835811891d11d3feb5ca47102ca97973c5b4e6fbd1b35b1293d412d29d9cc", size = 6062121, upload-time = "2026-10-21T00:46:31.418Z" },+ { url = "https://files.pythonhosted.org/packages/51/59/1868e2d6b3581eb9f327cb7db4270c4f38e80c5b175517e439e106eac704/prek-0.5.7-py3-none-macosx_11_0_arm64.whl", hash = "sha256:ef10cf46c0660b011fc067b7ce20dc78f2c44b6f905bf8dc49402353f67283b1", size = 5686422, upload-time = "2026-10-21T00:46:34.006Z" },+ { url = "https://files.pythonhosted.org/packages/7f/e3/90901432ee7ca288b46872552ca8f658b2262cf56d9af3c1eb0416f206da/prek-0.5.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.musllinux_1_1_aarch64.whl", hash = "sha256:b38075f9363066d72d1cd887b5a260ec938516fea9ea44def53e592ee75090d5", size = 5817816, upload-time = "2026-10-21T00:46:35.869Z" },+ { url = "https://files.pythonhosted.org/packages/b5/d1/f8e24b15906e433850a2c8409ae3a9270724b2a5d4a71b8c4eadafeb201b/prek-0.5.7-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:6a8f7734931c4b6a5f2efca121fabed7979408df233ce6d9b043f4148873021c", size = 6276177, upload-time = "2026-10-21T00:46:37.511Z" },+ { url = "https://files.pythonhosted.org/packages/4b/15/c83456872211706839ff326474aa9f2d870eef7ee5ec2c436446519779d2/prek-0.5.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c139c494fb1d9826688f8107d1514fa2a58f8f4a0f0527b68e7970fa50a8b723", size = 6140221, upload-time = "2026-10-21T00:46:39.29Z" },+ { url = "https://files.pythonhosted.org/packages/cb/b5/996b05447d4c2a4399947a7c5c910b2cd2c544b3074c11153ae3e21b4112/prek-0.5.7-py3-none-manylinux_2_28_aarch64.whl", hash = "sha256:e86139ab5662124818dc1957854d8281f635414016e545ab72e63365c995824b", size = 5812638, upload-time = "2026-10-21T00:46:41.006Z" },+ { url = "https://files.pythonhosted.org/packages/83/e5/60e0e76cd6819d75026b3a8147ddbd2b3fcab27c02236bce8b3a559e0e64/prek-0.5.7-py3-none-musllinux_1_1_x86_64.whl", hash = "sha256:94bd6a93ccf8ebb1d30b822161515e3e31ea916ce7411febe8ceb5f607eb840d", size = 6298681, upload-time = "2026-10-21T00:46:42.618Z" },+ { url = "https://files.pythonhosted.org/packages/54/97/e14b12e7d8fbdb468581d778fb892c855fbca325d4344cc535c12e2851a5/prek-0.5.7-py3-none-win_amd64.whl", hash = "sha256:fa69837b6d1d2b6be5fe7fe4cd27fd5606f2155e784fec55ee7df7ed9f9bf211", size = 5692294, upload-time = "2026-10-21T00:46:44.385Z" },+ { url = "https://files.pythonhosted.org/packages/bf/28/9dc15c0644cc6019c16c5cdd44e5004b641f5e910488f830e80dfdd11042/prek-0.5.7-py3-none-win_arm64.whl", hash = "sha256:239ccb081e3766d83a6a9a5ebee1d5cbb7986fc8e4f230e785423d409cff95e3", size = 5626111, upload-time = "2026-10-21T00:46:46.341Z" },][[package]]