diff options
| author | historia <historiavg@proton.me> | 2026-08-27 18:41:10 -0400 |
|---|---|---|
| committer | historia <historiavg@proton.me> | 2026-08-27 18:41:10 -0400 |
| commit | b6795046bf20023fd7b2e083ead20e7362f0c0d7 (patch) | |
| tree | 20c8fd1cde5ed7fbb2c630e8250af098f547be05 /app/converter/converter.py | |
| parent | 0047a875d0a969005f3cea3df18de909d285f910 (diff) | |
| download | tts-audiobook-generator-b6795046bf20023fd7b2e083ead20e7362f0c0d7.tar.gz | |
feat: simply generate audiobooks menu, move more config to settings menu
Diffstat (limited to 'app/converter/converter.py')
| -rw-r--r-- | app/converter/converter.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/app/converter/converter.py b/app/converter/converter.py index b356448..d2d06b9 100644 --- a/app/converter/converter.py +++ b/app/converter/converter.py @@ -36,13 +36,26 @@ from .clients import ( logger = logging.getLogger(__name__) # Folders, resolved from the project root so the converter runs from any -# working directory. User-facing dirs (input/, output/) stay at the root; +# working directory. User-facing dirs (input/, output/) come from config +# (INPUT_DIR/OUTPUT_DIR; relative paths resolve against the project root); # scratch/log dirs live under the app/ container. BASE_DIR = Path(__file__).resolve().parent.parent.parent APP_DIR = BASE_DIR / "app" -BOOKS_FOLDER = BASE_DIR / "input" -AUDIOBOOKS_FOLDER = BASE_DIR / "output" + +def resolve_dir(value, default: str) -> Path: + """Resolve a configured directory VALUE (str/Path) to a Path. + + Blank values fall back to DEFAULT ("input"/"output"); relative + paths resolve against the project root so the converter runs from + any working directory, and "~" expands to the home directory. + """ + path = Path(str(value or "").strip() or default).expanduser() + return path if path.is_absolute() else BASE_DIR / path + + +BOOKS_FOLDER = resolve_dir(config.INPUT_DIR, "input") +AUDIOBOOKS_FOLDER = resolve_dir(config.OUTPUT_DIR, "output") CHUNKS_FOLDER = APP_DIR / "chunks" # Per-chunk scratch audio, cleaned per book LOGS_FOLDER = APP_DIR / "logs" DEBUG_FOLDER = APP_DIR / "debug" # --debug dumps, kept across runs |
