diff --git a/app.py b/app.py index 9897f1b..03b5803 100644 --- a/app.py +++ b/app.py @@ -64,6 +64,22 @@ MIN_SOURCE_SECONDS = int(os.environ.get("MIN_SOURCE_SECONDS", "45")) QUALITY_PROBE_SCRIPT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "quality_probe.py") DISABLE_YOUTUBE_URL = os.environ.get("DISABLE_YOUTUBE_URL", "false").lower() in ("1", "true", "yes") +# Every log line in this module is emoji-prefixed, and a Windows console is +# cp1252 by default. _recover_jobs_from_disk() prints one during startup, so +# without this the server dies before it ever listens: +# +# UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1 +# ERROR: Application startup failed. Exiting. +# +# subtitles._configure_stdio solved this for the transcription path; the server +# needs it too, and needs it before the first print. +for _stream in (sys.stdout, sys.stderr): + if hasattr(_stream, "reconfigure"): + try: + _stream.reconfigure(encoding="utf-8", errors="replace") + except Exception: + pass + # ---- Cloud billing (paid / managed-keys) integration -------------------------- # All paid-mode code lives in the optional `cloud/` package and is imported ONLY # when BILLING_ENABLED is set. With the flag off, the app behaves exactly as the