Fix GUI debug code

This commit is contained in:
DevilXD committed 2025-08-22 18:58:05 +02:00
1 parent cb9b6ab42f
commit 1b17dd6784
2 files changed
+14 -6

No files matched your search

+7
View File
@@ -106,8 +106,15 @@ class ImageCache:
except (FileNotFoundError, Image_module.UnidentifiedImageError): except (FileNotFoundError, Image_module.UnidentifiedImageError):
pass pass
if image is None: if image is None:
try:
async with self._twitch.request("GET", url) as response: async with self._twitch.request("GET", url) as response:
if response.status != 404:
image = Image_module.open(io.BytesIO(await response.read())) image = Image_module.open(io.BytesIO(await response.read()))
except Exception:
pass
if image is None:
# use a blank white image as a fallback
image = Image_module.new("RGB", (10, 10), (255, 255, 255))
img_hash = self._hash(image) img_hash = self._hash(image)
self._images[img_hash] = image self._images[img_hash] = image
image.save(CACHE_PATH / img_hash) image.save(CACHE_PATH / img_hash)
+7 -6
View File
@@ -2341,11 +2341,12 @@ if __name__ == "__main__":
cm = current_minutes cm = current_minutes
tm = total_minutes tm = total_minutes
ref_stamp = datetime.now(timezone.utc) ref_stamp = datetime.now(timezone.utc)
image_url = ( drop_image_url = (
"https://static-cdn.jtvnw.net/twitch-drops-assets-prod/" "https://static-cdn.jtvnw.net/twitch-quests-assets/"
"BENEFIT-81ab5665-b2f4-4179-96e6-74da5a82da28.jpeg" "REWARD/e0ede26e-b071-47f0-af5f-b80b26fa9fb4.png"
) )
benefits = [SimpleNamespace(name=name, image_url=image_url) for name in rewards] campaign_image_url = "https://static-cdn.jtvnw.net/ttv-boxart/515025-120x160.jpg"
benefits = [SimpleNamespace(name=name, image_url=drop_image_url) for name in rewards]
mock = SimpleNamespace( mock = SimpleNamespace(
id="0", id="0",
campaign=HashNamespace( campaign=HashNamespace(
@@ -2358,7 +2359,7 @@ if __name__ == "__main__":
eligible=False, eligible=False,
finished=False, finished=False,
link_url="https://google.com", link_url="https://google.com",
image_url="https://static-cdn.jtvnw.net/ttv-boxart/460630-285x380.jpg", image_url=campaign_image_url,
allowed_channels=[], allowed_channels=[],
starts_at=ref_stamp, starts_at=ref_stamp,
ends_at=ref_stamp + timedelta(days=7), ends_at=ref_stamp + timedelta(days=7),
@@ -2370,7 +2371,7 @@ if __name__ == "__main__":
progress=(cd * tm + cm) / (td * tm), progress=(cd * tm + cm) / (td * tm),
remaining_minutes=(td - cd) * tm - cm, remaining_minutes=(td - cd) * tm - cm,
), ),
image_url=image_url, image_url=drop_image_url,
can_claim=False, can_claim=False,
can_earn=lambda: False, can_earn=lambda: False,
is_claimed=False, is_claimed=False,