ui

package
v0.3.22 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountItemsWithProgress added in v0.2.2

func CountItemsWithProgress(items []*plex.MediaItem) int

CountItemsWithProgress counts how many items in the list have resumable progress.

func DownloadPoster

func DownloadPoster(plexURL, thumbPath, token string) string

DownloadPoster downloads the poster image and returns the local path

func GetEpisodesForSeason added in v0.2.2

func GetEpisodesForSeason(episodes []plex.MediaItem, showName string, seasonNum int) []plex.MediaItem

GetEpisodesForSeason filters episodes for a specific show and season number. It returns all episodes matching the show name and season (ParentIndex). Use seasonNum=0 to get specials. Returns episodes sorted by episode number (Index). Returns an empty slice if no matching episodes are found.

func GetRecentlyAddedTVShows added in v0.2.7

func GetRecentlyAddedTVShows(episodes []plex.MediaItem, limit int) []string

GetRecentlyAddedTVShows returns unique show names ordered by how recently their newest episode was added (newest first), capped at limit. A limit of 0 means no cap. Episodes are grouped by show (ParentTitle), and each show is ranked by the most recent AddedAt across its episodes.

func GetSeasonsForShow added in v0.2.2

func GetSeasonsForShow(episodes []plex.MediaItem, showName string) []int

GetSeasonsForShow extracts unique season numbers for a specific show. It filters episodes by show name and collects unique ParentIndex values. Season 0 (specials) is placed at the end of the list if present. Returns a numerically sorted slice of season numbers.

func GetUniqueTVShows added in v0.2.2

func GetUniqueTVShows(episodes []plex.MediaItem) []string

GetUniqueTVShows extracts unique TV show titles from a slice of media items. It only considers items with Type "episode" and a non-empty ParentTitle. Returns an alphabetically sorted slice of unique show names. Returns an empty slice if no TV shows are found.

func HasResumableProgress added in v0.2.2

func HasResumableProgress(media *plex.MediaItem) bool

HasResumableProgress returns true if the media has progress that can be resumed. Returns false if no progress or if >=95% complete (treated as watched).

func IsAvailable

func IsAvailable(fzfPath string) bool

IsAvailable checks if fzf is available on the system

func Logo(version string)

Logo prints a styled ASCII art logo with version information

func PluralizeItems added in v0.2.0

func PluralizeItems(count int) string

PluralizeItems returns "1 item" or "N items" based on count

func PromptAction

func PromptAction(fzfPath string) (string, error)

PromptAction asks the user what action to take

func PromptActionWithQueue added in v0.2.0

func PromptActionWithQueue(fzfPath string, selectionCount, queueCount, outplayerCount int) (string, error)

PromptActionWithQueue asks the user what action to take, showing queue count. "Transfer to Outplayer" is only offered when outplayerCount > 0.

func PromptMoreAction added in v0.2.6

func PromptMoreAction(fzfPath string) (string, error)

PromptMoreAction shows the secondary action menu containing the less-common playback/streaming options (SenPlayer, Stream) that would otherwise clutter the main action menu. Returns "cancel" when the user backs out.

func PromptQueueAction added in v0.2.0

func PromptQueueAction(fzfPath string, queueCount, outplayerCount int) (string, error)

PromptQueueAction shows queue management options. "Transfer to Outplayer" is only offered when outplayerCount > 0.

func SelectMedia

func SelectMedia(media []plex.MediaItem, prompt string, fzfPath string) (*plex.MediaItem, error)

SelectMedia presents media items in fzf and returns the selected item

func SelectMediaType

func SelectMediaType(fzfPath string) (string, error)

SelectMediaType asks user to select Movies or TV Shows

func SelectMediaTypeWithQueue added in v0.2.0

func SelectMediaTypeWithQueue(fzfPath string, queueCount, continueCount int) (string, error)

SelectMediaTypeWithQueue presents the top-level browse menu. It adds a "View Queue" option when the queue has items and a "Continue Watching" hub when continueCount items have resumable progress. Returns a normalized selection token: "queue", "continue watching", "recently added movies", "recently added tv shows", "movies", "tv shows", or "all".

func SelectMediaWithCustomLabels added in v0.2.2

func SelectMediaWithCustomLabels(media []plex.MediaItem, labels []string, prompt string, fzfPath string, plexURL string, plexToken string) (int, error)

SelectMediaWithCustomLabels is like SelectMediaWithPreview but uses caller-supplied labels (one per media item) and single-select. Used by search where labels carry extra context (e.g. "matched description") that FormatMediaTitle wouldn't produce. Returns the selected index, or -1 with errors.ErrCancelled if the user cancels.

func SelectMediaWithPreview

func SelectMediaWithPreview(media []plex.MediaItem, prompt string, fzfPath string, plexURL string, plexToken string) ([]int, error)

SelectMediaWithPreview presents media in fzf with preview window showing metadata and poster

func SelectQueueItemsForRemoval added in v0.2.0

func SelectQueueItemsForRemoval(queue []*plex.MediaItem, fzfPath string) ([]int, error)

SelectQueueItemsForRemoval shows queue items for multi-select removal

func SelectSeason added in v0.2.2

func SelectSeason(seasons []int, showName string, fzfPath string) (int, error)

SelectSeason presents seasons in fzf and returns the selected season number. It displays "Specials" for Season 0 and "Season N" for regular seasons. Returns the season number (0 for specials, positive for regular seasons). Returns -1 and an error if no seasons are available or selection fails.

func SelectTVShow added in v0.2.2

func SelectTVShow(shows []string, fzfPath string) (string, error)

SelectTVShow presents TV shows in fzf and returns the selected show name. It displays the shows in an interactive fzf picker. Returns the selected show name or an error if cancelled or no shows available.

func SelectWithFzf

func SelectWithFzf(items []string, prompt string, fzfPath string) (string, int, error)

SelectWithFzf presents items in fzf and returns the selected item

Types

type BrowserModel

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

Browser is a TUI browser for media items

func NewBrowser

func NewBrowser(media []plex.MediaItem, plexURL, plexToken string) *BrowserModel

NewBrowser creates a new browser model

func (*BrowserModel) GetSelected

func (m *BrowserModel) GetSelected() *plex.MediaItem

GetSelected returns the selected media item (if any)

func (*BrowserModel) Init

func (m *BrowserModel) Init() tea.Cmd

func (*BrowserModel) Update

func (m *BrowserModel) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (*BrowserModel) View

func (m *BrowserModel) View() string

type MultiResumeChoice added in v0.2.2

type MultiResumeChoice int

MultiResumeChoice represents the user's choice when multiple items have progress.

const (
	// ResumeAll indicates resuming all items from their saved positions.
	ResumeAll MultiResumeChoice = iota
	// StartAllFromBeginning indicates starting all items from the beginning.
	StartAllFromBeginning
	// ChooseIndividually indicates the user wants to choose for each item.
	ChooseIndividually
)

func PromptMultiResume added in v0.2.2

func PromptMultiResume(itemsWithProgress int, totalItems int, fzfPath string) (MultiResumeChoice, error)

PromptMultiResume displays a prompt when multiple items have progress.

type ResumeChoice added in v0.2.2

type ResumeChoice int

ResumeChoice represents the user's choice for resuming playback.

const (
	// ResumeFromPosition indicates the user wants to resume from saved position.
	ResumeFromPosition ResumeChoice = iota
	// StartFromBeginning indicates the user wants to start from the beginning.
	StartFromBeginning
)

func PromptResume added in v0.2.2

func PromptResume(opts ResumePromptOptions) (ResumeChoice, error)

PromptResume displays a resume prompt using fzf and returns the user's choice.

type ResumePromptOptions added in v0.2.2

type ResumePromptOptions struct {
	Title      string
	ViewOffset int // milliseconds
	Duration   int // milliseconds
	FzfPath    string
}

ResumePromptOptions contains the options for the resume prompt.

Jump to

Keyboard shortcuts

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