Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
fix: ignore invalid URLs in input file (#1297)
NTFSvolume33b485497afb
diff --git a/cyberdrop_dl/scraper/scrape_mapper.py b/cyberdrop_dl/scraper/scrape_mapper.pyindex 8f4eb4405..9ea79e04d 100644--- a/cyberdrop_dl/scraper/scrape_mapper.py+++ b/cyberdrop_dl/scraper/scrape_mapper.py@@ -26,7 +26,7 @@ from cyberdrop_dl.utils.logger import log, log_spacerfrom cyberdrop_dl.utils.utilities import get_download_path, get_filename_and_ext, remove_trailing_slashif TYPE_CHECKING:- from collections.abc import AsyncGenerator, Sequence+ from collections.abc import AsyncGenerator, Generator, Sequencefrom types import TracebackTypefrom cyberdrop_dl.config.global_model import GenericCrawlerInstances, GlobalSettings@@ -148,19 +148,17 @@ class ScrapeMapper:current_group_name = ""async with aiofiles.open(input_file, encoding="utf8") as f:async for line in f:- assert isinstance(line, str)-if line.startswith(("---", "===")): # New group begins herecurrent_group_name = line.replace("---", "").replace("===", "").strip()if current_group_name:self.groups.add(current_group_name)- yield (current_group_name, regex_links(line))+ yield (current_group_name, list(regex_links(line)))continueblock_quote = not block_quote if line == "#\n" else block_quoteif not block_quote:- yield ("", regex_links(line))+ yield ("", list(regex_links(line)))# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~``@@ -358,21 +356,23 @@ class ScrapeMapper:return crawler-def regex_links(line: str) -> list[AbsoluteHttpURL]:+def regex_links(line: str) -> Generator[AbsoluteHttpURL]:"""Regex grab the links from the URLs.txt file.This allows code blocks or full paragraphs to be copy and pasted into the URLs.txt."""- if line.lstrip().rstrip().startswith("#"):- return []+ line = line.strip()+ if line.startswith("#"):+ return- yarl_links = []- all_links = [x.group().replace(".md.", ".") for x in re.finditer(REGEX_LINKS, line)]- for link in all_links:- encoded = "%" in link- yarl_links.append(AbsoluteHttpURL(link, encoded=encoded))- return yarl_links+ http_urls = (x.group().replace(".md.", ".") for x in re.finditer(REGEX_LINKS, line))+ for link in http_urls:+ try:+ encoded = "%" in link+ yield AbsoluteHttpURL(link, encoded=encoded)+ except Exception as e:+ log(f"Unable to parse URL from input file: {link} {e:!r}", 40)def create_item_from_entry(entry: Sequence) -> ScrapeItem: