DownloadResult#

class scikitplot.corpus.DownloadResult(input_url, output_path, suffix, content_type='', suggested_filename='')[source]#

Immutable result object returned by every BaseDownloader.

Parameters:
input_urlstr

The original URL that was downloaded.

output_pathpathlib.Path

Absolute path to the downloaded local file. The file exists and is readable when this object is returned.

suffixstr

File extension including the leading dot, e.g. ".pdf". Always lower-cased. Used by DocumentReader.create to dispatch the file to the correct reader. May differ from path.suffix when the extension was inferred from Content-Type or Content-Disposition rather than the URL path.

content_typestr, optional

MIME type from the HTTP Content-Type header, lower-cased and stripped of parameters (e.g. "application/pdf"). Empty string when not available (local files, custom handlers).

suggested_filenamestr, optional

Filename suggested by the server via Content-Disposition, or the last URL path segment. Empty string when not available.

Parameters:
  • input_url (str)

  • output_path (Path)

  • suffix (str)

  • content_type (str)

  • suggested_filename (str)

Notes

Why carry suffix separately from output_path.suffix? The URL path may have no extension (API endpoints, GDrive share links). In those cases the downloader infers the correct suffix from the Content-Type header and stores a file with a synthetic name. suffix is the authoritative extension; output_path.suffix is implementation detail.

Examples

>>> from pathlib import Path
>>> r = DownloadResult(
...     input_url="https://example.com/paper",
...     output_path=Path("/tmp/skplt_abc123.pdf"),
...     suffix=".pdf",
...     content_type="application/pdf",
...     suggested_filename="paper.pdf",
... )
>>> r.suffix
'.pdf'
content_type: str = ''#
input_url: str[source]#
output_path: Path[source]#
suffix: str[source]#
suggested_filename: str = ''#