50 lines
1.5 KiB
Swift
50 lines
1.5 KiB
Swift
import Foundation
|
|
|
|
extension Components.Schemas.BaseItemPerson: Identifiable {
|
|
public var id: String { Name ?? UUID().uuidString }
|
|
}
|
|
|
|
extension Components.Schemas.BaseItemDto: Identifiable {
|
|
public var id: String { Id ?? "" }
|
|
}
|
|
|
|
public extension Components.Schemas.SearchHint {
|
|
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"
|
|
}
|
|
}
|
|
|
|
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
|
|
}
|
|
}
|