def update_game(source, id, force=False, sleep_between_downloads=0): if not force: game = db.load_game_by_key(source, id, ignore_empty=False) if game: print 'up-to-date %s/%d...' % (source, int(id)) return game else: print 'force', print 'updating %s/%d...' % (source, int(id)), sys.stdout.flush() if sleep_between_downloads: print 'sleeping %s sec...' % sleep_between_downloads, sys.stdout.flush() time.sleep(sleep_between_downloads) game = parse_game(source, id) if game: print 'found:"' + game.name + '"...', db.save_game(game) else: print 'no game found...', g = Game() g.source = source g.id = id db.save_game(g) print 'OK' return game
def search_game(source, id): # x=sources.manager.find_plugin(source) # game=db.load_game_by_key(x.info.get('short_name'), id) game = db.load_game_by_key(source, id) return game