Added download settings and optimized the downloader system with concurrency.

This commit is contained in:
2026-09-03 18:26:10 +02:00
parent ba079ef6fa
commit c61254e4a9
5 changed files with 954 additions and 84 deletions

View File

@@ -95,6 +95,17 @@ def fetch_news_image(
return _fetch_png_image(article.image_url, cache_path, timeout_seconds, opener)
def read_cached_news_image(
article: NewsArticle,
cache_directory: Path,
) -> bytes | None:
"""Read article artwork without contacting the network."""
if article.image_url is None:
return None
return _read_png(_image_cache_path(cache_directory, article))
def fetch_official_logo(
cache_path: Path,
*,
@@ -106,6 +117,12 @@ def fetch_official_logo(
return _fetch_png_image(OFFICIAL_LOGO_URL, cache_path, timeout_seconds, opener)
def read_cached_official_logo(cache_path: Path) -> bytes | None:
"""Read the official logo cache without contacting the network."""
return _read_png(cache_path)
def _fetch_png_image(
url: str,
cache_path: Path,