A media library backend that extracts book, music, and movie references from natural language text, looks them up against public APIs, and persists them to a per-user SQLite database.
When given a Discord username, a media type, and a raw message, the pipeline:
- Sends the text to the free chatjimmy.ai LLM and asks it to extract entity names as a JSON array
- Looks each name up against the appropriate public API
- Upserts the result into SQLite and records the user → media association with a timestamp
Supported media types:
| Type | Extraction | API |
|---|---|---|
books |
Book titles | Open Library — no key required |
music |
Artist names | TheAudioDB — no key required |
movies |
Movie titles | OMDB — free key required |
# Install dependencies
uv sync
# Add media from a message
python main.py add <username> books "I've been rereading 1984 and Animal Farm"
python main.py add <username> music "been listening to a lot of Radiohead and Portishead"
python main.py add <username> movies "just watched Parasite and Everything Everywhere All at Once"
# Show a user's library
python main.py show <username> # all categories
python main.py show <username> books
python main.py show <username> music
python main.py show <username> moviesOMDB requires an API key (free at https://www.omdbapi.com/apikey.aspx):
export OMDB_API_KEY=your_key_hereThe repo now includes an Astro-based static site that reads from library.db at build time.
# Install Astro dependencies
npm install
# Export SQLite data to JSON and build the site
npm run buildGenerated files are written to dist/.
The build pipeline is:
uv run python export_site_data.pyastro build
nmemos needs to call into this library in two places:
1. /library <type> command handler
When a user runs /library books, /library music, or /library movies, nmemos should grab the content of the previous message and call:
from db import connect, init_db
from library import process_message
conn = connect()
init_db(conn)
result = process_message(conn, discord_username, previous_message_text, media_type)
# result = {"user": "...", "added": [...], "skipped": [...]}Reply to the user with result["added"] (saved) and result["skipped"] (no API results found).
2. Displaying a user's library
When a user wants to see their saved media:
from db import connect, get_user_books, get_user_artists, get_user_movies
conn = connect()
books = get_user_books(conn, discord_username) # list[UserBook]
artists = get_user_artists(conn, discord_username) # list[UserArtist]
movies = get_user_movies(conn, discord_username) # list[UserMovie]Each entry has a .added_at timestamp and the full API metadata object (.book, .artist, .movie).
The connect() call will use library.db in the project root by default. Pass a Path to connect() if nmemos needs the database at a different location.
- Book extraction + Open Library API
- Music extraction + TheAudioDB API
- Movie extraction + OMDB API
- SQLite database with per-user history
- SSG to generate a static website from the database
- GitHub Action to auto-deploy the website
- nmemos
/librarycommand integration