mirror of
https://github.com/rangermix/TwitchDropsMiner.git
synced 2026-06-06 12:29:36 +00:00
Speed up get_drop
This commit is contained in:
10
twitch.py
10
twitch.py
@@ -772,6 +772,16 @@ class Twitch:
|
||||
self.inventory[game].append(campaign)
|
||||
|
||||
def get_drop(self, drop_id: str) -> Optional[TimedDrop]:
|
||||
"""
|
||||
Returns a drop from the inventory, based on it's ID.
|
||||
"""
|
||||
# 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:
|
||||
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:
|
||||
|
||||
Reference in New Issue
Block a user