Skip to content

Bulk asynchronous downloader for multiple file hosts

Cleanup

Jules-WinnfieldX62fa369cd8e2
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.py
index c80035ded..0341d7746 100644
--- a/cyberdrop_dl/main.py
+++ b/cyberdrop_dl/main.py
@@ -1,17 +1,11 @@
import argparse
import asyncio
-import logging
-import os
from pathlib import Path
-import re
-
-from colorama import Fore, Style
-import requests
from . import __version__ as VERSION
from .utils.scraper import scrape
from .utils.downloaders import get_downloaders
-from .utils.data_classes import *
+from .utils.base_functions import *
def parse_args():
@@ -29,16 +23,6 @@ def parse_args():
return args
-def log(text, style = Fore.WHITE) -> None:
- """Wrapper around print() to add color to text"""
- print(style + str(text) + Style.RESET_ALL)
-
-
-def clear() -> None:
- """Clears the terminal screen"""
- os.system('cls' if os.name == 'nt' else 'clear')
-
-
def regex_links(urls) -> list:
all_links = [x.group().replace(".md.", ".") for x in re.finditer(r"(?:http.*?)(?=('|$|\n|\r\n|\r|\s)|\")", urls)]
return all_links
diff --git a/cyberdrop_dl/utils/base_functions.py b/cyberdrop_dl/utils/base_functions.py
index be145162c..b6675384b 100644
--- a/cyberdrop_dl/utils/base_functions.py
+++ b/cyberdrop_dl/utils/base_functions.py
@@ -1,6 +1,12 @@
+import logging
+import os
import re
from urllib.parse import urljoin
+from colorama import Fore, Style
+
+"""This file contains generic information and functions that are used around the program"""
+
FILE_FORMATS = {
'Images': {
'.jpg', '.jpeg', '.png', '.gif',
@@ -25,9 +31,22 @@ mapping_Erome = ["erome.com"]
mapping_GoFile = ["gofile.io"]
mapping_Pixeldrain = ["pixeldrain.com"]
-user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
+user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 ' \
+ 'Safari/537.36'
MAX_FILENAME_LENGTH = 100
+logger = logging.getLogger(__name__)
+
+
+def log(text, style = Fore.WHITE) -> None:
+ """Wrapper around print() to add color to text"""
+ print(style + str(text) + Style.RESET_ALL)
+
+
+def clear() -> None:
+ """Clears the terminal screen"""
+ os.system('cls' if os.name == 'nt' else 'clear')
+
def make_title_safe(title: str):
title = re.sub(r'[\\*?:"<>|./]', "-", title)
diff --git a/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py b/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py
index b696cd039..c004929a8 100644
--- a/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py
+++ b/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py
@@ -1,5 +1,3 @@
-import logging
-
import tldextract
from bs4 import BeautifulSoup
@@ -7,9 +5,6 @@ from ..base_functions import *
from ..data_classes import *
-logger = logging.getLogger(__name__)
-
-
class ChibisafeCrawler():
def __init__(self, *, include_id=False, **kwargs):
self.include_id = include_id
diff --git a/cyberdrop_dl/utils/crawlers/Erome_Spider.py b/cyberdrop_dl/utils/crawlers/Erome_Spider.py
index 16b64e0a3..dd2896ee5 100644
--- a/cyberdrop_dl/utils/crawlers/Erome_Spider.py
+++ b/cyberdrop_dl/utils/crawlers/Erome_Spider.py
@@ -1,5 +1,3 @@
-import logging
-
import tldextract
from bs4 import BeautifulSoup
@@ -7,9 +5,6 @@ from ..base_functions import *
from ..data_classes import *
-logger = logging.getLogger(__name__)
-
-
class EromeCrawler():
def __init__(self, *, include_id=False, **kwargs):
self.include_id = include_id
diff --git a/cyberdrop_dl/utils/crawlers/GoFile_Spider.py b/cyberdrop_dl/utils/crawlers/GoFile_Spider.py
index 60989cc61..2332f4a2a 100644
--- a/cyberdrop_dl/utils/crawlers/GoFile_Spider.py
+++ b/cyberdrop_dl/utils/crawlers/GoFile_Spider.py
@@ -2,7 +2,6 @@ from typing import Union
from gofile import Gofile
-from ..base_functions import *
from ..data_classes import *
diff --git a/cyberdrop_dl/utils/crawlers/ShareX_Spider.py b/cyberdrop_dl/utils/crawlers/ShareX_Spider.py
index fe54b28f3..5d26413d5 100644
--- a/cyberdrop_dl/utils/crawlers/ShareX_Spider.py
+++ b/cyberdrop_dl/utils/crawlers/ShareX_Spider.py
@@ -1,5 +1,3 @@
-import logging
-
import tldextract
from bs4 import BeautifulSoup
@@ -7,9 +5,6 @@ from ..base_functions import *
from ..data_classes import *
-logger = logging.getLogger(__name__)
-
-
class ShareXCrawler():
def __init__(self, *, include_id=False, **kwargs):
self.include_id = include_id
diff --git a/cyberdrop_dl/utils/downloaders.py b/cyberdrop_dl/utils/downloaders.py
index 7c4544e5a..3c03e98e4 100644
--- a/cyberdrop_dl/utils/downloaders.py
+++ b/cyberdrop_dl/utils/downloaders.py
@@ -1,7 +1,6 @@
import asyncio
from functools import wraps
import http
-import logging
import multiprocessing
from pathlib import Path
import ssl
@@ -13,7 +12,6 @@ import aiofiles.os
import aiohttp
import aiohttp.client_exceptions
import certifi
-from colorama import Fore, Style
from sanitize_filename import sanitize
from tqdm import tqdm
import yarl
@@ -21,13 +19,6 @@ import yarl
from .base_functions import *
from .data_classes import *
-logger = logging.getLogger(__name__)
-
-
-def log(text, style):
- # Log function for printing to command line
- print(style + str(text) + Style.RESET_ALL)
-
class FailureException(Exception):
"""Basic failure exception I can throw to force a retry."""
diff --git a/cyberdrop_dl/utils/scraper.py b/cyberdrop_dl/utils/scraper.py
index fa05429b7..7ea559241 100644
--- a/cyberdrop_dl/utils/scraper.py
+++ b/cyberdrop_dl/utils/scraper.py
@@ -1,12 +1,7 @@
-from collections import OrderedDict
-import logging
-import re
-
import asyncio
import aiohttp
import tldextract
-from colorama import Fore, Style
from .crawlers.ShareX_Spider import ShareXCrawler
from .crawlers.Erome_Spider import EromeCrawler
@@ -16,14 +11,6 @@ from .data_classes import *
from .base_functions import *
-logger = logging.getLogger(__name__)
-
-
-def log(text, style):
- # Log function for printing to command line
- print(style + str(text) + Style.RESET_ALL)
-
-
async def scrape(urls, include_id: bool):
Cascade = CascadeItem({})