source_utils_rowItemText.bs
import "pkg:/source/utils/misc.bs"
' Returns the primary display title for a row item.
'
' - Season: returns the season label (item.name, e.g. "Season 1")
' - Episode: returns the episode code and title (item.subtitle, e.g. "S1E2 - Pilot")
' - Audio: "{trackNumber}. {name}" when indexNumber > 0 (item.name unchanged for ItemDetails title)
' - All others: returns item.name
'
' @param item - JellyfinBaseItem content node
' @returns Display title string, or "" if item is invalid
function getRowItemTitle(item as object) as string
if not isValid(item) then return ""
' Chapter: display the chapter name
if item.type = "Chapter"
return item.name
end if
' Season: item.name is the season label; subtitle holds seriesName (shown as secondary text)
if item.type = "Season"
return item.name
end if
' Episode: subtitle holds the pre-computed episode code + title ("S1E2 - Name");
' seriesName provides context and is shown as secondary text below.
if item.type = "Episode"
return item.subtitle
end if
' Audio: prefix with track number when available. item.name is left unmodified so
' ItemDetails can use it as the page title without a numeric prefix.
if item.type = "Audio" and item.indexNumber > 0
return stri(item.indexNumber).trim() + ". " + item.name
end if
return item.name
end function
' Returns the secondary display subtitle for a row item.
'
' - Season: returns the series name (stored in item.subtitle by the transformer)
' - Episode: returns the series name (item.seriesName)
' - All others: returns the pre-computed subtitle field
' (e.g., "2024 • PG-13" for Movie, "2020 - Present" for Series)
'
' @param item - JellyfinBaseItem content node
' @returns Display subtitle string, or "" if item is invalid
function getRowItemSubtitle(item as object) as string
if not isValid(item) then return ""
' Chapter: display the timestamp (pre-computed in buildChapterItems)
if item.type = "Chapter"
return item.subtitle
end if
' Season: subtitle field holds the series name; name holds "Season N" (shown as title)
if item.type = "Season"
return item.subtitle
end if
' Episode: series name provides context for the episode code+title shown above
if item.type = "Episode"
return item.seriesName
end if
return item.subtitle
end function