from chessdotcom import get_player_game_archives import requests import chess.pgn import io from lama2923 import clear_screen def fetch_all_games(username): archives = get_player_game_archives(username).json['archives'] games = [] for archive_url in archives: games_data = requests.get(archive_url).json() games.extend(games_data['games']) return games def calculate_accuracy(pgn): game = chess.pgn.read_game(io.StringIO(pgn)) if game is None: return None try: analysis = game.analyze() accuracy = analysis['accuracy'] return accuracy except Exception as e: print(f"Analiz sırasında hata oluştu: {e}") return None def main(username): games = fetch_all_games(username) game_accuracies = [] for game in games: pgn = game.get('pgn') if pgn: accuracy = calculate_accuracy(pgn) if accuracy is not None: game_id = game.get('url').split('/')[-1] analysis_url = f"https://www.chess.com/analysis/game/live/{game_id}" game_accuracies.append((accuracy, analysis_url)) game_accuracies.sort(reverse=True, key=lambda x: x[0]) clear_screen() for accuracy, analysis_url in game_accuracies: print(f"Doğruluk Oranı: {accuracy:.2f}% - Analiz Linki: {analysis_url}") if __name__ == "__main__": username = "lama2923" main(username)