Skip to content

Downloader

cdse.downloader.Downloader

Download products from CDSE.

This class handles downloading satellite products from the Copernicus Data Space Ecosystem using the OData API.

Attributes:

Name Type Description
ODATA_URL

OData API base URL for product downloads

CATALOG_URL

OData catalog URL for product lookups

Example

downloader = Downloader(session, output_dir="./data") path = downloader.download(product)

__init__(session: requests.Session, output_dir: str = '.', chunk_size: int = 131072, max_workers: int = 4)

Initialize the downloader.

Parameters:

Name Type Description Default
session Session

Authenticated requests session (with Bearer token)

required
output_dir str

Default directory for downloaded files

'.'
chunk_size int

Size of download chunks in bytes (default: 128KB)

131072
max_workers int

Maximum number of parallel downloads

4

download(product: Product, output_dir: Optional[str] = None, filename: Optional[str] = None, progress: bool = True, progress_callback: Optional[Callable[[int, int], None]] = None) -> Path

Download a single product.

Parameters:

Name Type Description Default
product Product

Product to download

required
output_dir Optional[str]

Override output directory

None
filename Optional[str]

Custom filename (default: product_id.zip)

None
progress bool

Show progress bar (default: True)

True
progress_callback Optional[Callable[[int, int], None]]

Optional callback(downloaded, total) for progress

None

Returns:

Type Description
Path

Path to the downloaded file

Raises:

Type Description
DownloadError

If download fails

download_all(products: list[Product], output_dir: Optional[str] = None, skip_existing: bool = True, progress: bool = True, parallel: bool = False, max_workers: Optional[int] = None) -> list[Path]

Download multiple products.

Parameters:

Name Type Description Default
products list[Product]

List of products to download

required
output_dir Optional[str]

Override output directory

None
skip_existing bool

Skip already downloaded products

True
progress bool

Show progress bars

True
parallel bool

Enable parallel downloads

False
max_workers Optional[int]

Override max parallel workers (default: self.max_workers)

None

Returns:

Type Description
list[Path]

List of paths to downloaded files

get_product_info(product_id: str) -> dict[str, Any]

Get detailed information about a product.

Parameters:

Name Type Description Default
product_id str

Product UUID

required

Returns:

Type Description
dict[str, Any]

Dictionary with product metadata

Raises:

Type Description
DownloadError

If API request fails

format_size(size_bytes: int) -> str staticmethod

Format file size in human-readable format.

Parameters:

Name Type Description Default
size_bytes int

Size in bytes

required

Returns:

Type Description
str

Formatted string (e.g., "1.23 GB")

verify_checksum(file_path: Path, expected_checksum: str, algorithm: str = 'md5') -> bool

Verify file checksum.

Parameters:

Name Type Description Default
file_path Path

Path to file to verify

required
expected_checksum str

Expected checksum value

required
algorithm str

Hash algorithm (md5, sha256, sha1)

'md5'

Returns:

Type Description
bool

True if checksum matches, False otherwise

download_with_checksum(product: Product, output_dir: Optional[str] = None, progress: bool = True, retry_on_mismatch: bool = True) -> Path

Download a product and verify its checksum.

Parameters:

Name Type Description Default
product Product

Product to download

required
output_dir Optional[str]

Override output directory

None
progress bool

Show progress bar

True
retry_on_mismatch bool

Retry download if checksum fails

True

Returns:

Type Description
Path

Path to the downloaded file

Raises:

Type Description
DownloadError

If download or checksum verification fails

calculate_checksum(file_path: Path, algorithm: str = 'md5') -> str

Calculate checksum of a file.

Parameters:

Name Type Description Default
file_path Path

Path to file

required
algorithm str

Hash algorithm (md5, sha256, sha1)

'md5'

Returns:

Type Description
str

Hexadecimal checksum string

download_quicklook(product: Product, output_dir: Optional[str] = None) -> Path

Download quicklook (preview) image for a product.

The quicklook is a small JPEG preview of the product, useful for visual inspection without downloading the full product.

Parameters:

Name Type Description Default
product Product

Product to get quicklook for

required
output_dir Optional[str]

Override output directory

None

Returns:

Type Description
Path

Path to downloaded quicklook image (JPEG)

Raises:

Type Description
DownloadError

If quicklook is not available or download fails

download_all_quicklooks(products: list[Product], output_dir: Optional[str] = None, parallel: bool = True, max_workers: int = 4) -> list[Path]

Download quicklooks for multiple products.

Parameters:

Name Type Description Default
products list[Product]

List of products to download quicklooks for

required
output_dir Optional[str]

Override output directory

None
parallel bool

Enable parallel downloads (default: True)

True
max_workers int

Number of parallel workers

4

Returns:

Type Description
list[Path]

List of paths to downloaded quicklook images