Documentation
¶
Overview ¶
Package cache provides persistent storage for Plex media library data. It caches media items locally for fast offline browsing without requiring repeated API calls to the Plex server. The cache is stored as JSON in the user's config directory.
Index ¶
- func GetCachePath() (string, error)
- func GetMetaPath() (string, error)
- func SaveMeta(m CacheMeta) error
- type Cache
- func (c *Cache) ApplyOffsets(offsets map[string]int) bool
- func (c *Cache) FormatForFzf() []string
- func (c *Cache) GetMediaByFormattedTitle(formattedTitle string) (*plex.MediaItem, error)
- func (c *Cache) GetMediaByIndex(index int) (*plex.MediaItem, error)
- func (c *Cache) GetMediaByTitle(title string) []plex.MediaItem
- func (c *Cache) IsStale(maxAge time.Duration) bool
- func (c *Cache) Save() error
- type CacheMeta
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCachePath ¶
GetCachePath returns the path to the cache file
func GetMetaPath ¶ added in v0.3.7
GetMetaPath returns the path to the freshness sidecar file.
Types ¶
type Cache ¶
type Cache struct {
// Media contains all cached media items from the Plex library
Media []plex.MediaItem `json:"media"`
// LastUpdated tracks when the cache was last refreshed from Plex
LastUpdated time.Time `json:"last_updated"`
}
Cache stores media items and metadata about when the cache was last updated. Use Load() to read from disk and Save() to persist changes.
func (*Cache) ApplyOffsets ¶ added in v0.2.8
ApplyOffsets writes playback positions (milliseconds, keyed by media key) into the matching cached items, updating ViewOffset and LastViewedAt. It is used after playback to flush progress into the local cache so items appear in "Continue Watching" immediately, without a full reindex. It returns true if any item was updated. Callers persist the change with Save().
func (*Cache) FormatForFzf ¶
FormatForFzf returns a slice of formatted strings for fzf
func (*Cache) GetMediaByFormattedTitle ¶
GetMediaByFormattedTitle returns the media item matching the formatted title
func (*Cache) GetMediaByIndex ¶
GetMediaByIndex returns the media item at the given index
func (*Cache) GetMediaByTitle ¶
GetMediaByTitle returns media items that match the given title