From 5afc7ec27d52a670fcf1acbdba58a65b0675f882 Mon Sep 17 00:00:00 2001 From: DevilXD Date: Fri, 19 Aug 2022 11:57:18 +0200 Subject: [PATCH] Make image cache use the request wrapper --- cache.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cache.py b/cache.py index 951170a..1082945 100644 --- a/cache.py +++ b/cache.py @@ -8,7 +8,6 @@ from typing import Dict, TypedDict, NewType, TYPE_CHECKING from utils import json_load, json_save from constants import URLType, CACHE_PATH, CACHE_DB -import aiohttp from PIL import Image as Image_module from PIL.ImageTk import PhotoImage @@ -37,6 +36,7 @@ class ImageCache: def __init__(self, manager: GUIManager) -> None: self._root = manager._root + self._twitch = manager._twitch CACHE_PATH.mkdir(parents=True, exist_ok=True) self._hashes: Hashes = json_load(CACHE_DB, default_database, merge=False) self._images: dict[ImageHash, Image] = {} @@ -94,7 +94,7 @@ class ImageCache: except FileNotFoundError: pass if image is None: - async with aiohttp.request("GET", url) as response: + async with self._twitch.request("GET", url) as response: image = Image_module.open(io.BytesIO(await response.read())) img_hash = self._hash(image) self._images[img_hash] = image