Skip to content

Bulk asynchronous downloader for multiple file hosts

Implement free space check

Jules-WinnfieldXb87ca8a09993
diff --git a/Pipfile b/Pipfile
index 9ff0014ea..5db27ee9b 100644
--- a/Pipfile
+++ b/Pipfile
@@ -12,6 +12,7 @@ colorama = "==0.4.6"
gofile_client = "==1.0.1"
myjdapi = "==1.1.6"
PyYAML = "==6.0"
+psutil = "==5.9.4"
setuptools = "==65.6.3"
tqdm = "==4.64.1"
yarl = "==1.8.2"
\ No newline at end of file
diff --git a/Pipfile.lock b/Pipfile.lock
index 674effed5..2ca0b2f69 100644
--- a/Pipfile.lock
+++ b/Pipfile.lock
@@ -1,7 +1,7 @@
{
"_meta": {
"hash": {
- "sha256": "db7496f706bdcd408c95ea9575146d15c264219e3e6a6f12a87ca11d7edb2e68"
+ "sha256": "30596b17614bab089aac374141aed3a10ef02e6febfc703bcc84de556b6a0755"
},
"pipfile-spec": 6,
"requires": {},
@@ -133,11 +133,11 @@
},
"attrs": {
"hashes": [
- "sha256:29adc2665447e5191d0e7c568fde78b21f9672d344281d0c6e1ab085429b22b6",
- "sha256:86efa402f67bf2df34f51a335487cf46b1ec130d02b8d39fd248abfd30da551c"
+ "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836",
+ "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"
],
- "markers": "python_version >= '3.5'",
- "version": "==22.1.0"
+ "markers": "python_version >= '3.6'",
+ "version": "==22.2.0"
},
"beautifulsoup4": {
"hashes": [
@@ -269,83 +269,83 @@
},
"multidict": {
"hashes": [
- "sha256:018c8e3be7f161a12b3e41741b6721f9baeb2210f4ab25a6359b7d76c1017dce",
- "sha256:01b456046a05ff7cceefb0e1d2a9d32f05efcb1c7e0d152446304e11557639ce",
- "sha256:114a4ab3e5cfbc56c4b6697686ecb92376c7e8c56893ef20547921552f8bdf57",
- "sha256:12e0d396faa6dc55ff5379eee54d1df3b508243ff15bfc8295a6ec7a4483a335",
- "sha256:190626ced82d4cc567a09e7346340d380154a493bac6905e0095d8158cdf1e38",
- "sha256:1f5d5129a937af4e3c4a1d6c139f4051b7d17d43276cefdd8d442a7031f7eef2",
- "sha256:21e1ce0b187c4e93112304dcde2aa18922fdbe8fb4f13d8aa72a5657bce0563a",
- "sha256:24e8d513bfcaadc1f8b0ebece3ff50961951c54b07d5a775008a882966102418",
- "sha256:2523a29006c034687eccd3ee70093a697129a3ffe8732535d3b2df6a4ecc279d",
- "sha256:26fbbe17f8a7211b623502d2bf41022a51da3025142401417c765bf9a56fed4c",
- "sha256:2b66d61966b12e6bba500e5cbb2c721a35e119c30ee02495c5629bd0e91eea30",
- "sha256:2cf5d19e12eff855aa198259c0b02fd3f5d07e1291fbd20279c37b3b0e6c9852",
- "sha256:2cfda34b7cb99eacada2072e0f69c0ad3285cb6f8e480b11f2b6d6c1c6f92718",
- "sha256:3541882266247c7cd3dba78d6ef28dbe704774df60c9e4231edaa4493522e614",
- "sha256:36df958b15639e40472adaa4f0c2c7828fe680f894a6b48c4ce229f59a6a798b",
- "sha256:38d394814b39be1c36ac709006d39d50d72a884f9551acd9c8cc1ffae3fc8c4e",
- "sha256:4159fc1ec9ede8ab93382e0d6ba9b1b3d23c72da39a834db7a116986605c7ab4",
- "sha256:445c0851a1cbc1f2ec3b40bc22f9c4a235edb3c9a0906122a9df6ea8d51f886c",
- "sha256:47defc0218682281a52fb1f6346ebb8b68b17538163a89ea24dfe4da37a8a9a3",
- "sha256:4cc5c8cd205a9810d16a5cd428cd81bac554ad1477cb87f4ad722b10992e794d",
- "sha256:4ccf55f28066b4f08666764a957c2b7c241c7547b0921d69c7ceab5f74fe1a45",
- "sha256:4fb3fe591956d8841882c463f934c9f7485cfd5f763a08c0d467b513dc18ef89",
- "sha256:526f8397fc124674b8f39748680a0ff673bd6a715fecb4866716d36e380f015f",
- "sha256:578bfcb16f4b8675ef71b960c00f174b0426e0eeb796bab6737389d8288eb827",
- "sha256:5b51969503709415a35754954c2763f536a70b8bf7360322b2edb0c0a44391f6",
- "sha256:5e58ec0375803526d395f6f7e730ecc45d06e15f68f7b9cdbf644a2918324e51",
- "sha256:62db44727d0befea68e8ad2881bb87a9cfb6b87d45dd78609009627167f37b69",
- "sha256:67090b17a0a5be5704fd109f231ee73cefb1b3802d41288d6378b5df46ae89ba",
- "sha256:6cd14e61f0da2a2cfb9fe05bfced2a1ed7063ce46a7a8cd473be4973de9a7f91",
- "sha256:70740c2bc9ab1c99f7cdcb104f27d16c63860c56d51c5bf0ef82fc1d892a2131",
- "sha256:73009ea04205966d47e16d98686ac5c438af23a1bb30b48a2c5da3423ec9ce37",
- "sha256:791458a1f7d1b4ab3bd9e93e0dcd1d59ef7ee9aa051dcd1ea030e62e49b923fd",
- "sha256:7f9511e48bde6b995825e8d35e434fc96296cf07a25f4aae24ff9162be7eaa46",
- "sha256:81c3d597591b0940e04949e4e4f79359b2d2e542a686ba0da5e25de33fec13e0",
- "sha256:8230a39bae6c2e8a09e4da6bace5064693b00590a4a213e38f9a9366da10e7dd",
- "sha256:8b92a9f3ab904397a33b193000dc4de7318ea175c4c460a1e154c415f9008e3d",
- "sha256:94cbe5535ef150546b8321aebea22862a3284da51e7b55f6f95b7d73e96d90ee",
- "sha256:960ce1b790952916e682093788696ef7e33ac6a97482f9b983abdc293091b531",
- "sha256:99341ca1f1db9e7f47914cb2461305665a662383765ced6f843712564766956d",
- "sha256:9aac6881454a750554ed4b280a839dcf9e2133a9d12ab4d417d673fb102289b7",
- "sha256:9d359b0a962e052b713647ac1f13eabf2263167b149ed1e27d5c579f5c8c7d2c",
- "sha256:9dbab2a7e9c073bc9538824a01f5ed689194db7f55f2b8102766873e906a6c1a",
- "sha256:a27b029caa3b555a4f3da54bc1e718eb55fcf1a11fda8bf0132147b476cf4c08",
- "sha256:a8b817d4ed68fd568ec5e45dd75ddf30cc72a47a6b41b74d5bb211374c296f5e",
- "sha256:ad7d66422b9cc51125509229693d27e18c08f2dea3ac9de408d821932b1b3759",
- "sha256:b46e79a9f4db53897d17bc64a39d1c7c2be3e3d4f8dba6d6730a2b13ddf0f986",
- "sha256:baa96a3418e27d723064854143b2f414a422c84cc87285a71558722049bebc5a",
- "sha256:beeca903e4270b4afcd114f371a9602240dc143f9e944edfea00f8d4ad56c40d",
- "sha256:c2a1168e5aa7c72499fb03c850e0f03f624fa4a5c8d2e215c518d0a73872eb64",
- "sha256:c5790cc603456b6dcf8a9a4765f666895a6afddc88b3d3ba7b53dea2b6e23116",
- "sha256:cb4a08f0aaaa869f189ffea0e17b86ad0237b51116d494da15ef7991ee6ad2d7",
- "sha256:cd5771e8ea325f85cbb361ddbdeb9ae424a68e5dfb6eea786afdcd22e68a7d5d",
- "sha256:ce8e51774eb03844588d3c279adb94efcd0edeccd2f97516623292445bcc01f9",
- "sha256:d09daf5c6ce7fc6ed444c9339bbde5ea84e2534d1ca1cd37b60f365c77f00dea",
- "sha256:d0e798b072cf2aab9daceb43d97c9c527a0c7593e67a7846ad4cc6051de1e303",
- "sha256:d325d61cac602976a5d47b19eaa7d04e3daf4efce2164c630219885087234102",
- "sha256:d408172519049e36fb6d29672f060dc8461fc7174eba9883c7026041ef9bfb38",
- "sha256:d52442e7c951e4c9ee591d6047706e66923d248d83958bbf99b8b19515fffaef",
- "sha256:dc4cfef5d899f5f1a15f3d2ac49f71107a01a5a2745b4dd53fa0cede1419385a",
- "sha256:df7b4cee3ff31b3335aba602f8d70dbc641e5b7164b1e9565570c9d3c536a438",
- "sha256:e068dfeadbce63072b2d8096486713d04db4946aad0a0f849bd4fc300799d0d3",
- "sha256:e07c24018986fb00d6e7eafca8fcd6e05095649e17fcf0e33a592caaa62a78b9",
- "sha256:e0bce9f7c30e7e3a9e683f670314c0144e8d34be6b7019e40604763bd278d84f",
- "sha256:e1925f78a543b94c3d46274c66a366fee8a263747060220ed0188e5f3eeea1c0",
- "sha256:e322c94596054352f5a02771eec71563c018b15699b961aba14d6dd943367022",
- "sha256:e4a095e18847c12ec20e55326ab8782d9c2d599400a3a2f174fab4796875d0e2",
- "sha256:e5a811aab1b4aea0b4be669363c19847a8c547510f0e18fb632956369fdbdf67",
- "sha256:eddf604a3de2ace3d9a4e4d491be7562a1ac095a0a1c95a9ec5781ef0273ef11",
- "sha256:ee9b1cae9a6c5d023e5a150f6f6b9dbb3c3bbc7887d6ee07d4c0ecb49a473734",
- "sha256:f1650ea41c408755da5eed52ac6ccbc8938ccc3e698d81e6f6a1be02ff2a0945",
- "sha256:f2c0957b3e8c66c10d27272709a5299ab3670a0f187c9428f3b90d267119aedb",
- "sha256:f76109387e1ec8d8e2137c94c437b89fe002f29e0881aae8ae45529bdff92000",
- "sha256:f8a728511c977df6f3d8af388fcb157e49f11db4a6637dd60131b8b6e40b0253",
- "sha256:fb6c3dc3d65014d2c782f5acf0b3ba14e639c6c33d3ed8932ead76b9080b3544"
+ "sha256:01a3a55bd90018c9c080fbb0b9f4891db37d148a0a18722b42f94694f8b6d4c9",
+ "sha256:0b1a97283e0c85772d613878028fec909f003993e1007eafa715b24b377cb9b8",
+ "sha256:0dfad7a5a1e39c53ed00d2dd0c2e36aed4650936dc18fd9a1826a5ae1cad6f03",
+ "sha256:11bdf3f5e1518b24530b8241529d2050014c884cf18b6fc69c0c2b30ca248710",
+ "sha256:1502e24330eb681bdaa3eb70d6358e818e8e8f908a22a1851dfd4e15bc2f8161",
+ "sha256:16ab77bbeb596e14212e7bab8429f24c1579234a3a462105cda4a66904998664",
+ "sha256:16d232d4e5396c2efbbf4f6d4df89bfa905eb0d4dc5b3549d872ab898451f569",
+ "sha256:21a12c4eb6ddc9952c415f24eef97e3e55ba3af61f67c7bc388dcdec1404a067",
+ "sha256:27c523fbfbdfd19c6867af7346332b62b586eed663887392cff78d614f9ec313",
+ "sha256:281af09f488903fde97923c7744bb001a9b23b039a909460d0f14edc7bf59706",
+ "sha256:33029f5734336aa0d4c0384525da0387ef89148dc7191aae00ca5fb23d7aafc2",
+ "sha256:3601a3cece3819534b11d4efc1eb76047488fddd0c85a3948099d5da4d504636",
+ "sha256:3666906492efb76453c0e7b97f2cf459b0682e7402c0489a95484965dbc1da49",
+ "sha256:36c63aaa167f6c6b04ef2c85704e93af16c11d20de1d133e39de6a0e84582a93",
+ "sha256:39ff62e7d0f26c248b15e364517a72932a611a9b75f35b45be078d81bdb86603",
+ "sha256:43644e38f42e3af682690876cff722d301ac585c5b9e1eacc013b7a3f7b696a0",
+ "sha256:4372381634485bec7e46718edc71528024fcdc6f835baefe517b34a33c731d60",
+ "sha256:458f37be2d9e4c95e2d8866a851663cbc76e865b78395090786f6cd9b3bbf4f4",
+ "sha256:45e1ecb0379bfaab5eef059f50115b54571acfbe422a14f668fc8c27ba410e7e",
+ "sha256:4b9d9e4e2b37daddb5c23ea33a3417901fa7c7b3dee2d855f63ee67a0b21e5b1",
+ "sha256:4ceef517eca3e03c1cceb22030a3e39cb399ac86bff4e426d4fc6ae49052cc60",
+ "sha256:4d1a3d7ef5e96b1c9e92f973e43aa5e5b96c659c9bc3124acbbd81b0b9c8a951",
+ "sha256:4dcbb0906e38440fa3e325df2359ac6cb043df8e58c965bb45f4e406ecb162cc",
+ "sha256:509eac6cf09c794aa27bcacfd4d62c885cce62bef7b2c3e8b2e49d365b5003fe",
+ "sha256:52509b5be062d9eafc8170e53026fbc54cf3b32759a23d07fd935fb04fc22d95",
+ "sha256:52f2dffc8acaba9a2f27174c41c9e57f60b907bb9f096b36b1a1f3be71c6284d",
+ "sha256:574b7eae1ab267e5f8285f0fe881f17efe4b98c39a40858247720935b893bba8",
+ "sha256:5979b5632c3e3534e42ca6ff856bb24b2e3071b37861c2c727ce220d80eee9ed",
+ "sha256:59d43b61c59d82f2effb39a93c48b845efe23a3852d201ed2d24ba830d0b4cf2",
+ "sha256:5a4dcf02b908c3b8b17a45fb0f15b695bf117a67b76b7ad18b73cf8e92608775",
+ "sha256:5cad9430ab3e2e4fa4a2ef4450f548768400a2ac635841bc2a56a2052cdbeb87",
+ "sha256:5fc1b16f586f049820c5c5b17bb4ee7583092fa0d1c4e28b5239181ff9532e0c",
+ "sha256:62501642008a8b9871ddfccbf83e4222cf8ac0d5aeedf73da36153ef2ec222d2",
+ "sha256:64bdf1086b6043bf519869678f5f2757f473dee970d7abf6da91ec00acb9cb98",
+ "sha256:64da238a09d6039e3bd39bb3aee9c21a5e34f28bfa5aa22518581f910ff94af3",
+ "sha256:666daae833559deb2d609afa4490b85830ab0dfca811a98b70a205621a6109fe",
+ "sha256:67040058f37a2a51ed8ea8f6b0e6ee5bd78ca67f169ce6122f3e2ec80dfe9b78",
+ "sha256:6748717bb10339c4760c1e63da040f5f29f5ed6e59d76daee30305894069a660",
+ "sha256:6b181d8c23da913d4ff585afd1155a0e1194c0b50c54fcfe286f70cdaf2b7176",
+ "sha256:6ed5f161328b7df384d71b07317f4d8656434e34591f20552c7bcef27b0ab88e",
+ "sha256:7582a1d1030e15422262de9f58711774e02fa80df0d1578995c76214f6954988",
+ "sha256:7d18748f2d30f94f498e852c67d61261c643b349b9d2a581131725595c45ec6c",
+ "sha256:7d6ae9d593ef8641544d6263c7fa6408cc90370c8cb2bbb65f8d43e5b0351d9c",
+ "sha256:81a4f0b34bd92df3da93315c6a59034df95866014ac08535fc819f043bfd51f0",
+ "sha256:8316a77808c501004802f9beebde51c9f857054a0c871bd6da8280e718444449",
+ "sha256:853888594621e6604c978ce2a0444a1e6e70c8d253ab65ba11657659dcc9100f",
+ "sha256:99b76c052e9f1bc0721f7541e5e8c05db3941eb9ebe7b8553c625ef88d6eefde",
+ "sha256:a2e4369eb3d47d2034032a26c7a80fcb21a2cb22e1173d761a162f11e562caa5",
+ "sha256:ab55edc2e84460694295f401215f4a58597f8f7c9466faec545093045476327d",
+ "sha256:af048912e045a2dc732847d33821a9d84ba553f5c5f028adbd364dd4765092ac",
+ "sha256:b1a2eeedcead3a41694130495593a559a668f382eee0727352b9a41e1c45759a",
+ "sha256:b1e8b901e607795ec06c9e42530788c45ac21ef3aaa11dbd0c69de543bfb79a9",
+ "sha256:b41156839806aecb3641f3208c0dafd3ac7775b9c4c422d82ee2a45c34ba81ca",
+ "sha256:b692f419760c0e65d060959df05f2a531945af31fda0c8a3b3195d4efd06de11",
+ "sha256:bc779e9e6f7fda81b3f9aa58e3a6091d49ad528b11ed19f6621408806204ad35",
+ "sha256:bf6774e60d67a9efe02b3616fee22441d86fab4c6d335f9d2051d19d90a40063",
+ "sha256:c048099e4c9e9d615545e2001d3d8a4380bd403e1a0578734e0d31703d1b0c0b",
+ "sha256:c5cb09abb18c1ea940fb99360ea0396f34d46566f157122c92dfa069d3e0e982",
+ "sha256:cc8e1d0c705233c5dd0c5e6460fbad7827d5d36f310a0fadfd45cc3029762258",
+ "sha256:d5e3fc56f88cc98ef8139255cf8cd63eb2c586531e43310ff859d6bb3a6b51f1",
+ "sha256:d6aa0418fcc838522256761b3415822626f866758ee0bc6632c9486b179d0b52",
+ "sha256:d6c254ba6e45d8e72739281ebc46ea5eb5f101234f3ce171f0e9f5cc86991480",
+ "sha256:d6d635d5209b82a3492508cf5b365f3446afb65ae7ebd755e70e18f287b0adf7",
+ "sha256:dcfe792765fab89c365123c81046ad4103fcabbc4f56d1c1997e6715e8015461",
+ "sha256:ddd3915998d93fbcd2566ddf9cf62cdb35c9e093075f862935573d265cf8f65d",
+ "sha256:ddff9c4e225a63a5afab9dd15590432c22e8057e1a9a13d28ed128ecf047bbdc",
+ "sha256:e41b7e2b59679edfa309e8db64fdf22399eec4b0b24694e1b2104fb789207779",
+ "sha256:e69924bfcdda39b722ef4d9aa762b2dd38e4632b3641b1d9a57ca9cd18f2f83a",
+ "sha256:ea20853c6dbbb53ed34cb4d080382169b6f4554d394015f1bef35e881bf83547",
+ "sha256:ee2a1ece51b9b9e7752e742cfb661d2a29e7bcdba2d27e66e28a99f1890e4fa0",
+ "sha256:eeb6dcc05e911516ae3d1f207d4b0520d07f54484c49dfc294d6e7d63b734171",
+ "sha256:f70b98cd94886b49d91170ef23ec5c0e8ebb6f242d734ed7ed677b24d50c82cf",
+ "sha256:fc35cb4676846ef752816d5be2193a1e8367b4c1397b74a565a9d0389c433a1d",
+ "sha256:ff959bee35038c4624250473988b24f846cbeb2c6639de3602c073f10410ceba"
],
"markers": "python_version >= '3.7'",
- "version": "==6.0.3"
+ "version": "==6.0.4"
},
"myjdapi": {
"hashes": [
@@ -355,6 +355,26 @@
"index": "pypi",
"version": "==1.1.6"
},
+ "psutil": {
+ "hashes": [
+ "sha256:149555f59a69b33f056ba1c4eb22bb7bf24332ce631c44a319cec09f876aaeff",
+ "sha256:16653106f3b59386ffe10e0bad3bb6299e169d5327d3f187614b1cb8f24cf2e1",
+ "sha256:3d7f9739eb435d4b1338944abe23f49584bde5395f27487d2ee25ad9a8774a62",
+ "sha256:3ff89f9b835100a825b14c2808a106b6fdcc4b15483141482a12c725e7f78549",
+ "sha256:54c0d3d8e0078b7666984e11b12b88af2db11d11249a8ac8920dd5ef68a66e08",
+ "sha256:54d5b184728298f2ca8567bf83c422b706200bcbbfafdc06718264f9393cfeb7",
+ "sha256:6001c809253a29599bc0dfd5179d9f8a5779f9dffea1da0f13c53ee568115e1e",
+ "sha256:68908971daf802203f3d37e78d3f8831b6d1014864d7a85937941bb35f09aefe",
+ "sha256:6b92c532979bafc2df23ddc785ed116fced1f492ad90a6830cf24f4d1ea27d24",
+ "sha256:852dd5d9f8a47169fe62fd4a971aa07859476c2ba22c2254d4a1baa4e10b95ad",
+ "sha256:9120cd39dca5c5e1c54b59a41d205023d436799b1c8c4d3ff71af18535728e94",
+ "sha256:c1ca331af862803a42677c120aff8a814a804e09832f166f226bfd22b56feee8",
+ "sha256:efeae04f9516907be44904cc7ce08defb6b665128992a56957abc9b61dca94b7",
+ "sha256:fd8522436a6ada7b4aad6638662966de0d61d241cb821239b2ae7013d41a43d4"
+ ],
+ "index": "pypi",
+ "version": "==5.9.4"
+ },
"pycryptodome": {
"hashes": [
"sha256:0198fe96c22f7bc31e7a7c27a26b2cec5af3cf6075d577295f4850856c77af32",
diff --git a/README.md b/README.md
index db02fbb99..dec2b126e 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# `cyberdrop-dl`
**Bulk downloader for multiple file hosts**
-The latest version of the program is 3.6.42
+The latest version of the program is 3.6.43
<a href="https://www.buymeacoffee.com/juleswinnft" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
@@ -99,6 +99,7 @@ optional arguments:
--proxy HTTP/HTTPS proxy used for downloading, format [protocal]://[ip]:[port]
--separate-posts Separates forum scraping into folders by post number
--mark-downloaded Sets the scraped files as downloaded without downloading
+ --required-free-space Required free space (in gigabytes) for the program to run
--pixeldrain-api-key api key for premium pixeldrain
--xbunker-username username to login to xbunker (only required if the thread requires it)
--xbunker-password password to login to xbunker (only required if the thread requires it)
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py
index 9f443f25c..1654d8997 100644
--- a/cyberdrop_dl/__init__.py
+++ b/cyberdrop_dl/__init__.py
@@ -1 +1 @@
-__version__ = "3.6.42"
+__version__ = "3.6.43"
diff --git a/cyberdrop_dl/base_functions/base_functions.py b/cyberdrop_dl/base_functions/base_functions.py
index 3156cc501..726296222 100644
--- a/cyberdrop_dl/base_functions/base_functions.py
+++ b/cyberdrop_dl/base_functions/base_functions.py
@@ -6,6 +6,7 @@ import os
import re
from pathlib import Path
+import psutil as psutil
import yaml
from colorama import Fore, Style
from yarl import URL
@@ -99,6 +100,15 @@ async def regex_links(urls) -> list:
return yarl_links
+async def check_free_space(required_space: int, download_directory: Path):
+ free_space = psutil.disk_usage(str(download_directory.parent)).free
+ free_space = ((free_space / 1024) / 1024) / 1024
+ if required_space > free_space:
+ return False
+ else:
+ return True
+
+
async def cyberdrop_parse(url: URL) -> URL:
mapping_direct = [r'img-...cyberdrop...',
r'f.cyberdrop...', r'fs-...cyberdrop...']
diff --git a/cyberdrop_dl/base_functions/config_schema.py b/cyberdrop_dl/base_functions/config_schema.py
index badef45f2..b33793dc3 100644
--- a/cyberdrop_dl/base_functions/config_schema.py
+++ b/cyberdrop_dl/base_functions/config_schema.py
@@ -26,6 +26,7 @@ config_default = [
"Runtime": {
"threads": 0,
"attempts": 10,
+ "required_free_space": 5,
"disable_attempt_limit": False,
"connection_timeout": 15,
"ratelimit": 50,
@@ -54,4 +55,4 @@ authentication_args = ["pixeldrain_api_key",
jdownloader_args = ["jdownloader_enable", "jdownloader_username", "jdownloader_password", "jdownloader_device"]
runtime_args = ["threads", "attempts", "disable_attempt_limit", "connection_timeout", "ratelimit", "throttle",
"include_id", "exclude_videos", "exclude_images", "exclude_audio", "exclude_other", "ignore_history",
- "output_last_forum_post", "mark_downloaded", "separate_posts", "skip_hosts", "proxy"]
+ "output_last_forum_post", "mark_downloaded", "separate_posts", "skip_hosts", "proxy", "required_free_space"]
diff --git a/cyberdrop_dl/client/downloaders.py b/cyberdrop_dl/client/downloaders.py
index ca023ac6f..664ac78cc 100644
--- a/cyberdrop_dl/client/downloaders.py
+++ b/cyberdrop_dl/client/downloaders.py
@@ -8,11 +8,12 @@ from random import gauss
import aiofiles
import aiofiles.os
import aiohttp.client_exceptions
+from colorama import Fore
from tqdm import tqdm
from yarl import URL
from ..base_functions.base_functions import FILE_FORMATS, MAX_FILENAME_LENGTH, log, logger, sanitize, FailureException, \
- is_forum
+ is_forum, check_free_space
from ..base_functions.sql_helper import SQLHelper
from ..base_functions.data_classes import AlbumItem, CascadeItem, FileLock
from ..client.client import Client, DownloadSession
@@ -66,13 +67,7 @@ def retry(f):
args = list(args)
args[0] = args[0].with_host('img-01.cyberdrop.to')
args = tuple(args)
- else:
- args = list(args)
- args[0] = URL(str(args[0]).replace('fs-05.', 'fs-04.'))
- args = tuple(args)
-
await asyncio.sleep(2)
-
return wrapper
@@ -112,6 +107,10 @@ class Downloader:
async def download_file(self, url: URL, referral: URL, filename: str, session: DownloadSession, db_path: str,
show_progress: bool = True) -> None:
"""Download the content of given URL"""
+ if not await check_free_space(self.runtime_args['required_free_space'], self.file_args['output_folder']):
+ await log("Not enough free space to download file, skipping.", quiet=True)
+ return
+
if url.parts[-1] not in self.current_attempt:
self.current_attempt[url.parts[-1]] = 0
@@ -346,6 +345,9 @@ class Downloader:
async def download_content(self, show_progress: bool = True, conn_timeout: int = 15) -> None:
"""Download the content of all links and save them as files."""
session = DownloadSession(self.client, conn_timeout)
+ if not await check_free_space(self.runtime_args['required_free_space'], self.file_args['output_folder']):
+ await log("Not enough free space to run the program.", Fore.RED)
+ exit(0)
coros = [self.download_and_store(url_object, session, show_progress)
for url_object in self.album_obj.link_pairs]
for func in tqdm(asyncio.as_completed(coros), total=len(coros), desc=self.title, unit='FILE'):
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py
index 8865d31d6..72f675022 100644
--- a/cyberdrop_dl/main.py
+++ b/cyberdrop_dl/main.py
@@ -13,7 +13,7 @@ from yarl import URL
from cyberdrop_dl.scraper.scraper_helper import ScrapeMapper
from . import __version__ as VERSION
from cyberdrop_dl.base_functions.base_functions import clear, create_config, log, logger, purge_dir, regex_links, \
- run_args
+ run_args, check_free_space
from cyberdrop_dl.base_functions.data_classes import AuthData, SkipData
from cyberdrop_dl.base_functions.sql_helper import SQLHelper
from cyberdrop_dl.client.client import Client
@@ -43,6 +43,7 @@ def parse_args():
parser.add_argument("--proxy", help="HTTP/HTTPS proxy used for downloading, format [protocal]://[ip]:[port]", default=None)
parser.add_argument("--separate-posts", help="Separates forum scraping into folders by post number", action="store_true")
parser.add_argument("--mark-downloaded", help="Sets the scraped files as downloaded without downloading", action="store_true")
+ parser.add_argument("--required-free-space", type=int, help="Required free space (in gigabytes) for the program to run", default=5)
parser.add_argument("--pixeldrain-api-key", type=str, help="api key for premium pixeldrain", default=None)
parser.add_argument("--xbunker-username", type=str, help="username to login to xbunker", default=None)
parser.add_argument("--xbunker-password", type=str, help="password to login to xbunker", default=None)
@@ -126,6 +127,10 @@ async def download_all(auth_args: Dict, file_args: Dict, jdownloader_args: Dict,
exit(0)
await clear()
+ if not await check_free_space(runtime_args['required_free_space'], file_args['output_folder']):
+ await log("Not enough free space to run the program.", Fore.RED)
+ return
+
backup_scraper = ScrapeMapper(client=client, file_args=file_args, jdownloader_args=jdownloader_args,
runtime_args=runtime_args, jdownloader_auth=jdownloader_auth,
simpcity_auth=simpcity_auth, socialmediagirls_auth=socialmediagirls_auth,
diff --git a/requirements.txt b/requirements.txt
index ba20bd636..c8fc994e3 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -6,6 +6,7 @@ colorama==0.4.6
gofile_client==1.0.1
myjdapi==1.1.6
PyYAML==6.0
+psutil~=5.9.4
setuptools==65.6.3
tqdm==4.64.1
-yarl==1.8.2
+yarl==1.8.2
\ No newline at end of file
diff --git a/setup.cfg b/setup.cfg
index ad15d3319..9e83a3e11 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -23,6 +23,7 @@ install_requires =
gofile_client>=1.0.1
myjdapi>=1.1.6
PyYAML>=6.0
+ psutil>=5.9.4
setuptools>=65.6.3
tqdm>=4.64.1
yarl>=1.8.2