from dataclasses import dataclass
from typing import Optional


@dataclass(slots=True)
class DownloadTask:
    url: str
    output_path: str
    support_range: Optional[bool] = None
    content_length: Optional[int] = None
    download_plan: dict[int, tuple[int, int, int]] | None = None  # part_id -> (start_byte, end_byte, length)
    download_progress: dict[int, float] | None = None   # part_id -> downloaded_bytes
    total_downloaded: int = 0
    
    def __init__(self, url: str, output: str) -> None:
        self.url = url
        self.output_path = output
        self.support_range = None
        self.content_length = None
        self.download_plan = None
        self.download_progress = None
        self.total_downloaded = 0