コード例 #1
0
def get_most_recent_game(username):
    # data variable gets the players history of games of chess.
    data = get_player_game_archives(username).json
    url = data['archives'][-1]
    games = requests.get(url).json()
    game = games['games'][-1]
    # Prints it out
    printer.pprint(game)
コード例 #2
0
def get_most_recnt_game(username):
    data = get_player_game_archives(username).json
    # print(data)
    url = data['archives'][-1]
    # print(url)
    games = requests.get(url).json()
    # print(games)
    game = games['games'][-1]
    # print(game)
    printer.pprint(game)
コード例 #3
0
ファイル: GetGames.py プロジェクト: Abiggj/ChessPupil
def getgames_from_username(username):
    dates = []
    archives = chessdotcom.get_player_game_archives(username).json['archives']
    for url in archives:
        date = list(map(int, url[-7:].split('/')))
        dates.append(date)

    for year, month in dates:
        count = 1
        data = chessdotcom.get_player_games_by_month_pgn(
            username, year, month).json['pgn']['pgn']
        pgn_list = data.split('\n\n\n')
        for pgn in pgn_list:
            filename = os.getcwd() + "/Database/{}/{}/{}".format(
                username, year, month)
            os.makedirs(filename, exist_ok=True)
            file_addr = '/' + str(count) + ".pgn"
            with open(filename + file_addr, 'w') as file:
                file.write(pgn)
                count += 1
コード例 #4
0
def get_most_recent_game(username):
    data = get_player_game_archives(username).json
    url = data['archives'][-1]
    games = requests.get(url).json()
    game = games['games'][-1]
    printer.pprint(game)
コード例 #5
0
def get_most_recelt_game_for(player):
    data = get_player_game_archives(player).json
    Url = data['archives'][-1]
    games = requests.get(Url).json()
    last_game = games['games'][-1]
    printer.pprint(last_game)