Pure logic module for resolving output file paths from book metadata and sanitizing components for filesystem safety. No I/O, no network — all deterministic string manipulation.
downloader module (path logic):
Default conditional path pattern:
Book has series AND series_num: <FIRST_AUTHOR>/<SERIES_NAME>/Book <SERIES_NUM> <BOOK_TITLE>
Book has series but no series_num: <FIRST_AUTHOR>/<SERIES_NAME>/<BOOK_TITLE>
Book has no series: <FIRST_AUTHOR>/<BOOK_TITLE>
Custom path_pattern support with token substitution: FIRST_AUTHOR, ALL_AUTHORS, SERIES_NAME, SERIES_NUM, BOOK_TITLE, ISBN, FIRST_NARRATOR, ALL_NARRATORS, PUBLICATION_YEAR, PUBLICATION_MONTH, PUBLICATION_DAY
When custom pattern is set, it fully overrides the default conditional behavior
Sanitization rules (applied to every path component):
Replace : characters with -
Strip < > / \ | ? * and control characters (\x00-\x1F)
Remove trailing dots
Trim whitespace
Cap component length at 255 characters
Preserve: dashes, commas, apostrophes, parentheses, periods (non-trailing)
Subdirectory decision logic:
Given a book metadata object, determine whether a subdirectory is needed (based on presence of accompanying files — PDF extras or cover art)
This slice builds the function; actual subdirectory creation happens in later slices
Acceptance criteria
Default path resolves correctly for book with series + series_num
Default path resolves correctly for book with series but no series_num
Default path resolves correctly for book without series
Custom path_pattern with token substitution works for all documented tokens
## Parent
#1
## What to build
Pure logic module for resolving output file paths from book metadata and sanitizing components for filesystem safety. No I/O, no network — all deterministic string manipulation.
**downloader module (path logic):**
- Default conditional path pattern:
- Book has series AND series_num: `<FIRST_AUTHOR>/<SERIES_NAME>/Book <SERIES_NUM> <BOOK_TITLE>`
- Book has series but no series_num: `<FIRST_AUTHOR>/<SERIES_NAME>/<BOOK_TITLE>`
- Book has no series: `<FIRST_AUTHOR>/<BOOK_TITLE>`
- Custom `path_pattern` support with token substitution: FIRST_AUTHOR, ALL_AUTHORS, SERIES_NAME, SERIES_NUM, BOOK_TITLE, ISBN, FIRST_NARRATOR, ALL_NARRATORS, PUBLICATION_YEAR, PUBLICATION_MONTH, PUBLICATION_DAY
- When custom pattern is set, it fully overrides the default conditional behavior
**Sanitization rules** (applied to every path component):
1. Replace `:` characters with ` -`
2. Strip `< > / \ | ? *` and control characters (`\x00-\x1F`)
3. Remove trailing dots
4. Trim whitespace
5. Cap component length at 255 characters
6. Preserve: dashes, commas, apostrophes, parentheses, periods (non-trailing)
**Subdirectory decision logic:**
- Given a book metadata object, determine whether a subdirectory is needed (based on presence of accompanying files — PDF extras or cover art)
- This slice builds the function; actual subdirectory creation happens in later slices
## Acceptance criteria
- [ ] Default path resolves correctly for book with series + series_num
- [ ] Default path resolves correctly for book with series but no series_num
- [ ] Default path resolves correctly for book without series
- [ ] Custom path_pattern with token substitution works for all documented tokens
- [ ] Custom path_pattern overrides default when set
- [ ] Colons replaced with ` -` in all components
- [ ] Illegal chars stripped: `< > / \ | ? *`
- [ ] Control characters stripped
- [ ] Trailing dots removed
- [ ] Whitespace trimmed
- [ ] Components capped at 255 chars
- [ ] Dashes, commas, apostrophes, parentheses preserved
- [ ] Subdirectory-needed returns True when PDF extras or cover art present
- [ ] Subdirectory-needed returns False when neither present
- [ ] ~20 tests covering all path patterns, every sanitization rule, edge cases (empty strings, max-length input, unicode)
- [ ] All tests pass
## Blocked by
#3
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Parent
#1
What to build
Pure logic module for resolving output file paths from book metadata and sanitizing components for filesystem safety. No I/O, no network — all deterministic string manipulation.
downloader module (path logic):
<FIRST_AUTHOR>/<SERIES_NAME>/Book <SERIES_NUM> <BOOK_TITLE><FIRST_AUTHOR>/<SERIES_NAME>/<BOOK_TITLE><FIRST_AUTHOR>/<BOOK_TITLE>path_patternsupport with token substitution: FIRST_AUTHOR, ALL_AUTHORS, SERIES_NAME, SERIES_NUM, BOOK_TITLE, ISBN, FIRST_NARRATOR, ALL_NARRATORS, PUBLICATION_YEAR, PUBLICATION_MONTH, PUBLICATION_DAYSanitization rules (applied to every path component):
:characters with-< > / \ | ? *and control characters (\x00-\x1F)Subdirectory decision logic:
Acceptance criteria
-in all components< > / \ | ? *Blocked by
#3