MCPcopy
hub / github.com/scrapy/scrapy / image_downloaded

Method image_downloaded

scrapy/pipelines/images.py:129–153  ·  view source on GitHub ↗
(
        self,
        response: Response,
        request: Request,
        info: MediaPipeline.SpiderInfo,
        *,
        item: Any = None,
    )

Source from the content-addressed store, hash-verified

127 return await self.image_downloaded(response, request, info, item=item)
128
129 async def image_downloaded(
130 self,
131 response: Response,
132 request: Request,
133 info: MediaPipeline.SpiderInfo,
134 *,
135 item: Any = None,
136 ) -> str:
137 checksum: str | None = None
138 for path, image, buf in self.get_images(response, request, info, item=item):
139 if checksum is None:
140 buf.seek(0)
141 checksum = _md5sum(buf)
142 width, height = image.size
143 await ensure_awaitable(
144 self.store.persist_file(
145 path,
146 buf,
147 info,
148 meta={"width": width, "height": height},
149 headers={"Content-Type": "image/jpeg"},
150 )
151 )
152 assert checksum is not None
153 return checksum
154
155 def get_images(
156 self,

Callers 1

file_downloadedMethod · 0.95

Calls 4

get_imagesMethod · 0.95
_md5sumFunction · 0.90
ensure_awaitableFunction · 0.90
persist_fileMethod · 0.45

Tested by

no test coverage detected