$ show Felix3322/PotPlayer_ChatGPT_Translate
This repository contains a PotPlayer subtitle translation plugin written in AngleScript. It provides real-time subtitle translation by sending subtitle text to OpenAI-compatible chat completion APIs. Two variants are included: one with context (sends recent subtitles for better accuracy) and one without (faster, no context). The plugin handles configuration via a dual-layer system: installer-injected defaults that can be overridden by PotPlayer's settings panel. It supports retry logic, request delays, hallucination detection, small model mode, and context caching (including OpenAI prompt caching and Gemini cached content). The installer is a separate component built with Inno Setup that provides a GUI for selecting variant, configuring API settings, and injecting defaults into the script files. The code demonstrates solid engineering with careful error handling, configuration precedence, and extensibility for multi-provider support.
The LLM identified 1 files worth highlighting for reuse:
The functions BuildConfigSentinel, LoadInstallerConfig, and EnsureConfigDefault implement a pattern for layered configuration: installer-provided defaults are written as preprocessor strings in the script, but PotPlayer's panel settings take precedence when explicitly saved. The sentinel detects if the user has ever saved a value via PotPlayer's HostSaveString, allowing a clean fallback to installer defaults. This pattern is self-contained and can be extracted to any application needing a two-tier config system where defaults come from installation and user overrides persist afterward.