Skip to content

Bulk asynchronous downloader for multiple file hosts

fix ssl errors?

Jules-WinnfieldX68534e5f7ce8
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py
index 57a42d3df..cd12916f8 100644
--- a/cyberdrop_dl/__init__.py
+++ b/cyberdrop_dl/__init__.py
@@ -1 +1 @@
-__version__ = "2.10.6"
+__version__ = "2.10.7"
diff --git a/cyberdrop_dl/utils/base_functions.py b/cyberdrop_dl/utils/base_functions.py
index 3c100ced1..0137e14ad 100644
--- a/cyberdrop_dl/utils/base_functions.py
+++ b/cyberdrop_dl/utils/base_functions.py
@@ -2,7 +2,9 @@ import logging
import os
import re
from urllib.parse import urljoin
+import ssl
+import certifi
from yarl import *
from colorama import Fore, Style
@@ -37,6 +39,8 @@ 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'
+ssl_context = ssl.create_default_context(cafile=certifi.where())
+
MAX_FILENAME_LENGTH = 100
logger = logging.getLogger(__name__)
diff --git a/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py b/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py
index f7e6cc8ea..0023282cd 100644
--- a/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py
+++ b/cyberdrop_dl/utils/crawlers/Chibisafe_Spider.py
@@ -19,7 +19,7 @@ class ChibisafeCrawler():
logging.debug("Starting scrape of " + str(url))
try:
- async with session.get(url) as response:
+ async with session.get(url, ssl=ssl_context) as response:
text = await response.text()
soup = BeautifulSoup(text, 'html.parser')
diff --git a/cyberdrop_dl/utils/crawlers/Erome_Spider.py b/cyberdrop_dl/utils/crawlers/Erome_Spider.py
index 4d6f93557..a1a8c7cd3 100644
--- a/cyberdrop_dl/utils/crawlers/Erome_Spider.py
+++ b/cyberdrop_dl/utils/crawlers/Erome_Spider.py
@@ -19,7 +19,7 @@ class EromeCrawler():
logging.debug("Starting scrape of " + str(url))
try:
- async with session.get(url) as response:
+ async with session.get(url, ssl=ssl_context) as response:
text = await response.text()
soup = BeautifulSoup(text, 'html.parser')
diff --git a/cyberdrop_dl/utils/crawlers/ShareX_Spider.py b/cyberdrop_dl/utils/crawlers/ShareX_Spider.py
index d8f319025..31cc697fd 100644
--- a/cyberdrop_dl/utils/crawlers/ShareX_Spider.py
+++ b/cyberdrop_dl/utils/crawlers/ShareX_Spider.py
@@ -37,7 +37,7 @@ class ShareXCrawler():
async def get_albums(self, url, session):
results = []
try:
- async with session.get(url) as response:
+ async with session.get(url, ssl=ssl_context) as response:
text = await response.text()
soup = BeautifulSoup(text, 'html.parser')
albums = soup.select("a[class='image-container --media']")
@@ -52,7 +52,7 @@ class ShareXCrawler():
async def get_singular(self, url, session):
results = []
try:
- async with session.get(url) as response:
+ async with session.get(url, ssl=ssl_context) as response:
text = await response.text()
soup = BeautifulSoup(text, 'html.parser')
link = URL(soup.select_one("input[id=embed-code-2]").get('value'))
@@ -67,7 +67,7 @@ class ShareXCrawler():
async def get_sub_album_links(self, url, session, og_title):
results = []
try:
- async with session.get(url) as response:
+ async with session.get(url, ssl=ssl_context) as response:
text = await response.text()
soup = BeautifulSoup(text, 'html.parser')
albums = soup.select("div[class=pad-content-listing] div")
@@ -84,7 +84,7 @@ class ShareXCrawler():
async def parse_profile(self, url, session):
results = []
try:
- async with session.get(url) as response:
+ async with session.get(url, ssl=ssl_context) as response:
text = await response.text()
soup = BeautifulSoup(text, 'html.parser')
title = soup.select_one("div[class=header] h1 strong").get_text()
@@ -105,7 +105,7 @@ class ShareXCrawler():
async def get_list_links(self, url, session, title):
results = []
try:
- async with session.get(url) as response:
+ async with session.get(url, ssl=ssl_context) as response:
text = await response.text()
soup = BeautifulSoup(text, 'html.parser')
if url.host == 'jpg.church':
@@ -130,7 +130,7 @@ class ShareXCrawler():
async def parse(self, url, session, og_title=None):
results = []
try:
- async with session.get(url) as response:
+ async with session.get(url, ssl=ssl_context) as response:
text = await response.text()
soup = BeautifulSoup(text, 'html.parser')
diff --git a/cyberdrop_dl/utils/downloaders.py b/cyberdrop_dl/utils/downloaders.py
index fad1e5a9b..85139929f 100644
--- a/cyberdrop_dl/utils/downloaders.py
+++ b/cyberdrop_dl/utils/downloaders.py
@@ -3,7 +3,6 @@ from functools import wraps
import http
import multiprocessing
from pathlib import Path
-import ssl
import time
import traceback
@@ -11,7 +10,6 @@ import aiofiles
import aiofiles.os
import aiohttp
import aiohttp.client_exceptions
-import certifi
from tqdm import tqdm
from .base_functions import *
@@ -94,7 +92,6 @@ class Downloader:
) -> None:
"""Download the content of given URL"""
headers = {'Referer': str(referral), 'user-agent': user_agent}
- ssl_context = ssl.create_default_context(cafile=certifi.where())
try:
async with self._semaphore: