Documentation
¶
Index ¶
- func IsHTTPStatus(err error, statusCode int) bool
- func SortRecentlyAdded(items []LibraryItem)
- func TranscriptIno(files []LibraryFile, audioFilename string) string
- type AudioTrack
- type Author
- type Bookmark
- type Chapter
- type Client
- func (c *Client) BaseURL() string
- func (c *Client) CloseSession(ctx context.Context, sessionID string, currentTime, timeListened float64) error
- func (c *Client) CreateBookmark(ctx context.Context, itemID string, time float64, title string) error
- func (c *Client) DeleteBookmark(ctx context.Context, itemID string, time float64) error
- func (c *Client) DeleteEpisode(ctx context.Context, podcastID string, episodeID string, hardDelete bool) error
- func (c *Client) DeleteItem(ctx context.Context, itemID string, hardDelete bool) error
- func (c *Client) FilterAudioLibraries(ctx context.Context, libs []Library) ([]Library, error)
- func (c *Client) GetBookmarks(ctx context.Context, itemID string) ([]Bookmark, error)
- func (c *Client) GetLibraries(ctx context.Context) ([]Library, error)
- func (c *Client) GetLibraryFile(ctx context.Context, itemID, ino string) ([]byte, error)
- func (c *Client) GetLibraryFiles(ctx context.Context, itemID string) ([]LibraryFile, error)
- func (c *Client) GetLibraryItem(ctx context.Context, itemID string) (*LibraryItem, error)
- func (c *Client) GetLibraryItems(ctx context.Context, libraryID string, page, limit int) (*LibraryItemsResponse, error)
- func (c *Client) GetLibraryItemsBatch(ctx context.Context, ids []string) ([]*LibraryItem, error)
- func (c *Client) GetLibrarySeries(ctx context.Context, libraryID string, page, limit int) (*LibrarySeriesResponse, error)
- func (c *Client) GetMe(ctx context.Context) (*MeResponse, error)
- func (c *Client) GetMediaProgress(ctx context.Context, itemID string) (*MediaProgressWithBookmarks, error)
- func (c *Client) GetPersonalized(ctx context.Context, libraryID string) ([]PersonalizedResponse, error)
- func (c *Client) GetRecentEpisodes(ctx context.Context, libraryID string, limit int) ([]LibraryItem, error)
- func (c *Client) GetRecentlyAdded(ctx context.Context, libraries []Library) ([]LibraryItem, error)
- func (c *Client) GetSeries(ctx context.Context, libraryID, seriesID string) (*Series, error)
- func (c *Client) GetSeriesContents(ctx context.Context, libraryID, seriesID string) (*SeriesContents, error)
- func (c *Client) Login(ctx context.Context, username, password string) (string, error)
- func (c *Client) SearchPodcastEpisodes(ctx context.Context, libraryID, query string) ([]LibraryItem, error)
- func (c *Client) StartEpisodePlaySession(ctx context.Context, itemID, episodeID string, device DeviceInfo) (*PlaySession, error)
- func (c *Client) StartPlaySession(ctx context.Context, itemID string, device DeviceInfo) (*PlaySession, error)
- func (c *Client) SyncSession(ctx context.Context, sessionID string, currentTime, timeListened float64) error
- func (c *Client) Token() string
- func (c *Client) UpdateBookmark(ctx context.Context, itemID string, time float64, title string) error
- func (c *Client) UpdateEpisodeProgress(ctx context.Context, itemID, episodeID string, currentTime, progress float64, ...) error
- func (c *Client) UpdateLibraryItemMedia(ctx context.Context, itemID string, req UpdateMediaRequest) (*LibraryItem, error)
- func (c *Client) UpdatePodcastEpisode(ctx context.Context, itemID, episodeID string, req UpdatePodcastEpisodeRequest) (*LibraryItem, error)
- func (c *Client) UpdateProgress(ctx context.Context, itemID string, currentTime, progress float64, ...) error
- type DeviceInfo
- type FileMetadata
- type HTTPStatusError
- type Library
- type LibraryFile
- type LibraryItem
- type LibraryItemsResponse
- type LibrarySeriesResponse
- type LoginResponse
- type LoginUser
- type MeResponse
- type Media
- type MediaMetadata
- func (m MediaMetadata) DisplayAuthor() string
- func (m MediaMetadata) HasMultipleAuthors() bool
- func (m MediaMetadata) HasMultipleSeries() bool
- func (m MediaMetadata) PrimarySeries() *SeriesSequence
- func (m MediaMetadata) SeriesByID(id string) *SeriesSequence
- func (m *MediaMetadata) UnmarshalJSON(data []byte) error
- type MediaProgressEntry
- type MediaProgressWithBookmarks
- type PersonalizedResponse
- type PlaySession
- type PlaySessionItem
- type PodcastEpisode
- type Series
- type SeriesBook
- type SeriesContents
- type SeriesSequence
- type UpdateMediaMetadata
- type UpdateMediaRequest
- type UpdatePodcastEpisodeRequest
- type UserMediaProgress
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsHTTPStatus ¶
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
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 (*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 ¶
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
DeleteItem deletes a library item from the server. To also delete the files from the filesystem, set hardDelete to true.
func (*Client) FilterAudioLibraries ¶
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 ¶
GetBookmarks returns bookmarks for a library item via the per-item progress endpoint.
func (*Client) GetLibraries ¶
GetLibraries returns all libraries on the server.
func (*Client) GetLibraryFile ¶ added in v0.6.0
GetLibraryFile downloads a library file by inode.
func (*Client) GetLibraryFiles ¶ added in v0.6.0
GetLibraryFiles returns libraryFiles from an expanded item without storing the item.
func (*Client) GetLibraryItem ¶
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 ¶
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 ¶
GetRecentlyAdded fetches and merges the "recently-added" personalized shelf for the given libraries.
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) 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) 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.
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
FileMetadata is ABS file metadata used to match audio tracks to sidecars.
type HTTPStatusError ¶
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 ¶
HasDuration returns true if a non-zero duration is available.
func (Media) TotalDuration ¶
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.