playwithfriends/playwithfriends/intersections.py

13 lines
375 B
Python
Raw Permalink Normal View History

2017-03-19 02:16:29 -04:00
from playwithfriends import steam
2017-03-19 12:28:09 -04:00
from functools import reduce
2017-03-19 02:16:29 -04:00
2017-03-19 12:28:09 -04:00
def intersecting_games(*args):
2017-03-19 02:16:29 -04:00
api = steam.SteamAPI()
2017-03-19 12:28:09 -04:00
games_list = [api.get_games(steamid) for steamid in args]
2017-03-19 13:46:50 -04:00
game_ids = [g.keys() for g in games_list]
ids_mutual = reduce(lambda l, r: set(l).intersection(r), game_ids)
2017-03-19 02:16:29 -04:00
2017-03-19 12:28:09 -04:00
return {game_id: games_list[0][game_id] for game_id in ids_mutual}