Features: - VOD library with movie grouping and version detection - TV show library with season/episode organization - TMDB integration for trending shows and recently aired episodes - Recent releases section with TMDB release date sorting - Watch history tracking with continue watching - Playlist caching (12-hour TTL) for offline support - M3U playlist parsing with XStream API support - Authentication with credential storage Technical: - SwiftUI for tvOS - Actor-based services for thread safety - Persistent caching for playlists, TMDB data, and watch history - KSPlayer integration for video playback Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
65 lines
1.7 KiB
Swift
65 lines
1.7 KiB
Swift
import Foundation
|
|
|
|
struct WatchHistoryEntry: Identifiable, Codable, Hashable, Sendable {
|
|
let id: String
|
|
let name: String
|
|
let streamURL: String
|
|
let iconURL: String?
|
|
let watchedAt: Date
|
|
let duration: TimeInterval
|
|
let progress: TimeInterval
|
|
let isMovie: Bool
|
|
|
|
var progressPercent: Double {
|
|
guard duration > 0 else { return 0 }
|
|
return progress / duration
|
|
}
|
|
|
|
var isCompleted: Bool {
|
|
progressPercent >= 0.95
|
|
}
|
|
|
|
var formattedProgress: String {
|
|
let progressMinutes = Int(progress) / 60
|
|
let progressSeconds = Int(progress) % 60
|
|
return String(format: "%d:%02d", progressMinutes, progressSeconds)
|
|
}
|
|
|
|
var formattedDuration: String {
|
|
let durationMinutes = Int(duration) / 60
|
|
let durationSeconds = Int(duration) % 60
|
|
return String(format: "%d:%02d", durationMinutes, durationSeconds)
|
|
}
|
|
|
|
init(
|
|
id: String,
|
|
name: String,
|
|
streamURL: String,
|
|
iconURL: String?,
|
|
watchedAt: Date = Date(),
|
|
duration: TimeInterval,
|
|
progress: TimeInterval,
|
|
isMovie: Bool
|
|
) {
|
|
self.id = id
|
|
self.name = name
|
|
self.streamURL = streamURL
|
|
self.iconURL = iconURL
|
|
self.watchedAt = watchedAt
|
|
self.duration = duration
|
|
self.progress = progress
|
|
self.isMovie = isMovie
|
|
}
|
|
|
|
init(from vodItem: VODItem, duration: TimeInterval, progress: TimeInterval) {
|
|
self.id = vodItem.id
|
|
self.name = vodItem.name
|
|
self.streamURL = vodItem.streamURL
|
|
self.iconURL = vodItem.iconURL
|
|
self.watchedAt = Date()
|
|
self.duration = duration
|
|
self.progress = progress
|
|
self.isMovie = vodItem.isMovie
|
|
}
|
|
}
|