abs

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: MIT Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsHTTPStatus

func IsHTTPStatus(err error, statusCode int) bool

IsHTTPStatus reports whether err or one of its wrapped errors is an HTTPStatusError for the given status code.

func SortRecentlyAdded

func SortRecentlyAdded(items []LibraryItem)

SortRecentlyAdded sorts library items by descending addedAt and then title.

func TranscriptIno added in v0.6.0

func TranscriptIno(files []LibraryFile, audioFilename string) string

TranscriptIno returns the inode of the VTT sidecar for audioFilename. If audioFilename is empty and the item has exactly one VTT, that file is used.

Types

type AudioTrack

type AudioTrack struct {
	Index       int          `json:"index"`
	StartOffset float64      `json:"startOffset"`
	Duration    float64      `json:"duration"`
	ContentURL  string       `json:"contentUrl"`
	Metadata    FileMetadata `json:"metadata"`
}

AudioTrack represents a single audio track in a play session.

type Author added in v0.3.0

type Author struct {
	ID   string `json:"id,omitempty"`
	Name string `json:"name"`
}

Author is an Audiobookshelf author reference attached to book metadata.

type Bookmark

type Bookmark struct {
	LibraryItemID string  `json:"libraryItemId,omitempty"`
	Title         string  `json:"title"`
	Time          float64 `json:"time"`      // seconds
	CreatedAt     int64   `json:"createdAt"` // unix timestamp ms
}

Bookmark represents a user bookmark within a media item.

type Chapter

type Chapter struct {
	ID    int     `json:"id"`
	Start float64 `json:"start"`
	End   float64 `json:"end"`
	Title string  `json:"title"`
}

Chapter represents a chapter within a media item.

type Client

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

Client is an HTTP client for the Audiobookshelf API.

func NewClient

func NewClient(baseURL, token string) *Client

NewClient creates a new ABS API client.

func (*Client) BaseURL

func (c *Client) BaseURL() string

BaseURL returns the server base URL.

func (*Client) CloseSession

func (c *Client) CloseSession(ctx context.Context, sessionID string, currentTime, timeListened float64) error

CloseSession closes an active playback session.

func (*Client) CreateBookmark

func (c *Client) CreateBookmark(ctx context.Context, itemID string, time float64, title string) error

CreateBookmark creates a bookmark on a library item at the given time.

func (*Client) DeleteBookmark

func (c *Client) DeleteBookmark(ctx context.Context, itemID string, time float64) error

DeleteBookmark deletes a bookmark from a library item at the given time.

func (*Client) DeleteEpisode added in v0.4.0

func (c *Client) DeleteEpisode(ctx context.Context, podcastID string, episodeID string, hardDelete bool) error

DeleteEpisode deletes a podcast episode from the server.

func (*Client) DeleteItem added in v0.4.0

func (c *Client) DeleteItem(ctx context.Context, itemID string, hardDelete bool) error

DeleteItem deletes a library item from the server. To also delete the files from the filesystem, set hardDelete to true.

func (*Client) FilterAudioLibraries

func (c *Client) FilterAudioLibraries(ctx context.Context, libs []Library) ([]Library, error)

FilterAudioLibraries filters out "book" type libraries that contain no audio content (ebooks without audio). Podcasts are always kept. For book libraries, it samples items and checks if any has Duration > 0 to determine if it's an audio library. Audio checks for book libraries run in parallel.

func (*Client) GetBookmarks

func (c *Client) GetBookmarks(ctx context.Context, itemID string) ([]Bookmark, error)

GetBookmarks returns bookmarks for a library item via the per-item progress endpoint.

func (*Client) GetLibraries

func (c *Client) GetLibraries(ctx context.Context) ([]Library, error)

GetLibraries returns all libraries on the server.

func (*Client) GetLibraryFile added in v0.6.0

func (c *Client) GetLibraryFile(ctx context.Context, itemID, ino string) ([]byte, error)

GetLibraryFile downloads a library file by inode.

