### Install Project Dependencies Source: https://github.com/yyorky/footballvideoanalyst/blob/main/README.md Commands to clone the repository and install the necessary Python packages. ```bash # Clone the repository git clone https://github.com/yYorky/FootballVideoAnalyst.git cd footballvideoanalyst # Install required dependencies pip install -r requirements.txt ``` -------------------------------- ### Run the Application Source: https://github.com/yyorky/footballvideoanalyst/blob/main/README.md Command to launch the Streamlit web interface. ```bash streamlit run app.py ``` -------------------------------- ### Configure Google API Key Source: https://github.com/yyorky/footballvideoanalyst/blob/main/test.ipynb Sets up the Google API key from environment variables or Google Colab user data. Ensure the GOOGLE_API_KEY is defined in your .env file for local execution. ```python # For Google Colab # from google.colab import userdata # GOOGLE_API_KEY = userdata.get('GOOGLE_AI_STUDIO') # For local environment import os from dotenv import load_dotenv load_dotenv() GOOGLE_API_KEY = os.getenv('GOOGLE_API_KEY') # Verify API key exists if GOOGLE_API_KEY is None: print("⚠️ API key not found. Please set GOOGLE_API_KEY in .env file.") else: print("✅ API key loaded successfully!") ``` -------------------------------- ### Initialize Gemini Client Source: https://github.com/yyorky/footballvideoanalyst/blob/main/test.ipynb Creates a client instance for the Gemini API and defines the target model version. ```python # Initialize the Gemini client client = genai.Client(api_key=GOOGLE_API_KEY) # Set the model name MODEL_NAME = "gemini-2.5-pro-exp-03-25" ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/yyorky/footballvideoanalyst/blob/main/README.md Set the required Google API key in a .env file. ```text GOOGLE_API_KEY=your_api_key_here ``` -------------------------------- ### Import Required Libraries Source: https://github.com/yyorky/footballvideoanalyst/blob/main/test.ipynb Loads the Google Generative AI SDK and custom project modules. Requires the project root to be in the system path. ```python import os import time import json from google import genai from google.genai import types # Import our custom modules import sys sys.path.append('.') from modules.video_utils import extract_youtube_id, embed_youtube_video from modules.analysis import analyze_football_video, get_rating_class ``` -------------------------------- ### Project Directory Structure Source: https://github.com/yyorky/footballvideoanalyst/blob/main/README.md Overview of the project file organization. ```text FootballVideoAnalyst/ ├── app.py # Main Streamlit application ├── LICENSE # MIT license file ├── README.md # Project documentation ├── requirements.txt # Python dependencies ├── test.ipynb # Jupyter notebook for testing/experiments ├── .env.example # Example environment file structure ├── modules/ # Core project modules │ ├── analysis.py # Video analysis functionality │ ├── config.py # Configuration settings (API keys, model names) │ ├── styles.py # UI styling and CSS │ ├── ui_components.py # Reusable Streamlit UI elements │ └── video_utils.py # YouTube video processing utilities └── static/ # Static assets (images, GIFs) ├── football_1.gif ├── football_2.gif └── FootballVideoAnalystCover.JPG ``` -------------------------------- ### Run Football Video Analysis Source: https://github.com/yyorky/footballvideoanalyst/blob/main/test.ipynb Executes the video analysis process using the Gemini 2.5 Pro model and measures the execution time. ```python # Measure execution time start_time = time.time() # Run the analysis print("Analyzing football video with Gemini 2.5 Pro...") analysis_result = analyze_football_video(youtube_url, client, MODEL_NAME) # Calculate elapsed time elapsed_time = time.time() - start_time print(f"Analysis completed in {elapsed_time:.2f} seconds") # Check if we got an error if "error" in analysis_result: print(f"Error: {analysis_result['error']}") if "raw_response" in analysis_result: print("Raw response:") print(analysis_result["raw_response"]) ``` -------------------------------- ### Analyze YouTube Video Content Source: https://github.com/yyorky/footballvideoanalyst/blob/main/test.ipynb Uses the Gemini model to process a YouTube URL and generate a structured analysis based on a provided prompt. ```python from google.genai import types youtube_url = "https://www.youtube.com/watch?v=LMhe2egLsrQ" prompt = """Analyze the following YouTube video content. Provide a detailed breakdown: 1. **Main Thesis/Claim:** What is the central point the creator is making? 2. **Key Topics:** List the main subjects discussed, referencing specific sections or timestamps if possible. 3. **Call to Action:** Identify any explicit requests made to the viewers. 4. **Summary:** Provide a concise summary of the video content. Use the provided title, chapter timestamps/descriptions, and description text if available. """ # Analyze the video response = client.models.generate_content( model="gemini-2.5-pro-exp-03-25", contents=types.Content( parts=[ types.Part(text=prompt), types.Part( file_data=types.FileData(file_uri=youtube_url) ) ] ) ) print(response.text) ``` -------------------------------- ### Analyze and Embed Football Video Source: https://github.com/yyorky/footballvideoanalyst/blob/main/test.ipynb Extracts the YouTube ID from a URL and renders the video within the notebook environment. ```python # Example football highlight video URL # Manchester City vs Real Madrid UCL 2023 semi-final youtube_url = "https://www.youtube.com/watch?v=LMhe2egLsrQ" # Extract video ID for embedding video_id = extract_youtube_id(youtube_url) print(f"Video ID: {video_id}") # Display embedded video from IPython.display import HTML HTML(embed_youtube_video(youtube_url)) ``` -------------------------------- ### Display Match Information Source: https://github.com/yyorky/footballvideoanalyst/blob/main/test.ipynb Extracts and prints match details, scores, and the summary from the analysis result. ```python # Extract match information if "error" not in analysis_result: competition = analysis_result.get("competition", "Unknown Competition") match_date = analysis_result.get("match_date", "") match_stage = analysis_result.get("match_stage", "") team1 = analysis_result.get("team1", {}) team2 = analysis_result.get("team2", {}) team1_name = team1.get("name", "Team 1") team2_name = team2.get("name", "Team 2") team1_score = team1.get("score", "?") team2_score = team2.get("score", "?") print(f"{competition} {match_stage} {match_date}") print(f"{team1_name} {team1_score} - {team2_score} {team2_name}") print("\nMatch Summary:") print(analysis_result.get("match_summary", "No summary available")) ``` -------------------------------- ### Display Player Ratings and Analysis Source: https://github.com/yyorky/footballvideoanalyst/blob/main/test.ipynb Defines a function to iterate through team data and display individual player ratings, analysis, and key moments. ```python # Function to display player ratings and analysis def display_team_analysis(team_data): team_name = team_data.get("name", "Unknown Team") print(f"\n{team_name} Player Ratings:") print("-" * 50) for player in team_data.get("players", []): name = player.get("name", "Unknown Player") rating = player.get("rating", "?") analysis = player.get("analysis", "No analysis available") print(f"{name}: {rating}/10") print(f"Analysis: {analysis}") # Display key moments if available key_moments = player.get("key_moments", []) if key_moments: print("Key moments:") for moment in key_moments: time = moment.get("time", "?") desc = moment.get("description", "") print(f" • {time}: {desc}") print("-" * 50) # Display analysis for both teams if "error" not in analysis_result: # Team 1 analysis display_team_analysis(team1) # Team 2 analysis display_team_analysis(team2) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.