Metadata Sources
Metadata Extraction Guide
Section titled “Metadata Extraction Guide”This guide explains how the Audiobook Organizer extracts metadata from various file formats and how to configure field mapping for non-standard metadata structures.
Overview
Section titled “Overview”The organizer can extract audiobook metadata from four sources:
- metadata.json files - JSON files created by Audiobookshelf
- Embedded EPUB metadata - Dublin Core metadata in EPUB files
- Embedded MP3 tags - ID3v2 tags in MP3 audio files
- Embedded M4B tags - iTunes-style metadata in M4B audio files
Hybrid mode: When metadata.json exists alongside audio files, the organizer automatically merges book-level metadata from JSON with track-level metadata from audio files.
Metadata Sources
Section titled “Metadata Sources”1. metadata.json Files (Audiobookshelf)
Section titled “1. metadata.json Files (Audiobookshelf)”Default mode. The organizer looks for metadata.json files created by Audiobookshelf.
File structure:
{ "title": "The Final Empire", "authors": ["Brandon Sanderson"], "series": ["Mistborn #1"], "publisher": "Tor Books", "publishedYear": "2006", "description": "...", "genres": ["Fantasy", "Epic Fantasy"], "narrator": "Michael Kramer"}How to use:
# Automatic if metadata.json files existaudiobook-organizer --dir=/path/to/audiobooksPros:
- Clean, structured metadata
- Book-level information (not per-file)
- Consistent format
Cons:
- Requires Audiobookshelf or manual JSON creation
- Doesn’t include track numbers for multi-file books
2. Embedded EPUB Metadata
Section titled “2. Embedded EPUB Metadata”Uses Dublin Core metadata embedded in EPUB files.
Extracted fields:
- Title (
dc:title) - Authors (
dc:creator) - Publisher (
dc:publisher) - Publication date (
dc:date) - Description (
dc:description) - Language (
dc:language)
How to use:
audiobook-organizer --dir=/path/to/epubs --use-embedded-metadataPros:
- Self-contained (no external metadata needed)
- Standardized Dublin Core format
Cons:
- No track/disc numbers (EPUB is single file)
- Limited series information
3. Embedded MP3 Tags (ID3v2)
Section titled “3. Embedded MP3 Tags (ID3v2)”Extracts ID3v2 tags from MP3 audio files.
Common fields:
- Title (
TIT2) - Artist (
TPE1) - Album (
TALB) - Album Artist (
TPE2) - Track Number (
TRCK) - Disc Number (
TPOS) - Year (
TYERorTDRC) - Comment (
COMM)
How to use:
audiobook-organizer --dir=/path/to/mp3s --use-embedded-metadataPros:
- Widely supported
- Per-file metadata (track numbers)
- No external files needed
Cons:
- Inconsistent field usage (see Field Mapping below)
- May lack book-level metadata
4. Embedded M4B Tags (iTunes)
Section titled “4. Embedded M4B Tags (iTunes)”Extracts iTunes-style metadata from M4B audio files.
Common fields:
- Title (
©nam) - Artist (
©ART) - Album (
©alb) - Album Artist (
aART) - Track Number (
trkn) - Disc Number (
disk) - Year (
©day) - Comment (
©cmt)
How to use:
audiobook-organizer --dir=/path/to/m4bs --use-embedded-metadataPros:
- Audiobook-specific format
- Good metadata support
- Per-file track information
Cons:
- Less common than MP3
- Field mapping still may be needed
Hybrid Metadata Mode
Section titled “Hybrid Metadata Mode”NEW Feature: Automatic merging of metadata.json with embedded audio tags.
How It Works
Section titled “How It Works”When both metadata.json and audio files exist in the same directory:
-
Book-level metadata comes from
metadata.json:- Title, authors, series
- Publisher, publication date
- Description, genres
- Narrator
-
File-level metadata comes from embedded tags:
- Track numbers
- Disc numbers
- Individual chapter titles (if different from book title)
-
Merging logic:
metadata.jsonfields take priority for book info- Audio file tags used for track/disc numbers
- Best of both sources
Example
Section titled “Example”Directory structure:
/audiobooks/Mistborn/├── metadata.json # Contains: title, authors, series├── track01.mp3 # Contains: track=1, disc=1├── track02.mp3 # Contains: track=2, disc=1└── track03.mp3 # Contains: track=3, disc=1Result:
- Title: From metadata.json → “The Final Empire”
- Author: From metadata.json → “Brandon Sanderson”
- Series: From metadata.json → “Mistborn #1”
- Track Numbers: From MP3 files → 1, 2, 3
- Disc Numbers: From MP3 files → 1, 1, 1
Benefits:
- Complete metadata picture
- Proper track numbering for multi-file books
- No manual intervention needed
Enabling Hybrid Mode
Section titled “Enabling Hybrid Mode”Automatic - No special flags needed. If both metadata.json and audio files exist, hybrid mode activates automatically.
# Just run normallyaudiobook-organizer --dir=/path/to/audiobooksFlat vs Non-Flat Processing
Section titled “Flat vs Non-Flat Processing”The --flat flag changes how files are discovered and grouped.
Non-Flat Mode (Default)
Section titled “Non-Flat Mode (Default)”Behavior:
- All files in a directory treated as one book
- Shared metadata per directory
- Directory structure implies book grouping
Good for:
- Multi-file audiobooks
- Pre-organized collections
- Books split across multiple MP3/M4B files
Example:
Input: /books/ Mistborn_The_Final_Empire/ chapter1.mp3 # All belong to same book chapter2.mp3 chapter3.mp3
Output: /organized/ Brandon Sanderson/ Mistborn/ The Final Empire/ chapter1.mp3 chapter2.mp3 chapter3.mp3Command:
audiobook-organizer --dir=/books --out=/organizedFlat Mode (--flat)
Section titled “Flat Mode (--flat)”Behavior:
- Each file processed independently
- Files grouped ONLY if they have identical metadata
- Ignores directory structure
Good for:
- Single-file audiobooks (EPUB, single M4B)
- Mixed collections in one directory
- Files with complete per-file metadata
Example:
Input: /downloads/ book1.epub # Metadata: Author A, Book 1 book2.epub # Metadata: Author B, Book 2 book3_ch1.mp3 # Metadata: Author C, Book 3 book3_ch2.mp3 # Metadata: Author C, Book 3 (same metadata → grouped)
Output: /organized/ Author A/ Book 1/ book1.epub Author B/ Book 2/ book2.epub Author C/ Book 3/ book3_ch1.mp3 book3_ch2.mp3 # Grouped because identical metadataCommand:
audiobook-organizer --dir=/downloads --out=/organized --flatImportant: Flat mode auto-enables --use-embedded-metadata.
When to Use Each Mode
Section titled “When to Use Each Mode”| Scenario | Mode | Reason |
|---|---|---|
| Multi-file books in separate directories | Non-flat (default) | Directory structure groups files |
| Single-file audiobooks (EPUB, M4B) | Flat | Each file is complete book |
| Mixed collection in one directory | Flat | Files need independent processing |
| Pre-organized library | Non-flat (default) | Directory structure is meaningful |
| Files with complete metadata | Flat | Metadata determines grouping |
| Files with partial metadata | Non-flat (default) | Directory structure provides context |
Field Mapping
Section titled “Field Mapping”Problem: Metadata fields aren’t standardized. MP3 files might use “artist” for author, “album” for title, etc.
Solution: Field mapping tells the organizer which fields contain author, title, series, etc.
Why Field Mapping is Needed
Section titled “Why Field Mapping is Needed”Standard audiobook metadata:
Title: The Final EmpireAuthors: Brandon SandersonSeries: MistbornTrack: 1Real MP3 file metadata:
title: Chapter 1 (track title, not book title!)artist: Michael Kramer (narrator, not author!)album: The Final Empire (book title in album field!)album_artist: Brandon Sanderson (author in album_artist field!)Without field mapping: Organizer uses wrong fields → incorrect organization
With field mapping: Organizer knows to use album for title, album_artist for author
Field Mapping Options
Section titled “Field Mapping Options”Author Fields
Section titled “Author Fields”Comma-separated list of fields to try in priority order:
--author-fields="authors,narrators,album_artist,artist"How it works:
- Try
authorsfield first - If empty, try
narrators - If empty, try
album_artist - If empty, try
artist - Use first non-empty value
Common configurations:
| Use Case | Configuration |
|---|---|
| Standard Audiobookshelf | --author-fields="authors" |
| Standard MP3s | --author-fields="artist,album_artist" |
| Audiobooks with narrator as artist | --author-fields="narrators,album_artist,artist" |
| MP3s with author in album_artist | --author-fields="album_artist,artist,authors" |
Title Field
Section titled “Title Field”Single field to use for book title:
--title-field="album" # Use album tag as title--title-field="title" # Use title tag (default)Common use cases:
| Use Case | Configuration |
|---|---|
| MP3s where album = book title | --title-field="album" |
| Standard metadata | --title-field="title" |
| EPUBs | --title-field="title" (default works) |
Series Field
Section titled “Series Field”Single field to use for series:
--series-field="series" # Use series tag (default)--series-field="album" # Use album as seriesTrack Field
Section titled “Track Field”Single field to use for track numbers:
--track-field="track" # Use track tag (default)--track-field="track_number" # Alternative field nameField Mapping in Different Modes
Section titled “Field Mapping in Different Modes”Use flags directly:
audiobook-organizer \ --dir=/media/audiobooks \ --use-embedded-metadata \ --author-fields="album_artist,artist" \ --title-field="album" \ --series-field="series"Config File
Section titled “Config File”Set in config file:
author-fields: "album_artist,artist,narrators"title-field: "album"series-field: "series"track-field: "track"Environment Variables
Section titled “Environment Variables”export AO_AUTHOR_FIELDS="album_artist,artist,narrators"export AO_TITLE_FIELD="album"export AO_SERIES_FIELD="series"export AO_TRACK_FIELD="track"Click “Configure Field Mapping” button → Interactive dialog with dropdowns
Navigate to Field Mapping screen → Select fields with keyboard
Field Mapping Presets
Section titled “Field Mapping Presets”Common configurations for different file types:
Preset 1: Audio (Default)
Section titled “Preset 1: Audio (Default)”For well-structured MP3/M4B files:
--author-fields="authors,album_artist,artist"--title-field="title"--series-field="series"--track-field="track"Preset 2: Audio (Album as Title)
Section titled “Preset 2: Audio (Album as Title)”For MP3s where book title is in album field:
--author-fields="album_artist,artist,narrators"--title-field="album"--series-field="series"--track-field="track"Preset 3: Audiobookshelf + Audio
Section titled “Preset 3: Audiobookshelf + Audio”For hybrid mode (metadata.json + audio files):
# Book info from metadata.json, track info from audio--author-fields="authors" # From JSON--title-field="title" # From JSON--series-field="series" # From JSON--track-field="track" # From audio filesAlbum Detection
Section titled “Album Detection”Multi-file audiobooks are automatically detected and grouped.
How It Works
Section titled “How It Works”Files are grouped into albums when they share:
- Same directory (in non-flat mode)
- Same author
- Same title/album
- Same series (if present)
Result: Files treated as chapters of one book
Example
Section titled “Example”Input files: /books/mistborn/chapter01.mp3 # Author: Sanderson, Album: Mistborn /books/mistborn/chapter02.mp3 # Author: Sanderson, Album: Mistborn /books/mistborn/chapter03.mp3 # Author: Sanderson, Album: Mistborn
Detection: ✓ Same directory ✓ Same author (Sanderson) ✓ Same album (Mistborn) → Grouped as one book with 3 chapters
Output: /organized/Brandon Sanderson/Mistborn/ chapter01.mp3 chapter02.mp3 chapter03.mp3Indicators
Section titled “Indicators”GUI/TUI: Shows album indicator (📀 icon) with file count
CLI: Logs “Processing album: Title (X files)“
Metadata Viewer
Section titled “Metadata Viewer”Use the metadata viewer to explore extracted fields:
audiobook-organizer metadata-tui --dir=/path/to/audiobooksShows:
- All extracted metadata fields
- Field source (metadata.json, MP3, M4B, EPUB)
- Which fields are populated
- Color-coded indicators for mapped fields
Use cases:
- Understand metadata structure before organizing
- Design field mapping configuration
- Troubleshoot extraction issues
- Compare different file formats
Troubleshooting Metadata Issues
Section titled “Troubleshooting Metadata Issues”No metadata found
Section titled “No metadata found”Symptoms: Scan completes but no audiobooks found, or books have empty metadata
Solutions:
- Verify files contain metadata:
Terminal window audiobook-organizer metadata --dir=/path --json - Check file formats are supported (EPUB, MP3, M4B, metadata.json)
- Try
--use-embedded-metadataif no metadata.json files - Use
--flatfor single-file audiobooks
Wrong author/title extracted
Section titled “Wrong author/title extracted”Symptoms: Books organized under wrong author or title
Solutions:
- Use metadata viewer to see available fields:
Terminal window audiobook-organizer metadata-tui --dir=/path - Configure field mapping:
Terminal window audiobook-organizer \--dir=/path \--author-fields="album_artist,artist" \--title-field="album" - Use GUI field mapping dialog for visual configuration
Files not grouped as album
Section titled “Files not grouped as album”Symptoms: Multi-file book split into separate books
Causes:
- Inconsistent metadata across files
- Using
--flatmode (files processed independently) - Different author/title/album values
Solutions:
- Verify metadata consistency:
Terminal window audiobook-organizer metadata-tui --dir=/path - Use non-flat mode (default) for multi-file books
- Edit file tags to ensure consistent metadata
- Check track numbers are sequential
Track numbers missing or wrong
Section titled “Track numbers missing or wrong”Symptoms: Files not in correct order, or numbered incorrectly
Solutions:
- Check track field:
Terminal window audiobook-organizer metadata-tui --dir=/path - Configure track field:
Terminal window --track-field="track_number" # If track field is named differently - Verify audio files have track tags
- Use hybrid mode if metadata.json has track info
Hybrid mode not working
Section titled “Hybrid mode not working”Symptoms: Track numbers still missing despite audio files + metadata.json
Solutions:
- Verify both exist in same directory:
Terminal window ls -la /path/to/book/# Should show: metadata.json, *.mp3 or *.m4b - Check metadata.json is valid JSON
- Verify audio files have track tags
- Use metadata viewer to see merged result
Best Practices
Section titled “Best Practices”1. Preview First
Section titled “1. Preview First”Always use --dry-run to preview metadata extraction:
audiobook-organizer --dir=/path --dry-run --verbose2. Start with Metadata Viewer
Section titled “2. Start with Metadata Viewer”Before organizing, explore metadata:
audiobook-organizer metadata-tui --dir=/path3. Test Field Mapping
Section titled “3. Test Field Mapping”Test field mapping on a small subset:
audiobook-organizer \ --dir=/path/to/test-book \ --author-fields="album_artist,artist" \ --title-field="album" \ --dry-run4. Use Config Files for Complex Mappings
Section titled “4. Use Config Files for Complex Mappings”Save complex field mappings to config file:
author-fields: "narrators,album_artist,artist,authors,composer"title-field: "album,title"series-field: "series,album,grouping"track-field: "track,track_number,trck"5. Document Your Configuration
Section titled “5. Document Your Configuration”Add comments to config files:
# Field mapping for Libby MP3 downloads# - Author is in album_artist field# - Book title is in album field# - Narrator is in artist fieldauthor-fields: "album_artist,artist"title-field: "album"See Also
Section titled “See Also”- CLI.md - Command-line reference for field mapping flags
- GUI.md - GUI field mapping dialog documentation
- TUI.md - TUI field mapping screen guide
- CONFIGURATION.md - Config file format for field mapping
- Main README - Project overview
Feedback & Support
Section titled “Feedback & Support”- Bug reports: GitHub Issues
- Metadata questions: GitHub Discussions Q&A
When reporting metadata issues, please include:
- File format (MP3, M4B, EPUB, metadata.json)
- Output of
audiobook-organizer metadata --dir=/path --json - Expected vs actual metadata
- Sample file (if possible)