This commit introduces a series of improvements across the codebase:
1. **Logging:**
* Integrated Python's `logging` module throughout the application.
* Replaced custom `print_step/print_substep` functions with standard logging calls (INFO, WARNING, ERROR, DEBUG).
* Configured file logging (rotating logs) and console logging (using RichHandler if available).
* Enhanced FFmpeg error logs to include commands and stderr.
2. **Error Handling:**
* Made error handling more robust in TTS modules, Playwright interactions (screenshotting), API calls, and file operations.
* Replaced `sys.exit()` calls in modules with exceptions to allow better control by the caller.
* Improved reporting of unhandled exceptions in `main.py` with tracebacks to the log file.
3. **Code Quality & Modularity:**
* Refactored `main.py` and `video_creation/final_video.py` into smaller, more manageable functions, reducing global state and improving readability.
* Replaced `eval()` in configuration parsing (`utils/settings.py`, `utils/gui_utils.py`) with safer type conversion methods.
* Decoupled background choice management from the static TOML template, now dynamically loaded from `backgrounds.json`.
* Standardized path handling using `pathlib.Path` across numerous modules, replacing `os.path` and manual string concatenations.
* Corrected OS dispatcher logic in `utils/ffmpeg_install.py`.
* Clarified voice selection logic in `TTS/pyttsx.py`.
4. **FFmpeg Interaction:**
* Reviewed and refined the `ProgressFfmpeg` class for more robust progress parsing and thread management.
5. **Testing Groundwork:**
* Created `tests/` directory and added initial unit tests for utility functions `name_normalize` and `_safe_str_to_bool` using `unittest`.
6. **Documentation:**
* Added/updated module-level and key function docstrings in `main.py` and `video_creation/final_video.py`.
In get_latest_ms_progress(), the value of out_time_ms can equal 'N/A\n', this code confirms this will not be the case in the future. Since this is only a progress indicator, it should not crash the program.
The RedditVideoMakerBot has been updated to version 3.2, bringing exciting new features and bug fixes. Introducing **ElevenLabs TTS** for high-quality audio. Enjoy **background audio** and **random voices per comment**. Run the bot with one click using the **bat file**. Use the **zoom setting** for bigger text. Bug fixes include video downloader improvements, random story mode fix, updated dependencies, code optimizations, text size adjustments, enhanced Reddit credentials validation, and translator fixes. Enjoy the new features and **thanks to all contributors**!