From f5ee64cb6d4056e2259ba91918217d3842f88163 Mon Sep 17 00:00:00 2001 From: ^_^ <8480595+ballaballaballa@users.noreply.github.com> Date: Tue, 28 Oct 2025 22:28:30 +0100 Subject: [PATCH 01/11] Update README with correct paths for config file --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fa2135..87cf544 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,10 @@ grawlix --username "user@example.com" --password "SuperSecretPassword" username = "user@example.com" password = "SuperSecretPassword" ``` -Config file should be placed in `~/.config/grawlix/grawlix.toml` +Config file should be placed in: +- Linux: `~/.config/grawlix/grawlix.toml` +- macOS: `~/Library/Application Support/grawlix/grawlix.toml` +- Windows: `%LOCALAPPDATA%\jo1gi\grawlix\grawlix.toml` ### Cookies Some sources can be authenticated with Netscape cookie files. I use From ea7ca71408c0c8dd1c9b3afadea9ab6cc09733d6 Mon Sep 17 00:00:00 2001 From: ^_^ <8480595+ballaballaballa@users.noreply.github.com> Date: Wed, 29 Oct 2025 00:06:50 +0100 Subject: [PATCH 02/11] Added functionality to write metadata to epub. Only for Storytel for now. Can be triggered with parameter or set in config. Added option to add output path to config file. --- README.md | 109 ++++++++++- grawlix/__main__.py | 59 +++++- grawlix/arguments.py | 7 + grawlix/book.py | 3 +- grawlix/config.py | 22 ++- grawlix/epub_metadata.py | 303 +++++++++++++++++++++++++++++++ grawlix/epub_metadata_writers.py | 71 ++++++++ grawlix/output/__init__.py | 72 +++++++- grawlix/sources/storytel.py | 70 ++++++- 9 files changed, 691 insertions(+), 25 deletions(-) create mode 100644 grawlix/epub_metadata.py create mode 100644 grawlix/epub_metadata_writers.py diff --git a/README.md b/README.md index 87cf544..b327f00 100644 --- a/README.md +++ b/README.md @@ -50,10 +50,15 @@ grawlix --username "user@example.com" --password "SuperSecretPassword" **Config file example** ```toml -[sources.name] +# Global settings +write_metadata_to_epub = true +output = "~/ebooks/{series}/{index} - {title}.{ext}" + +[sources.storytel] username = "user@example.com" password = "SuperSecretPassword" ``` + Config file should be placed in: - Linux: `~/.config/grawlix/grawlix.toml` - macOS: `~/Library/Application Support/grawlix/grawlix.toml` @@ -61,14 +66,112 @@ Config file should be placed in: ### Cookies Some sources can be authenticated with Netscape cookie files. I use -[this extension](https://github,com/rotemdan/ExportCookies) to export my +[this extension](https://github.com/rotemdan/ExportCookies) to export my cookies from my browser. Cookies can be placed in current dir as `cookies.txt` or be given with the -`--cookie` argument. +`--cookies` argument. + +## Configuration + +### Global Settings + +The following settings can be added to your config file (before any `[sources.*]` sections): + +| Setting | Type | Description | Example | +|---------|------|-------------|---------| +| `write_metadata_to_epub` | boolean | Automatically write metadata to EPUB files (currently supports Storytel) | `true` or `false` | +| `output` | string | Default output path template (supports `~`, environment variables, and template variables) | `"~/ebooks/{title}.{ext}"` | + +### Output Templates + +The `output` setting supports template variables that are replaced with book metadata: + +| Variable | Description | Example | +|----------|-------------|---------| +| `{title}` | Book title | "The Witcher" | +| `{series}` | Series name | "The Witcher Saga" | +| `{index}` | Series index/number | "1" | +| `{authors}` | Authors (semicolon-separated) | "Andrzej Sapkowski" | +| `{publisher}` | Publisher name | "Orbit" | +| `{language}` | Language code | "en" | +| `{release_date}` | Release date | "2020-01-15" | +| `{ext}` | File extension | "epub" | + +**Example templates:** +```toml +# Simple +output = "~/books/{title}.{ext}" + +# Organized by series +output = "~/books/{series}/{index} - {title}.{ext}" + +# With author +output = "~/books/{authors}/{series}/{title}.{ext}" +``` + +**Path expansion:** +- `~` expands to home directory +- Environment variables work: `$HOME` (Unix) or `%USERPROFILE%` (Windows) +- Absolute paths: `/path/to/books` or `C:\Books` +- Relative paths: `downloads/{title}.{ext}` (relative to current directory) ## Download books + To download a book run: ```shell grawlix [options] ``` + +### Command Line Options + +| Option | Short | Description | +|--------|-------|-------------| +| `--version` | `-v` | Show version number | +| `--file ` | `-f` | File with URLs (one per line) | +| `--username ` | `-u` | Username for authentication | +| `--password ` | `-p` | Password for authentication | +| `--library ` | | Library name (for sources that require it) | +| `--cookies ` | `-c` | Path to Netscape cookie file | +| `--output