From 5167d95051097ad7f68e6a6cf52842cfc04d562b Mon Sep 17 00:00:00 2001 From: DevilXD <4180725+DevilXD@users.noreply.github.com> Date: Fri, 10 Nov 2023 21:35:49 +0100 Subject: [PATCH] Game slugs are now sourced from Twitch, instead of being generated --- constants.py | 2 +- utils.py | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/constants.py b/constants.py index f57bbcdd..7adf4ff7 100644 --- a/constants.py +++ b/constants.py @@ -290,7 +290,7 @@ def with_variables(self, variables: JsonType) -> GQLOperation: # returns extended information about a particular campaign "CampaignDetails": GQLOperation( "DropCampaignDetails", - "f6396f5ffdde867a8f6f6da18286e4baf02e5b98d14689a69b5af320a4c7b7b8", + "e5916665a37150808f8ad053ed6394b225d5504d175c7c0b01b9a89634c57136", variables={ "channelLogin": ..., # user login "dropID": ..., # campaign ID diff --git a/utils.py b/utils.py index e86b7d52..b4f698b3 100644 --- a/utils.py +++ b/utils.py @@ -16,6 +16,7 @@ from pathlib import Path from functools import wraps from contextlib import suppress +from functools import cached_property from datetime import datetime, timezone from collections import abc, OrderedDict from typing import ( @@ -388,7 +389,9 @@ def clear(self) -> None: class Game: def __init__(self, data: JsonType): self.id: int = int(data["id"]) - self.name: str = data["name"] + self.name: str = data.get("displayName") or data["name"] + if "slug" in data: + self.slug = data["slug"] def __str__(self) -> str: return self.name @@ -404,7 +407,7 @@ def __eq__(self, other: object) -> bool: def __hash__(self) -> int: return self.id - @property + @cached_property def slug(self) -> str: """ Converts the game name into a slug, useable for the GQL API.