~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.
Python academiaanthropicarxivbravedeep-researchencryptionhome-automationhomeserverlocallocal-deep-researchlocal-llmmistralollamaopenaipubmedresearchresearch-toolretrieval-augmented-generationsearxngself-hosted
feat: add DirectPDFDownloader for efficient handling of direct PDF links
LearningCircuit055625ced599
diff --git a/src/local_deep_research/research_library/downloaders/__init__.py b/src/local_deep_research/research_library/downloaders/__init__.pyindex 0bbde9113a..6367912da3 100644--- a/src/local_deep_research/research_library/downloaders/__init__.py+++ b/src/local_deep_research/research_library/downloaders/__init__.py@@ -7,6 +7,7 @@ from .base import BaseDownloader, ContentType, DownloadResultfrom .arxiv import ArxivDownloaderfrom .pubmed import PubMedDownloaderfrom .biorxiv import BioRxivDownloader+from .direct_pdf import DirectPDFDownloaderfrom .generic import GenericDownloader__all__ = [@@ -16,5 +17,6 @@ __all__ = ["ArxivDownloader","PubMedDownloader","BioRxivDownloader",+ "DirectPDFDownloader","GenericDownloader",]diff --git a/src/local_deep_research/research_library/downloaders/direct_pdf.py b/src/local_deep_research/research_library/downloaders/direct_pdf.pynew file mode 100644index 0000000000..8304595b8d--- /dev/null+++ b/src/local_deep_research/research_library/downloaders/direct_pdf.py@@ -0,0 +1,99 @@+"""+Direct PDF Link Downloader+"""++from typing import Optional+from loguru import logger++from .base import BaseDownloader, ContentType, DownloadResult+++class DirectPDFDownloader(BaseDownloader):+ """Downloader for direct PDF links."""++ def can_handle(self, url: str) -> bool:+ """Check if URL is a direct PDF link."""+ # Check for .pdf extension or PDF in query params+ url_lower = url.lower()+ return (+ url_lower.endswith(".pdf")+ or ".pdf?" in url_lower+ or "/pdf/" in url_lower+ or "type=pdf" in url_lower+ or "format=pdf" in url_lower+ )++ def download(+ self, url: str, content_type: ContentType = ContentType.PDF+ ) -> Optional[bytes]:+ """Download PDF directly from URL."""+ if content_type == ContentType.TEXT:+ # Download PDF and extract text+ pdf_content = self._download_pdf(url)+ if pdf_content:+ text = self._extract_text_from_pdf(pdf_content)+ if text:+ return text.encode("utf-8")+ return None+ else:+ return self._download_pdf(url)++ def download_with_result(+ self, url: str, content_type: ContentType = ContentType.PDF+ ) -> DownloadResult:+ """Download content and return detailed result with skip reason."""+ if content_type == ContentType.TEXT:+ # Download PDF and extract text+ pdf_content = self._download_pdf(url)+ if pdf_content:+ text = self._extract_text_from_pdf(pdf_content)+ if text:+ return DownloadResult(+ content=text.encode("utf-8"), is_success=True+ )+ else:+ return DownloadResult(+ skip_reason="PDF downloaded but text extraction failed"+ )+ return DownloadResult(+ skip_reason="Could not download PDF from direct link"+ )+ else:+ # Try to download PDF directly+ logger.info(f"Attempting direct PDF download from {url}")+ pdf_content = super()._download_pdf(url)++ if pdf_content:+ logger.info(f"Successfully downloaded PDF directly from {url}")+ return DownloadResult(content=pdf_content, is_success=True)+ else:+ # Try to determine specific reason for failure+ try:+ response = self.session.head(+ url, timeout=5, allow_redirects=True+ )+ if response.status_code == 404:+ return DownloadResult(+ skip_reason="PDF file not found (404) - link may be broken"+ )+ elif response.status_code == 403:+ return DownloadResult(+ skip_reason="Access denied (403) - PDF requires authentication"+ )+ elif response.status_code >= 500:+ return DownloadResult(+ skip_reason=f"Server error ({response.status_code}) - try again later"+ )+ else:+ return DownloadResult(+ skip_reason=f"Could not download PDF - server returned status {response.status_code}"+ )+ except Exception:+ return DownloadResult(+ skip_reason="Failed to download PDF from direct link"+ )++ def _download_pdf(self, url: str) -> Optional[bytes]:+ """Download PDF directly from URL."""+ logger.info(f"Downloading PDF directly from: {url}")+ return super()._download_pdf(url)diff --git a/src/local_deep_research/research_library/services/download_service.py b/src/local_deep_research/research_library/services/download_service.pyindex e674252390..f10c7184fb 100644--- a/src/local_deep_research/research_library/services/download_service.py+++ b/src/local_deep_research/research_library/services/download_service.py@@ -35,6 +35,7 @@ from ..downloaders import (ArxivDownloader,PubMedDownloader,BioRxivDownloader,+ DirectPDFDownloader,GenericDownloader,)@@ -61,7 +62,9 @@ class DownloadService:self._setup_directories()# Initialize modular downloaders+ # DirectPDFDownloader first for efficiency with direct PDF linksself.downloaders = [+ DirectPDFDownloader(timeout=30), # Handle direct PDF links firstArxivDownloader(timeout=30),PubMedDownloader(timeout=30, rate_limit_delay=1.0),BioRxivDownloader(timeout=30),