# yeokim5/smart-recording architecture

> Architecture diagram of the GitHub repository yeokim5/smart-recording, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yeokim5/smart-recording
- Repository: https://github.com/yeokim5/smart-recording

## Overview

##### Main Components
- Main Application: Represented by main.py, which contains the primary logic and the scheduler. It configures parameters like the search URL, start time, and recording duration.
- Browser Automation: Utilizes Selenium and webdriver-manager to open Google Chrome, navigate to the sports stream URL, search for the desired game, extract the embed source, and update the local HTML file. This component interacts directly with Chrome.
- HTML Test Page: The test.html file acts as a display and trigger for the stream by embedding the updated source URL. This page is used for fullscreen playback.
- Recording Integration: Windows Game Bar is used to capture the screen once the stream is playing. The process is automated via keyboard shortcuts (Win+Alt+R) likely triggered by modules such as pyautogui and pygetwindow.
- External Services/Tools: Google Chrome for browsing; the Chrome WebDriver (automatically managed via webdriver-manager); and the external libraries required for automation (selenium, pyautogui, etc.).

##### Relationships and Interactions
- The Main Application (main.py) is the central orchestrator. It schedules the recording by setting parameters (search URL, start time, duration) and initiates the workflow.
- Once the schedule is met, main.py invokes the Browser Automation module which:
- Opens Chrome
- Navigates to the search URL to locate the stream
- Scrapes or extracts the embed URL from the stream page
- The extracted embed URL is then used to update test.html (dynamically replacing a placeholder in the HTML).
- The HTML Test Page is then launched in fullscreen mode.
- Concurrently, automation scripts (powered by pyautogui and pygetwindow) trigger Windows Game Bar commands (e.g., Win+Alt+R) to start and stop the recording.

##### Architectural Patterns and Design Principles
- Modular Design: Each functionality—web automation, HTML manipulation, scheduling, and recording—is separated into distinct components or modules.
- Sequential Workflow: The process follows clear sequential steps from configuring the recording, navigating the browser, updating the HTML, initiating playback, and finally recording via Windows Game Bar.
- Integration of External Tools: Relies on third-party tools (Chrome, Windows Game Bar) and libraries to accomplish specific tasks, highlighting the importance of well-defined integration points.

##### Relevant Technologies and Libraries
- Python, serving as the primary language.
- Selenium and webdriver-manager for browser automation.
- PyAutoGUI and PyGetWindow for automating keypresses and handling window interactions.
- Windows Game Bar as the recording utility.
- Google Chrome as the browser.

##### Details
- Don’t overcomplicate: Clearly separate the project’s core functionalities into well-defined sections.
- Showing the dependencies (e.g., required installations and external tools) that play a significant role in the system’s overall behavior.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Local Modules"
        MA["Main Application [main.py]"]:::local
        BA["Browser Automation [Selenium/ChromeDriver]"]:::local
        HT["HTML Test Page [test.html]"]:::local
        RI["Recording Integration [Windows Game Bar]"]:::local
        AUX_PY["Auxiliary Script [arrow.py]"]:::local
        AUX_BAT["Auxiliary Script [arrow.bat]"]:::local
    end

    subgraph "External Services"
        GC["Google Chrome"]:::external
        WG["Windows Game Bar"]:::external
        LIBS["Automation Libraries (Selenium,PyAutoGUI,PyGetWindow)"]:::external
    end

    MA -->|"ScheduleTrigger"| BA
    BA -->|"Navigate&ExtractStream"| HT
    HT -->|"LaunchFullScreen"| RI
    MA -->|"InvokeAuxScripts"| AUX_PY
    MA -->|"InvokeAuxScripts"| AUX_BAT
    BA -->|"Launches"| GC
    BA -->|"Uses"| LIBS
    RI -->|"TriggersRecording"| WG
    RI -->|"Uses"| LIBS

    click MA "https://github.com/yeokim5/smart-recording/blob/main/main.py"
    click BA "https://github.com/yeokim5/smart-recording/blob/main/main.py"
    click HT "https://github.com/yeokim5/smart-recording/blob/main/test.html"
    click AUX_PY "https://github.com/yeokim5/smart-recording/blob/main/arrow.py"
    click AUX_BAT "https://github.com/yeokim5/smart-recording/blob/main/arrow.bat"

    classDef local fill:#9fdfbf,stroke:#2e856e,stroke-width:2px;
    classDef external fill:#f9e79f,stroke:#f1c40f,stroke-width:2px;
```
