overdrive

package
v0.167.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package overdrive maps OverDrive/Libby "thunder" API records (as cached by a scan) directly to libcodex BIBFRAME Work/Instance grains (see bibframe.go). It is the ingest half of the OverDrive reference provider (ARCHITECTURE §9): each cached Item exposes Identity/Work/Instance for the shared ingest.Run pipeline, so a cached collection becomes canonical feed:overdrive grains with no MARC intermediate. The live fetch is a separate concern; this reads the on-disk page cache so a build needs no API call.

Index

Constants

View Source
const (
	// SourceBISAC is the bf:source of a BISAC subject-category code.
	SourceBISAC = "bisacsh"
	// SourceOverDrive is the bf:source of the OverDrive title id.
	SourceOverDrive = "overdrive"
	// SourceReserveID is the bf:source of the OverDrive Reserve ID -- the stable
	// per-edition key the availability adapter queries at view time.
	SourceReserveID = "overdrive-reserve"
)

bf:source scheme codes for OverDrive's identifiers and classification, tagged so each is unambiguously recoverable from a grain (ARCHITECTURE §9, tasks/008). They are exported so downstream consumers -- notably the runtime availability adapter (tasks/004), which keys on the Reserve ID -- select the right node by scheme.

View Source
const ProviderName = "overdrive"

ProviderName is the OverDrive provider's registry key and default provenance feed graph (feed:overdrive).

Variables

This section is empty.

Functions

func New

func New(cfg ingest.Config) (ingest.Provider, error)

New is the ingest.Factory for OverDrive. It takes the scan cache directory from Config.Source and the provenance feed from Config.Feed (defaulting to feed:overdrive). It errors when no cache is configured.

Types

type BISAC

type BISAC struct {
	Code        string `json:"code"`
	Description string `json:"description"`
}

BISAC is a controlled subject classification.

type Creator

type Creator struct {
	Name     string `json:"name"`
	Role     string `json:"role"` // Author, Narrator, Illustrator, Editor, Translator
	SortName string `json:"sortName"`
}

Creator is a contributor with an OverDrive role and an authorized sort form.

type Format

type Format struct {
	Identifiers []Identifier `json:"identifiers"`
}

Format is one delivery format; ISBNs ride on its identifiers.

type Identifier

type Identifier struct {
	Type  string `json:"type"`
	Value string `json:"value"`
}

Identifier is a typed identifier (ISBN, ASIN, ...) on a format.

type Item

type Item struct {
	ID          string    `json:"id"`        // OverDrive numeric title id
	ReserveID   string    `json:"reserveId"` // OverDrive Reserve ID (Thunder availability key)
	Title       string    `json:"title"`
	Subtitle    string    `json:"subtitle"`
	Edition     string    `json:"edition"`
	Series      string    `json:"series"`
	Description string    `json:"description"` // HTML fragment; plain-texted into bf:summary (tasks/126)
	Type        NamedID   `json:"type"`        // {id: ebook|audiobook, name}
	Publisher   *NamedID  `json:"publisher"`
	PublishDate string    `json:"publishDate"` // ISO 8601
	Creators    []Creator `json:"creators"`
	Languages   []NamedID `json:"languages"`
	Subjects    []NamedID `json:"subjects"`
	BISAC       []BISAC   `json:"bisac"`
	Formats     []Format  `json:"formats"`
}

Item is the subset of an OverDrive media record this connector maps. Field names match the raw thunder feed (cache/pages/*.json).

func ReadCache

func ReadCache(dir string) ([]Item, error)

ReadCache reads every page-*.json in dir (the OverDrive scan cache) and returns all items across the pages, in page order. A dir with no page files is an error, not an empty feed: a mistyped --cache path must not read as "the provider now carries zero titles" (tasks/103).

func (Item) BIBFRAME

func (it Item) BIBFRAME() *codexbf.BIBFRAME

BIBFRAME crosswalks one OverDrive item directly to a libcodex BIBFRAME Work/Instance pair -- the OverDrive reference provider's real path (ARCHITECTURE §9), mapping the Thunder JSON feed straight to BIBFRAME with no MARC intermediate. This keeps data the MARC detour drops (notably BISAC classification) and models subjects as bf:Topic without MARC's 6xx/653 constraints. The result is serialized by BIBFRAME.Graph, so it takes the same graph shape as a record-derived BIBFRAME.

func (Item) ISBNs

func (it Item) ISBNs() []string

ISBNs returns the deduped ISBNs across all formats, in first-seen order.

func (Item) Identity

func (it Item) Identity() identity.Record

Identity returns the record's resolution keys and clustering fields for identity.Resolver to assign stable Work/Instance ids (ARCHITECTURE §4). The keys are the OverDrive title id, each ISBN, and the Reserve ID, namespaced by scheme -- ordered so the most specific (the title id) resolves first and ISBN serves as the cross-provider merge key. The clustering fields are the primary author, the main title, and the original language.

func (Item) Instance

func (it Item) Instance() codexbf.Instance

Instance returns the item's Instance-level BIBFRAME (this publication): transcribed title, edition, provision, and identifiers (ISBNs, the OverDrive title id, and the Reserve ID). Each clustered item contributes one Instance.

func (Item) Work

func (it Item) Work() codexbf.Work

Work returns the item's Work-level BIBFRAME (intellectual content): content class, preferred title, agents, topical subjects, languages, and BISAC classification. When items cluster into one Work, this is the shared node.

func (Item) WorkID

func (it Item) WorkID() string

WorkID returns a stable, IRI- and filesystem-safe id for the item, taken from the OverDrive title id (falling back to the Reserve ID). It names the grain file and the #<id>Work / #<id>Instance node IRIs. Phase 0 only: ARCHITECTURE §4's identity model replaces this with a minted, provider-independent id.

type NamedID

type NamedID struct {
	ID   string `json:"id"`
	Name string `json:"name"`
}

NamedID is OverDrive's {id, name} pair (types, subjects, languages, publisher).

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

Provider is the OverDrive reference ingest provider (ARCHITECTURE §9): it reads a cached Thunder scan and yields its items as resolvable records for the shared ingest.Run pipeline. It holds only build-time config; the live availability half is a separate runtime adapter (tasks/004).

func (Provider) Name

func (p Provider) Name() string

Name returns the provider's provenance feed graph name.

func (Provider) Records

func (p Provider) Records(_ context.Context) ([]ingest.Record, error)

Records reads the OverDrive scan cache and returns its items as ingest records, in page order. Each Item already exposes Identity/Work/Instance, so it is an ingest.Record with no adaptation. ctx is accepted for the Provider contract; the cache read is local and does not observe cancellation.

func (Provider) Role

func (p Provider) Role() ingest.Role

Role reports OverDrive as a bibliographic ingest source (feed:<name>).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL