From a42ad6499483c264cc4ebdcfc7b2dc5c5b88ddb7 Mon Sep 17 00:00:00 2001 From: "Casper V. Kristensen" Date: Sat, 25 Aug 2018 19:28:42 +0200 Subject: [PATCH] Add support for multiple Steam games of the exact same title. Fixes for example "Wolfenstein II: The New Colossus" having both international and german version under the same name. --- dailyreleases/steam.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dailyreleases/steam.py b/dailyreleases/steam.py index 2b3e105..8bfaf56 100644 --- a/dailyreleases/steam.py +++ b/dailyreleases/steam.py @@ -60,8 +60,10 @@ class Steam(object): payload = { "term": query } - items = {i["name"]: i for i in self.cache.get("https://store.steampowered.com/api/storesearch", - params=payload).json()["items"]} + # Reverse results to make the first one take precedence over later ones if multiple results have the same name. + # E.g. "Wolfenstein II: The New Colossus" has both international and german version under the same name. + items = {i["name"]: i for i in reversed(self.cache.get("https://store.steampowered.com/api/storesearch", + params=payload).json()["items"])} best_match = util.case_insensitive_close_matches(query, items, n=1, cutoff=0.90)