func (*Client) GetLibraryFiles added in v0.6.0

func (c *Client) GetLibraryFiles(ctx context.Context, itemID string) ([]LibraryFile, error)

GetLibraryFiles returns libraryFiles from an expanded item without storing the item.

func (*Client) GetLibraryItem

func (c *Client) GetLibraryItem(ctx context.Context, itemID string) (*LibraryItem, error)

GetLibraryItem returns a single library item by ID with full details (including episodes for podcasts). include=progress makes ABS embed userMediaProgress; expanded=1 is required for include to take effect.

func (*Client) GetLibraryItems

func (c *Client) GetLibraryItems(ctx context.Context, libraryID string, page, limit int) (*LibraryItemsResponse, error)

GetLibraryItems returns a paginated list of items in a library.

func (*Client) GetLibraryItemsBatch

func (c *Client) GetLibraryItemsBatch(ctx context.Context, ids []string) ([]*LibraryItem, error)

GetLibraryItemsBatch fetches multiple library items concurrently.

func (*Client) GetLibrarySeries

func (c *Client) GetLibrarySeries(ctx context.Context, libraryID string, page, limit int) (*LibrarySeriesResponse, error)

GetLibrarySeries returns a paginated list of series in a library.

func (*Client) GetMe added in v0.6.0

func (c *Client) GetMe(ctx context.Context) (*MeResponse, error)

GetMe returns the current user, including all media progress records.

func (*Client) GetMediaProgress

func (c *Client) GetMediaProgress(ctx context.Context, itemID string) (*MediaProgressWithBookmarks, error)

GetMediaProgress returns the user's media progress (including bookmarks) for a specific library item.

func (*Client) GetPersonalized

func (c *Client) GetPersonalized(ctx context.Context, libraryID string) ([]PersonalizedResponse, error)

GetPersonalized returns personalized shelves for a library (e.g. "continue-listening").

func (*Client) GetRecentEpisodes added in v0.2.0

func (c *Client) GetRecentEpisodes(ctx context.Context, libraryID string, limit int) ([]LibraryItem, error)

GetRecentEpisodes fetches recently added podcast episodes for a library.

func (*Client) GetRecentlyAdded

func (c *Client) GetRecentlyAdded(ctx context.Context, libraries []Library) ([]LibraryItem, error)

GetRecentlyAdded fetches and merges the "recently-added" personalized shelf for the given libraries.

func (*Client) GetSeries

func (c *Client) GetSeries(ctx context.Context, libraryID, seriesID string) (*Series, error)

GetSeries returns series metadata scoped to a library.

func (*Client) GetSeriesContents

func (c *Client) GetSeriesContents(ctx context.Context, libraryID, seriesID string) (*SeriesContents, error)

GetSeriesContents returns series metadata plus all library items in that series.

func (*Client) Login

func (c *Client) Login(ctx context.Context, username, password string) (string, error)

Login authenticates with the ABS server and stores the token.

func (*Client) SearchPodcastEpisodes

func (c *Client) SearchPodcastEpisodes(ctx context.Context, libraryID, query string) ([]LibraryItem, error)

SearchPodcastEpisodes scans podcast library items and returns episode-level prefix hits.

func (*Client) StartEpisodePlaySession

func (c *Client) StartEpisodePlaySession(ctx context.Context, itemID, episodeID string, device DeviceInfo) (*PlaySession, error)

StartEpisodePlaySession starts a new playback session for a podcast episode.

func (*Client) StartPlaySession

func (c *Client) StartPlaySession(ctx context.Context, itemID string, device DeviceInfo) (*PlaySession, error)

StartPlaySession starts a new playback session for a library item.

func (*Client) SyncSession

func (c *Client) SyncSession(ctx context.Context, sessionID string, currentTime, timeListened float64) error

SyncSession syncs the current playback position for an active session.

func (*Client) Token

func (c *Client) Token() string

Token returns the auth token.

func (*Client) UpdateBookmark

func (c *Client) UpdateBookmark(ctx context.Context, itemID string, time float64, title string) error

UpdateBookmark updates the title of an existing bookmark.

func (*Client) UpdateEpisodeProgress

func (c *Client) UpdateEpisodeProgress(ctx context.Context, itemID, episodeID string, currentTime, progress float64, isFinished bool) error

UpdateEpisodeProgress updates the user's progress on a podcast episode.

func (*Client) UpdateLibraryItemMedia added in v0.3.0

func (c *Client) UpdateLibraryItemMedia(ctx context.Context, itemID string, req UpdateMediaRequest) (*LibraryItem, error)

UpdateLibraryItemMedia updates an ABS library item's media metadata.

func (*Client) UpdatePodcastEpisode added in v0.3.0

func (c *Client) UpdatePodcastEpisode(ctx context.Context, itemID, episodeID string, req UpdatePodcastEpisodeRequest) (*LibraryItem, error)

UpdatePodcastEpisode updates ABS metadata for a single podcast episode.

func (*Client) UpdateProgress

func (c *Client) UpdateProgress(ctx context.Context, itemID string, currentTime, progress float64, isFinished bool) error

UpdateProgress updates the user's progress on a library item.

type DeviceInfo

type DeviceInfo struct {
	DeviceID      string `json:"deviceId"`
	Manufacturer  string `json:"manufacturer"`
	Model         string `json:"model"`
	ClientName    string `json:"clientName"`
	ClientVersion string `json:"clientVersion"`
}

DeviceInfo identifies the client device for a play session.

type FileMetadata added in v0.6.0

type FileMetadata struct {
	Filename string `json:"filename"`
	Ext      string `json:"ext,omitempty"`
}

FileMetadata is ABS file metadata used to match audio tracks to sidecars.

type HTTPStatusError

type HTTPStatusError struct {
	StatusCode int
	Body       string
}

HTTPStatusError wraps a non-2xx HTTP response status.

func (*HTTPStatusError) Error

func (e *HTTPStatusError) Error() string

type Library

type Library struct {
	ID        string `json:"id"`
	Name      string `json:"name"`
	MediaType string `json:"mediaType"` // "book" or "podcast"
}

Library represents an Audiobookshelf library.

type LibraryFile added in v0.6.0

type LibraryFile struct {
	Ino      string       `json:"ino"`
	FileType string       `json:"fileType,omitempty"`
	Metadata FileMetadata `json:"metadata"`
}

LibraryFile is a file attached to a library item.

type LibraryItem

type LibraryItem struct {
	ID                string             `json:"id"`
	LibraryID         string             `json:"libraryId,omitempty"`
	AddedAt           int64              `json:"addedAt,omitempty"`
	MediaType         string             `json:"mediaType"` // "book" or "podcast"
	Media             Media              `json:"media"`
	UserMediaProgress *UserMediaProgress `json:"userMediaProgress,omitempty"`
	RecentEpisode     *PodcastEpisode    `json:"recentEpisode,omitempty"`
}

LibraryItem represents a book or podcast in a library.

type LibraryItemsResponse

type LibraryItemsResponse struct {
	Results []LibraryItem `json:"results"`
	Total   int           `json:"total"`
	Limit   int           `json:"limit"`
	Page    int           `json:"page"`
}

LibraryItemsResponse is returned by GET /api/libraries/{id}/items.

type LibrarySeriesResponse

type LibrarySeriesResponse struct {
	Results []Series `json:"results"`
	Total   int      `json:"total"`
	Limit   int      `json:"limit"`
	Page    int      `json:"page"`
}

LibrarySeriesResponse is returned by GET /api/libraries/{id}/series.

type LoginResponse

type LoginResponse struct {
	User LoginUser `json:"user"`
}

LoginResponse is returned by POST /login.

type LoginUser

type LoginUser struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Token    string `json:"token"`
}

LoginUser contains user info including the auth token.

type MeResponse added in v0.6.0

type MeResponse struct {
	MediaProgress []MediaProgressEntry `json:"mediaProgress"`
}

MeResponse is the subset of GET /api/me used by pine.

type Media

type Media struct {
	Metadata      MediaMetadata    `json:"metadata"`
	Duration      *float64         `json:"duration,omitempty"`
	CoverPath     *string          `json:"coverPath,omitempty"`
	Episodes      []PodcastEpisode `json:"episodes,omitempty"`
	NumAudioFiles *int             `json:"numAudioFiles,omitempty"`
	NumTracks     *int             `json:"numTracks,omitempty"`
}

Media contains the media content and metadata of a library item.

func (Media) HasDuration

func (m Media) HasDuration() bool

HasDuration returns true if a non-zero duration is available.

func (Media) TotalDuration

func (m Media) TotalDuration() float64

TotalDuration returns the item duration, checking media.duration first then falling back to media.metadata.duration. Returns 0 if neither is set.

type MediaMetadata

type MediaMetadata struct {
	Title       string           `json:"title"`
	AuthorName  *string          `json:"authorName,omitempty"`
	Authors     []Author         `json:"authors,omitempty"`
	Description *string          `json:"description,omitempty"`
	Duration    *float64         `json:"duration,omitempty"` // seconds
	Chapters    []Chapter        `json:"chapters,omitempty"`
	Series      *SeriesSequence  `json:"series,omitempty"`
	SeriesList  []SeriesSequence `json:"-"`
}

MediaMetadata holds descriptive information about a media item.

func (MediaMetadata) DisplayAuthor added in v0.3.0

func (m MediaMetadata) DisplayAuthor() string

DisplayAuthor returns the best author string for UI display and search.

func (MediaMetadata) HasMultipleAuthors added in v0.3.0

func (m MediaMetadata) HasMultipleAuthors() bool

HasMultipleAuthors reports whether ABS returned more than one non-empty author.

func (MediaMetadata) HasMultipleSeries added in v0.3.0

func (m MediaMetadata) HasMultipleSeries() bool

HasMultipleSeries reports whether ABS returned more than one series entry.

func (MediaMetadata) PrimarySeries added in v0.3.0

func (m MediaMetadata) PrimarySeries() *SeriesSequence

PrimarySeries returns the first ABS series entry used by pine's current single-series behavior.

func (MediaMetadata) SeriesByID added in v0.3.0

func (m MediaMetadata) SeriesByID(id string) *SeriesSequence

SeriesByID returns the series entry with the given ABS series ID.

func (*MediaMetadata) UnmarshalJSON

func (m *MediaMetadata) UnmarshalJSON(data []byte) error

UnmarshalJSON handles ABS returning series metadata as either an object or an array.

type MediaProgressEntry added in v0.6.0

type MediaProgressEntry struct {
	LibraryItemID string  `json:"libraryItemId"`
	EpisodeID     string  `json:"episodeId"`
	CurrentTime   float64 `json:"currentTime"`
	Progress      float64 `json:"progress"`
	IsFinished    bool    `json:"isFinished"`
}

MediaProgressEntry is a single user progress record from /api/me.

type MediaProgressWithBookmarks

type MediaProgressWithBookmarks struct {
	LibraryItemID string     `json:"libraryItemId"`
	EpisodeID     string     `json:"episodeId,omitempty"`
	CurrentTime   float64    `json:"currentTime"`
	Progress      float64    `json:"progress"`
	IsFinished    bool       `json:"isFinished"`
	Bookmarks     []Bookmark `json:"bookmarks"`
}

MediaProgressWithBookmarks extends progress with bookmark data.

type PersonalizedResponse

type PersonalizedResponse struct {
	ID       string        `json:"id"` // e.g. "continue-listening"
	Entities []LibraryItem `json:"entities"`
}

PersonalizedResponse is a section returned by GET /api/libraries/{id}/personalized.

type PlaySession

type PlaySession struct {
	ID            string          `json:"id"`
	AudioTracks   []AudioTrack    `json:"audioTracks"`
	CurrentTime   float64         `json:"currentTime"`
	EpisodeID     string          `json:"episodeId,omitempty"`
	MediaMetadata MediaMetadata   `json:"mediaMetadata"`
	Chapters      []Chapter       `json:"chapters,omitempty"`
	LibraryItem   PlaySessionItem `json:"libraryItem"`
}

PlaySession is returned by POST /api/items/{id}/play or /api/items/{id}/play/{episodeId}.

func (PlaySession) TranscriptIno added in v0.6.0

func (s PlaySession) TranscriptIno(audioFilename string) string

TranscriptIno returns the VTT inode for audioFilename from the session item.

type PlaySessionItem added in v0.6.0

type PlaySessionItem struct {
	LibraryFiles []LibraryFile `json:"libraryFiles,omitempty"`
}

PlaySessionItem is the nested library item on a play-session response.

type PodcastEpisode

type PodcastEpisode struct {
	ID          string     `json:"id"`
	Index       *int       `json:"index"`
	Title       string     `json:"title"`
	Description string     `json:"description,omitempty"`
	Season      string     `json:"season,omitempty"`
	Episode     string     `json:"episode,omitempty"`
	EpisodeType string     `json:"episodeType,omitempty"`
	Duration    float64    `json:"duration"`
	Size        int64      `json:"size,omitempty"`
	AudioTrack  AudioTrack `json:"audioTrack,omitempty"`
	PublishedAt *int64     `json:"publishedAt,omitempty"`
	AddedAt     int64      `json:"addedAt,omitempty"`
}

PodcastEpisode represents a single episode of a podcast.

type Series

type Series struct {
	ID          string       `json:"id"`
	Name        string       `json:"name"`
	Description string       `json:"description,omitempty"`
	LibraryID   string       `json:"libraryId,omitempty"`
	AddedAt     int64        `json:"addedAt,omitempty"`
	UpdatedAt   int64        `json:"updatedAt,omitempty"`
	Books       []SeriesBook `json:"books"`
}

Series contains series metadata returned by ABS.

type SeriesBook

type SeriesBook struct {
	LibraryItem
	Sequence string `json:"sequence,omitempty"`
}

SeriesBook is a library item embedded in some ABS responses with sequence info.

type SeriesContents

type SeriesContents struct {
	Series Series
	Items  []LibraryItem
}

SeriesContents combines series metadata with the library items in that series.

type SeriesSequence

type SeriesSequence struct {
	ID       string `json:"id,omitempty"`
	Name     string `json:"name"`
	Sequence string `json:"sequence,omitempty"`
}

SeriesSequence is the minimal series context attached to a library item.

type UpdateMediaMetadata added in v0.3.0

type UpdateMediaMetadata struct {
	Title   *string           `json:"title,omitempty"`
	Authors *[]Author         `json:"authors,omitempty"`
	Series  *[]SeriesSequence `json:"series,omitempty"`
}

UpdateMediaMetadata contains only metadata fields pine intentionally edits.

type UpdateMediaRequest added in v0.3.0

type UpdateMediaRequest struct {
	Metadata UpdateMediaMetadata `json:"metadata"`
}

UpdateMediaRequest is the body for PATCH /api/items/{id}/media.

type UpdatePodcastEpisodeRequest added in v0.3.0

type UpdatePodcastEpisodeRequest struct {
	Title       *string `json:"title,omitempty"`
	Description *string `json:"description,omitempty"`
	Season      *string `json:"season,omitempty"`
	Episode     *string `json:"episode,omitempty"`
	EpisodeType *string `json:"episodeType,omitempty"`
}

UpdatePodcastEpisodeRequest is the body for PATCH /api/podcasts/{id}/episode/{episodeId}.

type UserMediaProgress

type UserMediaProgress struct {
	CurrentTime float64 `json:"currentTime"` // seconds
	Progress    float64 `json:"progress"`    // 0.0 - 1.0
	IsFinished  bool    `json:"isFinished"`
}

UserMediaProgress tracks a user's progress on a media item.

Jump to

Keyboard shortcuts

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