Created
March 6, 2017 21:51
-
-
Save commadelimited/68ec9ced0b50d0348bbf066af7109964 to your computer and use it in GitHub Desktop.
Pull a list of unique played games for X-Y time period, print game name, id, designers, and play count.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
from boardgamegeek.api import BoardGameGeek | |
bgg = BoardGameGeek() | |
username = 'commadelimited' | |
start = '2013-01-01' | |
end = '2017-03-07' | |
mindate = datetime.strptime(start, '%Y-%m-%d') | |
maxdate = datetime.strptime(end, '%Y-%m-%d') | |
games = {} | |
designers = [] | |
bgg = BoardGameGeek() | |
plays = bgg.plays(name=username, min_date=mindate, max_date=maxdate) | |
for play in plays: | |
if play.game_name in games: | |
plays = games[play.game_name].get('plays') + 1 | |
games[play.game_name].update(plays=plays) | |
else: | |
games[play.game_name] = { | |
'game_id': play.game_id, | |
'game_name': play.game_name, | |
'plays': 1, | |
} | |
for game in games: | |
query = bgg.game(game_id=games[game].get('game_id')) | |
games[game].update(designers=query.designers) | |
print games[game] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Results look like this: