Documentation
¶
Overview ¶
Package view holds shared HTML view models for Outtake pages and widgets.
Index ¶
- Constants
- func AudioTrackLabel(stream library.AudioStream) string
- func ClipTypeLabel(clipType clip.Type) string
- func FormatClipCreated(created time.Time) string
- func GIFFPSOrDefault(fps int) int
- func GIFWidthOrDefault(width int) int
- func SeasonLabel(item plex.MediaItem) string
- func SessionBrowseURL(libraryID, itemID, itemTitle, parentID, parentTitle string) string
- func SessionItemURL(id string) string
- func SortSelected(current, value, fallback string) bool
- func ThumbSrc(path string) string
- func TitleJumpKey(titleSort, title string) string
- type AudioTrackOption
- type ClipItem
- type ClipProfileItem
- type Crumb
- type ExportForm
- type LetterIndex
- type LibraryItem
- type MediaItem
- type MediaProps
- type Playback
- type ServerItem
- type SessionItem
Constants ¶
const ( // ClipSortCreatedDesc lists newest created clips first. ClipSortCreatedDesc = catalog.SortCreatedDesc // ClipSortCreatedAsc lists oldest created clips first. ClipSortCreatedAsc = catalog.SortCreatedAsc // ClipSortUpdatedDesc lists recently modified clips first. ClipSortUpdatedDesc = catalog.SortUpdatedDesc // ClipSortUpdatedAsc lists oldest modified clips first. ClipSortUpdatedAsc = catalog.SortUpdatedAsc // ClipSortNameAsc lists clips by display name A-Z. ClipSortNameAsc = catalog.SortNameAsc // ClipSortNameDesc lists clips by display name Z-A. ClipSortNameDesc = catalog.SortNameDesc )
const ( // DefaultGIFWidth is the GIF export width used when a clip carries none. DefaultGIFWidth = 480 // DefaultGIFFPS is the GIF export frame rate used when a clip carries none. DefaultGIFFPS = 10 )
const ( // MediaSortTitleAsc lists titles A-Z. MediaSortTitleAsc = library.SortTitleAsc // MediaSortTitleDesc lists titles Z-A. MediaSortTitleDesc = library.SortTitleDesc // MediaSortYearDesc lists newest years first. MediaSortYearDesc = library.SortYearDesc // MediaSortYearAsc lists oldest years first. MediaSortYearAsc = library.SortYearAsc // MediaSortAddedDesc lists recently added titles first. MediaSortAddedDesc = library.SortAddedDesc // MediaSortAddedAsc lists oldest added titles first. MediaSortAddedAsc = library.SortAddedAsc // JumpOtherKey is the mark for a jump target that is neither a letter, a year, nor a month. JumpOtherKey = library.JumpOtherKey )
Variables ¶
This section is empty.
Functions ¶
func AudioTrackLabel ¶ added in v0.3.0
func AudioTrackLabel(stream library.AudioStream) string
AudioTrackLabel builds a short description of an audio stream.
Parameters:
- stream: Probed audio stream.
Returns:
- label: Language, codec, layout, and title joined for display.
func ClipTypeLabel ¶
ClipTypeLabel is the user-facing name for a clip type.
Parameters:
- clipType: Clip type recorded for the clip.
Returns:
- label: The display name, or Clip for a type that is neither kind.
func FormatClipCreated ¶ added in v0.3.0
FormatClipCreated renders a clip timestamp for display, or blank when unset.
Parameters:
- created: Clip creation time.
Returns:
- stamp: Formatted UTC timestamp, or an empty string for a zero time.
func GIFFPSOrDefault ¶ added in v0.3.0
GIFFPSOrDefault returns the GIF export frame rate to show.
Parameters:
- fps: Carried GIF frame rate, where zero means the field was never set.
Returns:
- value: fps when it was carried, otherwise DefaultGIFFPS.
func GIFWidthOrDefault ¶ added in v0.3.0
GIFWidthOrDefault returns the GIF export width to show.
Parameters:
- width: Carried GIF width, where zero means the field was never set.
Returns:
- value: width when it was carried, otherwise DefaultGIFWidth.
func SeasonLabel ¶ added in v0.3.0
SeasonLabel returns ParentTitle, or Season N from ParentIndex.
Parameters:
- item: Media item the session is playing.
Returns:
- label: The parent title, a season name, or an empty string.
func SessionBrowseURL ¶ added in v0.3.0
SessionBrowseURL returns a container browse URL when library and item ids exist.
Parameters:
- libraryID: Library the container belongs to.
- itemID: Container to browse.
- itemTitle: Container title for the link.
- parentID: Optional show id the container sits under.
- parentTitle: Optional show title for the link.
Returns:
- location: Browse URL, or an empty string when an id is missing.
func SessionItemURL ¶ added in v0.3.0
SessionItemURL returns the media item path when id is set.
Parameters:
- id: Plex media item id.
Returns:
- location: Media item URL, or an empty string when the id is unset.
func SortSelected ¶ added in v0.3.0
SortSelected reports whether a sort option is the active one.
Parameters:
- current: Active sort key, or empty when the query carried none.
- value: Sort key the option being rendered stands for.
- fallback: Sort key shown when current is empty.
Returns:
- selected: True when the option is the active one.
func ThumbSrc ¶ added in v0.3.0
ThumbSrc rewrites a Plex thumb path onto the local cache proxy.
Parameters:
- path: Plex thumb path, which may be empty or malformed.
Returns:
- proxyURL: Local thumb proxy URL, or empty when the path cannot be proxied.
func TitleJumpKey ¶ added in v0.3.0
TitleJumpKey returns the first-letter jump key for a title.
Parameters:
- titleSort: PMS titleSort value, preferred when set.
- title: Display title used when titleSort is empty.
Returns:
- key: A through Z, or JumpOtherKey for anything else.
Types ¶
type AudioTrackOption ¶
AudioTrackOption is a probed audio stream in an audio select.
func AudioTrackOptions ¶ added in v0.3.0
func AudioTrackOptions(streams []library.AudioStream) []AudioTrackOption
AudioTrackOptions maps probed audio streams onto select options.
Parameters:
- streams: Probed audio streams.
Returns:
- options: One form option per stream, in probe order.
type ClipItem ¶
type ClipItem struct {
ID string
Name string
MediaID string
MediaTitle string
ClipType clip.Type
Status clip.Status
Progress int
CreatedAt string
StartTime time.Duration
Duration time.Duration
Quality string
ProfileName string
Profiles []profile.ProfileOption
FileExists bool
AudioIndex int
AudioTracks []AudioTrackOption
CropBlackBars bool
WebSafeColor bool
PreserveHDR bool
SourceHDR bool
MediaDuration time.Duration
Width int
FPS int
MaxDur time.Duration
Error string
}
ClipItem is one clip card on the clips list and media item pages.
func NewClipItem ¶ added in v0.3.0
func NewClipItem( job *clip.Job, options []profile.ProfileOption, limit time.Duration, fileExists bool, ) ClipItem
NewClipItem maps a job onto a card the clips list and a clip update both show.
Parameters:
- job: Render the card is built from.
- profiles: Profiles the card offers as a quality choice.
- limit: Longest clip the installation accepts.
- fileExists: Whether the job's output is still on disk.
Returns:
- item: Page model for the clip card.
func NewClipItems ¶ added in v0.3.0
func NewClipItems( jobs []*clip.Job, options []profile.ProfileOption, limit time.Duration, fileExists func(string) bool, ) []ClipItem
NewClipItems maps jobs onto the cards the clips list and a media item page show, which resolve the profiles and the output checks the same way for every row.
Parameters:
- jobs: Renders to show.
- options: Profiles every card offers as a quality choice.
- limit: Longest clip the installation accepts.
- fileExists: Whether a job's output is still on disk.
Returns:
- items: One page model per clip, in the order the clips were given.
func (*ClipItem) CanPlay ¶
CanPlay reports whether a completed clip file is available for preview.
Returns:
- playable: True when status is completed and the file exists.
func (*ClipItem) DisplayName ¶
DisplayName returns the clip name, or the media title when the name is empty.
Returns:
- name: The label shown on clip cards.
func (*ClipItem) EndTime ¶
EndTime is the clip end as start plus duration.
Returns:
- end: StartTime + Duration.
func (*ClipItem) GIFFPS ¶
GIFFPS is the GIF frame rate, or the New export default when unset.
Returns:
- fps: Stored fps, or 10 when FPS is 0.
type ClipProfileItem ¶ added in v0.3.0
type ClipProfileItem struct {
ID string
Name string
CRF int
Preset string
AudioKbps int
MaxWidth int
IsDefault bool
}
ClipProfileItem is one editable clip profile on the settings page.
func ClipProfileItems ¶ added in v0.3.0
func ClipProfileItems(stored []profile.Profile) []ClipProfileItem
ClipProfileItems maps stored clip profiles onto the settings page models.
Parameters:
- stored: Profiles the page lists.
Returns:
- items: One page model per profile, in the order the profiles were given.
type Crumb ¶
Crumb is one step in the media library trail.
func ItemCrumbs ¶ added in v0.3.0
func ItemCrumbs(item plex.MediaItem, libs []LibraryItem) []Crumb
ItemCrumbs builds Libraries / library / show / season / title for a media item.
Parameters:
- item: Media item being rendered.
- libs: Discovered libraries, used to resolve the library title.
Returns:
- crumbs: The full trail, ending with the item's own title.
func MediaCrumbs ¶ added in v0.3.0
func MediaCrumbs(libs []LibraryItem, libraryID, upID, upTitle, title string) []Crumb
MediaCrumbs builds the library, container, and current title trail for a browse view.
Parameters:
- libs: Discovered libraries, used to resolve the library title.
- libraryID: Library the browse view is scoped to.
- upID: Parent container id to link back to.
- upTitle: Parent container title.
- title: Current container title, shown without a link.
Returns:
- crumbs: Trail from the library root down to the current container.
func SessionTitleParts ¶ added in v0.3.0
SessionTitleParts builds dashboard title crumbs for a live session.
Parameters:
- item: Media item the session is playing.
Returns:
- parts: Title crumbs, which may be a single plain-text crumb.
- year: Release year, reported only for a non-episode.
type ExportForm ¶ added in v0.3.0
type ExportForm struct {
// Type is the export kind: clip, gif, or screenshot.
Type clip.Type
// Name is the user-supplied clip name.
Name string
// Quality is the selected clip profile id.
Quality string
// AudioIndex is the selected audio stream index on the source.
AudioIndex int
// Width is the GIF export width in pixels.
Width int
// FPS is the GIF export frame rate.
FPS int
// CropBlackBars is the trim-black-bars toggle.
CropBlackBars bool
// WebSafeColor is the HDR tone-map toggle.
WebSafeColor bool
// PreserveHDR is the keep-HDR-as-is toggle.
PreserveHDR bool
}
ExportForm is the New export form state on the media item page.
func (ExportForm) ApplyToQuery ¶ added in v0.3.0
func (form ExportForm) ApplyToQuery(values url.Values)
ApplyToQuery writes the export form state onto a query string, so a redirect can carry the form as it was submitted.
Parameters:
- values: Query values to mutate.
type LetterIndex ¶
type LetterIndex = library.LetterIndex
LetterIndex is one first-character jump target on a library section.
type LibraryItem ¶
LibraryItem is a Plex library in the sidebar and media browse grid.
func LibraryItems ¶ added in v0.3.0
func LibraryItems(libs []plex.Library) []LibraryItem
LibraryItems maps Plex libraries onto page models.
Parameters:
- libs: Plex libraries.
Returns:
- items: Page models in the order Plex returned them.
type MediaItem ¶
type MediaItem struct {
ID string
Title string
Type string
Duration time.Duration
ThumbPath string
Browsable bool
BrowseURL string
Year int
Index int
ParentIndex int
ShowTitle string
EpisodeLabel string
TitleSort string
AddedAt int64
}
MediaItem is one title or container in the media library grid.
func MediaItems ¶ added in v0.3.0
MediaItems maps Plex media onto page models.
Parameters:
- items: Plex media items from a listing or a search.
- libraryID: Section key every card is filed under, which overrides the one the item carries.
- parentID: Rating key of the container being drilled into.
- parentTitle: Title of that container, carried on the drill-down link.
Returns:
- items: Page models in the order Plex returned them.
type MediaProps ¶
type MediaProps struct {
Items []MediaItem
Libraries []LibraryItem
Crumbs []Crumb
Letters []LetterIndex
Query string
LibraryID string
ParentID string
ParentTitle string
UpID string
UpTitle string
Sort string
Letter string
Start int
Total int
PageSize int
HasServer bool
}
MediaProps is the media library page and its HTMX results fragment.
type ServerItem ¶ added in v0.3.0
type ServerItem struct {
Name string
Address string
Port int
Scheme string
Token string
Local bool
Selected bool
}
ServerItem is one discovered Plex server.
func ServerItems ¶ added in v0.3.0
func ServerItems(servers []plex.Server, current plex.Server) []ServerItem
ServerItems maps discovered servers onto the server picker models.
Parameters:
- servers: Discovered servers.
- current: Currently bound server, used to mark the selection.
Returns:
- items: One page model per discovered server, in the order they arrived.
type SessionItem ¶ added in v0.3.0
type SessionItem struct {
ID string
MediaID string
Parts []Crumb
Year int
ViewOffset time.Duration
Duration time.Duration
}
SessionItem is one live Plex playback session.
func SessionItems ¶ added in v0.3.0
func SessionItems(sessions []plex.Session) []SessionItem
SessionItems maps live Plex sessions onto the dashboard models.
Parameters:
- sessions: Sessions playing right now.
Returns:
- items: One page model per live session, in the order they arrived.
func (SessionItem) ResumeURL ¶ added in v0.3.0
func (item SessionItem) ResumeURL() string
ResumeURL is where the Clip now link points, carrying the playback offset.
Returns:
- location: Media item URL starting at the offset, or an empty string when the session plays something without a media id.