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 byDocumentReader.createto dispatch the file to the correct reader. May differ frompath.suffixwhen the extension was inferred fromContent-TypeorContent-Dispositionrather than the URL path.- content_typestr, optional
MIME type from the HTTP
Content-Typeheader, 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:
Notes
Why carry
suffixseparately fromoutput_path.suffix? The URL path may have no extension (API endpoints, GDrive share links). In those cases the downloader infers the correct suffix from theContent-Typeheader and stores a file with a synthetic name.suffixis the authoritative extension;output_path.suffixis 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'