Ejemplo n.º 1
0
 def __init__(self, project_name, cache_bgg):
     if cache_bgg:
         self.client = BGGClient(cache=CacheBackendSqlite(
             path=f"{project_name}-cache.sqlite",
             ttl=60 * 60 * 24,
         ))
     else:
         self.client = BGGClient()
Ejemplo n.º 2
0
 def __init__(self, cache_bgg):
     project_name = SETTINGS["project"]["name"]
     if cache_bgg:
         self.client = BGGClient(cache=CacheBackendSqlite(
             path=f"{SETTINGS['project']['name']}-cache.sqlite",
             ttl=60 * 60 * 24,
         ))
     else:
         self.client = BGGClient()
Ejemplo n.º 3
0
 def __init__(self):
     project_name = SETTINGS["project"]["name"]
     self.client = BGGClient(cache=CacheBackendSqlite(
         path=f"{project_name}-cache.sqlite", ttl=60 * 60 * 24))
Ejemplo n.º 4
0
#!/usr/bin/env python3

from math import ceil

from boardgamegeek import BGGClient, BGGRestrictCollectionTo as restrict
from boardgamegeek.cache import CacheBackendSqlite

INCH_TO_CM = 2.54  # Exactly!

bgg = BGGClient(cache=CacheBackendSqlite(path=".cache.bgg2", ttl=3600 * 24))

collection = bgg.collection('arnauldvm',
                            own=True,
                            exclude_subtype=restrict.BOARD_GAME_EXTENSION,
                            version=True)
print(f"{collection}")

unknown_boxes_count = 0

longest_dimension = 0

long_boxes_count = 0
long_boxes_total_height = 0

average_boxes_count = 0
average_boxes_total_height = 0

small_boxes_count = 0
small_boxes_total_height = 0

for game in collection:
Ejemplo n.º 5
0
                    default=DEFAULT_USERNAME,
                    help="username for collection")
parser.add_argument('-o', '--output_format',
                    type=Format, default=DEFAULT_FORMAT,
                    help=f"output format ({'|'.join([f.value for f in Format])})")
parser.add_argument('list_id',
                    nargs='?', default=DEFAULT_LIST_ID,
                    help="identifier of the boardgame geeklist")
args = parser.parse_args()

effective_cache_ttl = args.cache_ttl
if args.force:
    print("Forcing cache refresh")
    effective_cache_ttl = 0

cache = CacheBackendSqlite(path=".cache.bgg", ttl=effective_cache_ttl)

bgg1 = BGGClientLegacy(cache=cache)
list = bgg1.geeklist(args.list_id, comments=True)
print(f"[{list.id}] {list.name}\n{list.description}")

bgg2 = BGGClient(cache=cache)
games_id_list = [
    item.object.id for item in list
    if item.object.type == 'thing' and item.object.subtype == 'boardgame'
]
games = bgg2.game_list(games_id_list)
games_dict = {game.id: game for game in games}

collection = bgg2.collection(user_name=args.username)
collection_dict = {colgame.id: colgame for colgame in collection}