granicus_archiver.downloader¶
- exception granicus_archiver.downloader.DownloadError[source]¶
Bases:
ExceptionRaised if the downloaded content size does not match the “Content-Length” from the response headers
- exception granicus_archiver.downloader.StupidZeroContentLengthError[source]¶
Bases:
ExceptionRaised when the reported “Content-Length” is zero
- exception granicus_archiver.downloader.ThisShouldBeA404ErrorButItsNot(request_info: None, history: Tuple[None, ...], *, code: int | None = None, status: int | None = None, message: str = '', headers: MultiMapping[str] | None = None)[source]¶
Bases:
ClientResponseErrorException raised when Granicus redirects you to a warning page saying a file doesn’t exist even though that is something built into the HTTP protocol yes this is a runon sentence in a docstring header line but I am beyond the point of caring
Yes, another lovely edge case discovered - shocking.
The response can be detected by a
302 "Found"redirect with"/Confirmation.aspx"as the url path andM1=Gonein the query.- Parameters:
- Return type:
None
- class granicus_archiver.downloader.DownloadRequest[source]¶
Bases:
TypedDictKeyword arguments to create
FileDownloadinstances- filename: Path¶
Local filename for the download
- chunk_size: NotRequired[int]¶
Chunk size for streaming download segments
- timeout: NotRequired[ClientTimeout]¶
Custom
ClientTimeoutspecification
- class granicus_archiver.downloader.DownloadResult[source]¶
Bases:
TypedDictResult type used for
FileDownload.result
- class granicus_archiver.downloader.FileDownload(session: ClientSession, **kwargs: Unpack[DownloadRequest])[source]¶
Bases:
objectDownloads a single file
- Parameters:
session (aiohttp.ClientSession)
**kwargs (DownloadRequest)
- session: ClientSession¶
The current
aiohttp.ClientSession
- property result: DownloadResult¶
The completed
DownloadResult
- class granicus_archiver.downloader.Downloader(session: ClientSession, scheduler: Scheduler | None = None)[source]¶
Bases:
objectManager for scheduling
FileDownloadjobs- Parameters:
session (ClientSession)
scheduler (Scheduler | None)
- session: ClientSession¶
The current
aiohttp.ClientSession
- default_timeout: ClientTimeout¶
Default to use for
FileDownload.timeout
- async spawn(**kwargs: Unpack[DownloadRequest]) Job[FileDownload][source]¶
Create a
FileDownloadand run it on theschedulerIf
chunk_sizeis not provided, thedefault_chunk_sizewill be used.If
timeoutis not provided,default_timeoutwill be used.
- Parameters:
**kwargs (DownloadRequest) – Keyword arguments to initialize the
FileDownloadinstance- Return type:
Job[FileDownload]
- async download(**kwargs: Unpack[DownloadRequest]) FileDownload[source]¶
Create a
FileDownloadand begin downloading immediately (bypassingscheduler)If
chunk_sizeis not provided, thedefault_chunk_sizewill be used.If
timeoutis not provided,default_timeoutwill be used.
- Parameters:
**kwargs (DownloadRequest) – Keyword arguments to initialize the
FileDownloadinstance- Return type: