From 753da82a48c125c0d9f3cc270985c6f3b40cca34 Mon Sep 17 00:00:00 2001 From: Sangha Lee Date: Mon, 4 Aug 2025 13:50:15 +0900 Subject: [PATCH] fix: missing chunk from attachment files --- utils/scraper.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/utils/scraper.py b/utils/scraper.py index d9caaba..9f2d659 100644 --- a/utils/scraper.py +++ b/utils/scraper.py @@ -176,12 +176,7 @@ class Scraper(ClientSession): return document.select_one('source')['src'] - async def download_attachment( - self, - url: str, - save_dir: Path, - chunk_size = 8192 - ) -> Attachment: + async def download_attachment(self, url: str, save_dir: Path) -> Attachment: """ 첨부 파일을 받아옵니다 @@ -208,7 +203,7 @@ class Scraper(ClientSession): with NamedTemporaryFile('wb') as temp_file: async with await self.get(attachment.source_url) as response: - async for chunk in response.content.iter_chunked(chunk_size): + async for chunk, _ in response.content.iter_chunks(): temp_file.write(chunk) hash.update(chunk) @@ -244,7 +239,7 @@ class Scraper(ClientSession): urls = [ # 이미지 *[ - tag['data-original'].strip() + tag.attrs.get('data-mp4', tag['data-original']).strip() for tag in post.body.select('img[data-original]') ],