Luminate/Sources/LuminateCore/BaseItemDto+Display.swift

31 lines
935 B
Swift

import Foundation
public extension Components.Schemas.BaseItemDto {
var isMovie: Bool { _Type?.value1 == .Movie }
var isSeries: Bool { _Type?.value1 == .Series }
var isEpisode: Bool { _Type?.value1 == .Episode }
var isSeason: Bool { _Type?.value1 == .Season }
var isFolder: Bool { IsFolder ?? false }
var runtimeString: String {
guard let ticks = RunTimeTicks else { return "" }
let totalSeconds = Int(ticks / 10_000_000)
let hours = totalSeconds / 3600
let minutes = (totalSeconds % 3600) / 60
if hours > 0 { return "\(hours)h \(minutes)m" }
return "\(minutes)m"
}
var yearString: String {
guard let year = ProductionYear else { return "" }
return "\(year)"
}
var primaryImageTag: String? {
ImageTags?.additionalProperties["Primary"]
}
var backdropImageTag: String? {
BackdropImageTags?.first
}
}