Last active
October 26, 2016 20:34
-
-
Save allisontharp/61cebfb59f0c1730db038ea7d5ae5681 to your computer and use it in GitHub Desktop.
This file contains 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
# This script generates a list of all of the new games you play in a month with a specific person (your partner). | |
# An example output is available here: https://boardgamegeek.com/geeklist/201514/item/4608920#item4608920 | |
# More information on this script can be found at www.techtrek.io | |
from boardgamegeek import BoardGameGeek | |
from collections import Counter | |
import datetime, unicodedata | |
def strip_accents(s): | |
return ''.join(c for c in unicodedata.normalize('NFD', s) | |
if unicodedata.category(c) != 'Mn') | |
def translate(name): | |
try: | |
name = name.translate(None, "'&-:") | |
except TypeError as e: | |
name = unicode(name) | |
name = strip_accents(name) | |
name = name.encode("ascii", "ignore") | |
name = name.replace("'", "") | |
return name | |
# USER INPUTS | |
m = 8 # Month number (1 = January, 2 = February, etc) | |
y = 2016 # Year number (2015, 2016, etc) | |
bggid = 'mad4hatter' # BGG username | |
partnername = 'Troy' # name of the person you want to track | |
# connect to BGG | |
bgg = BoardGameGeek() | |
myplays = bgg.plays(bggid).plays | |
mgames = [] | |
ygames = [] | |
newplays = [] | |
gameids = [] | |
for games in reversed(myplays): | |
temp = games.players | |
partnertest = ['yes' for players in temp if players.name == partnername] | |
if partnertest == ['yes']: | |
if games.date.year == y: | |
if games.date.month == m: | |
mgames.append(games.game_name) | |
gameids.append(games.game_id) | |
newplayers = '' | |
aind = [item for item in range(len(games.players)) if games.players[item].name == 'Allison'] | |
if games.players[aind[0]].new == '1': | |
newplays.append(games.game_name) | |
elif games.date.month < m: ygames.append(games.game_name) | |
mgames = [game for game in mgames if game not in ygames] # get the games that you played for the first time this year | |
mgames_unique = list(set(mgames)) #make unique | |
mgames_unique.sort() # make list alphabetical | |
print "[u][b]" + datetime.date(1900,m,1).strftime('%B') + "[/u][/b]" | |
print "[i]Stats: Fun Facts: [/i]" | |
count = Counter(mgames) | |
freq_list= count.values() | |
max_cnt = max(freq_list) | |
total = freq_list.count(max_cnt) | |
mostplayed = count.most_common(total) | |
mostplayed = [elem[0] for elem in mostplayed] | |
d = dict(zip(mgames, gameids)) | |
for games in mgames_unique: | |
out = "" | |
url="[url=https://boardgamegeek.com/boardgame/" | |
url = url + str(d[games]) + "]" | |
if games in newplays: | |
out += ":star:" | |
if games in mostplayed: | |
out += ":thumbsup:" | |
print(out + url + translate(games) + "[/url]") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment