Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
Add retry functionality
Jules-WinnfieldX16e83c898c32
diff --git a/cyberdrop_dl/main.py b/cyberdrop_dl/main.pyindex 457199d3d..ecec448d8 100644--- a/cyberdrop_dl/main.py+++ b/cyberdrop_dl/main.py@@ -49,7 +49,11 @@ async def runtime(manager: Manager) -> None:download_manager = manager.download_managerasyncio.create_task(scrape_mapper.map_urls())- await scrape_mapper.load_links()+ if not manager.args_manager.retry:+ await scrape_mapper.load_links()+ else:+ await scrape_mapper.load_failed_links()+while True:if await scrape_mapper.check_complete() and await download_manager.check_complete():breakdiff --git a/cyberdrop_dl/managers/args_manager.py b/cyberdrop_dl/managers/args_manager.pyindex e2f35af86..524e96dac 100644--- a/cyberdrop_dl/managers/args_manager.py+++ b/cyberdrop_dl/managers/args_manager.py@@ -7,6 +7,9 @@ class ArgsManager:def __init__(self):self.parsed_args = {}+ self.all_configs = False+ self.retry = False+self.immediate_download = Falseself.load_config_from_args = Falseself.load_config_name = ""diff --git a/cyberdrop_dl/scraper/crawler.py b/cyberdrop_dl/scraper/crawler.pyindex 83820a308..5120cf1c9 100644--- a/cyberdrop_dl/scraper/crawler.py+++ b/cyberdrop_dl/scraper/crawler.py@@ -1,6 +1,7 @@from __future__ import annotationsimport asyncio+import copyfrom abc import ABC, abstractmethodfrom dataclasses import fieldfrom typing import TYPE_CHECKING, Optional@@ -143,6 +144,19 @@ class Crawler(ABC):"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""+ async def create_scrape_item(self, parent_scrape_item: ScrapeItem, url: URL, new_title_part: str,+ part_of_album: bool = False,+ possible_datetime: Optional[int] = None) -> ScrapeItem:+ """Creates a scrape item"""+ scrape_item = copy.deepcopy(parent_scrape_item)+ scrape_item.url = url+ if new_title_part:+ await scrape_item.add_to_parent_title(new_title_part)+ scrape_item.part_of_album = part_of_album if part_of_album else scrape_item.part_of_album+ if possible_datetime:+ scrape_item.possible_datetime = possible_datetime+ return scrape_item+async def create_title(self, title: str, album_id: Optional[str], thread_id: Optional[str]) -> str:"""Creates the title for the scrape item"""if self.manager.config_manager.settings_data['Download_Options']['include_album_id_in_folder_name']:diff --git a/cyberdrop_dl/scraper/crawlers/celebforum_crawler.py b/cyberdrop_dl/scraper/crawlers/celebforum_crawler.pyindex 81e31c51e..6cbb37717 100644--- a/cyberdrop_dl/scraper/crawlers/celebforum_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/celebforum_crawler.py@@ -96,11 +96,8 @@ class CelebForumCrawler(Crawler):if post_number > current_post_number:continue- new_scrape_item = ScrapeItem(thread_url, scrape_item.parent_title)- await new_scrape_item.add_to_parent_title(title)-date = int(post.select_one(self.post_date_selector).get(self.post_date_attribute))- new_scrape_item.possible_datetime = date+ new_scrape_item = await self.create_scrape_item(scrape_item, thread_url, title, False, date)for elem in post.find_all(self.quotes_selector):elem.decompose()@@ -132,7 +129,7 @@ class CelebForumCrawler(Crawler):async def post(self, scrape_item: ScrapeItem, post_content: Tag, post_number: int) -> None:"""Scrapes a post"""if self.manager.config_manager.settings_data['Download_Options']['separate_posts']:- scrape_item = ScrapeItem(scrape_item.url, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ scrape_item = await self.create_scrape_item(scrape_item, scrape_item.url, "")await scrape_item.add_to_parent_title("post-" + str(post_number))await self.links(scrape_item, post_content)@@ -163,7 +160,7 @@ class CelebForumCrawler(Crawler):try:if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -197,7 +194,7 @@ class CelebForumCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -223,7 +220,7 @@ class CelebForumCrawler(Crawler):link = "https:" + linklink = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -238,7 +235,7 @@ class CelebForumCrawler(Crawler):link = link.replace("ifr", "watch")link = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -264,7 +261,7 @@ class CelebForumCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -278,6 +275,5 @@ class CelebForumCrawler(Crawler):async def handle_internal_links(self, link: URL, scrape_item: ScrapeItem) -> None:"""Handles internal links"""filename, ext = await get_filename_and_ext(link.name, True)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title("Attachments")+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "Attachments", True)await self.handle_file(link, new_scrape_item, filename, ext)diff --git a/cyberdrop_dl/scraper/crawlers/coomer_crawler.py b/cyberdrop_dl/scraper/crawlers/coomer_crawler.pyindex ad209d7b7..bb8126baf 100644--- a/cyberdrop_dl/scraper/crawlers/coomer_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/coomer_crawler.py@@ -123,7 +123,6 @@ class CoomerCrawler(Crawler):if self.manager.config_manager.settings_data['Download_Options']['include_album_id_in_folder_name']:post_title = post_id + " - " + post_title- new_scrape_item = ScrapeItem(link, old_scrape_item.parent_title, True, await self.parse_datetime(date))- await new_scrape_item.add_to_parent_title(f"{user} ({self.folder_domain})")+ new_scrape_item = await self.create_scrape_item(old_scrape_item, link, f"{user} ({self.folder_domain})", True, await self.parse_datetime(date))await new_scrape_item.add_to_parent_title(post_title)await self.scraper_queue.put(new_scrape_item)diff --git a/cyberdrop_dl/scraper/crawlers/cyberdrop_crawler.py b/cyberdrop_dl/scraper/crawlers/cyberdrop_crawler.pyindex 69d756975..8e726b852 100644--- a/cyberdrop_dl/scraper/crawlers/cyberdrop_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/cyberdrop_crawler.py@@ -52,8 +52,7 @@ class CyberdropCrawler(Crawler):link = self.primary_base_url.with_path(link)link = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, date)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True, date)await self.scraper_queue.put(new_scrape_item)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py b/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.pyindex 93d2db8cf..4cf3dfeaf 100644--- a/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/cyberfile_crawler.py@@ -70,8 +70,7 @@ class CyberfileCrawler(Crawler):await log(f"Couldn't find folder or file id for {scrape_item.url} element")continue- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)page += 1@@ -106,8 +105,7 @@ class CyberfileCrawler(Crawler):await log(f"Couldn't find folder or file id for {scrape_item.url} element")continue- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)page += 1diff --git a/cyberdrop_dl/scraper/crawlers/ehentai_crawler.py b/cyberdrop_dl/scraper/crawlers/ehentai_crawler.pyindex f1c7611ee..6260fc955 100644--- a/cyberdrop_dl/scraper/crawlers/ehentai_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/ehentai_crawler.py@@ -48,8 +48,7 @@ class EHentaiCrawler(Crawler):images = soup.select("div[class=gdtm] div a")for image in images:link = URL(image.get('href'))- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, date)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True, date)await self.scraper_queue.put(new_scrape_item)next_page_opts = soup.select('td[onclick="document.location=this.firstChild.href"]')@@ -61,7 +60,7 @@ class EHentaiCrawler(Crawler):if next_page is not None:next_page = URL(next_page.get('href'))if next_page is not None:- new_scrape_item = ScrapeItem(next_page, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, next_page, "")await self.scraper_queue.put(new_scrape_item)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/erome_crawler.py b/cyberdrop_dl/scraper/crawlers/erome_crawler.pyindex 018e03ada..ebe160f92 100644--- a/cyberdrop_dl/scraper/crawlers/erome_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/erome_crawler.py@@ -42,14 +42,13 @@ class EromeCrawler(Crawler):for album in albums:link = URL(album['href'])- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)next_page = soup.select_one('a[rel="next"]')if next_page:next_page = next_page.get("href").split("page=")[-1]- new_scrape_item = ScrapeItem(scrape_item.url.with_query(f"page={next_page}"), scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, scrape_item.url.with_query(f"page={next_page}"), "")await self.scraper_queue.put(new_scrape_item)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/f95zone_crawler.py b/cyberdrop_dl/scraper/crawlers/f95zone_crawler.pyindex 54bdbf3fc..9b2852e32 100644--- a/cyberdrop_dl/scraper/crawlers/f95zone_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/f95zone_crawler.py@@ -96,11 +96,8 @@ class F95ZoneCrawler(Crawler):if post_number > current_post_number:continue- new_scrape_item = ScrapeItem(thread_url, scrape_item.parent_title)- await new_scrape_item.add_to_parent_title(title)-date = int(post.select_one(self.post_date_selector).get(self.post_date_attribute))- new_scrape_item.possible_datetime = date+ new_scrape_item = await self.create_scrape_item(scrape_item, thread_url, title, False, date)for elem in post.find_all(self.quotes_selector):elem.decompose()@@ -132,7 +129,7 @@ class F95ZoneCrawler(Crawler):async def post(self, scrape_item: ScrapeItem, post_content: Tag, post_number: int) -> None:"""Scrapes a post"""if self.manager.config_manager.settings_data['Download_Options']['separate_posts']:- scrape_item = ScrapeItem(scrape_item.url, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ scrape_item = await self.create_scrape_item(scrape_item, scrape_item.url, "")await scrape_item.add_to_parent_title("post-" + str(post_number))await self.links(scrape_item, post_content)@@ -168,7 +165,7 @@ class F95ZoneCrawler(Crawler):try:if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.host:await self.handle_internal_links(link, scrape_item)@@ -202,7 +199,7 @@ class F95ZoneCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.host:await self.handle_internal_links(link, scrape_item)@@ -228,7 +225,7 @@ class F95ZoneCrawler(Crawler):link = "https:" + linklink = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -243,7 +240,7 @@ class F95ZoneCrawler(Crawler):link = link.replace("ifr", "watch")link = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -269,7 +266,7 @@ class F95ZoneCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.host:await self.handle_internal_links(link, scrape_item)@@ -283,8 +280,7 @@ class F95ZoneCrawler(Crawler):async def handle_internal_links(self, link: URL, scrape_item: ScrapeItem) -> None:"""Handles internal links"""filename, ext = await get_filename_and_ext(link.name, True)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title("Attachments")+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "Attachments", True)await self.handle_file(link, new_scrape_item, filename, ext)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/fapello_crawler.py b/cyberdrop_dl/scraper/crawlers/fapello_crawler.pyindex 189c15b44..27d9364e2 100644--- a/cyberdrop_dl/scraper/crawlers/fapello_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/fapello_crawler.py@@ -49,12 +49,11 @@ class FapelloCrawler(Crawler):if "javascript" in post.get('href'):video_tag = post.select_one('iframe')video_link = URL(video_tag.get('src'))- new_scrape_item = ScrapeItem(video_link, scrape_item.parent_title, True, scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, video_link, "", True)await self.manager.queue_manager.url_objects_to_map.put(new_scrape_item)else:link = URL(post.get('href'))- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)next_page = soup.select_one('div[id="next_page"] a')diff --git a/cyberdrop_dl/scraper/crawlers/gofile_crawler.py b/cyberdrop_dl/scraper/crawlers/gofile_crawler.pyindex 6ac418a18..1e873db37 100644--- a/cyberdrop_dl/scraper/crawlers/gofile_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/gofile_crawler.py@@ -72,8 +72,7 @@ class GoFileCrawler(Crawler):for content_id in contents:content = contents[content_id]if content["type"] == "folder":- new_scrape_item = ScrapeItem(scrape_item.url.with_name(content["name"]), scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, URL(content["name"]), title, True)await self.scraper_queue.put(new_scrape_item)continueif content["link"] == "overloaded":diff --git a/cyberdrop_dl/scraper/crawlers/imageban_crawler.py b/cyberdrop_dl/scraper/crawlers/imageban_crawler.pyindex 4df16c4c8..13f895329 100644--- a/cyberdrop_dl/scraper/crawlers/imageban_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/imageban_crawler.py@@ -9,7 +9,7 @@ from yarl import URLfrom cyberdrop_dl.scraper.crawler import Crawlerfrom cyberdrop_dl.utils.dataclasses.url_objects import ScrapeItem-from cyberdrop_dl.utils.utilities import get_filename_and_ext, error_handling_wrapper, log+from cyberdrop_dl.utils.utilities import get_filename_and_ext, error_handling_wrapperif TYPE_CHECKING:from cyberdrop_dl.managers.manager import Manager@@ -57,8 +57,8 @@ class ImageBanCrawler(Crawler):link = URL("https://" + scrape_item.url.host + link_path)else:link = URL(link_path)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)++ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)next_page = soup.select_one('a[class*="page-link next"]')@@ -68,7 +68,7 @@ class ImageBanCrawler(Crawler):link = URL("https://" + scrape_item.url.host + link_path)else:link = URL(link_path)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "", True)await self.scraper_queue.put(new_scrape_item)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/imgbb_crawler.py b/cyberdrop_dl/scraper/crawlers/imgbb_crawler.pyindex 61699f4c7..1810cf825 100644--- a/cyberdrop_dl/scraper/crawlers/imgbb_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/imgbb_crawler.py@@ -49,8 +49,7 @@ class ImgBBCrawler(Crawler):albums = soup.select("a[class='image-container --media']")for album in albums:sub_album_link = URL(album.get('href'))- new_scrape_item = ScrapeItem(sub_album_link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, sub_album_link, title, True)await self.scraper_queue.put(new_scrape_item)async with self.request_limiter:@@ -63,8 +62,7 @@ class ImgBBCrawler(Crawler):links = soup.select("a[class*=image-container]")for link in links:link = URL(link.get('href'))- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)link_next = soup.select_one('a[data-pagination=next]')diff --git a/cyberdrop_dl/scraper/crawlers/imgkiwi_crawler.py b/cyberdrop_dl/scraper/crawlers/imgkiwi_crawler.pyindex 77663090c..4a16d11eb 100644--- a/cyberdrop_dl/scraper/crawlers/imgkiwi_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/imgkiwi_crawler.py@@ -51,8 +51,7 @@ class ImgKiwiCrawler(Crawler):links = soup.select("a[href*=image]")for link in links:link = URL(link.get('href'))- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)link_next = soup.select_one('a[data-pagination=next]')diff --git a/cyberdrop_dl/scraper/crawlers/imgur_crawler.py b/cyberdrop_dl/scraper/crawlers/imgur_crawler.pyindex d675fb63e..bf3c1105b 100644--- a/cyberdrop_dl/scraper/crawlers/imgur_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/imgur_crawler.py@@ -62,9 +62,8 @@ class ImgurCrawler(Crawler):for image in JSON_Obj["data"]:link = URL(image["link"])date = image["datetime"]- new_scrape_object = ScrapeItem(link, scrape_item.parent_title, True, date)- await new_scrape_object.add_to_parent_title(title)- await self.handle_direct(new_scrape_object)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True, date)+ await self.handle_direct(new_scrape_item)@error_handling_wrapperasync def image(self, scrape_item: ScrapeItem) -> None:@@ -80,8 +79,8 @@ class ImgurCrawler(Crawler):date = JSON_Obj["data"]["datetime"]link = URL(JSON_Obj["data"]["link"])- new_scrape_object = ScrapeItem(link, scrape_item.parent_title, possible_datetime=date)- await self.handle_direct(new_scrape_object)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "", True, date)+ await self.handle_direct(new_scrape_item)@error_handling_wrapperasync def handle_direct(self, scrape_item: ScrapeItem) -> None:diff --git a/cyberdrop_dl/scraper/crawlers/jpgchurch_crawler.py b/cyberdrop_dl/scraper/crawlers/jpgchurch_crawler.pyindex 5040873d6..a62489c53 100644--- a/cyberdrop_dl/scraper/crawlers/jpgchurch_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/jpgchurch_crawler.py@@ -49,8 +49,7 @@ class JPGChurchCrawler(Crawler):albums = soup.select("a[class='image-container --media']")for album in albums:sub_album_link = URL(album.get('href'))- new_scrape_item = ScrapeItem(sub_album_link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, sub_album_link, title, True)await self.scraper_queue.put(new_scrape_item)async with self.request_limiter:@@ -63,8 +62,7 @@ class JPGChurchCrawler(Crawler):links = soup.select("a[href*=img]")for link in links:link = URL(link.get('href'))- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)link_next = soup.select_one('a[data-pagination=next]')diff --git a/cyberdrop_dl/scraper/crawlers/kemono_crawler.py b/cyberdrop_dl/scraper/crawlers/kemono_crawler.pyindex 2216e3b79..1b96dfabc 100644--- a/cyberdrop_dl/scraper/crawlers/kemono_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/kemono_crawler.py@@ -140,7 +140,6 @@ class KemonoCrawler(Crawler):if self.manager.config_manager.settings_data['Download_Options']['include_album_id_in_folder_name']:post_title = post_id + " - " + post_title- new_scrape_item = ScrapeItem(link, old_scrape_item.parent_title, True, await self.parse_datetime(date))- await new_scrape_item.add_to_parent_title(f"{user} ({self.folder_domain})")+ new_scrape_item = await self.create_scrape_item(old_scrape_item, link, f"{user} ({self.folder_domain})", True, await self.parse_datetime(date))await new_scrape_item.add_to_parent_title(post_title)await self.scraper_queue.put(new_scrape_item)diff --git a/cyberdrop_dl/scraper/crawlers/leakedmodels_crawler.py b/cyberdrop_dl/scraper/crawlers/leakedmodels_crawler.pyindex 03b652d4b..d82d24cf0 100644--- a/cyberdrop_dl/scraper/crawlers/leakedmodels_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/leakedmodels_crawler.py@@ -100,11 +100,8 @@ class LeakedModelsCrawler(Crawler):if post_number > current_post_number:continue- new_scrape_item = ScrapeItem(thread_url, scrape_item.parent_title)- await new_scrape_item.add_to_parent_title(title)-date = int(post.select_one(self.post_date_selector).get(self.post_date_attribute))- new_scrape_item.possible_datetime = date+ new_scrape_item = await self.create_scrape_item(scrape_item, thread_url, title, False, date)for elem in post.find_all(self.quotes_selector):elem.decompose()@@ -136,7 +133,7 @@ class LeakedModelsCrawler(Crawler):async def post(self, scrape_item: ScrapeItem, post_content: Tag, post_number: int) -> None:"""Scrapes a post"""if self.manager.config_manager.settings_data['Download_Options']['separate_posts']:- scrape_item = ScrapeItem(scrape_item.url, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ scrape_item = await self.create_scrape_item(scrape_item, scrape_item.url, "")await scrape_item.add_to_parent_title("post-" + str(post_number))await self.links(scrape_item, post_content)@@ -171,7 +168,7 @@ class LeakedModelsCrawler(Crawler):try:if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -201,7 +198,7 @@ class LeakedModelsCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -227,7 +224,7 @@ class LeakedModelsCrawler(Crawler):link = "https:" + linklink = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -242,7 +239,7 @@ class LeakedModelsCrawler(Crawler):link = link.replace("ifr", "watch")link = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -268,7 +265,7 @@ class LeakedModelsCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -282,6 +279,5 @@ class LeakedModelsCrawler(Crawler):async def handle_internal_links(self, link: URL, scrape_item: ScrapeItem) -> None:"""Handles internal links"""filename, ext = await get_filename_and_ext(link.name, True)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title("Attachments")+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "Attachments", True)await self.handle_file(link, new_scrape_item, filename, ext)diff --git a/cyberdrop_dl/scraper/crawlers/mediafire_crawler.py b/cyberdrop_dl/scraper/crawlers/mediafire_crawler.pyindex 261fbfef6..fdeb6773c 100644--- a/cyberdrop_dl/scraper/crawlers/mediafire_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/mediafire_crawler.py@@ -52,8 +52,7 @@ class MediaFireCrawler(Crawler):for file in files:date = await self.parse_datetime(file['created'])link = URL(file['links']['normal_download'])- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, date)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True, date)await self.scraper_queue.put(new_scrape_item)if folder_contents["folder_content"]["more_chunks"] == "yes":diff --git a/cyberdrop_dl/scraper/crawlers/nudostar_crawler.py b/cyberdrop_dl/scraper/crawlers/nudostar_crawler.pyindex 453be29a2..cdab2631c 100644--- a/cyberdrop_dl/scraper/crawlers/nudostar_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/nudostar_crawler.py@@ -97,11 +97,8 @@ class NudoStarCrawler(Crawler):if post_number > current_post_number:continue- new_scrape_item = ScrapeItem(thread_url, scrape_item.parent_title)- await new_scrape_item.add_to_parent_title(title)-date = int(post.select_one(self.post_date_selector).get(self.post_date_attribute))- new_scrape_item.possible_datetime = date+ new_scrape_item = await self.create_scrape_item(new_scrape_item, thread_url, title, True, date)for elem in post.find_all(self.quotes_selector):elem.decompose()@@ -133,7 +130,7 @@ class NudoStarCrawler(Crawler):async def post(self, scrape_item: ScrapeItem, post_content: Tag, post_number: int) -> None:"""Scrapes a post"""if self.manager.config_manager.settings_data['Download_Options']['separate_posts']:- scrape_item = ScrapeItem(scrape_item.url, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ scrape_item = await self.create_scrape_item(scrape_item, scrape_item.url, "")await scrape_item.add_to_parent_title("post-" + str(post_number))await self.links(scrape_item, post_content)@@ -165,7 +162,7 @@ class NudoStarCrawler(Crawler):try:if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -197,7 +194,7 @@ class NudoStarCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -220,7 +217,7 @@ class NudoStarCrawler(Crawler):link = "https:" + linklink = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -244,7 +241,7 @@ class NudoStarCrawler(Crawler):if link.endswith("/"):link = link[:-1]link = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -267,7 +264,7 @@ class NudoStarCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -282,6 +279,5 @@ class NudoStarCrawler(Crawler):"""Handles internal links"""temp_link = URL(str(link)[:-1]) if str(link).endswith("/") else linkfilename, ext = await get_filename_and_ext(temp_link.name, True)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title("Attachments")+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "Attachments", True)await self.handle_file(link, new_scrape_item, filename, ext)diff --git a/cyberdrop_dl/scraper/crawlers/nudostartv_crawler.py b/cyberdrop_dl/scraper/crawlers/nudostartv_crawler.pyindex 69832c6b3..c4f7beca7 100644--- a/cyberdrop_dl/scraper/crawlers/nudostartv_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/nudostartv_crawler.py@@ -39,13 +39,12 @@ class NudoStarTVCrawler(Crawler):content = soup.select('div[id=list_videos_common_videos_list_items] div a')for page in content:link = URL(page.get('href'))- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.image(new_scrape_item)next_page = soup.select_one('li[class=next] a')if next_page:link = URL(next_page.get('href'))- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.scraper_queue.put(new_scrape_item)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/omegascans_crawler.py b/cyberdrop_dl/scraper/crawlers/omegascans_crawler.pyindex 16144ab62..14742d8af 100644--- a/cyberdrop_dl/scraper/crawlers/omegascans_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/omegascans_crawler.py@@ -50,7 +50,7 @@ class OmegaScansCrawler(Crawler):chapter_path = self.primary_base_domain / chapter_path[1:]else:chapter_path = URL(chapter_path)- new_scrape_item = ScrapeItem(chapter_path, scrape_item.parent_title, True, scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, chapter_path, "", True)await self.scraper_queue.put(new_scrape_item)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/pimpandhost_crawler.py b/cyberdrop_dl/scraper/crawlers/pimpandhost_crawler.pyindex bf9d8f69d..78bb7f23b 100644--- a/cyberdrop_dl/scraper/crawlers/pimpandhost_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/pimpandhost_crawler.py@@ -46,8 +46,7 @@ class PimpAndHostCrawler(Crawler):files = soup.select('a[class*="image-wrapper center-cropped im-wr"]')for file in files:link = URL(file.get("href"))- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, date)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True, date)await self.scraper_queue.put(new_scrape_item)next_page = soup.select_one("li[class=next] a")@@ -55,7 +54,7 @@ class PimpAndHostCrawler(Crawler):next_page = next_page.get("href")if next_page.startswith("/"):next_page = URL("https://pimpandhost.com" + next_page)- new_scrape_item = ScrapeItem(next_page, scrape_item.parent_title, True, date)+ new_scrape_item = await self.create_scrape_item(scrape_item, next_page, "", True, date)await self.scraper_queue.put(new_scrape_item)@error_handling_wrapper@@ -71,7 +70,7 @@ class PimpAndHostCrawler(Crawler):date = soup.select_one("span[class=date-time]").get("title")date = await self.parse_datetime(date)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, date)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "", True, date)filename, ext = await get_filename_and_ext(link.name)await self.handle_file(link, new_scrape_item, filename, ext)diff --git a/cyberdrop_dl/scraper/crawlers/pixeldrain_crawler.py b/cyberdrop_dl/scraper/crawlers/pixeldrain_crawler.pyindex 64ab42fbd..84dbf7714 100644--- a/cyberdrop_dl/scraper/crawlers/pixeldrain_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/pixeldrain_crawler.py@@ -46,8 +46,7 @@ class PixelDrainCrawler(Crawler):link = await self.create_download_link(file['id'])date = await self.parse_datetime(file['date_upload'].replace("T", " ").split(".")[0])filename, ext = await get_filename_and_ext(file['name'])- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, date)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True, date)await self.handle_file(link, new_scrape_item, filename, ext)@error_handling_wrapper@@ -59,7 +58,7 @@ class PixelDrainCrawler(Crawler):link = await self.create_download_link(JSON_Resp['id'])date = await self.parse_datetime(JSON_Resp['date_upload'].replace("T", " ").split(".")[0])filename, ext = await get_filename_and_ext(JSON_Resp['name'])- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, scrape_item.part_of_album, date)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "", False, date)await self.handle_file(link, new_scrape_item, filename, ext)"""~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"""diff --git a/cyberdrop_dl/scraper/crawlers/postimg_crawler.py b/cyberdrop_dl/scraper/crawlers/postimg_crawler.pyindex 22155addd..4ea42b652 100644--- a/cyberdrop_dl/scraper/crawlers/postimg_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/postimg_crawler.py@@ -50,8 +50,7 @@ class PostImgCrawler(Crawler):for image in JSON_Resp['images']:link = URL(image[4])filename, ext = image[2], image[3]- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.handle_file(link, new_scrape_item, filename, ext)if not JSON_Resp['has_page_next']:diff --git a/cyberdrop_dl/scraper/crawlers/reddit_crawler.py b/cyberdrop_dl/scraper/crawlers/reddit_crawler.pyindex 399cc22d3..839d287e0 100644--- a/cyberdrop_dl/scraper/crawlers/reddit_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/reddit_crawler.py@@ -121,7 +121,8 @@ class RedditCrawler(Crawler):async def create_new_scrape_item(self, link: URL, old_scrape_item: ScrapeItem, title: str, date: int) -> ScrapeItem:"""Creates a new scrape item with the same parent as the old scrape item"""- new_scrape_item = ScrapeItem(link, old_scrape_item.parent_title, True, date)++ new_scrape_item = await self.create_scrape_item(old_scrape_item, link, "", True, date)if self.manager.config_manager.settings_data['Download_Options']['separate_posts']:await new_scrape_item.add_to_parent_title(title)return new_scrape_itemdiff --git a/cyberdrop_dl/scraper/crawlers/redgifs_crawler.py b/cyberdrop_dl/scraper/crawlers/redgifs_crawler.pyindex b7ca4d304..19e60f694 100644--- a/cyberdrop_dl/scraper/crawlers/redgifs_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/redgifs_crawler.py@@ -56,7 +56,7 @@ class RedGifsCrawler(Crawler):else:link = URL(links["sd"])- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "", True)await self.scraper_queue.put(new_scrape_item)page += 1diff --git a/cyberdrop_dl/scraper/crawlers/rule34xxx_crawler.py b/cyberdrop_dl/scraper/crawlers/rule34xxx_crawler.pyindex 19845a8b5..23036da8b 100644--- a/cyberdrop_dl/scraper/crawlers/rule34xxx_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/rule34xxx_crawler.py@@ -51,8 +51,7 @@ class Rule34XXXCrawler(Crawler):if link.startswith("/"):link = f"{self.primary_base_url}{link}"link = URL(link, encoded=True)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)next_page = soup.select_one("a[alt=next]")@@ -63,7 +62,7 @@ class Rule34XXXCrawler(Crawler):next_page = scrape_item.url.with_query(next_page[1:])else:next_page = URL(next_page)- new_scrape_item = ScrapeItem(next_page, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, next_page, "")await self.scraper_queue.put(new_scrape_item)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/rule34xyz_crawler.py b/cyberdrop_dl/scraper/crawlers/rule34xyz_crawler.pyindex 3f8404291..cd73900f3 100644--- a/cyberdrop_dl/scraper/crawlers/rule34xyz_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/rule34xyz_crawler.py@@ -49,8 +49,7 @@ class Rule34XYZCrawler(Crawler):if link.startswith("/"):link = f"{self.primary_base_url}{link}"link = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.scraper_queue.put(new_scrape_item)if not content:return@@ -60,7 +59,7 @@ class Rule34XYZCrawler(Crawler):next_page = scrape_item.url.with_path(f"/{scrape_item.url.parts[1]}/page/{page + 1}")else:next_page = scrape_item.url.with_path(f"/{scrape_item.url.parts[1]}/page/2")- new_scrape_item = ScrapeItem(next_page, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, next_page, "")await self.scraper_queue.put(new_scrape_item)@error_handling_wrapper@@ -68,7 +67,10 @@ class Rule34XYZCrawler(Crawler):"""Scrapes an image"""async with self.request_limiter:soup = await self.client.get_BS4(self.domain, scrape_item.url)+date = await self.parse_datetime(soup.select_one('div[class="posted ng-star-inserted"]').text.split("(")[1].split(")")[0])+ scrape_item.date = date+image = soup.select_one('img[class*="img shadow-base"]')if image:link = self.primary_base_url.with_path(image.get('src'))diff --git a/cyberdrop_dl/scraper/crawlers/simpcity_crawler.py b/cyberdrop_dl/scraper/crawlers/simpcity_crawler.pyindex 639b39716..55c93fed5 100644--- a/cyberdrop_dl/scraper/crawlers/simpcity_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/simpcity_crawler.py@@ -97,11 +97,8 @@ class SimpCityCrawler(Crawler):if post_number > current_post_number:continue- new_scrape_item = ScrapeItem(thread_url, scrape_item.parent_title)- await new_scrape_item.add_to_parent_title(title)-date = int(post.select_one(self.post_date_selector).get(self.post_date_attribute))- new_scrape_item.possible_datetime = date+ new_scrape_item = await self.create_scrape_item(scrape_item, thread_url, title, False, date)for elem in post.find_all(self.quotes_selector):elem.decompose()@@ -133,7 +130,7 @@ class SimpCityCrawler(Crawler):async def post(self, scrape_item: ScrapeItem, post_content: Tag, post_number: int) -> None:"""Scrapes a post"""if self.manager.config_manager.settings_data['Download_Options']['separate_posts']:- scrape_item = ScrapeItem(scrape_item.url, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ scrape_item = await self.create_scrape_item(scrape_item, scrape_item.url, "")await scrape_item.add_to_parent_title("post-" + str(post_number))await self.links(scrape_item, post_content)@@ -168,7 +165,7 @@ class SimpCityCrawler(Crawler):try:if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -203,7 +200,7 @@ class SimpCityCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -229,7 +226,7 @@ class SimpCityCrawler(Crawler):link = "https:" + linklink = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -253,7 +250,7 @@ class SimpCityCrawler(Crawler):if link.endswith("/"):link = link[:-1]link = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -279,7 +276,7 @@ class SimpCityCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -293,6 +290,5 @@ class SimpCityCrawler(Crawler):async def handle_internal_links(self, link: URL, scrape_item: ScrapeItem) -> None:"""Handles internal links"""filename, ext = await get_filename_and_ext(link.name, True)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title("Attachments")+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "Attachments", True)await self.handle_file(link, new_scrape_item, filename, ext)diff --git a/cyberdrop_dl/scraper/crawlers/socialmediagirls_crawler.py b/cyberdrop_dl/scraper/crawlers/socialmediagirls_crawler.pyindex 8dbe508af..1f512fcc1 100644--- a/cyberdrop_dl/scraper/crawlers/socialmediagirls_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/socialmediagirls_crawler.py@@ -97,11 +97,8 @@ class SocialMediaGirlsCrawler(Crawler):if post_number > current_post_number:continue- new_scrape_item = ScrapeItem(thread_url, scrape_item.parent_title)- await new_scrape_item.add_to_parent_title(title)-date = int(post.select_one(self.post_date_selector).get(self.post_date_attribute))- new_scrape_item.possible_datetime = date+ new_scrape_item = await self.create_scrape_item(scrape_item, thread_url, title, True, date)for elem in post.find_all(self.quotes_selector):elem.decompose()@@ -133,7 +130,7 @@ class SocialMediaGirlsCrawler(Crawler):async def post(self, scrape_item: ScrapeItem, post_content: Tag, post_number: int) -> None:"""Scrapes a post"""if self.manager.config_manager.settings_data['Download_Options']['separate_posts']:- scrape_item = ScrapeItem(scrape_item.url, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ scrape_item = await self.create_scrape_item(scrape_item, scrape_item.url, "")await scrape_item.add_to_parent_title("post-" + str(post_number))await self.links(scrape_item, post_content)@@ -171,7 +168,7 @@ class SocialMediaGirlsCrawler(Crawler):returntry:if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts or "smgmedia" in link.host:await self.handle_internal_links(link, scrape_item)@@ -206,7 +203,7 @@ class SocialMediaGirlsCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts or "smgmedia" in link.host:await self.handle_internal_links(link, scrape_item)@@ -232,7 +229,7 @@ class SocialMediaGirlsCrawler(Crawler):link = "https:" + linklink = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -256,7 +253,7 @@ class SocialMediaGirlsCrawler(Crawler):if link.endswith("/"):link = link[:-1]link = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -282,7 +279,7 @@ class SocialMediaGirlsCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts or "smgmedia" in link.host:await self.handle_internal_links(link, scrape_item)@@ -296,8 +293,7 @@ class SocialMediaGirlsCrawler(Crawler):async def handle_internal_links(self, link: URL, scrape_item: ScrapeItem) -> None:"""Handles internal links"""filename, ext = await get_filename_and_ext(link.name, True)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title("Attachments")+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "Attachments", True)await self.handle_file(link, new_scrape_item, filename, ext)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/toonily_crawler.py b/cyberdrop_dl/scraper/crawlers/toonily_crawler.pyindex d5d7cc662..11dbf99c1 100644--- a/cyberdrop_dl/scraper/crawlers/toonily_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/toonily_crawler.py@@ -51,7 +51,7 @@ class ToonilyCrawler(Crawler):chapter_path = self.primary_base_domain / chapter_path[1:]else:chapter_path = URL(chapter_path)- new_scrape_item = ScrapeItem(chapter_path, scrape_item.parent_title, True, scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, chapter_path, "", True)await self.scraper_queue.put(new_scrape_item)@error_handling_wrapperdiff --git a/cyberdrop_dl/scraper/crawlers/xbunker_crawler.py b/cyberdrop_dl/scraper/crawlers/xbunker_crawler.pyindex cb2749505..5e65e06ce 100644--- a/cyberdrop_dl/scraper/crawlers/xbunker_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/xbunker_crawler.py@@ -101,11 +101,8 @@ class XBunkerCrawler(Crawler):if post_number > current_post_number:continue- new_scrape_item = ScrapeItem(thread_url, scrape_item.parent_title)- await new_scrape_item.add_to_parent_title(title)-date = int(post.select_one(self.post_date_selector).get(self.post_date_attribute))- new_scrape_item.possible_datetime = date+ new_scrape_item = await self.create_scrape_item(scrape_item, thread_url, title, False, date)for elem in post.find_all(self.quotes_selector):elem.decompose()@@ -137,7 +134,7 @@ class XBunkerCrawler(Crawler):async def post(self, scrape_item: ScrapeItem, post_content: Tag, post_number: int) -> None:"""Scrapes a post"""if self.manager.config_manager.settings_data['Download_Options']['separate_posts']:- scrape_item = ScrapeItem(scrape_item.url, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ scrape_item = await self.create_scrape_item(scrape_item, scrape_item.url, "")await scrape_item.add_to_parent_title("post-" + str(post_number))await self.links(scrape_item, post_content)@@ -171,7 +168,7 @@ class XBunkerCrawler(Crawler):link = URL(link)try:if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts or self.extra_attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -204,7 +201,7 @@ class XBunkerCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts or self.extra_attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -230,7 +227,7 @@ class XBunkerCrawler(Crawler):link = "https:" + linklink = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -254,7 +251,7 @@ class XBunkerCrawler(Crawler):if link.endswith("/"):link = link[:-1]link = URL(link)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)@error_handling_wrapper@@ -280,7 +277,7 @@ class XBunkerCrawler(Crawler):link = URL(link)if self.domain not in link.host:- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, possible_datetime=scrape_item.possible_datetime)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "")await self.handle_external_links(new_scrape_item)elif self.attachment_url_part in link.parts or self.extra_attachment_url_part in link.parts:await self.handle_internal_links(link, scrape_item)@@ -294,6 +291,5 @@ class XBunkerCrawler(Crawler):async def handle_internal_links(self, link: URL, scrape_item: ScrapeItem) -> None:"""Handles internal links"""filename, ext = await get_filename_and_ext(link.name, True)- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title("Attachments")+ new_scrape_item = await self.create_scrape_item(scrape_item, link, "Attachments", True)await self.handle_file(link, new_scrape_item, filename, ext)diff --git a/cyberdrop_dl/scraper/crawlers/xbunkr_crawler.py b/cyberdrop_dl/scraper/crawlers/xbunkr_crawler.pyindex 0bc2bebef..3c3fa0c45 100644--- a/cyberdrop_dl/scraper/crawlers/xbunkr_crawler.py+++ b/cyberdrop_dl/scraper/crawlers/xbunkr_crawler.py@@ -49,6 +49,5 @@ class XBunkrCrawler(Crawler):except NoExtensionFailure:await log(f"Couldn't get extension for {str(link)}")continue- new_scrape_item = ScrapeItem(link, scrape_item.parent_title, True, scrape_item.possible_datetime)- await new_scrape_item.add_to_parent_title(title)+ new_scrape_item = await self.create_scrape_item(scrape_item, link, title, True)await self.handle_file(link, new_scrape_item, filename, ext)diff --git a/cyberdrop_dl/scraper/scraper.py b/cyberdrop_dl/scraper/scraper.pyindex 9bf4b4a71..13e6e4fda 100644--- a/cyberdrop_dl/scraper/scraper.py+++ b/cyberdrop_dl/scraper/scraper.py@@ -3,6 +3,7 @@ from __future__ import annotationsimport asyncioimport refrom dataclasses import Field+from pathlib import Pathfrom typing import TYPE_CHECKINGimport aiofiles@@ -282,6 +283,16 @@ class ScrapeMapper:item = ScrapeItem(url=link, parent_title="")await self.manager.queue_manager.url_objects_to_map.put(item)+ async def load_failed_links(self) -> None:+ """Loads failed links from db"""+ items = await self.manager.db_manager.history_table.get_failed_items()+ for item in items:+ link = URL(item[2])+ retry_path = Path(item[3])++ item = ScrapeItem(link, parent_title="", part_of_album=True, retry=True, retry_path=retry_path)+ await self.manager.queue_manager.url_objects_to_map.put(item)+async def extension_check(self, url: URL) -> bool:"""Checks if the URL has a valid extension"""try:diff --git a/cyberdrop_dl/ui/prompts/general_prompts.py b/cyberdrop_dl/ui/prompts/general_prompts.pyindex afe7c9348..e0b5be05f 100644--- a/cyberdrop_dl/ui/prompts/general_prompts.py+++ b/cyberdrop_dl/ui/prompts/general_prompts.py@@ -28,14 +28,15 @@ def main_prompt(manager: Manager) -> int:choices=[Choice(1, "Download"),Choice(2, "Download (All Configs)"),- Choice(3, "Edit URLs File"),+ Choice(3, "Retry Failed Downloads"),+ Choice(4, "Edit URLs File"),Separator(),- Choice(4, f"Select Config (Current: {manager.config_manager.loaded_config})"),- Choice(5, "Manage Configs"),+ Choice(5, f"Select Config (Current: {manager.config_manager.loaded_config})"),+ Choice(6, "Manage Configs"),Separator(),- Choice(6, "Import Cyberdrop_V4 Items"),- Choice(7, "Donate"),- Choice(8, "Exit"),+ Choice(7, "Import Cyberdrop_V4 Items"),+ Choice(8, "Donate"),+ Choice(9, "Exit"),], long_instruction="ARROW KEYS: Navigate | ENTER: Select",).execute()diff --git a/cyberdrop_dl/ui/ui.py b/cyberdrop_dl/ui/ui.pyindex 5d840fc3c..acc2f24dc 100644--- a/cyberdrop_dl/ui/ui.py+++ b/cyberdrop_dl/ui/ui.py@@ -32,22 +32,28 @@ def program_ui(manager: Manager):if action == 1:break+ # Download (All Configs)if action == 2:manager.args_manager.all_configs = Truebreak- # Edit URLs+ # Retry Failed Downloadselif action == 3:+ manager.args_manager.retry = True+ break++ # Edit URLs+ elif action == 4:edit_urls_prompt(manager.file_manager.input_file)# Select Config- elif action == 4:+ elif action == 5:configs = manager.config_manager.get_configs()selected_config = select_config_prompt(configs)manager.config_manager.load_config(selected_config)# Manage Configs- elif action == 5:+ elif action == 6:while True:console.clear()console.print("[bold]Manage Configs[/bold]")@@ -100,13 +106,13 @@ def program_ui(manager: Manager):break# Import Cyberdrop_V4 Items- elif action == 6:+ elif action == 7:import_cyberdrop_v4_items_prompt(manager)# Donate- elif action == 7:+ elif action == 8:donations_prompt()# Exit- elif action == 8:+ elif action == 9:exit(0)diff --git a/cyberdrop_dl/utils/database/tables/history_table.py b/cyberdrop_dl/utils/database/tables/history_table.pyindex 0d02c22d5..d14a77916 100644--- a/cyberdrop_dl/utils/database/tables/history_table.py+++ b/cyberdrop_dl/utils/database/tables/history_table.py@@ -1,7 +1,9 @@from __future__ import annotations+from sqlite3 import Row+import aiosqlite-from typing import TYPE_CHECKING+from typing import TYPE_CHECKING, Iterablefrom yarl import URLfrom cyberdrop_dl.utils.database.table_definitions import create_history@@ -56,17 +58,24 @@ class HistoryTable:await self.db_conn.execute("""UPDATE media SET completed = 1 WHERE domain = ? and url_path = ?""", (domain, url_path))await self.db_conn.commit()- async def check_filename_exists(self, filename: str):+ async def check_filename_exists(self, filename: str) -> bool:"""Checks whether a downloaded filename exists in the database"""cursor = await self.db_conn.cursor()result = await cursor.execute("""SELECT EXISTS(SELECT 1 FROM media WHERE download_filename = ?)""", (filename,))sql_file_check = await result.fetchone()return sql_file_check == 1- async def get_downloaded_filename(self, domain: str, media_item: MediaItem):+ async def get_downloaded_filename(self, domain: str, media_item: MediaItem) -> str:"""Returns the downloaded filename from the database"""url_path = await get_db_path(media_item.url, str(media_item.referer))cursor = await self.db_conn.cursor()result = await cursor.execute("""SELECT download_filename FROM media WHERE domain = ? and url_path = ?""", (domain, url_path))sql_file_check = await result.fetchone()return sql_file_check[0] if sql_file_check else None++ async def get_failed_items(self) -> Iterable[Row]:+ """Returns a list of failed items"""+ cursor = await self.db_conn.cursor()+ result = await cursor.execute("""SELECT * FROM media WHERE completed = 0""")+ failed_files = await result.fetchall()+ return failed_filesdiff --git a/cyberdrop_dl/utils/dataclasses/url_objects.py b/cyberdrop_dl/utils/dataclasses/url_objects.pyindex ec8fbf786..7f34b5a1a 100644--- a/cyberdrop_dl/utils/dataclasses/url_objects.py+++ b/cyberdrop_dl/utils/dataclasses/url_objects.py@@ -25,14 +25,17 @@ class MediaItem:class ScrapeItem:- def __init__(self, url: "URL", parent_title: str, part_of_album: bool = False, possible_datetime: int = None):+ def __init__(self, url: "URL", parent_title: str, part_of_album: bool = False, possible_datetime: int = None,+ retry: bool = False, retry_path: Path = None):self.url: URL = urlself.parent_title: str = parent_titleself.part_of_album: bool = part_of_albumself.possible_datetime: int = possible_datetime+ self.retry: bool = retry+ self.retry_path: Path = retry_pathasync def add_to_parent_title(self, title: str) -> None:- if not title:+ if not title or self.retry:returntitle = await sanitize_folder(title)self.parent_title = (self.parent_title + "/" + title) if self.parent_title else titlediff --git a/cyberdrop_dl/utils/utilities.py b/cyberdrop_dl/utils/utilities.pyindex cfb448656..1fd03b7ac 100644--- a/cyberdrop_dl/utils/utilities.py+++ b/cyberdrop_dl/utils/utilities.py@@ -139,6 +139,9 @@ async def get_filename_and_ext(filename: str, forum: bool = False) -> Tuple[str,async def get_download_path(manager: Manager, scrape_item: ScrapeItem, domain: str) -> Path:"""Returns the path to the download folder"""+ if scrape_item.retry:+ return scrape_item.retry_path+if scrape_item.parent_title and scrape_item.part_of_album:return manager.directory_manager.downloads / scrape_item.parent_titleelif scrape_item.parent_title: