Metadata-Version: 2.4
Name: shelfinventory
Version: 0.1.0
Summary: Export an Audiobookshelf library to CSV, one row per book, with the columns people asked for. Read only, no dependencies.
Author: Younes Z.
License: MIT
Project-URL: Homepage, https://github.com/Rezarys/shelfinventory
Project-URL: Issues, https://github.com/Rezarys/shelfinventory/issues
Keywords: audiobookshelf,audiobook,library,inventory,csv,export,catalog,selfhosted
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Utilities
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# shelfinventory

```
pip install shelfinventory
```

Export an Audiobookshelf library to CSV, one row per book, with the columns people actually asked for on the upstream request thread. It reads over the HTTP API and writes nothing back to your server.

Why it exists: the request thread [advplyr/audiobookshelf#2085](https://github.com/advplyr/audiobookshelf/issues/2085) asks for a CSV inventory of what is really in the library. The workarounds described there are exporting from another tool, which reflects a different catalog, or opening the SQLite database with a generic client. This does the same job in one command, through the API, without touching the database file.

## Use

Set a token, then run it.

```
export AUDIOBOOKSHELF_TOKEN=your-api-token
```

```
shelfinventory --url https://abs.example
```

That prints the CSV on standard output. To write a file instead:

```
shelfinventory --url https://abs.example --out books.csv
```

The token is the API token from your Audiobookshelf account settings. It is read from the environment only, never from an argument, so it does not land in your shell history. The server address can also come from `AUDIOBOOKSHELF_URL`.

Titles contain commas, so the delimiter is yours to choose:

```
shelfinventory --url https://abs.example --delimiter tab
```

`--delimiter` takes one character, or one of `comma`, `semicolon`, `tab`, `pipe`, `colon`. Fields are quoted properly whatever you pick, so a comma inside a title never splits a row.

## Columns

Eighteen columns, in this order:

- `title`
- `subtitle`
- `authors`
- `narrators`
- `series_name`
- `series_sequence`
- `genres`
- `tags`
- `published_date`
- `published_year`
- `publisher`
- `asin`
- `isbn`
- `duration`
- `date_added`
- `library_name`
- `relative_path`
- `explicit`

That list is not mine. It is the list written on the request thread, in the same order, with one change: the single "published date or year" entry became two columns, because the server stores those as two separate fields and merging them would throw one away.

Multiple genres, tags or series are joined with `; ` inside one cell. Multiple authors and narrators get that same `; ` join only when you pass `--exact`; without it, they keep whatever separator the server itself used to join them. `duration` is `H:MM:SS` by default, or a number of seconds with `--duration seconds`. `date_added` is an ISO 8601 instant in UTC.

Every run, unless you pass `--quiet`, prints a short report on standard error saying how many books were exported and which columns your server left empty for every one of them. That report is the honest answer to whether your library really carries this metadata, and it never mixes into the CSV.

With no `--library`, every book library goes into the same CSV, and the `library_name` column says which one each row came from.

## Series sequences, and one honest caveat

The paginated library endpoint does not expose a series sequence as its own field. It exposes one joined string per book, built by the server as `"<name> #<sequence>"` entries separated by a comma. This tool splits that back apart, which is a guess and not a reading: a series whose own name contains a comma cannot be recovered that way.

If exact series and author fields matter to you, use:

```
shelfinventory --url https://abs.example --exact
```

That reads each book a second time, through the endpoint that returns real lists, so nothing has to be split. It costs one extra request per book, which is why it is not the default.

## Other options

- `--library NAME` picks one library by name or id, and repeats.
- `--list-libraries` prints what the token can read, then stops.
- `--page-size N` sets how many books are fetched per request.
- `--timeout SECONDS` sets the request timeout.
- `--quiet` drops the column report.

Podcast libraries are never exported. The columns above are book columns.

## What is not verified

Being plain about this matters more than looking finished:

- No real Audiobookshelf instance has been read with this tool. The response shapes it expects come from the upstream public source code, read on 2026-09-30: `server/models/Book.js`, `server/models/LibraryItem.js` and `server/controllers/LibraryController.js`.
- The tests run on sample payloads written for the tests, not on captured traffic from a live server.
- Whether your server fills all eighteen columns is not something anyone has measured. The report printed on standard error is there so you can see it for yourself on the first run.

If you run it on a real library, please say so on the issue tracker, whether it worked or not. The paragraph above gets corrected the day someone reports a first-hand result.

## Requirements

Python 3.9 or newer. The standard library only, no dependencies.

## License

MIT. Built with AI assistance, reviewed and tested by me.

Younes Z.
