Skip to content

Bulk asynchronous downloader for multiple file hosts

Add support for anonfiles

Jules-WinnfieldXe37892379cc7
diff --git a/cyberdrop_dl/utils/base_functions.py b/cyberdrop_dl/utils/base_functions.py
index e0947afd5..9aa85a7fa 100644
--- a/cyberdrop_dl/utils/base_functions.py
+++ b/cyberdrop_dl/utils/base_functions.py
@@ -37,6 +37,7 @@ mapping_Erome = ["erome.com"]
mapping_GoFile = ["gofile.io"]
mapping_Pixeldrain = ["pixeldrain.com"]
mapping_Thotsbay = ["thotsbay.com"]
+mapping_Anonfiles = ["anonfiles.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'
@@ -111,6 +112,7 @@ def url_sort(urls, Cascade):
Erome_urls = []
GoFile_urls = []
Thotsbay_urls = []
+ Anonfiles_urls = []
for url in urls:
url_extract = tldextract.extract(str(url))
@@ -141,6 +143,9 @@ def url_sort(urls, Cascade):
title = str(url).split('/')[-1]
Cascade.add_to_album(base_domain, title, pixeldrain_parse(url, title), url)
+ elif base_domain in mapping_Anonfiles:
+ Anonfiles_urls.append(url)
+
elif base_domain in mapping_Thotsbay:
Thotsbay_urls.append(url)
@@ -148,4 +153,4 @@ def url_sort(urls, Cascade):
log(str(url) + " is not supported currently.")
logger.debug(str(url) + " is not supported currently.")
- return ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls
+ return ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls, Anonfiles_urls
diff --git a/cyberdrop_dl/utils/crawlers/Anonfiles_Spider.py b/cyberdrop_dl/utils/crawlers/Anonfiles_Spider.py
new file mode 100644
index 000000000..600a8e9ba
--- /dev/null
+++ b/cyberdrop_dl/utils/crawlers/Anonfiles_Spider.py
@@ -0,0 +1,37 @@
+from bs4 import BeautifulSoup
+
+from ..base_functions import *
+from ..data_classes import *
+
+
+class AnonfilesCrawler():
+ def __init__(self, *, include_id=False):
+ self.include_id = include_id
+
+ async def fetch(self, session, url):
+ url_extract = tldextract.extract(str(url))
+ base_domain = "{}.{}".format(url_extract.domain, url_extract.suffix)
+ domain_obj = DomainItem(base_domain, {})
+
+ log("Starting scrape of " + str(url), Fore.WHITE)
+ logging.debug("Starting scrape of " + str(url))
+
+ try:
+ async with session.get(url, ssl=ssl_context) as response:
+ text = await response.text()
+ soup = BeautifulSoup(text, 'html.parser')
+
+ title = "Anonfiles"
+
+ link = soup.select_one("a[id=download-url]")
+ link = URL(link.get('href'))
+ domain_obj.add_to_album(title, link, url)
+
+ except Exception as e:
+ logger.debug("Error encountered while handling %s", str(url), exc_info=True)
+ logger.debug(e)
+
+ log("Finished scrape of " + str(url), Fore.WHITE)
+ logging.debug("Finished scrape of " + str(url))
+
+ return domain_obj
diff --git a/cyberdrop_dl/utils/scraper.py b/cyberdrop_dl/utils/scraper.py
index 3717ee671..e7e49bf50 100644
--- a/cyberdrop_dl/utils/scraper.py
+++ b/cyberdrop_dl/utils/scraper.py
@@ -5,6 +5,7 @@ from .crawlers.Erome_Spider import EromeCrawler
from .crawlers.Chibisafe_Spider import ChibisafeCrawler
from .crawlers.GoFile_Spider import GofileCrawler
from .crawlers.Thotsbay_Spider import ThotsbayCrawler
+from .crawlers.Anonfiles_Spider import AnonfilesCrawler
from .data_classes import *
from .base_functions import *
@@ -14,15 +15,17 @@ async def scrape(urls, include_id: bool, thotsbay_username: str, thotsbay_passwo
log("Starting Scrape", Fore.WHITE)
- ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls = url_sort(urls, Cascade)
+ ShareX_urls, Chibisafe_urls, Erome_urls, GoFile_urls, Thotsbay_urls, Anonfile_urls = url_sort(urls, Cascade)
erome_crawler = EromeCrawler(include_id=include_id)
sharex_crawler = ShareXCrawler(include_id=include_id)
chibisafe_crawler = ChibisafeCrawler(include_id=include_id)
gofile_crawler = GofileCrawler()
+ anonfiles_crawler = AnonfilesCrawler(include_id=include_id)
thotsbay_crawler = ThotsbayCrawler(include_id=include_id, username=thotsbay_username, password=thotsbay_password,
erome_crawler=erome_crawler, sharex_crawler=sharex_crawler,
- chibisafe_crawler=chibisafe_crawler, gofile_crawler=gofile_crawler)
+ chibisafe_crawler=chibisafe_crawler, gofile_crawler=gofile_crawler,
+ anonfiles_crawler=anonfiles_crawler)
tasks = []
headers = {"user-agent": user_agent}
@@ -38,6 +41,8 @@ async def scrape(urls, include_id: bool, thotsbay_username: str, thotsbay_passwo
tasks.append(chibisafe_crawler.fetch(session, url))
for url in GoFile_urls:
tasks.append(gofile_crawler.fetch(session, url))
+ for url in Anonfile_urls:
+ tasks.append(anonfiles_crawler.fetch(session, url))
results = await asyncio.gather(*tasks)
for domain_item in results: