diff --git a/dhere/http.py b/dhere.py similarity index 56% rename from dhere/http.py rename to dhere.py index d0a6efc..556f998 100644 --- a/dhere/http.py +++ b/dhere.py @@ -1,7 +1,12 @@ +from concurrent.futures import ThreadPoolExecutor +import pyperclip import cloudscraper from tqdm import tqdm +concurrent_downloads = 5 + + scraper = cloudscraper.CloudScraper() failed = [] @@ -22,4 +27,18 @@ def download(url: str): file.write(data) except Exception as ex: - failed.append(url) \ No newline at end of file + failed.append(url) + + +if __name__ == "__main__": + with ThreadPoolExecutor(max_workers=concurrent_downloads) as exe: + for line in pyperclip.paste().splitlines(): + line = line.strip() + if line == "": + continue + exe.submit(download, line) + + if len(failed) != 0: + with open("failed.log", "w") as file: + for url in failed: + file.write(url+"\n") \ No newline at end of file diff --git a/dhere/__main__.py b/dhere/__main__.py deleted file mode 100644 index cf8d996..0000000 --- a/dhere/__main__.py +++ /dev/null @@ -1,17 +0,0 @@ -from .http import download, failed -from concurrent.futures import ThreadPoolExecutor -import pyperclip - - -if __name__ == "__main__": - with ThreadPoolExecutor(max_workers=5) as exe: - for line in pyperclip.paste().splitlines(): - line = line.strip() - if line == "": - continue - exe.submit(download, line) - - if len(failed) != 0: - with open("failed.log", "w") as file: - for url in failed: - file.write(url+"\n") \ No newline at end of file