==================================================
❤ UPDATE v2.2 — Major Overhaul
==================================================
Big update! The script is now smarter, safer, and fully configurable from OBS.
No more editing script files — everything works out of the box.

==================================================
⭐️ NEW FEATURES
==================================================
Expanded Game Library (50 → 80+ games)
The built-in dictionary now recognizes even more games automatically.

Added:
• Helldivers 2, Starfield, Hogwarts Legacy, Lies of P
• War Thunder, World of Tanks, Final Fantasy XIV
• Path of Exile, Lost Ark, New World, Warframe
• Resident Evil 2/3/4, Monster Hunter World/Rise, Sekiro
• Red Dead Redemption 2, Skyrim, Fallout, Diablo, WoW
• Deep Rock Galactic, Valheim, No Man's Sky, Subnautica
• Satisfactory, The Sims 4, Minecraft Java (javaw.exe)

️ Full OBS GUI Settings
All settings are now configurable directly in OBS Scripts panel.
No need to open the script file anymore!

• Organized collapsible groups
• Emoji icons for easy navigation
• Groups: File Naming, Organization, Spam Protection, Tools

Expanded Ignore List (20 → 70+ apps)
New categories added to prevent false detections:

• Editing: Premiere, DaVinci, Vegas, Audacity, Photoshop
• Overlays: NVIDIA Share, Overwolf, Medal, AMD Radeon
• Dev Tools: VS Code, Sublime, JetBrains IDEs, Terminal
• Utilities: 7-Zip, WinRAR, FileZilla, PowerShell
• Launchers: EA Desktop, Ubisoft Connect, Bethesda

Session Statistics
See how many clips were organized when OBS closes.
Example: "Session: 15 moved, 2 skipped"

==================================================
BUG FIXES
==================================================
Fixed Timer Bug (Critical)
• Old: Used os.clock() (CPU time — unreliable when idle)
• New: Uses os.time() (real time — always accurate)

Fixed Handle Validation
• Added proper INVALID_HANDLE_VALUE checking
• Prevents crashes with Anti-Cheat protected processes

Removed Blocking Retry Loop
• Old version could freeze OBS during file operations
• Now handles errors gracefully without blocking

==================================================
️ NEW SAFETY FEATURES
==================================================
Path Length Protection
• Validates paths against Windows MAX_PATH limit (260 chars)
• Auto-truncates long filenames: "VeryLongName..." + extension
• No more "path too long" errors

File Size Validation
• Checks file size before moving
• Warns about empty or potentially corrupted files
• Shows file size in debug mode

Improved Crash Protection
• All Windows API calls wrapped in pcall
• Better error messages with full paths
• Graceful fallback on failures

==================================================
‍ IMPROVEMENTS
==================================================
• Centralized CONFIG table structure
• Improved is_invalid_handle() function
• Consistent [Smart Replay] log prefix
• Better debug output formatting
• Cleaner code organization

==================================================
This is the most stable version yet. We fixed critical bugs related to non-English file paths and improved the spam protection logic.

Critical Fixes:
  • Unicode Support: Fixed a major issue where os.remove failed on paths containing Cyrillic/Special characters. The script now uses DeleteFileW (Windows API) to correctly handle and delete files in any language.
  • Dictionary Logic: Fixed a logic bug where cleaning the process name prevented looking it up in the custom dictionary.

️ Improvements:
  • Smarter Spam Cleanup: The duplicate prevention now verifies if the file was actually deleted. If the standard method fails, it attempts a forced delete via WinAPI.
  • User Friendly: Added detailed comments and instructions directly inside the .lua file, making it easy for anyone to configure.
Big update! The script is now smarter and requires almost no configuration.
Changelog:
  • ⭐️ Added "Smart Pattern" Detection: The script now includes a built-in library of 50+ popular games (CoD, Minecraft, Roblox, LoL, etc.). It scans process names for keywords, so you don't need to manually add them to the dictionary.
  • ⭐️ Added Folder Normalization: The script now scans your drive before creating folders to prevent case-sensitivity duplicates.
    • Example: If you already have a folder named "CS2", the script will use it instead of creating a new "cs2" folder.
  • Improved Ignored List: Added more launchers and clients (Riot Client, Steam Client) to the ignore list to ensure the actual game is detected.
  • Code Cleanup: Improved WinAPI handling for better performance.
Top