import Foundation
import SwiftData

/// Persistent record of a YouTube video downloaded to the device (Issue #21).
/// Files live in the app's documents directory under `videos/<videoId>.mp4`;
/// this model tracks the metadata needed to locate, display, and manage them.
///
/// Lives in the local store, not CloudKit — downloads are per-device.
@Model
public final class DownloadedVideo {
    /// YouTube video ID — the primary key (unique).
    @Attribute(.unique) public var videoId: String = ""
    public var title: String = ""
    public var filename: String = ""
    public var byteCount: Int = 0
    public var downloadedAt: Date = Date()

    public init(videoId: String, title: String, filename: String, byteCount: Int) {
        self.videoId = videoId
        self.title = title
        self.filename = filename
        self.byteCount = byteCount
        self.downloadedAt = Date()
    }
}
