diff --git a/inventory.py b/inventory.py index 0e003d8..446dc1b 100644 --- a/inventory.py +++ b/inventory.py @@ -251,3 +251,6 @@ class DropsCampaign: def _on_minutes_changed(self) -> None: invalidate_cache(self, "progress", "remaining_minutes") + + def get_drop(self, drop_id: str) -> Optional[TimedDrop]: + return self.timed_drops.get(drop_id) diff --git a/twitch.py b/twitch.py index 960955c..f9d55f9 100644 --- a/twitch.py +++ b/twitch.py @@ -828,13 +828,11 @@ class Twitch: # try it with the currently selected game first if self.game is not None: for campaign in self.inventory[self.game]: - drop = campaign.timed_drops.get(drop_id) - if drop is not None: + if (drop := campaign.get_drop(drop_id)) is not None: return drop # fallback to checking all campaigns for campaign in chain(*self.inventory.values()): - drop = campaign.timed_drops.get(drop_id) - if drop is not None: + if (drop := campaign.get_drop(drop_id)) is not None: return drop return None