Skip to content

Bulk asynchronous downloader for multiple file hosts

Update regex and include handling for missing title

Jules-WinnfieldX6c07f1f99f67
diff --git a/main.py b/main.py
index 36eb24509..a8750c762 100644
--- a/main.py
+++ b/main.py
@@ -47,7 +47,7 @@ def version_check() -> None:
def regex_links(urls) -> list:
- all_links = [x.group().replace(".md.", ".") for x in re.finditer(r"(?:http.*?)(?=('|$|\n|\r\n|\r)|\")", urls)]
+ all_links = [x.group().replace(".md.", ".") for x in re.finditer(r"(?:http.*?)(?=('|$|\n|\r\n|\r)|\"|\[)", urls)]
return all_links
diff --git a/settings.py b/settings.py
index dca8499ea..03bd80439 100644
--- a/settings.py
+++ b/settings.py
@@ -1,8 +1,11 @@
# Change at own risk, values here are default
# Defaults:
-# threads = 0 (Will run all threads), **this is not the same as cores.**
-# download_folder = "./Downloads/" will download in the CyberDropDownloader folder
+# threads = 0 - (Will run all threads), **this is not the same as cores.**
+# download_folder = "./Downloads/" - will download in the CyberDropDownloader folder
+# download_attempts = 10 - will try and download each file 10 times before giving up.
+# include_id_in_download_folder_name = False - setting this to true will all the ID to download folder names.
threads = 0
download_folder = "./Downloads/"
-download_attempts = 10
\ No newline at end of file
+download_attempts = 10
+include_id_in_download_folder_name = False
\ No newline at end of file
diff --git a/utils/scrapers.py b/utils/scrapers.py
index aa97695f7..23ae1c20c 100644
--- a/utils/scrapers.py
+++ b/utils/scrapers.py
@@ -54,9 +54,13 @@ class ShareX_Spider(Spider):
yield Request(url, self.parse_profile)
def parse_profile(self, response):
+ try:
+ title = response.css('div[class=header] h1 strong::text').get()
+ title = title.replace(r"\n", "").strip()
+ except Exception as e:
+ title = response.url.split('/')[-1]
+
list_recent = response.css('a[id=list-most-recent-link]::attr(href)').get()
- title = response.css('div[class=header] h1 strong::text').get()
- title = title.replace(r"\n", "").strip()
yield Request(list_recent, callback=self.get_list_links, meta={'title': title})
def get_albums(self, response):
@@ -65,9 +69,13 @@ class ShareX_Spider(Spider):
yield Request(url, callback=self.parse)
def parse(self, response, **kwargs):
+ try:
+ title = response.css('a[data-text=album-name]::text').get()
+ title = title.replace(r"\n", "").strip()
+ except Exception as e:
+ title = response.url.split('/')[-1]
+
list_recent = response.css('a[id=list-most-recent-link]::attr(href)').get()
- title = response.css('a[data-text=album-name]::text').get()
- title = title.replace(r"\n", "").strip()
yield Request(list_recent, callback=self.get_list_links, meta={'title': title})
def get_singular(self, response):
@@ -78,9 +86,13 @@ class ShareX_Spider(Spider):
def get_list_links(self, response):
links = response.meta.get('links', [])
- title = response.meta.get('title')
links.extend(response.css('a[href*=image] img::attr(src)').getall())
+ try:
+ title = response.meta.get('title')
+ except Exception as e:
+ title = response.url.split('/')[-1]
+
next_page = response.css('li.pagination-next a::attr("href")').get()
meta = {'links': links, 'title': title}
if next_page is not None:
@@ -118,8 +130,11 @@ class ChibisafeSpider(Spider):
def parse(self, response, **kwargs):
links = response.css('a[class=image]::attr(href)').getall()
- title = response.css('h1[id=title]::text').get()
- title = title.replace(r"\n", "").strip()
+ try:
+ title = response.css('h1[id=title]::text').get()
+ title = title.replace(r"\n", "").strip()
+ except Exception as e:
+ title = response.url.split('/')[-1]
for link in links:
netloc = urlparse(link).netloc.replace('www.', '')
yield {'netloc': netloc, 'url': link, 'title': title, 'referal': response.url, 'cookies': ''}